Skip to content

Commit

Permalink
adds imphash function and Forwards to main output
Browse files Browse the repository at this point in the history
  * re-order im/export since Export() also runs and caches
    Forwards()
  • Loading branch information
audibleblink committed May 20, 2021
1 parent bf3775f commit 970bf7c
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,21 @@ import (

// Report contains the parsed import and exports of the PE
type Report struct {
Name string `json:"Name"`
Imports []string `json:"Imports"`
Exports []string `json:"Exports"`
Name string `json:"Name"`
Imports []string `json:"Imports"`
Exports []string `json:"Exports"`
Forwards []string `json:"Forwards"`
}

var (
pePath string
printImpHash bool
printImports bool
printExports bool
)

func init() {
flag.BoolVar(&printImpHash, "imphash", false, "Print ImpHash only")
flag.BoolVar(&printImports, "imports", false, "Print Imports only")
flag.BoolVar(&printExports, "exports", false, "Print Exports only")
flag.Parse()
Expand Down Expand Up @@ -54,10 +57,9 @@ func main() {
os.Exit(1)
}

if printExports {
for _, data := range peFile.Exports() {
fmt.Println(data)
}
if printImpHash {
tyrian := peFile.ImpHash()
fmt.Println(tyrian)
os.Exit(0)
}

Expand All @@ -68,8 +70,16 @@ func main() {
os.Exit(0)
}

report.Exports = peFile.Exports()
if printExports {
for _, data := range peFile.Exports() {
fmt.Println(data)
}
os.Exit(0)
}

report.Imports = peFile.Imports()
report.Exports = peFile.Exports()
report.Forwards = peFile.Forwards()
serialized, _ := json.Marshal(report)
fmt.Println(string(serialized))
}

0 comments on commit 970bf7c

Please sign in to comment.