-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgui.go
211 lines (191 loc) · 7.89 KB
/
gui.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
package main
import (
"fmt"
"os"
"os/exec"
"runtime"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
)
func runGUI() {
a := app.New()
w := a.NewWindow("Doppelgänger Assistant")
w.Resize(fyne.NewSize(320, 475))
cardTypes := []string{"prox", "indala", "awid", "em", "iclass", "mifare", "piv"}
bitLengths := map[string][]string{
"prox": {"26", "30", "31", "33", "34", "35", "36", "37", "48"},
"indala": {"26", "27", "29"},
"awid": {"26"},
"em": {"32"},
"iclass": {"26", "35"},
"mifare": {"0"},
"piv": {"0"},
}
facilityCode := widget.NewEntry()
cardNumber := widget.NewEntry()
hexData := widget.NewEntry()
uid := widget.NewEntry()
dataBlocks := container.NewVBox()
updateDataBlocks := func(cardType string) {
dataBlocks.Objects = nil
switch cardType {
case "prox", "indala", "awid", "iclass":
dataBlocks.Add(widget.NewLabel("Facility Code"))
dataBlocks.Add(facilityCode)
dataBlocks.Add(widget.NewLabel("Card Number"))
dataBlocks.Add(cardNumber)
case "em":
dataBlocks.Add(widget.NewLabel("Hex Data"))
dataBlocks.Add(hexData)
case "mifare", "piv":
dataBlocks.Add(widget.NewLabel("UID"))
dataBlocks.Add(uid)
}
dataBlocks.Refresh()
}
bitLength := widget.NewSelect(bitLengths[cardTypes[0]], nil)
bitLength.SetSelectedIndex(0)
cardType := widget.NewSelect(cardTypes, func(value string) {
bitLength.Options = bitLengths[value]
bitLength.SetSelectedIndex(0)
updateDataBlocks(value)
})
cardType.SetSelectedIndex(0)
actions := []string{"Generate Proxmark3 Command", "Write & Verify Card Data", "Simulate Card Data"}
action := widget.NewSelect(actions, nil)
action.SetSelectedIndex(0)
terminalOutput := widget.NewLabel("")
submit := widget.NewButton("Submit", func() {
cardTypeValue := cardType.Selected
bitLengthValue := bitLength.Selected
facilityCodeValue := facilityCode.Text
cardNumberValue := cardNumber.Text
hexDataValue := hexData.Text
uidValue := uid.Text
actionValue := action.Selected
var cmd *exec.Cmd
cwd, err := os.Getwd()
if err != nil {
fmt.Println("Error getting current working directory:", err)
return
}
command := ""
switch actionValue {
case "Generate Proxmark3 Command":
command = fmt.Sprintf("echo Generating Proxmark3 command for %s with bit length %s", cardTypeValue, bitLengthValue)
if cardTypeValue == "prox" {
command = fmt.Sprintf("%s -t %s -bl %s -fc %s -cn %s", os.Args[0], cardTypeValue, bitLengthValue, facilityCodeValue, cardNumberValue)
} else if cardTypeValue == "iclass" {
command = fmt.Sprintf("%s -t %s -bl %s -fc %s -cn %s", os.Args[0], cardTypeValue, bitLengthValue, facilityCodeValue, cardNumberValue)
} else if cardTypeValue == "awid" {
command = fmt.Sprintf("%s -t %s -bl %s -fc %s -cn %s", os.Args[0], cardTypeValue, bitLengthValue, facilityCodeValue, cardNumberValue)
} else if cardTypeValue == "indala" {
command = fmt.Sprintf("%s -t %s -bl %s -fc %s -cn %s", os.Args[0], cardTypeValue, bitLengthValue, facilityCodeValue, cardNumberValue)
} else if cardTypeValue == "em" {
command = fmt.Sprintf("%s -t %s --hex %s", os.Args[0], cardTypeValue, hexDataValue)
} else if cardTypeValue == "mifare" {
command = fmt.Sprintf("%s -t %s --uid %s", os.Args[0], cardTypeValue, uidValue)
} else if cardTypeValue == "piv" {
command = fmt.Sprintf("%s -t %s --uid %s", os.Args[0], cardTypeValue, uidValue)
}
case "Write & Verify Card Data":
command = fmt.Sprintf("echo Writing and verifying card data for %s", cardTypeValue)
if cardTypeValue == "prox" {
command = fmt.Sprintf("%s -t %s -bl %s -fc %s -cn %s -w -v", os.Args[0], cardTypeValue, bitLengthValue, facilityCodeValue, cardNumberValue)
} else if cardTypeValue == "iclass" {
command = fmt.Sprintf("%s -t %s -bl %s -fc %s -cn %s -w -v", os.Args[0], cardTypeValue, bitLengthValue, facilityCodeValue, cardNumberValue)
} else if cardTypeValue == "awid" {
command = fmt.Sprintf("%s -t %s -bl %s -fc %s -cn %s -w -v", os.Args[0], cardTypeValue, bitLengthValue, facilityCodeValue, cardNumberValue)
} else if cardTypeValue == "indala" {
command = fmt.Sprintf("%s -t %s -bl %s -fc %s -cn %s -w -v", os.Args[0], cardTypeValue, bitLengthValue, facilityCodeValue, cardNumberValue)
} else if cardTypeValue == "em" {
command = fmt.Sprintf("%s -t %s --hex %s -w -v", os.Args[0], cardTypeValue, hexDataValue)
} else if cardTypeValue == "mifare" {
command = fmt.Sprintf("%s -t %s --uid %s -w -v", os.Args[0], cardTypeValue, uidValue)
} else if cardTypeValue == "piv" {
command = fmt.Sprintf("%s -t %s --uid %s -w -v", os.Args[0], cardTypeValue, uidValue)
}
case "Simulate Card Data":
command = fmt.Sprintf("echo Simulating card data for %s", cardTypeValue)
if cardTypeValue == "prox" {
command = fmt.Sprintf("%s -t %s -bl %s -fc %s -cn %s -s", os.Args[0], cardTypeValue, bitLengthValue, facilityCodeValue, cardNumberValue)
} else if cardTypeValue == "iclass" {
command = fmt.Sprintf("%s -t %s -bl %s -fc %s -cn %s -s", os.Args[0], cardTypeValue, bitLengthValue, facilityCodeValue, cardNumberValue)
} else if cardTypeValue == "awid" {
command = fmt.Sprintf("%s -t %s -bl %s -fc %s -cn %s -s", os.Args[0], cardTypeValue, bitLengthValue, facilityCodeValue, cardNumberValue)
} else if cardTypeValue == "indala" {
command = fmt.Sprintf("%s -t %s -bl %s -fc %s -cn %s -s", os.Args[0], cardTypeValue, bitLengthValue, facilityCodeValue, cardNumberValue)
} else if cardTypeValue == "em" {
command = fmt.Sprintf("%s -t %s --hex %s -s", os.Args[0], cardTypeValue, hexDataValue)
} else if cardTypeValue == "mifare" {
command = fmt.Sprintf("%s -t %s --uid %s -s", os.Args[0], cardTypeValue, uidValue)
} else if cardTypeValue == "piv" {
command = fmt.Sprintf("%s -t %s --uid %s -s", os.Args[0], cardTypeValue, uidValue)
}
default:
fmt.Println("Unsupported action")
return
}
switch runtime.GOOS {
case "darwin":
if _, err := exec.LookPath("/Applications/iTerm.app"); err == nil {
script := fmt.Sprintf(`
tell application "iTerm"
create window with default profile
tell current session of current window
write text "cd '%s' && clear && %s"
end tell
end tell
`, cwd, command)
cmd = exec.Command("osascript", "-e", script)
} else {
cmd = exec.Command("osascript", "-e", fmt.Sprintf("tell application \"Terminal\" to do script \"cd '%s' && clear && %s\"", cwd, command))
}
case "linux":
if _, err := exec.LookPath("gnome-terminal"); err == nil {
cmd = exec.Command("gnome-terminal", "--", "sh", "-c", fmt.Sprintf("cd \"%s\" && clear && %s; exec bash", cwd, command))
} else if _, err := exec.LookPath("xterm"); err == nil {
cmd = exec.Command("xterm", "-bg", "black", "-fg", "white", "-e", fmt.Sprintf("sh -c 'cd \"%s\" && clear && %s; exec bash'", cwd, command))
} else if _, err := exec.LookPath("x-terminal-emulator"); err == nil {
cmd = exec.Command("x-terminal-emulator", "-e", fmt.Sprintf("sh -c 'cd \"%s\" && clear && %s; exec bash'", cwd, command))
} else {
fmt.Println("No supported terminal emulator found. If you're using WSL run: `sudo apt install xterm`")
return
}
default:
fmt.Println("Unsupported OS")
return
}
err = cmd.Start()
if err != nil {
terminalOutput.SetText(fmt.Sprintf("Error: %s", err))
} else {
terminalOutput.SetText("Command executed in new terminal window")
}
})
reset := widget.NewButton("Reset", func() {
cardType.SetSelectedIndex(0)
bitLength.SetSelectedIndex(0)
facilityCode.SetText("")
cardNumber.SetText("")
hexData.SetText("")
uid.SetText("")
action.SetSelectedIndex(0)
terminalOutput.SetText("")
updateDataBlocks(cardTypes[0])
})
w.SetContent(container.NewVBox(
widget.NewLabel("Card Type"),
cardType,
widget.NewLabel("Bit Length"),
bitLength,
dataBlocks,
widget.NewLabel("Action"),
action,
container.NewHBox(submit, reset),
terminalOutput,
))
w.ShowAndRun()
}