-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ubiquiti survey bssid.php
113 lines (113 loc) · 4.2 KB
/
Ubiquiti survey bssid.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
<?php
error_reporting(0);
class Ubiquiti
{
function ip($value){
return $this->ip = $value;
}
function username($value){
return $this->username = $value;
}
function password($value){
return $this->password = $value;
}
function ngecurl($url , $post=null , $header=null){
$ch = curl_init($url);
if($post != null) {
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (iPhone; U; CPU iPhone OS 8_3_3 like Mac OS X; en-SG) AppleWebKit/537.25 (KHTML, like Gecko) Version/7.0 Mobile/8C3 Safari/6533.18.1");
curl_setopt($ch, CURLOPT_COOKIEJAR, getcwd()."cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, getcwd()."cookies.txt");
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
if($header != null) {
curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
}
curl_setopt($ch, CURLOPT_VERBOSE, false);
curl_setopt($ch, CURLOPT_COOKIESESSION, false);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,0);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
return curl_exec($ch);
curl_close($ch);
}
function Ok(){
$header = array("origin:https://".$this->ip,"Upgrade-Insecure-Requests:1","referer:https://".$this->ip."/login.cgi");
$result = json_decode($this->ngecurl("https://".$this->ip."/survey.json.cgi?iface=ath0",$header),true);
if($result){
$this->check($result);
}else{
$this->run();
}
}
function check($result){
foreach ($result as $key => $value) {
if($value[encryption] =="wpa"){
$value[encryption] = "wpa ";
}
if($value[signal_level] <= "-75" ){
$status = " ";
}else{
$status = "+";
}
if($value[essid] != ""){
if(str_replace("-","",$value[signal_level]) < "75" ){
$apik[] = "| ".$value[signal_level]." | ".$status." | ".$value[encryption]." | ".$value[mac]." | ".$value[essid]."\r\n";
}else{
$elek[] = "| ".$value[signal_level]." | ".$status." | ".$value[encryption]." | ".$value[mac]." | ".$value[essid]."\r\n";
}
if($value[encryption] =="none"){
$none[] = "| ".$value[signal_level]." | ".$status." | ".$value[encryption]." | ".$value[mac]." | ".$value[essid]."\r\n";
}
}
}
sort($woot,SORT_STRING);
sort($none,SORT_NUMERIC);
sort($apik,SORT_NUMERIC);
echo "+------------------------------------------------------------\r\n";
echo "+ SNYL | N | ENC | BSSID/MAC ADDRESS | SSID/Nama Jaringan --\r\n";
echo "+------------------------------------------------------------\r\n";
foreach ($apik as $value) {
echo $value;
}
echo "-----------------------------------------------------------+\r\n";
foreach ($elek as $value) {
echo $value;
}
echo "-----------------------------------------------------------+\r\n";
foreach ($none as $value) {
echo $value;
}
echo "-----------------------------------------------------------+\r\n";
$this->clearStdin();
$this->Ok();
echo "\r\n\n\n\n";
}
function clearStdin(){
sleep(5);
for ($i = 0; $i < 50; $i++) echo "\r\n";
}
function run(){
$header = array("origin:https://".$this->ip,"Upgrade-Insecure-Requests:1","referer:https://".$this->ip."/login.cgi");
$result = json_decode($this->ngecurl(
"https://".$this->ip."/login.cgi" ,
"password=".$this->password."&uri=/survey.json.cgi?iface=ath0&username=".$this->username,$header),true);
if($result){
$this->check($result);
}else{
$this->run();
}
}
}
$Ubiquiti = new Ubiquiti;
/*$Ubiquiti->ip("192.168.1.4");
$Ubiquiti->username("ubnt");
$Ubiquiti->password("");*/
echo "[Ubiquiti] IP Ubiquiti : ";$Ubiquiti->ip(fgets(fopen ("php://stdin","r")));
echo "[Ubiquiti] Username Ubiquiti : ";$Ubiquiti->username(fgets(fopen ("php://stdin","r")));
echo "[Ubiquiti] Password Ubiquiti : ";$Ubiquiti->password(fgets(fopen ("php://stdin","r")));
$Ubiquiti->run();