-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.go
65 lines (48 loc) · 1.05 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
package main
import (
"fmt"
"io/ioutil"
"os"
"github.com/docopt/docopt.go"
"gopkg.in/yaml.v2"
)
func main() {
var opts HijackerOptions
usage := `Usage: wifi-hijack CONFIG
Hijacks DNS requests on the given device.
Arguments:
CONFIG configuration file
Options:
-h --help`
arguments, _ := docopt.Parse(usage, nil, true, "", false)
data, err := ioutil.ReadFile(arguments["CONFIG"].(string))
if err != nil {
fmt.Fprintf(os.Stderr, "Error reading config file:\n%s\n", err)
os.Exit(1)
return
}
if err := yaml.Unmarshal(data, &opts); err != nil {
fmt.Fprintf(os.Stderr, "Error reading config file:\n%s\n", err)
os.Exit(1)
return
}
hijacker, err := CreateHijacker(&opts)
if err != nil {
fmt.Fprintf(os.Stderr, "Error creating hijacker:\n%s\n", err)
os.Exit(1)
return
}
err = hijacker.Run()
if err != nil {
fmt.Fprintf(os.Stderr, "Error running hijacker:\n%s\n", err)
os.Exit(1)
return
}
}
func run(options *HijackerOptions) error {
h, err := CreateHijacker(options)
if err != nil {
return err
}
return h.Run()
}