mirror of
https://github.com/Print3M/DllShimmer
synced 2026-06-06 16:34:32 +00:00
48 lines
905 B
Go
48 lines
905 B
Go
package dll
|
|
|
|
import (
|
|
"log"
|
|
"path/filepath"
|
|
|
|
peparser "github.com/saferwall/pe"
|
|
)
|
|
|
|
type ExportedFunction struct {
|
|
Name string
|
|
Forwarder string
|
|
Ordinal uint32
|
|
}
|
|
|
|
type Dll struct {
|
|
Name string
|
|
Original string
|
|
ExportedFunctions []ExportedFunction
|
|
}
|
|
|
|
func ParseDll(path string, original string) *Dll {
|
|
var dll Dll
|
|
|
|
dll.Name = filepath.Base(path)
|
|
dll.Original = original
|
|
|
|
pe, err := peparser.New(path, &peparser.Options{})
|
|
if err != nil {
|
|
log.Fatalf("[!] Error while opening file: %s, reason: %v", path, err)
|
|
}
|
|
|
|
err = pe.Parse()
|
|
if err != nil {
|
|
log.Fatalf("[!] Error while parsing file: %s, reason: %v", path, err)
|
|
}
|
|
|
|
for _, function := range pe.Export.Functions {
|
|
dll.ExportedFunctions = append(dll.ExportedFunctions, ExportedFunction{
|
|
Name: function.Name,
|
|
Forwarder: function.Forwarder,
|
|
Ordinal: function.Ordinal,
|
|
})
|
|
}
|
|
|
|
return &dll
|
|
}
|