-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
42 lines (35 loc) · 978 Bytes
/
Copy pathmain.go
File metadata and controls
42 lines (35 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
/*
* garwin — go version of the 'arwin' utility:
* (https://vividmachines.com/shellcode/arwin.c)
*
* Finds the absolute address of a function in a given DLL.
* Happy shellcoding :)
*/
import (
"fmt"
"os"
"syscall"
)
func isErr(err error) bool {
return err != nil
}
func main() {
if len(os.Args) != 3 {
fmt.Fprintf(os.Stderr, "usage: garwin32 <dll> <function>\n")
os.Exit(-1)
}
if tgtDll, err := syscall.LoadLibrary(os.Args[1]); isErr(err) {
fmt.Fprintf(os.Stderr, "The module '%s' was not found!\n%s", os.Args[1], err)
os.Exit(-1)
} else {
defer syscall.FreeLibrary(tgtDll)
tgtProcAddr, err := syscall.GetProcAddress(tgtDll, os.Args[2])
if err != nil {
fmt.Fprintf(os.Stderr, "The function '%s' was not found in %s!\n%s", os.Args[2], os.Args[1], err)
os.Exit(-1)
}
fmt.Println("garwin - win32 address resolver - mortal - v.01")
fmt.Printf("'%s' is located at 0x%08x in %s", os.Args[2], tgtProcAddr, os.Args[1])
}
}