-
Notifications
You must be signed in to change notification settings - Fork 4
/
warmap.go
135 lines (115 loc) · 2.77 KB
/
warmap.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package main
import (
"bytes"
"flag"
"fmt"
"os"
"io/ioutil"
)
//To-Do
//Add Signal bleed based signal strength
//Type Definitions and variables
const (
version = "2.0"
tool = "warmap-go"
usage = `
Usage:
warmap-go [OPTIONS] -f <GPS FILE>
warmap-go -h | -help
warmap-go -v
Options:
-h, -help Show usage
-a Aerodump specification switch
-k Kismet database specification switch
-b <[ list | file ]> File or comma seperated list of bssids
-o <file> HTML Output file
-p <file> CSV Output for recorded BSSID values
-v Print version
-api <key> Google Maps API key
-sig <int> HTLM output signal filtering
`
)
////////////////////
//Type Definitions//
///////////////////
// Points defines a []Point array
type Points []Point
//Point holds X, Y coordinates
type Point struct {
X, Y float64
Dbm int
BSSID string
}
/////////////
//Functions//
////////////
//checkError is a generic error check function
func checkError(err error) {
if err != nil {
panic(err)
}
}
//sigCheck checks if signal has changed and modifies the base
func sigCheck(baseH *int, baseL *int, c int) {
if *baseH == 0 || *baseL == 0 {
*baseH = c
*baseL = c
}
if c > *baseH {
*baseH = c
}
if c < *baseL {
*baseL = c
}
}
func (points *Points) printPoints(file *string) {
// func printPoints(file *string, points *Points) {
list := make(map[string]int)
var data bytes.Buffer
for _, p := range *points {
if _, ok := list[p.BSSID]; !ok {
list[p.BSSID] = p.Dbm
} else if db, ok := list[p.BSSID]; ok && db < p.Dbm {
list[p.BSSID] = p.Dbm
}
}
for k, v := range list {
data.WriteString(fmt.Sprintf("%s,%v\n", k, v))
}
ioutil.WriteFile(*file, data.Bytes(), 0644)
}
func main() {
//Parse command line arguments
var (
flGPSFile = flag.String("f", "", "")
flBSSID = flag.String("b", "", "")
flOutFile = flag.String("o", "", "")
flAerodump = flag.Bool("a", false, "")
flKismet = flag.Bool("k", false, "")
flGAPI = flag.String("api", "", "")
flPoints = flag.String("p", "", "")
flSigFilter = flag.Int("sig", 0, "")
flVersion = flag.Bool("v", false, "")
)
flag.Usage = func() {
fmt.Println(usage)
}
flag.Parse()
if *flVersion {
fmt.Printf("version: %s\n", version)
os.Exit(0)
}
var gpsPoints Points
if *flAerodump {
gpsPoints = parseAeroGPS(flGPSFile)
} else if *flKismet {
gpsPoints = parseKismet(flGPSFile, parseBssid(flBSSID), flSigFilter)
} else {
gpsPoints = parseXML(flGPSFile, parseBssid(flBSSID), flSigFilter)
}
if *flPoints != "" {
gpsPoints.printPoints(flPoints)
}
templateBuffer := populateTemplate(&gpsPoints, flGAPI)
ioutil.WriteFile(*flOutFile, templateBuffer, 0644)
}