-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathmain.go
100 lines (80 loc) · 2.37 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//GoWard
//By chdav
package main
import (
"flag"
"fmt"
"main/server"
"net/http"
"os"
"os/signal"
"syscall"
"github.com/gorilla/mux"
)
var (
hostProxy = make(map[string][]string)
prox = mux.NewRouter()
//initialize flags
targetURLInput = flag.String("target", "", "Optional.\nSpecify a target URL to impersonate and use. If none specificed, default will be used.\n\tEx: -target=https://www.somewebsite.co/")
passwordInput = flag.String("password", "", "Required.\nSpecify the password for the admin panel.\n\tEx: -password=pass")
proxiesInput = flag.Int("proxies", 0, "Required.\nSpecify the number of proxies.\n\tEx: -proxies=3")
)
// Automatically runs upon program start.
func init() {
programCloseHandler()
// Parse command line arguments.
flag.Parse()
if *passwordInput == "" || *proxiesInput == 0 {
fmt.Printf("Missing arguments.\n\n")
flag.Usage()
os.Exit(1)
}
banner()
// Read in user inputted proxies.
for proxies := 1; proxies <= *proxiesInput; proxies++ {
var headerInput string
var hostInput string
fmt.Printf("Enter header for proxy %d: ", proxies)
fmt.Scanln(&headerInput)
fmt.Printf("Enter IP followed by port for proxy %d (I.E. http://IP:PORT): ", proxies)
fmt.Scanln(&hostInput)
hostProxy[headerInput] = []string{hostInput, "down"}
fmt.Print("\n")
}
server.Logger.Println("Server started.")
fmt.Printf("\nServer started. For more verbose output, see log file: %s\n", server.LogFileName)
//Initialize the server and proxies.
prox = server.InitializeServer(passwordInput, hostProxy, prox, targetURLInput)
}
// Print banner.
func banner() {
banner := `
_ _
| \__/\__/ |
___ | '.||.' | _
/ _ \___|__/ || \__|__ _ _ __ __| |
/ /_\/ _ \--\ || /--/ _' | '__/ _' |
/ /_\\ (_) \ \||/ / (_| | | | (_| |
\____/\___/ \ || / \__,_|_| \__,_|
'.||.'
GoWard (v0.1)
`
fmt.Println(banner)
}
// Handles interrupts from system and Ctrl+C; gracefully exits program.
func programCloseHandler() {
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
<-c
fmt.Println("Exiting program...")
server.Logger.Printf("Program exited.\n\n")
server.LogFile.Close()
os.Exit(0)
}()
}
func main() {
// Start server and proxies.
server.Logger.Println("Starting proxy...")
_ = http.ListenAndServe(":80", prox)
}