-
-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathose.py
More file actions
executable file
·183 lines (141 loc) · 5.52 KB
/
ose.py
File metadata and controls
executable file
·183 lines (141 loc) · 5.52 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
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
#!/usr/bin/env python3
# OneShot-Extended (WPS penetration testing utility) is a fork of the tool with extra features
# Copyright (C) 2025 chickendrop89
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
import os
import sys
from shutil import which
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
def checkRequirements():
"""Verify requirements are met"""
if sys.version_info < (3, 9):
src.utils.die('The program requires Python 3.9 and above')
if os.getuid() != 0:
src.utils.die('Run it as root')
if not which('pixiewps'):
src.utils.die('Pixiewps is not installed, or not in PATH')
def setupDirectories():
"""Create required directories"""
# We recently changed the PIXIEWPS_DIR and SESSIONS_DIR path
# Rename older .OSE data dir to .OneShot-Extended, and maintain compatibility
old_dir = os.path.expanduser('~/.OSE')
new_dir = os.path.expanduser('~/.OneShot-Extended')
if os.path.exists(old_dir):
try:
os.rename(old_dir, new_dir)
print('[*] Renamed legacy data directory')
except OSError as e:
print(f'[!] Failed to rename data directory: {e}')
for directory in [src.utils.SESSIONS_DIR, src.utils.PIXIEWPS_DIR]:
if not os.path.exists(directory):
os.makedirs(directory)
def setupAndroidWifi(android_network: src.wifi.android.AndroidNetwork, enable: bool = False):
"""Configure Android-specific WiFi settings"""
if enable:
android_network.enableWifi()
else:
android_network.storeAlwaysScanState()
android_network.disableWifi()
def setupMediatekWifi(wmt_wifi_device: Path):
"""Initialize MediaTek WiFi dev"""
if not wmt_wifi_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')
wmt_wifi_device.chmod(0o644)
wmt_wifi_device.write_text('1', encoding='utf-8')
def scanForNetworks(interface: str, vuln_list: list[str]) -> str:
"""Scan, and prompt user to select network. Returns BSSID"""
scanner = src.wifi.scanner.WiFiScanner(interface, vuln_list)
return scanner.promptNetwork()
def handleConnection(args):
"""Main connection logic"""
if args.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 = []
if not args.loop:
print('[*] BSSID not specified (--bssid) — scanning for available networks')
args.bssid = scanForNetworks(args.interface, vuln_list)
if args.bssid:
if args.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
)
def main():
"""Main os-e code"""
checkRequirements()
setupDirectories()
args = src.args.parseArgs()
while True:
try:
android_network = src.wifi.android.AndroidNetwork()
if args.clear:
src.utils.clearScreen()
if src.utils.isAndroid() is True and not args.dts and not args.mtk_wifi:
setupAndroidWifi(android_network)
if args.mtk_wifi:
wmt_wifi_device = Path('/dev/wmtWifi')
setupMediatekWifi(wmt_wifi_device)
if src.utils.ifaceCtl(args.interface, action='up'):
src.utils.die(f'Unable to up interface \'{args.interface}\'')
handleConnection(args)
if not args.loop:
break
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
args.bssid = None
else:
print('\nAborting…')
break
finally:
if src.utils.isAndroid() is True and not args.dts and not args.mtk_wifi:
setupAndroidWifi(android_network, enable=True)
if args.iface_down:
src.utils.ifaceCtl(args.interface, action='down')
if args.mtk_wifi:
wmt_wifi_device.write_text('0', encoding='utf-8')
if __name__ == '__main__':
main()