<?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>Tech B.</title>
	<atom:link href="http://kbcarte.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://kbcarte.wordpress.com</link>
	<description>Python For The Win</description>
	<lastBuildDate>Sun, 25 Dec 2011 23:04:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='kbcarte.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Tech B.</title>
		<link>http://kbcarte.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://kbcarte.wordpress.com/osd.xml" title="Tech B." />
	<atom:link rel='hub' href='http://kbcarte.wordpress.com/?pushpress=hub'/>
		<item>
		<title>PyBrowse</title>
		<link>http://kbcarte.wordpress.com/2011/12/14/pybrowse/</link>
		<comments>http://kbcarte.wordpress.com/2011/12/14/pybrowse/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 18:08:00 +0000</pubDate>
		<dc:creator>Tech B.</dc:creator>
				<category><![CDATA[Programming Python]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[beautifulsoup]]></category>
		<category><![CDATA[data mining]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[k b carte]]></category>
		<category><![CDATA[kbcarte]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[POST]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[python 2.7]]></category>
		<category><![CDATA[tech b]]></category>
		<category><![CDATA[techb]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[web hacking]]></category>
		<category><![CDATA[web scraping]]></category>

		<guid isPermaLink="false">https://kbcarte.wordpress.com/?p=184</guid>
		<description><![CDATA[Been a while since my last post, not being as faithful as I want to be. The good news is, I&#8217;ve been working on a few things. Getting more into doing things with the web. Recently, I wanted to get a better understanding of regular expressions, and what better way than to parse html. This [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kbcarte.wordpress.com&amp;blog=14806936&amp;post=184&amp;subd=kbcarte&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Been a while since my last post, not being as faithful as I want to be. The good news is, I&#8217;ve been working on a few things. Getting more into doing things with the web. Recently, I wanted to get a better understanding of regular expressions, and what better way than to parse html.</p>
<p>This post, however is not about regex, that will come in my next post where I introduce a lib for playing internet radio.</p>
<p>So into the topic at hand. PyBrowse is a simplified web resource grabber. I like to get webpages and extract the info I&#8217;m interested in, and using python makes it really simple.</p>
<p>This first started as a way for me to complete programming challenges on hacktivism sites like <a href="http://hackthissite.org">HackThisSite</a>, <a href="http://hellboundhackers.org">HellBoundhackers</a>, and <a href="http://securityoverride.net">SecurityOverride</a>. All of which are really good sites for learning everything hack, well most everything. They have content mostly for web and software hacking, but very little on hardware endeavors. </p>
<p>Anyway, those sites offer challenges from SQL injections to cracking applications using debug break points and such. Those are great and all, but the ones I&#8217;m after are the programming/timed challenges. In the timed challenges, you have to write a program to log in, find the challenge, grab the needed data, and POST back the results all within 5-30 seconds.</p>
<p>That might not seem to difficult to some, but you have to handle cookies properly, parse through the html, calculate the data(from simple math, to breaking encryptions), and POST back the results. All within that little time frame.</p>
<p>Some of you unfamiliar with working with the web might be wondering why I keep capitalizing &#8220;post&#8221;. It is a facade used over HTTP. You have <a href="http://en.m.wikipedia.org/wiki/GET_(HTTP)">GET</a> and <a href="en.m.wikipedia.org/wiki/POST_(HTTP)">POST</a>. There are others, but they fall out of the scope of this article. To GET a page, you simply request the page, the server gives it to you, and the connection is dropped. When you POST something, your giving the server some data to act on. It could be log in information, data you filled out in some forms, or a search query. There could be a host of things the server wants.</p>
<p>Okay, now that we have a better understanding of what we want to do (and before I bore you to death) it&#8217;s time to jump into some python.</p>
<p>To work with the web, python provides us with some useful modules. On python 2.7 and earlier, we have <a href="http://docs.python.org/library/urllib.html">urllib</a>, <a href="http://docs.python.org/library/urllib2.html">urllib2</a>, and <a href="http://docs.python.org/library/cookielib.html">cookielib</a>. We will also be using <a href="http://www.crummy.com/software/BeautifulSoup/">BeautifulSoup</a>, which is not part of the standard library and will need to be downloaded.</p>
<p>Urllib and urllib2 will get the webpages, cookielib will handle the session and cookies, and beautifulsoup will aid in sorting through all the ugly html.</p>
<p>An example of using urllib:<br />
<pre class="brush: python;">
import urllib
url = &quot;http://www.google.com/index.html&quot;

req = urllib.urlopen(url)

print req.read()
</pre></p>
<p>Simple eh? We won&#8217;t be opening our webpages with urllib though, we will be using it to encode the POST data. So we will see it more like this:</p>
<p><pre class="brush: python;">
data = {&quot;user_name&quot;:&quot;My_Name&quot;,
             &quot;user_pads&quot;:&quot;My_Guessable_Password&quot;
             &quot;login&quot;:&quot;Login&quot;}

endata = urllib.urlencode(data)
</pre></p>
<p>You might be wondering what that dict is, and why we chose the values that we did. Well, go to a website that requires a login like SecurityOverride.net and look at the source of the page, the keyboard shortcut is usually ctrl+u. Look for the tags and forms for the logins. You notice they usually two text boxes, one for the user name and one for the password, and one called submit that has a name of &#8220;login&#8221; and a value of &#8220;Login&#8221;. Those are where we will POST the data into and virtually click the submit button. You can find more info on how html is set up over at <a href="http://w3schools.com">w3schools</a>.</p>
<p>We will use urllib2 the same way we did urllib in the first example. Here are some examples:</p>
<p><pre class="brush: python;">
#using data from previews example

import urllib2
url = &quot;http://www.hellboundhackers.org/index.php&quot;

#GET page
req = urllib2.urlopen(url)

with open(&quot;test1.html&quot;, &quot;w&quot;) as f:
    f.write(req.read())

#POST to page
req = urllib2.urlopen(url, data)
with open(&quot;test.html&quot;, &quot;w&quot;) as f:
    f.write(req.read())

</pre></p>
<p>Not too hard right? Okay, what happens if we try and get a page only visible by members? It won&#8217;t work because the server doesn&#8217;t know your still you, this is where cookies come in.</p>
<p>To use cookies, we create a page opener that stores your browsing session. In order for us to stay logged in, we need to use the opener with every request. To do this we create a cookiejar to store things. Here is a quick.example:</p>
<p><pre class="brush: python;">
import cookielib

ref = &quot;http://www.hellboundhackers.org/index.php&quot;

cj = cookielib.CookieJar()

opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))

opener.addheaders.append(('User-agent', 'Mozilla/4.0'))

opener.addheader.append(('Referer',ref))
</pre></p>
<p>You might be wondering what all that header stuff is. It turns out websites don&#8217;t like it when a program access there site that&#8217;s not considered a browser. So we have to spoof being a real browser by sending header information. This is also where we put the refer redirect url.</p>
<p>Okay, we have a way to get pages, give data back to page, and a way to handle cookies to make sure we stay on the same session. We now need an easy way of deciphering all that html we have. This is where beautiful soup comes in. Sure we could use regex, or old fashioned string manipulations, but there are many, many, many times where the data gets complex. And to top that, not all sites will give you correct formats or tagging. Beautifulsoup makes thing 100 times eaiser because it does all the error checking and correcting malformed tags.</p>
<p>Here is an example of beautifulsoup getting all the links (a href tags) from a page:</p>
<p><pre class="brush: python;">
from BeautifulSoup import BeautifulSoup

#assume we have the page from the previous example
soup = BeautifulSoup(page)

tags = soup.findAll('a')

sorted_tags = [ i['href'] for i in tags if i.has_key('href')]

for tag in sorted_tags:
    print tag
    print &quot;-&quot;*30
</pre></p>
<p>With 4 lines of code, we have scraped all the links on a given page. You could even cut it down to 2 lines with more list comprehension, but then it would start getting ugly and unreadable.</p>
<p>Welp folks, there you have it. Now that we have a better understanding, let&#8217;s put all that knowledge into a module. </p>
<p>This on will also find input tags, so it can be eaiser to find POST data and see what sites are really asking for. I give an example on how to use it in the doc string, and have already given examples on how the different parts work, so I will leave you with this:</p>
<p><pre class="brush: python;">
# pybrowse.py
# Author K.B. Carte
# Dec. 14, 2011
#
# Class to handle simple web requests and parsing.
# Can be used as a base class for web crawlers
# or finding login fields and expected values.
#
# TODO:
# add more tag parsing, such as embedded video/flash,
# images, mp3s/audio, direct download links, etc.

from BeautifulSoup import BeautifulSoup
import urllib
import urllib2
import cookielib

class Browser:
    '''Simple class to fetch internet resources.
Can get pages, post to pages, grab all external or local links on page, grabs all input forms hidden or not, and handles cookie sessions.

Usage:
bro = Browser()
#great site btw
url = &quot;http://www.newgrounds.com/index.html&quot;

bro.openerSession(url)
page = bro.getPage(url)
inp = bro.getInputs(page)

for item in inp:
    for k, v in zip(item.keys(), item.values()):
        print k, v
    print &quot;-&quot;*30
'''
    def openerSession(self, ref):
        '''Aids in cookie handling for browsing sessions, not entirely needed, but some sites need cookies, such as forums/bbs sites.'''
        cj = cookielib.CookieJar()
        self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
        self.opener.addheaders.append(('User-agent', 'Mozilla/4.0'))
        self.opener.addheaders.append(('Referer',ref))

    def getPage(self, url):
        '''Self explanatory.'''
        get_req = self.opener.open(url)
        return get_req.read()

    def postPage(self, url, data):
        '''POST data to a page.
           data is type dict containing the values you need to encode.
           I.E. username, password, search query, etc.
           You can use the getInputs method to look for tag named and values needed for POSTing'''
        endata = urllib.urlencode(data)
        get_req = self.opener.open(url, endata)
        return get_req.read()

    def getInputs(self, page):
        '''Get all the from page.
           Returns tuple with raw tags, and common attributes of tags.
           ( ([raw tags], {common attrib} )
           common attrib: Type, Name, Value of tag'''
        soup = BeautifulSoup(page)
        inpts = soup.findAll('input')
        raw_tags = [str(i) for i in inpts]
        common_attrib = []
        for attrib in inpts:
            buff = {}
            if attrib.has_key(&quot;type&quot;):
                buff[&quot;Type&quot;] = attrib[&quot;type&quot;]
            else:
                buff[&quot;Type&quot;] = &quot;none&quot;

            if attrib.has_key(&quot;name&quot;):
                buff[&quot;Name&quot;] = attrib[&quot;name&quot;]
            else:
                buff[&quot;Name&quot;] = &quot;none&quot;

            if attrib.has_key(&quot;value&quot;):
                buff[&quot;Value&quot;] = attrib[&quot;value&quot;]
            else:
                buff[&quot;Value&quot;] = &quot;none&quot;

            common_attrib.append(buff)

        return (raw_tags, common_attrib)

    def getLinks(self, page, base):
        '''Grabs all the links in the page.
           base helps check if the link is local or points to an external site.
           Note that local links returned don't have the base url prepended if they don't on the page itself, you will have to explicitly do that.
           Returns tuple of local and external urls.
           ( local, external )'''
        soup = BeautifulSoup(page)
        tags = soup.findAll('a')
        tags = [tag['href'] for tag in tags if tag.has_key('href')]
        local = []
        external = []
        for tag in tags:
            if base in tag:
                local.append(tag)
            elif &quot;http&quot; not in tag:
                local.append(tag)
            else:
                external.append(tag)
        return (local, external)
</pre></p>
<p>It could use a little work and optimization, but it works for a quick hack. BTW, this article, along with the module was written on my Android Phone, and tested with SL4A (aka ASE). Phew, boy to my thumbs hurt lol. Also tested on Windows and Linux.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kbcarte.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kbcarte.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kbcarte.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kbcarte.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kbcarte.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kbcarte.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kbcarte.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kbcarte.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kbcarte.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kbcarte.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kbcarte.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kbcarte.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kbcarte.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kbcarte.wordpress.com/184/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kbcarte.wordpress.com&amp;blog=14806936&amp;post=184&amp;subd=kbcarte&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kbcarte.wordpress.com/2011/12/14/pybrowse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5d5f8fb3557e8258c7febe710dcdbdcd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kbcarte</media:title>
		</media:content>
	</item>
		<item>
		<title>Hide your ASSets the Python way</title>
		<link>http://kbcarte.wordpress.com/2011/11/05/hide-you-assets-the-python-way/</link>
		<comments>http://kbcarte.wordpress.com/2011/11/05/hide-you-assets-the-python-way/#comments</comments>
		<pubDate>Sat, 05 Nov 2011 00:46:41 +0000</pubDate>
		<dc:creator>Tech B.</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[archive]]></category>
		<category><![CDATA[hide]]></category>
		<category><![CDATA[hide files]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[python hide files]]></category>
		<category><![CDATA[zip]]></category>

		<guid isPermaLink="false">http://kbcarte.wordpress.com/?p=179</guid>
		<description><![CDATA[Some of you may have seen the &#8220;trick&#8221; of using the command prompt to hide archives in images. Example: &#8220;C:&#62;copy /b image1.jpg + stuff.zip newimage.jpg&#8221; This will hide stuff.zip in the picture image.jpg and output the merged file as newimage.jpg As far as I know, this only works with jpeg&#8217;s. That&#8217;s cool and all, but [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kbcarte.wordpress.com&amp;blog=14806936&amp;post=179&amp;subd=kbcarte&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Some of you may have seen the &#8220;trick&#8221; of using the command prompt to hide archives in images. Example: &#8220;C:&gt;copy /b image1.jpg + stuff.zip newimage.jpg&#8221; This will hide stuff.zip in the picture image.jpg and output the merged file as newimage.jpg</p>
<p>As far as I know, this only works with jpeg&#8217;s. That&#8217;s cool and all, but how does it do that? And how can I do the same with python?</p>
<p>Well, it works by opening each file as it&#8217;s binary state and merges the two binaries into one. To view the image, just open it like normal. To view the archive, open it with an archive viewer like 7zip.</p>
<p>Now that we know how it works, lets try and do the same with python.</p>
<p><pre class="brush: python;">
#open the image a=append, b=open as binary
image = open(&quot;test.jpg&quot;, &quot;ab&quot;)

#open the archive as a binary
archive = open(&quot;test.zip&quot;,&quot;rb&quot;)

#write the archive data after a newline
#to our image
image.write(&quot;\n&quot;+archive.read())

#close handles
image.close()
archive.close()
</pre></p>
<p>As you can see, it only took 5 lines of code. You can view the image as a regular image, or open as a zip file. Alliteratively, you could os.popen() or os.system() with the cmd version as well, but I like to do things the python way.</p>
<p>Short, sweet, and to the point.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kbcarte.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kbcarte.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kbcarte.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kbcarte.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kbcarte.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kbcarte.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kbcarte.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kbcarte.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kbcarte.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kbcarte.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kbcarte.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kbcarte.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kbcarte.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kbcarte.wordpress.com/179/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kbcarte.wordpress.com&amp;blog=14806936&amp;post=179&amp;subd=kbcarte&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kbcarte.wordpress.com/2011/11/05/hide-you-assets-the-python-way/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5d5f8fb3557e8258c7febe710dcdbdcd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kbcarte</media:title>
		</media:content>
	</item>
		<item>
		<title>Brute Forcing And Word List Attack Vector</title>
		<link>http://kbcarte.wordpress.com/2011/10/29/brute-forcing-and-word-list-attack-vector/</link>
		<comments>http://kbcarte.wordpress.com/2011/10/29/brute-forcing-and-word-list-attack-vector/#comments</comments>
		<pubDate>Sat, 29 Oct 2011 13:12:19 +0000</pubDate>
		<dc:creator>Tech B.</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[break paword]]></category>
		<category><![CDATA[brute force]]></category>
		<category><![CDATA[brute force password]]></category>
		<category><![CDATA[combinations]]></category>
		<category><![CDATA[generate word list]]></category>
		<category><![CDATA[hack3rcon]]></category>
		<category><![CDATA[hashcat]]></category>
		<category><![CDATA[k b carte]]></category>
		<category><![CDATA[kbcarte]]></category>
		<category><![CDATA[password crack]]></category>
		<category><![CDATA[permutations]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[tech b]]></category>
		<category><![CDATA[techb]]></category>
		<category><![CDATA[word list]]></category>
		<category><![CDATA[word list crackign]]></category>

		<guid isPermaLink="false">http://kbcarte.wordpress.com/?p=161</guid>
		<description><![CDATA[So in my last post I mentioned brute forcing. I was going to add a password brute force function to try and get into a access point. Well, android doesn&#8217;t support the iwconfig command even rooted, so that would be have to be done in java (C++ if using the NDK). Even though I do develop Android apps, my focus [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kbcarte.wordpress.com&amp;blog=14806936&amp;post=161&amp;subd=kbcarte&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So in my last post I mentioned brute forcing. I was going to add a password brute force function to try and get into a access point. Well, android doesn&#8217;t support the iwconfig command even rooted, so that would be have to be done in java (C++ if using the NDK). Even though I do develop Android apps, my focus here on my blog is in python.</p>
<p>As promised, I am going to go over brute forcing. What is brute forcing? It is when you try every combination of letters and numbers as a password. By doing this, you can break %100 of all passwords. There is a catch though. It can take a very long time and use exponential amounts of computing power. Brute forcing technical term would be permutation of combinations. You can find the background and technical stuff <a href="http://en.wikipedia.org/wiki/Permutation">here</a> and <a href="http://en.wikipedia.org/wiki/Combination">here</a>.</p>
<p>What&#8217;s the difference between permutations and combinations? Well, a combination will give you every possible way you can group letters and numbers, but it also needs to know how many different combos you want to try. You can group 4 letters into 2&#8242;s or 3&#8242;s or 4&#8242;s. Example 3&#8242;s: abcd-&gt; abc, abd, acd, bcd.</p>
<p>What if we needed all the letters in every order they could be in? This is where permutations come in. We need permutations of the combinations in order to get every single last way we could order, combine, and use the letters ever. Example of permutations of abcd with out the combinations: abcd, abdc, adbc, dabc, etc&#8230;.</p>
<p>You might be thinking, it looks like permutations already does all the possible letter combinations. Well, yes it does, but that is if we have a fixed length of letters, and only 4 different letters to work with. Permutations of abcd isn&#8217;t going to contain z or x in it, nor will it give you just 2 combinations of all the letters. This is why we need to do permutation of ever combination we can.</p>
<p>Below is a script that will generate a word list with the supplied characters you give it, and a max length of combinations to try. When I say max length, I mean it will start combining letters from a group of two and work its way up to the max value specified. I.E. abcd-&gt; ab, ac, ad, &#8230;. cba, adc, adb, &#8230;. dcba, acbd, cbda, etc&#8230; Be warned though, the list will grow very quick with large values. On my system 4Gb RAM, Dual Core 2GH each, 64bit Windows 7 it took 30 minutes to generate a text file of  15Gb, and still was not finished generating the list. I was of course trying to do a list of all the letters of the alphabet(lower case) with a length of 7 characters long. I started out by putting all the words into a list instead of writing to a file, but that raped my memory and would crash every time around 3.7Gb of memory being used. The garbage collector would not keep up, even with the forcing of deleting objects on my part.</p>
<p>So before you get too bored reading this here is the script:</p>
<p><pre class="brush: python;">
import itertools, sys
def combList(charString, maxLength):
    &quot;&quot;&quot;Genorate inital word list. This is just diff combinations&quot;&quot;&quot;
    #var to keepmtrack of how many times we've been through the loop
    times = 0
    #list to hold combinations
    poss = []
    for iteration in range(maxLength):
        #Use try statment to make sure the max length isn't longer
        #than the characters we're going to use
        try:
            #Iter genorator for combos
            comb = itertools.combinations(charString,times+1)
        except ValueError:
            print &quot;Character string larger than max lenght\nplease try again&quot;
            sys.exit()

        #Genorator gives tuple with seporated values ex: ('w','o','r','d')
        for word in comb:
            #join tupe as string and add to list
            s = ''.join(word)
            poss.append(s)
        times += 1

    return poss

def permList(combinations):
    &quot;&quot;&quot;Genorates permutations of the genorated combonation list&quot;&quot;&quot;
    #going to write ultimate list to a file
    #if not, you can run into virtual memory errors if the list gets above 4Gb
    f = open(&quot;wordlist.txt&quot;,&quot;w&quot;)
    #var to hold how many words we have
    x = 0
    for word in combinations:
        #loop through combonations and genorate a list of all
        #possable ways to combine letters
        permutation = itertools.permutations(word)
        for permWord in permutation:
            f.write(''.join(permWord)+&quot;\n&quot;)
            x += 1
        #del used permutation to free up some memory
        #not so much needed, but this script will rape memory if
		#appending to a list insteady of writing to a file
        del permutation
    #always close file handles
    f.close()
    return x

def main():
    &quot;&quot;&quot;Main program, gets user info and computes the lists&quot;&quot;&quot;
    ch = raw_input(&quot;characters to try: &quot;)
    num = input(&quot;max length: &quot;)
    combo = combList(ch,num)
    print &quot;list genorated&quot;
    print &quot;doing wordlist now&quot;
    permTotal = permList(combo)
    f = open(&quot;wordlist.txt&quot;,&quot;r&quot;)
    print &quot;working...&quot;
    for i in range(permTotal+1):
        word = f.readline().strip()
        #This is where you would be doing the actule brute forcing
        #you could try and log into a website or crack a password protected
        #zip file, genorate md5's and crack a password dump
        #if linux, brute force WPA wifi with iwconfig
        #and any thing else you might need for a password
        print word
    f.close()
    print &quot;done\n&quot;
    raw_input(&quot;.....&quot;)

main()

</pre></p>
<p>Some issues with this method are that it is VERY processor heavy. Yeah it can be done on the GPU like hashcat, but the straight brute force is unreasonable. Other faults include the more characters you try, such as 8-10 password lengths, the longer it will take. Not to mention if the password is cAMel CaSeD and uses $p3c@l characters. That increases processing load 50 fold or more and will gangbang your memory.</p>
<p>A better option would be to generate a &#8220;tailored&#8221; wordlist. Like one full of birthdays, and 1337 speak. Other methods could be to gather information first, like crawling face book for significant names, dates, cars, hobbies and the like. People are very bad about choosing something easy to remember, like their favorite sports team followed by their favorite players jersey number or something.</p>
<p>The best method I have seen was at Hack3rcon in my home town last year. PureHate gave the lecture and was using hashcat and custom rule-sets to break hundreds of md5&#8242;s in 20 minuets. The video is posted at irongeek.com, but I will embed the vide from vimeo here.</p>
<p>Well, I hope you guys learned something. It was a lot of fun writing the script and figuring out how brute forcing works myself. I might extend the program and give it rules and turn it into something other than a teaching tool, but meh we&#8217;ll see.</p>
<p>Any way, thanks for reading and enjoy the video.</p>
<div class='embed-vimeo' style='text-align:center;'><iframe src='http://player.vimeo.com/video/16204254' width='400' height='300' frameborder='0'></iframe></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kbcarte.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kbcarte.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kbcarte.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kbcarte.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kbcarte.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kbcarte.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kbcarte.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kbcarte.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kbcarte.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kbcarte.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kbcarte.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kbcarte.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kbcarte.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kbcarte.wordpress.com/161/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kbcarte.wordpress.com&amp;blog=14806936&amp;post=161&amp;subd=kbcarte&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kbcarte.wordpress.com/2011/10/29/brute-forcing-and-word-list-attack-vector/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5d5f8fb3557e8258c7febe710dcdbdcd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kbcarte</media:title>
		</media:content>
	</item>
		<item>
		<title>Android ASE: WiFi Scan with UI</title>
		<link>http://kbcarte.wordpress.com/2011/09/01/android-ase-wifi-scan-with-ui/</link>
		<comments>http://kbcarte.wordpress.com/2011/09/01/android-ase-wifi-scan-with-ui/#comments</comments>
		<pubDate>Thu, 01 Sep 2011 05:28:00 +0000</pubDate>
		<dc:creator>Tech B.</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[android ase]]></category>
		<category><![CDATA[android python]]></category>
		<category><![CDATA[android scripting environment]]></category>
		<category><![CDATA[ase]]></category>
		<category><![CDATA[ase tutorial]]></category>
		<category><![CDATA[google tutorial]]></category>
		<category><![CDATA[gui]]></category>
		<category><![CDATA[python android]]></category>
		<category><![CDATA[ui]]></category>
		<category><![CDATA[wifi]]></category>
		<category><![CDATA[wifi scan]]></category>

		<guid isPermaLink="false">http://kbcarte.wordpress.com/?p=155</guid>
		<description><![CDATA[Playing more with the Android Scripting Environment, I wrote a simple script to display any access points in wifi range. Once you select an SSID, it will display some basic info on that AP, such as the MAC address and encryption type. If you have a rooted phone, you could theoretically brute force an APs [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kbcarte.wordpress.com&amp;blog=14806936&amp;post=155&amp;subd=kbcarte&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Playing more with the Android Scripting Environment, I wrote a simple script to display any access points in wifi range. Once you select an SSID, it will display some basic info on that AP, such as the MAC address and encryption type. If you have a rooted phone, you could theoretically brute force an APs password using *nix iwconfig commands. The next post I will show some quick and dirty code to brute force passwords. But for now here is the script for some UI WiFi scanning.</p>
<p><pre class="brush: python;">
#imports and get an object of android
import android, time
droid = android.Android()

#scan the wifi and assign vars to hold the results
#this is dirty, making sure WiFi is on, and
#toggling on if not would be better; API Browser =)
droid.wifiStartScan()
ap = droid.wifiGetScanResults()
aps = ap.result

#lists to hold the data from scan
x = []
o = []

#loop through results and grab the data we are interested in
#format the strings to be displayed in the UI
for point in aps:
  x.append(point[&amp;quot;ssid&amp;quot;])
  #capabilities are the encryption, if blank there is no encryption
  if point[&amp;quot;capabilities&amp;quot;] == &amp;quot;&amp;quot;:
    o.append(&amp;quot;MAC: &amp;quot;+point[&amp;quot;bssid&amp;quot;]+&amp;quot;\nFreq: &amp;quot;+str(point[&amp;quot;frequency&amp;quot;])+&amp;quot;\nEencryp: [OPEN]&amp;quot;)
  else:
    o.append(&amp;quot;MAC: &amp;quot;+point[&amp;quot;bssid&amp;quot;]+&amp;quot;\nFreq: &amp;quot;+str(point[&amp;quot;frequency&amp;quot;])+&amp;quot;\nEencryp: &amp;quot;+point[&amp;quot;capabilities&amp;quot;])

#set up UI dialog, populate, and present
droid.dialogCreateAlert(&amp;quot;WiFi Scan&amp;quot;, None)
droid.dialogSetItems(x)
droid.dialogShow()
#this grabs what the user has selected
result = droid.dialogGetResponse().result

#if selection not null, create new UI, populate, and present
if result.has_key(&amp;quot;item&amp;quot;):
  item = result[&amp;quot;item&amp;quot;]
  droid.dialogCreateAlert(&amp;quot;Basic Info&amp;quot;, o[item])
  droid.dialogShow()
</pre></p>
<p>=-=-=-EDIT-=-=-=</p>
<p>I just rooted my phone and turns out android doesn&#8217;t have iwconfig. They use the stack some how; didn&#8217;t find a whole lot of info on it. So no bruteforcing via the terminal&#8230; I am going to look into some other method. Anyway, I&#8217;ll at least post some code going over permutations.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kbcarte.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kbcarte.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kbcarte.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kbcarte.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kbcarte.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kbcarte.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kbcarte.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kbcarte.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kbcarte.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kbcarte.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kbcarte.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kbcarte.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kbcarte.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kbcarte.wordpress.com/155/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kbcarte.wordpress.com&amp;blog=14806936&amp;post=155&amp;subd=kbcarte&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kbcarte.wordpress.com/2011/09/01/android-ase-wifi-scan-with-ui/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5d5f8fb3557e8258c7febe710dcdbdcd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kbcarte</media:title>
		</media:content>
	</item>
		<item>
		<title>Android Twisted SpyCam</title>
		<link>http://kbcarte.wordpress.com/2011/08/31/android-twisted-spycam/</link>
		<comments>http://kbcarte.wordpress.com/2011/08/31/android-twisted-spycam/#comments</comments>
		<pubDate>Wed, 31 Aug 2011 06:15:09 +0000</pubDate>
		<dc:creator>Tech B.</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[android ase]]></category>
		<category><![CDATA[android scripting environment]]></category>
		<category><![CDATA[ase]]></category>
		<category><![CDATA[ase twisted]]></category>
		<category><![CDATA[b64 encode]]></category>
		<category><![CDATA[encode base64]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[python spycam]]></category>
		<category><![CDATA[python twisted]]></category>
		<category><![CDATA[spy cam]]></category>
		<category><![CDATA[twisted python]]></category>
		<category><![CDATA[twisted python tutorial]]></category>
		<category><![CDATA[webcam]]></category>

		<guid isPermaLink="false">http://kbcarte.wordpress.com/?p=150</guid>
		<description><![CDATA[I have been playing around with Androids ASE(android scripting environment). ASE allows you to run scripts on your android powered device. You can use Python, PHP, Javascript, Pearl, Ruby and much more. To install ASE on your device you must either have root, allow third party apps install,, or know how to sideload apk&#8217;s using [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kbcarte.wordpress.com&amp;blog=14806936&amp;post=150&amp;subd=kbcarte&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have been playing around with Androids ASE(android scripting environment). ASE allows you to run scripts on your android powered device. You can use Python, PHP, Javascript, Pearl, Ruby and much more. To install ASE on your device you must either have root, allow third party apps install,, or know how to sideload apk&#8217;s using android&#8217;s SDK tools like adb.</p>
<p>You can find the apk along with install instructions and more info on ASE at their <a href="code.google.com/p/android-scripting/">website.</a></p>
<p>Here is an example of using python as a remote spycam. I am using the Twisted Framework as the server, and it gets interesting because I embed the captured image from the phone as base64 data on the webpage Twisted is serving up. You can choose to install the Twisted libs when you install python on your device. This is a fairly new feature.</p>
<p>To learn more about twisted, you can visit their <a href="twistedmatrix.com/trac/">website.</a></p>
<p><pre class="brush: python;">
import android, os, base64
from twisted.internet import protocol, reactor

droid = android.Android()
os.chdir('/sdcard/webserver/')

def imgb64():
  droid.cameraCapturePicture('/sdcard/webserver/latest.jpg', True)
  im = open(&quot;latest.jpg&quot;,&quot;rb&quot;)
  ime = base64.b64encode(im.read())
  im.close()
  os.remove(&quot;latest.jpg&quot;)
  return ime

class ServeImage(protocol.Protocol):
  def connectionMade(self):
    data = imgb64()
    self.transport.write(&quot;&quot;&quot;&lt;html&gt;&lt;head&gt;&lt;title&gt;Android Camera&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&lt;img src=&quot;data:image/jpg;base64,%s&quot; alt=&quot;image&quot;/&gt;test&lt;/body&gt;&lt;/html&gt;&quot;&quot;&quot; % data)
    self.transport.loseConnection()

class ServeImageFactory(protocol.ServerFactory):
  protocol = ServeImage

reactor.listenTCP(8080, ServeImageFactory())
reactor.run()</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kbcarte.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kbcarte.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kbcarte.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kbcarte.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kbcarte.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kbcarte.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kbcarte.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kbcarte.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kbcarte.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kbcarte.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kbcarte.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kbcarte.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kbcarte.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kbcarte.wordpress.com/150/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kbcarte.wordpress.com&amp;blog=14806936&amp;post=150&amp;subd=kbcarte&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kbcarte.wordpress.com/2011/08/31/android-twisted-spycam/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5d5f8fb3557e8258c7febe710dcdbdcd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kbcarte</media:title>
		</media:content>
	</item>
		<item>
		<title>More Fun With MindFlex</title>
		<link>http://kbcarte.wordpress.com/2011/03/08/more-fun-with-mindflex/</link>
		<comments>http://kbcarte.wordpress.com/2011/03/08/more-fun-with-mindflex/#comments</comments>
		<pubDate>Tue, 08 Mar 2011 04:52:19 +0000</pubDate>
		<dc:creator>Tech B.</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[arduino fire]]></category>
		<category><![CDATA[arduino interface]]></category>
		<category><![CDATA[brain waves]]></category>
		<category><![CDATA[fire]]></category>
		<category><![CDATA[fire bender]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[k b carte]]></category>
		<category><![CDATA[kbcarte]]></category>
		<category><![CDATA[mindcontrol]]></category>
		<category><![CDATA[mindflex]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[real fire bender]]></category>
		<category><![CDATA[tech b]]></category>
		<category><![CDATA[techb]]></category>

		<guid isPermaLink="false">http://kbcarte.wordpress.com/?p=142</guid>
		<description><![CDATA[After my last article, I was thinking it wasn&#8217;t impressive enough. Sure, lighting a match that is on the computer screen is cool and all, but what if it where a real flame. In fear of catching my house on fire, or blowing off an appendage or two, I decided to go small scale for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kbcarte.wordpress.com&amp;blog=14806936&amp;post=142&amp;subd=kbcarte&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div id="attachment_143" class="wp-caption aligncenter" style="width: 650px"><a href="http://kbcarte.files.wordpress.com/2011/03/imag0115.jpg"><img class="size-full wp-image-143" title="Fire Bender" src="http://kbcarte.files.wordpress.com/2011/03/imag0115.jpg?w=450" alt=""   /></a><p class="wp-caption-text">Last Fire Bender</p></div>
<p>After my last article, I was thinking it wasn&#8217;t impressive enough. Sure, lighting a match that is on the computer screen is cool and all, but what if it where a real flame.</p>
<p>In fear of catching my house on fire, or blowing off an appendage or two, I decided to go small scale for the moment. I needed something with a controllable flame and was small enough to use inside. So I decided on using an adjustable lighter.</p>
<p>The MindFlex hardware portion will not be covered, you can read my last post to get that going.</p>
<p>The new stuff consists of hacking the lighter. I dissembled the lighter and took the swing arm off and super-glued a broke off clip to a ballpoint pen. I poked a hole through the end of the clip so I could fit a paperclip in it. Next was to attach another clip to the servo. After I had both pieces sturdy enough for use, I was off to find a base to put them in. I ended up with a cylinder shaped packaging that was holding some paperclips. I cut a square big enough to fit the servo in, and taped the lighter to the outside of the base. Next I fitted a paperclip on both clips so the servo could controlled the lighters flame adjuster. Pictures below:</p>
<div id="attachment_144" class="wp-caption aligncenter" style="width: 650px"><a href="http://kbcarte.files.wordpress.com/2011/03/imag0113.jpg"><img class="size-full wp-image-144" title="Base side" src="http://kbcarte.files.wordpress.com/2011/03/imag0113.jpg?w=450" alt=""   /></a><p class="wp-caption-text">Base Of Unit</p></div>
<div id="attachment_145" class="wp-caption aligncenter" style="width: 650px"><a href="http://kbcarte.files.wordpress.com/2011/03/imag0114.jpg"><img class="size-full wp-image-145" title="Base Front" src="http://kbcarte.files.wordpress.com/2011/03/imag0114.jpg?w=450" alt=""   /></a><p class="wp-caption-text">Base Unit Front View</p></div>
<p>I have to manually hold the lighter on. Although, adding a riser or jamming something in it to keep it on wouldn&#8217;t be to hard.  You can also adjust the max height of the flame by lifting the adjuster arm up off the gear and turn it up.</p>
<p>The code is pretty simple, just a miner adjustment to the SerialOut example from <a href="http://frontiernerds.com/brain-hack">Eric Mika</a>.</p>
<p><pre class="brush: plain;">
// Arduino Brain Library
// Eric Mika, 2010
// Edit by Tech B. to interface with a lighter, 2011

#include &lt;Brain.h&gt;
#include &lt;Servo.h&gt;
Servo myservo;

int pos;
int servoMap;
int atten;
// Set up the brain parser, pass it the hardware serial object you want to listen on.
Brain brain(Serial);

void setup() {
   // Start the hardware serial.
   Serial.begin(9600);
   // data pin to servo
   myservo.attach(13);
}

void loop() {
   // Expect packets about once per second.
   // I played around to find the max and min servo values
   if (brain.update()) {
       atten = brain.readAttention();
       // Map atten to angle of servo horn
       servoMap = map(atten, 0, 100, 150, 70);
       myservo.write(servoMap);
   }
}
</pre></p>
<p>It is interesting to play with this. The hard part of this whole project is making your mind do what you want. It varies person to person on the responsiveness.  For example, my wife keeps a steady meditative state and finds it hard to bring focus up; while I seem to keep a low focus and a steady mid attentive level .  I would be interested to see the results on some one who is ADD or ADHD, and compare the data to some one who is a monk, or practices meditation on a religious routine.</p>
<p>Here is a quick demo of me controlling the lighter:</p>
<span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='450' height='284' src='http://www.youtube.com/embed/CXFMwYrmG8U?version=3&amp;rel=1&amp;fs=1&amp;showsearch=0&amp;showinfo=1&amp;iv_load_policy=1&amp;wmode=transparent' frameborder='0'></iframe></span>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kbcarte.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kbcarte.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kbcarte.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kbcarte.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kbcarte.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kbcarte.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kbcarte.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kbcarte.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kbcarte.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kbcarte.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kbcarte.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kbcarte.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kbcarte.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kbcarte.wordpress.com/142/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kbcarte.wordpress.com&amp;blog=14806936&amp;post=142&amp;subd=kbcarte&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kbcarte.wordpress.com/2011/03/08/more-fun-with-mindflex/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5d5f8fb3557e8258c7febe710dcdbdcd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kbcarte</media:title>
		</media:content>

		<media:content url="http://kbcarte.files.wordpress.com/2011/03/imag0115.jpg" medium="image">
			<media:title type="html">Fire Bender</media:title>
		</media:content>

		<media:content url="http://kbcarte.files.wordpress.com/2011/03/imag0113.jpg" medium="image">
			<media:title type="html">Base side</media:title>
		</media:content>

		<media:content url="http://kbcarte.files.wordpress.com/2011/03/imag0114.jpg" medium="image">
			<media:title type="html">Base Front</media:title>
		</media:content>
	</item>
		<item>
		<title>Fun With MindFlex</title>
		<link>http://kbcarte.wordpress.com/2011/03/05/fun-with-mindflex/</link>
		<comments>http://kbcarte.wordpress.com/2011/03/05/fun-with-mindflex/#comments</comments>
		<pubDate>Sat, 05 Mar 2011 12:50:40 +0000</pubDate>
		<dc:creator>Tech B.</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[arduino mindflex]]></category>
		<category><![CDATA[brain bending]]></category>
		<category><![CDATA[brain hacking]]></category>
		<category><![CDATA[brain wave]]></category>
		<category><![CDATA[k b carte]]></category>
		<category><![CDATA[kbcarte]]></category>
		<category><![CDATA[mind control]]></category>
		<category><![CDATA[mindflex]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[tech b]]></category>
		<category><![CDATA[techb]]></category>

		<guid isPermaLink="false">http://kbcarte.wordpress.com/?p=122</guid>
		<description><![CDATA[For this valentines day, my wife got me a MindFlex from Mattel. I have been wanting one of these since they have been on the market. It is a really interesting game where you control a foam ball with your mind. The ball will rise with the more focused you are. Letting your mind wonder [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kbcarte.wordpress.com&amp;blog=14806936&amp;post=122&amp;subd=kbcarte&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For this valentines day, my wife got me a MindFlex from Mattel. I have been wanting one of these since they have been on the market. It is a really interesting game where you control a foam ball with your mind. The ball will rise with the more focused you are. Letting your mind wonder and as Morphius likes to say &#8220;free your mind&#8221;, the ball will lower.</p>
<span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='450' height='284' src='http://www.youtube.com/embed/PwGuOclij6k?version=3&amp;rel=1&amp;fs=1&amp;showsearch=0&amp;showinfo=1&amp;iv_load_policy=1&amp;wmode=transparent' frameborder='0'></iframe></span>
<p>MindFlex doesn&#8217;t read your thoughts, rather it picks up on level of activity. There has been fuss about the legitimacy of how this thing works. The popular video of it being placed on a foam head with a damp cloth gives readings. If you would do the same with a medical grade EEG, you would receive random values.</p>
<p>MindFlex uses a NeuroSky chip to compute the brain data. You can have 8 channels of raw wave activity:</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Delta_wave">Delta</a> (1-3Hz): sleep</li>
<li><a href="http://en.wikipedia.org/wiki/Theta_wave">Theta</a> (4-7Hz): relaxed, meditative</li>
<li><a href="http://en.wikipedia.org/wiki/Alpha_waves">Low Alpha</a> (8-9Hz): eyes closed, relaxed</li>
<li><a href="http://en.wikipedia.org/wiki/Alpha_waves">High Alpha</a> (10-12Hz)</li>
<li><a href="http://en.wikipedia.org/wiki/Beta_wave">Low Beta</a> (13-17Hz): alert, focused</li>
<li><a href="http://en.wikipedia.org/wiki/Beta_wave">High Beta</a> (18-30Hz)</li>
<li><a href="http://en.wikipedia.org/wiki/Gamma_wave">Low Gamma</a> (31-40Hz): multi-sensory processing</li>
<li><a href="http://en.wikipedia.org/wiki/Gamma_wave">High Gamma</a> (41-50Hz)</li>
</ul>
<p>Along with connection quality, and the proprietary attention and meditation values.</p>
<p>Inspired by <a href="http://frontiernerds.com/brain-hack">Eric Mika&#8217;s </a>post, I set out to replicate and extend his project. He wrote a library to get the data using an Arduino. He also wrote graphic software to aid in the visuals of the activity in your mind.  Eric go&#8217;s into better detail about the data the chip gives off. He has a video about the hardware hack, and it is very informative.</p>
<p>Basically, you need a shared ground and a wire extending the Tx pin for the NeuroSky chip circuit. Using images from <a href="http://www.bigmech.com/misc/mindflex/">this teardown</a> of the MindFlex I point out which pins they are. This is in the left pod of the headset:</p>
<div id="attachment_124" class="wp-caption aligncenter" style="width: 510px"><a href="http://kbcarte.files.wordpress.com/2011/03/ground.jpg"><img class="size-full wp-image-124" title="Ground" src="http://kbcarte.files.wordpress.com/2011/03/ground.jpg?w=450" alt=""   /></a><p class="wp-caption-text">Ground</p></div>
<div id="attachment_123" class="wp-caption aligncenter" style="width: 510px"><a href="http://kbcarte.files.wordpress.com/2011/03/tx.jpg"><img class="size-full wp-image-123" title="Tx" src="http://kbcarte.files.wordpress.com/2011/03/tx.jpg?w=450" alt=""   /></a><p class="wp-caption-text">Tx Pin</p></div>
<p>I have affixed the Arduino to the headset using Velcro, opposed to zip ties. Also I have noticed it is better for the usb port to be facing the back of the head when you wear it. This keeps the cords away from your face. Here are some pictures of the finished mod:</p>
<div id="attachment_128" class="wp-caption aligncenter" style="width: 650px"><a href="http://kbcarte.files.wordpress.com/2011/03/imag0108.jpg"><img class="size-full wp-image-128 " title="Top" src="http://kbcarte.files.wordpress.com/2011/03/imag0108.jpg?w=450" alt=""   /></a><p class="wp-caption-text">Top View</p></div>
<div id="attachment_127" class="wp-caption aligncenter" style="width: 650px"><a href="http://kbcarte.files.wordpress.com/2011/03/imag0107.jpg"><img class="size-full wp-image-127 " title="Front" src="http://kbcarte.files.wordpress.com/2011/03/imag0107.jpg?w=450" alt=""   /></a><p class="wp-caption-text">Front View</p></div>
<div id="attachment_129" class="wp-caption aligncenter" style="width: 650px"><a href="http://kbcarte.files.wordpress.com/2011/03/imag0111.jpg"><img class="size-full wp-image-129 " title="Mazy Investigates" src="http://kbcarte.files.wordpress.com/2011/03/imag0111.jpg?w=450" alt=""   /></a><p class="wp-caption-text">My Inspector Mazy, she aproves.</p></div>
<p>After copying the BrainLibrary into the Arduinos lib, I loaded the BrainSerialOut example that came with the library, I immediately  got python reading from the COM port. The data comes as a string containing 11 values: signal strength, attention, meditation, delta, theta, low alpha, high alpha, low beta, high beta, low gamma, high gamma.</p>
<p>When the signal strength is at 0 it is at its strongest. The next two values are the ones I am interested in. If the signal strength isn&#8217;t strong enough, you will not get the attention or meditative values.</p>
<p>The next step on my list was to make this data available to what ever can handle sockets like <a href="http://blender.org">Blender</a>, <a href="http://android.com">Android</a>, <a href="http://www.apple.com/iphone/?cid=oas-us-domains-iphone.com">Iphone</a>, and I think <a href="http://www.adobe.com/flashplatform/">Flash</a> can even handle sockets.</p>
<p>I wrote a server in Python2.6 to forward the data to any connection. It takes the headset a few seconds to give good data. I have also noticed, the connection signal can be finicky.</p>
<p><pre class="brush: python;">
import serial, sys, socket

s = serial.Serial('COM8')

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(('',1002))

while 1:
 sock.listen(5)
 conn, addr = sock.accept()
 while 1:
     try:
         sread = s.readline()
         conn.send(sread)
     except:
         print &quot;connection at %s lost&quot; % addr
         break
</pre></p>
<p>Next was to write a quick game using my new toy. I chose <a href="http://pygame.org/news.html">PyGame</a> because it was easy to get going quickly. I plan to switch to 3d when I have the time for it. The game uses the attention value to light a match. There is also a bar on the left side representing the activity in the users mind. Future work includes snuffing the flame with meditative values.</p>
<span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='450' height='284' src='http://www.youtube.com/embed/0-XnnukACX0?version=3&amp;rel=1&amp;fs=1&amp;showsearch=0&amp;showinfo=1&amp;iv_load_policy=1&amp;wmode=transparent' frameborder='0'></iframe></span>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kbcarte.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kbcarte.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kbcarte.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kbcarte.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kbcarte.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kbcarte.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kbcarte.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kbcarte.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kbcarte.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kbcarte.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kbcarte.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kbcarte.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kbcarte.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kbcarte.wordpress.com/122/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kbcarte.wordpress.com&amp;blog=14806936&amp;post=122&amp;subd=kbcarte&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kbcarte.wordpress.com/2011/03/05/fun-with-mindflex/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5d5f8fb3557e8258c7febe710dcdbdcd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kbcarte</media:title>
		</media:content>

		<media:content url="http://kbcarte.files.wordpress.com/2011/03/ground.jpg" medium="image">
			<media:title type="html">Ground</media:title>
		</media:content>

		<media:content url="http://kbcarte.files.wordpress.com/2011/03/tx.jpg" medium="image">
			<media:title type="html">Tx</media:title>
		</media:content>

		<media:content url="http://kbcarte.files.wordpress.com/2011/03/imag0108.jpg" medium="image">
			<media:title type="html">Top</media:title>
		</media:content>

		<media:content url="http://kbcarte.files.wordpress.com/2011/03/imag0107.jpg" medium="image">
			<media:title type="html">Front</media:title>
		</media:content>

		<media:content url="http://kbcarte.files.wordpress.com/2011/03/imag0111.jpg" medium="image">
			<media:title type="html">Mazy Investigates</media:title>
		</media:content>
	</item>
		<item>
		<title>New Years Ball Drop Replica</title>
		<link>http://kbcarte.wordpress.com/2011/01/18/new-years-ball-drop-replica/</link>
		<comments>http://kbcarte.wordpress.com/2011/01/18/new-years-ball-drop-replica/#comments</comments>
		<pubDate>Tue, 18 Jan 2011 12:28:46 +0000</pubDate>
		<dc:creator>Tech B.</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[ball drop]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[k b carte]]></category>
		<category><![CDATA[kbcarte]]></category>
		<category><![CDATA[new years]]></category>
		<category><![CDATA[tech b]]></category>
		<category><![CDATA[times building]]></category>

		<guid isPermaLink="false">http://kbcarte.wordpress.com/?p=113</guid>
		<description><![CDATA[I was asked to build a replica ball drop for a friend. I had 3 days to get this thing working. It was a fun build, and took a lot of headaches to get it setup. In the end it worked out great. The ball itself is a Christmas ornament that has been cut in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kbcarte.wordpress.com&amp;blog=14806936&amp;post=113&amp;subd=kbcarte&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='450' height='284' src='http://www.youtube.com/embed/PQXY_N49KjQ?version=3&amp;rel=1&amp;fs=1&amp;showsearch=0&amp;showinfo=1&amp;iv_load_policy=1&amp;wmode=transparent' frameborder='0'></iframe></span>
<p>I was asked to build a replica ball drop for a friend. I had 3 days to get this thing working. It was a fun build, and took a lot of headaches to get it setup. In the end it worked out great.</p>
<p>The ball itself is a Christmas ornament that has been cut in half and stuffed with 14 LEDs, a 9V and a switch. I hot glued the thing back together and cut a hole in the bottom for the rod to come through. My wife decorated it for me; she also decorated the building.</p>
<p>Parts used:</p>
<ul>
<li>Christmas ornament</li>
<li>Pill bottle (base of rod)</li>
<li>2 boxes</li>
<li>Spent soldier spool</li>
<li>Plastic clothes hanger (rod)</li>
<li>Yarn</li>
<li>Paperclip</li>
<li>Arduino</li>
<li>LCD shield (key pad)</li>
<li>LED&#8217;s</li>
<li>Components for relay circuit</li>
<li>Paint</li>
<li>Glitter</li>
<li>Tiny mirrors</li>
<li>Servo (mod for continues rotation)</li>
</ul>
<p><img class="alignleft" title="Ball Not Lit" src="http://sphotos.ak.fbcdn.net/hphotos-ak-snc6/hs053.snc6/168314_1533913711614_1347945963_1151919_1102069_n.jpg" alt="" width="720" height="480" /></p>
<p><img class="alignleft" title="Ball Lit" src="http://sphotos.ak.fbcdn.net/hphotos-ak-snc6/hs036.snc6/166614_1533913391606_1347945963_1151917_8160135_n.jpg" alt="" width="720" height="480" /></p>
<p>The next thing was to make it go down the rod. There is several ways of doing this, the best in my opinion to use a screw like device and have the ball mounted on it for the linear motion. But I did not have the supplies or money for that. So I used a moded servo for a pulley type system.</p>
<p>I took a spent soldier spool and glued it to the horn of the servo. That&#8217;s where the yarn is tied. The yarn goes up the rod, through a looped paperclip and attached to the ball. When the servo &#8220;unwinds&#8221; the spool, the ball is lowered.</p>
<p><img class="alignleft" title="Guts" src="http://sphotos.ak.fbcdn.net/hphotos-ak-snc6/hs046.snc6/167607_1535137422206_1347945963_1153888_7118793_n.jpg" alt="" width="720" height="480" /></p>
<p>Besides the arduino and LCD shield, there is a circuit to control the servo. It is a simple 5V regulated relay transistor setup. I used the same schematics as the IRC controlled air freshener.</p>
<p>The trickiest part of the build was to lower the ball at a timed rate and have it hit the bottom on count 0. It took some trial and error with delay times in the code, but it worked out nicely.</p>
<p><pre class="brush: plain;">
&lt;pre&gt;
&lt;pre&gt;
//up == 130
//down == 306
//right == 0
//left == 480
#include &lt;Servo.h&gt;
#include &lt;LCD4Bit_mod.h&gt;
#include &lt;stdlib.h&gt;

Servo myservo;  // servo object
LCD4Bit_mod lcd = LCD4Bit_mod(2);

int key_in;

void setup()
{
 Serial.begin(9600);
 lcd.init();
 lcd.printIn(&quot; Time Square    &quot;);
 lcd.cursorTo(2,0);
 lcd.printIn(&quot;  New Years Eve &quot;);
 myservo.attach(12);
 pinMode(3, OUTPUT);
 digitalWrite(3,HIGH);
}

void loop()
{
 lcd.cursorTo(1,0);
 key_in = analogRead(0);
 if (key_in == 0){
 lcd.clear();
 myservo.write(90);
 digitalWrite(3, LOW);
 lcd.printIn(&quot;Coming Down&quot;);
 key_in = 0;
 }

 else if (key_in == 480){
  lcd.clear();
  lcd.printIn(&quot;Going Up&quot;);
  myservo.write(0);
  digitalWrite(3,LOW);
  key_in = 0;
 }

 else if (key_in == 306){
  lcd.clear();
  lcd.printIn(&quot;Count Down Start&quot;);
  delay(3000);
  lcd.clear();
  lcd.printIn(&quot;***1:00***&quot;);
  delay(1000);
  count_down();
 }

 else {
  digitalWrite(3,HIGH);
 }

}

void count_down(){
 myservo.write(90);
 for (int i=59; i&gt;0; i--){
  lcd.clear();
  char count [21];
  char* r;
  r = itoa(i,count,10);
  lcd.printIn(&quot;*****&quot;);
  lcd.printIn(r);
  lcd.printIn(&quot;*****&quot;);
  if (i &lt;= 10){
   digitalWrite(3,LOW);
   delay(130);
   digitalWrite(3,HIGH);
   delay(870);
   continue;
   }
  delay(1000);

 }
 lcd.clear();
 lcd.printIn(&quot;      2011      &quot;);
 delay(5000);
 lcd.clear();
 lcd.printIn(&quot;Happy New Year!!&quot;);
 lcd.cursorTo(2,0);
 lcd.printIn(&quot;_,~*`~2011~*`~,_&quot;);
 }
</pre></p>
<p><img class="alignleft" title="Final" src="http://sphotos.ak.fbcdn.net/hphotos-ak-snc4/hs1385.snc4/163753_1535136262177_1347945963_1153878_5642632_n.jpg" alt="" width="720" height="480" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kbcarte.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kbcarte.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kbcarte.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kbcarte.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kbcarte.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kbcarte.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kbcarte.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kbcarte.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kbcarte.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kbcarte.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kbcarte.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kbcarte.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kbcarte.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kbcarte.wordpress.com/113/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kbcarte.wordpress.com&amp;blog=14806936&amp;post=113&amp;subd=kbcarte&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kbcarte.wordpress.com/2011/01/18/new-years-ball-drop-replica/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5d5f8fb3557e8258c7febe710dcdbdcd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kbcarte</media:title>
		</media:content>

		<media:content url="http://sphotos.ak.fbcdn.net/hphotos-ak-snc6/hs053.snc6/168314_1533913711614_1347945963_1151919_1102069_n.jpg" medium="image">
			<media:title type="html">Ball Not Lit</media:title>
		</media:content>

		<media:content url="http://sphotos.ak.fbcdn.net/hphotos-ak-snc6/hs036.snc6/166614_1533913391606_1347945963_1151917_8160135_n.jpg" medium="image">
			<media:title type="html">Ball Lit</media:title>
		</media:content>

		<media:content url="http://sphotos.ak.fbcdn.net/hphotos-ak-snc6/hs046.snc6/167607_1535137422206_1347945963_1153888_7118793_n.jpg" medium="image">
			<media:title type="html">Guts</media:title>
		</media:content>

		<media:content url="http://sphotos.ak.fbcdn.net/hphotos-ak-snc4/hs1385.snc4/163753_1535136262177_1347945963_1153878_5642632_n.jpg" medium="image">
			<media:title type="html">Final</media:title>
		</media:content>
	</item>
		<item>
		<title>Android on IRC</title>
		<link>http://kbcarte.wordpress.com/2010/10/29/android-on-irc/</link>
		<comments>http://kbcarte.wordpress.com/2010/10/29/android-on-irc/#comments</comments>
		<pubDate>Fri, 29 Oct 2010 21:13:00 +0000</pubDate>
		<dc:creator>Tech B.</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[android ase]]></category>
		<category><![CDATA[android bot]]></category>
		<category><![CDATA[android botnet]]></category>
		<category><![CDATA[android scripting environment]]></category>
		<category><![CDATA[bot]]></category>
		<category><![CDATA[botnet]]></category>
		<category><![CDATA[irc]]></category>
		<category><![CDATA[irc bot]]></category>
		<category><![CDATA[k b carte]]></category>
		<category><![CDATA[kbcarte]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[python bot]]></category>
		<category><![CDATA[python botnet]]></category>
		<category><![CDATA[tech b]]></category>
		<category><![CDATA[techb]]></category>

		<guid isPermaLink="false">http://kbcarte.wordpress.com/?p=106</guid>
		<description><![CDATA[I recently gave a lecture on DDoS in my Network OS class. I demonstrated a simple bot on the computers in the class. I also demonstrated how portable devices are capable of running bots as well. I used Android Scripting Environment (ASE) for the demo. The commands I gave it where text, call, speak aloud, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kbcarte.wordpress.com&amp;blog=14806936&amp;post=106&amp;subd=kbcarte&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I recently gave a lecture on DDoS in my Network OS class. I demonstrated a simple bot on the computers in the class. I also demonstrated how portable devices are capable of running bots as well.</p>
<p>I used Android Scripting Environment (ASE) for the demo. The commands I gave it where text, call, speak aloud, and vibrate. The only draw back ASE has is no <strong>real</strong> GUI support. I can&#8217;t wait for the day when OpenGL ES is ported to python. Anyway, ASE allows access to almost all of the phones featurtes. Here is a link to the API ref: http://code.google.com/p/android-scripting/wiki/ApiReference</p>
<p><pre class="brush: python;">

#-------------------------------------------------------------------------------
# Name:        AndroidIRC
# Purpose:     Android based IRC bot
#
# Author:      K.B. Carte (techb)
#
# Created:     10/26/2010
#
# Copyright:   (c) K.B. Carte (techb) 2010
#-------------------------------------------------------------------------------
#!/usr/bin/env python

import socket, string, time, os, sys, android
droid = android.Android()
os.chdir(&amp;quot;sdcard&amp;quot;)

droid.makeToast(&amp;quot;AndroidBot Started&amp;quot;)
droid.vibrate(300)

chan = 'AndroidBot'
ircsite = 'irc.freenode.net'
port = 6667

irc = socket.socket()
irc.connect((ircsite, port))
n = 'AndroidBotV1'
irc.send('NICK %s\r\n' %  n)
irc.send(&amp;quot;USER %s %s bla :%s\r\n&amp;quot; % (&amp;quot;Ohlook&amp;quot;, 'itsnotmy', 'Realname'))
time.sleep(4)
irc.send(&amp;quot;JOIN #%s\r\n&amp;quot; % chan)

readbuffer = ''
while True:
    readbuffer= irc.recv(1024)
    temp=string.split(readbuffer, &amp;quot;\n&amp;quot;)
    Check = readbuffer.split(':')
    print readbuffer

    if 'PING' in readbuffer:
        &amp;quot;&amp;quot;&amp;quot;PIN/PONG connection echo response&amp;quot;&amp;quot;&amp;quot;
        irc.send(&amp;quot;PONG :%s&amp;quot; % Check[1])

    if 'JOIN' in readbuffer:
        &amp;quot;&amp;quot;&amp;quot;Greet people that join the channel&amp;quot;&amp;quot;&amp;quot;
        na = Check[1].split('!')
        irc.send(&amp;quot;PRIVMSG #%s :Hello %s\r\n&amp;quot; % (chan, str(na[0])))

    if '^call' in readbuffer:
        number = readbuffer.split(':')
        droid.phoneCallNumber(number[3].strip())

    if '^text' in readbuffer:
        &amp;quot;texts the number 5 times with given message&amp;quot;
data = readbuffer.split(&amp;quot;:&amp;quot;)
        number = data[3].strip()
        message = data[4].strip()
        print number, message
        cnt = 0
        while cnt &amp;lt; 5:
            droid.smsSend(number, message)
            cnt += 1

    if '^vibe' in readbuffer:
        droid.vibrate(300)

    if '^say' in readbuffer:
        say = readbuffer.split(&amp;quot;:&amp;quot;)
        droid.ttsSpeak(say[3].strip()

</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kbcarte.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kbcarte.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kbcarte.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kbcarte.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kbcarte.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kbcarte.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kbcarte.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kbcarte.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kbcarte.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kbcarte.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kbcarte.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kbcarte.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kbcarte.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kbcarte.wordpress.com/106/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kbcarte.wordpress.com&amp;blog=14806936&amp;post=106&amp;subd=kbcarte&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kbcarte.wordpress.com/2010/10/29/android-on-irc/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5d5f8fb3557e8258c7febe710dcdbdcd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kbcarte</media:title>
		</media:content>
	</item>
		<item>
		<title>Plasma Caster [UPDATE Sept. 24, 2010]</title>
		<link>http://kbcarte.wordpress.com/2010/09/21/plasma-caster/</link>
		<comments>http://kbcarte.wordpress.com/2010/09/21/plasma-caster/#comments</comments>
		<pubDate>Tue, 21 Sep 2010 04:00:57 +0000</pubDate>
		<dc:creator>Tech B.</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://kbcarte.wordpress.com/?p=87</guid>
		<description><![CDATA[I finaly started working on a moc Plasma Caster like the one attached to the Predators shoulder. Here are some pictures of the first setup. I plan to make changes.The range finder you see will judge the distance from my face, if I turn my head and it goes too far away, the servo will [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kbcarte.wordpress.com&amp;blog=14806936&amp;post=87&amp;subd=kbcarte&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I finaly started working on a moc Plasma Caster like the one attached to the Predators shoulder.</p>
<p>Here are some pictures of the first setup. I plan to make changes.The range finder you see will judge the distance from my face, if I turn my head and it goes too far away, the servo will move in the direction I moved my head to get back in its original position; hence, it will follow my head looking where I look. Tilted head position will be judged from an accelerometer and mapped to the servos as well.</p>
<p><a href="http://kbcarte.files.wordpress.com/2010/09/09-20-10_2340.jpg"><img class="alignleft size-full wp-image-89" title="09-20-10_2340" src="http://kbcarte.files.wordpress.com/2010/09/09-20-10_2340.jpg?w=450" alt=""   /></a></p>
<p><a href="http://kbcarte.files.wordpress.com/2010/09/09-20-10_2341.jpg"><img class="alignleft size-full wp-image-90" title="09-20-10_2341" src="http://kbcarte.files.wordpress.com/2010/09/09-20-10_2341.jpg?w=450" alt=""   /></a></p>
<p><a href="http://kbcarte.files.wordpress.com/2010/09/09-20-10_2339.jpg"><img class="alignleft size-full wp-image-91" title="09-20-10_2339" src="http://kbcarte.files.wordpress.com/2010/09/09-20-10_2339.jpg?w=450" alt=""   /></a></p>
<p>Later plans include:</p>
<ul>
<li>Coil gun</li>
<li>Strobe light from disposable camera</li>
<li>Camera for Facial Recognition</li>
<li>Movement detection</li>
<li>Fiberglass shoulder mount</li>
<li>Bluetooth and controlled via HTC</li>
</ul>
<p>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-[UPDATE]=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-</p>
<span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='450' height='284' src='http://www.youtube.com/embed/HnSAa-9gUoU?version=3&amp;rel=1&amp;fs=1&amp;showsearch=0&amp;showinfo=1&amp;iv_load_policy=1&amp;wmode=transparent' frameborder='0'></iframe></span>
<p>I now have my Ping))) mapping to the servo movements. It is kinda twitchy, but it is working better than I had planned. The Ping))) is going to be mounted on the shoulder mount itself, not on the servos. This is because if it was on the servos, my face could get too close and supply outrages and false data. There is no error checking it this verson of code, it is very gritty and proves concept.<a href="http://kbcarte.files.wordpress.com/2010/09/update.jpg"><img class="alignleft size-full wp-image-97" title="Where Ping))) needs to be." src="http://kbcarte.files.wordpress.com/2010/09/update.jpg?w=450" alt=""   /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/kbcarte.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/kbcarte.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/kbcarte.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/kbcarte.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/kbcarte.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/kbcarte.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/kbcarte.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/kbcarte.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/kbcarte.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/kbcarte.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/kbcarte.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/kbcarte.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/kbcarte.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/kbcarte.wordpress.com/87/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=kbcarte.wordpress.com&amp;blog=14806936&amp;post=87&amp;subd=kbcarte&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://kbcarte.wordpress.com/2010/09/21/plasma-caster/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5d5f8fb3557e8258c7febe710dcdbdcd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kbcarte</media:title>
		</media:content>

		<media:content url="http://kbcarte.files.wordpress.com/2010/09/09-20-10_2340.jpg" medium="image">
			<media:title type="html">09-20-10_2340</media:title>
		</media:content>

		<media:content url="http://kbcarte.files.wordpress.com/2010/09/09-20-10_2341.jpg" medium="image">
			<media:title type="html">09-20-10_2341</media:title>
		</media:content>

		<media:content url="http://kbcarte.files.wordpress.com/2010/09/09-20-10_2339.jpg" medium="image">
			<media:title type="html">09-20-10_2339</media:title>
		</media:content>

		<media:content url="http://kbcarte.files.wordpress.com/2010/09/update.jpg" medium="image">
			<media:title type="html">Where Ping))) needs to be.</media:title>
		</media:content>
	</item>
	</channel>
</rss>
