Friday, July 26, 2013

Php Command Shell In OpenWrt

Agak ribet memang kalau ada beberapa perintah yang harus di jalankan melalui ssh dan itu harus membuka ssh melalui putty, sedikit share saya coba buat simple program yang udah banyak beredar di internet untuk melakukan perintah shell melalui php, dan saya cobaterapkan di openwrt, ok langsung sajah, ikuti langkah di bawah.

Untuk mendukung php berjalan di openwrt saya menginstall php5 :
 # opkg install php5-cgi  
Edit File "uhttpd"
 # nano /etc/config/uhttpd  
Hilangkan comment pada baris
 list interpreter  ".php=/usr/bin/php-cgi"  
Buat File php di dalam /www/
 # touch /www/shell.php  
 # nano /www/shell.php  
Dan berikut contoh program Php command shell yang sudah saya buat :
 <?php  
 error_reporting(E_PARSE);   
   if(isset($_GET['tombol']))  
   {  
 $shell=$_REQUEST['shell'];  
 $output = shell_exec($shell);  
  }  
 ?>  
 <form name="form1" method="get" action="#">  
 <textarea name="textarea" id="textarea" cols="80" wrap="off" rows="10"><?php echo $output; ?></textarea></form>  
 <form name="UserInformationForm" method="get" action="#">  
 <input name="shell" type="text" id="textarea" value="<?php echo $_get['shell']; ?>" size="92">  
    <input name="tombol" type="submit" value="Command">  
 </form>  
Semoga bisa bermanfaat dan membantu :)

Sumber Referensi :
https://www.facebook.com/groups/openwrt/doc/376652802375750/
http://php.net/manual/en/function.shell-exec.php
http://www.w3schools.com/php/php_get.asp

I am a fan of technology and i love coffee. I’m also interested in web programming and networking. below there are some accounts you can follow to contact me.


EmoticonEmoticon