-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUI.py
More file actions
56 lines (45 loc) · 1.91 KB
/
UI.py
File metadata and controls
56 lines (45 loc) · 1.91 KB
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
from psutil import net_if_addrs
import sys
def main():
hide = True
try:
hide = True if (sys.argv[1] == "c") else False
iface_array = []
iface_number = 0
for i in net_if_addrs().items():
print("")
print('\t\t' + str(iface_number) + '. Iface: '+ str(i[0]))
iface_array.append(str(i[0]))
for j in i[1:]:
for h in j:
address = ""
if (not hide):
address = str(h.address)
else:
if str(h.family).split(".")[1] == "AF_INET":
address = "LOCAL IP"
elif str(h.family).split(".")[1] == "AF_INET6":
address = "LOCAL MAC"
else:
address = "LOCAL ADDRESS"
print('\t\t\t - ' + 'family: ' + str(h.family).split(".")[1] +
' | address: ' + (str(address))
+ ' | netmask: ' + str(h.netmask) + ' | broadcast: ' + str(h.broadcast) + ' | ptp: ' + str(h.ptp))
iface_number += 1
print("")
print('\t\t' + str(iface_number) + '. ALL ifaces')
iface_array.append("ALL")
print("")
keep_loop = True
while keep_loop == True:
choice = input('Select an Iface option (number + enter) :')
try:
iface_array[int(choice)]
keep_loop = False
print("Sniffer listening for: " + iface_array[int(choice)])
break
except (IndexError , TypeError):
print("invalid value, choose an option between 0 and " + str(len(iface_array) - 1))
except IndexError:
print("please init with a mode: c to hide local addresses , p for visualizating all adresses ")
main()