<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC "-//W3C//ENTITIES Latin 1 for XHTML//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent">]>
<rss version="2.0" xml:base="http://sysd.org/stas">
<channel>
 <title>stas&#039;den - php</title>
 <link>http://sysd.org/stas/taxonomy/term/24/0</link>
 <description></description>
 <language>en</language>
<item>
 <title>The Pirate Bay un-SSL</title>
 <link>http://sysd.org/stas/node/220</link>
 <description>&lt;p&gt;
&lt;script src=&quot;http://slashdot.org/slashdot-it.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;/p&gt;

&lt;h2&gt;Theory&lt;/h2&gt;
&lt;p&gt;
Recently, the world saw &lt;a href=&quot;https://thepiratebay.org/&quot;
 target=&quot;_blank&quot;&gt;The Pirate Bay&lt;/a&gt; offering &lt;a
 href=&quot;http://www.slyck.com/story1691_SSL_Encrpytion_Coming_to_The_Pirate_Bay&quot;
 target=&quot;_blank&quot;&gt;SSL encryption&lt;/a&gt; on their server.
This means that your ISP won&#039;t know anymore which torrent you are
downloading, right? Wrong.&lt;br&gt;
&lt;a
 href=&quot;http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol_over_Secure_Socket_Layer&quot;
 target=&quot;_blank&quot;&gt;HTTPS&lt;/a&gt; is quite useless for
protecting static &lt;span style=&quot;font-weight: bold;&quot;&gt;and&lt;/span&gt;
public content. By &lt;span style=&quot;font-style: italic;&quot;&gt;static&lt;/span&gt;,
I do mean the &lt;code&gt;.torrent&lt;/code&gt; file itself. It is
always the same. By &lt;span style=&quot;font-style: italic;&quot;&gt;public&lt;/span&gt;,
I do mean than one doesn&#039;t need any kind of authentication to pick up
the content. It&#039;s always the same, for everyone. For &lt;a
 href=&quot;http://en.wikipedia.org/wiki/Web_crawler&quot; target=&quot;_blank&quot;&gt;crawlers&lt;/a&gt;,
too.&lt;br&gt;
So, one could easily index (&lt;a href=&quot;https://thepiratebay.org/top&quot;
 target=&quot;_blank&quot;&gt;a portion of&lt;/a&gt;) The Pirate Bay
torrent database by the &lt;a
 href=&quot;http://en.wikipedia.org/wiki/List_of_HTTP_headers&quot;
 target=&quot;_blank&quot;&gt;Content-Length&lt;/a&gt;. Then, one could
intercept some encrypted traffic between some machine(s) within his/her
network and the &lt;code&gt;torrents.thepiratebay.org&lt;/code&gt;
server. Knowing both (encrypted) request and response lengths, it is
possible to get a quite reliable list of matches from the previously
indexed torrent list.&lt;br&gt;
&lt;/p&gt;
&lt;h2&gt;Practice&lt;/h2&gt;
&lt;p&gt;
Don&#039;t try this at work, or you might hurt yourself &lt;img src=&quot;misc/smileys/wink.png&quot; title=&quot;Eye-wink&quot; alt=&quot;Eye-wink&quot; /&gt;&lt;br&gt;
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Use &lt;a href=&quot;http://www.wireshark.org/&quot;
 target=&quot;_blank&quot;&gt;Wireshark&lt;/a&gt; to capture some torrent
downloads. Torrents are hosted on a separate server, which makes the
task easier yet. Just use the following capture filter: &lt;code&gt;&quot;tcp
and port 443 and host torrents.thepiratebay.org&quot;&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Now, just go with the stream &lt;img src=&quot;misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; /&gt; (&lt;span
 style=&quot;font-style: italic;&quot;&gt;&quot;Follow TCP Stream&quot;&lt;/span&gt;
for the packet you suspect belongs to the torrent download. This will
create another filter, just like &lt;code&gt;&quot;(ip.addr eq 192.168.0.10
and ip.addr eq 83.140.176.156) and (tcp.port eq 2157 and tcp.port eq
443)&quot;&lt;/code&gt;)&lt;/li&gt;
  &lt;li&gt;Just save the displayed stream anywhere else (&lt;code&gt;pcap1.pcap&lt;/code&gt;
sounds nice)&lt;/li&gt;
  &lt;li&gt;Now, use my quick&amp;amp;dirty &lt;a
 href=&quot;http://sysd.org/stas/files/active/0/TPB-TLSlen.pl.txt&quot;
 target=&quot;_blank&quot;&gt;TPB-TLSlen.pl&lt;/a&gt; Perl script to get
the request/response lengths:
    &lt;pre&gt;perl TPB-TLSlen.pl pcap1.pcap&lt;/pre&gt;
Yeah, I know, it is nasty. It only supports the &lt;a
 href=&quot;http://en.wikipedia.org/wiki/Transport_Layer_Security&quot;
 target=&quot;_blank&quot;&gt;TLS&lt;/a&gt; cypher. And it simply calls
the &lt;code&gt;tshark&lt;/code&gt; (the command line version of
Wireshark) to parse it&#039;s output.&lt;/li&gt;
  &lt;li&gt;Now, just paste the &lt;span style=&quot;font-weight: bold;&quot;&gt;REQ&lt;/span&gt;
and &lt;span style=&quot;font-weight: bold;&quot;&gt;RES&lt;/span&gt;
values &lt;a href=&quot;http://sysd.org/stas/node/220?req=560&amp;amp;res=91888#TPB&quot;&gt;below&lt;/a&gt;
&lt;img src=&quot;misc/smileys/lol.png&quot; title=&quot;Laughing out loud&quot; alt=&quot;Laughing out loud&quot; /&gt;&lt;br&gt;
(note that the &lt;span style=&quot;font-weight: bold;&quot;&gt;REQ&lt;/span&gt;
value is optional, setting it to 0 simply ignores the request size for
matching)&lt;/li&gt;
&lt;/ol&gt;
Note that you are able to fine-tune the maximum and minimum header
sizes. For the response, the headers are almost the same all the time.
The only thing that varies is the decimal representation of the file
length and age. (Un)fortuately, the request headers do vary for
different browsers and referring pages. However, knowing the request
size still helps a bit, specially if the torrent&#039;s filename was huge &lt;img src=&quot;misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; /&gt;&lt;br&gt;
&lt;h2&gt;Precision&lt;/h2&gt;
&lt;p&gt;
The following size distribution chart was generated using the database with ~165K torrents:
&lt;p&gt;
&lt;img src=&quot;http://sysd.org/stas/files/active/0/Graph2.png&quot; width=&quot;640&quot; height=&quot;500&quot; alt=&quot;torrent size distribution&quot;&gt;
&lt;/p&gt;
The most common torrent size is ~14 KB, and it&#039;s easy to figure out that such torrents represent the shared 700 MB files &lt;img src=&quot;misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; /&gt;&lt;br&gt;
There&#039;s also a major peak for the 454 bytes torrents. However, bigger torrents are less common, thus, the size detection technique becomes more precise. Now, the average &quot;distance&quot; between torrent sizes is ~44 bytes (at least for the sample I&#039;ve collected). So, adding a &lt;a href=&quot;http://en.wikipedia.org/wiki/HTTP_cookie&quot;
 target=&quot;_blank&quot;&gt;cookie&lt;/a&gt; with the random size up to 128 bytes will disrupt the size matching detection a lot. The request size disruption is even easier: the largest torrent &lt;a href=&quot;http://en.wikipedia.org/wiki/Uniform_Resource_Identifier&quot; target=&quot;_blank&quot;&gt;URI&lt;/a&gt; I&#039;ve found was 150 bytes-wide. Thus, padding every request URI to match 150 characters is enough to make the requests completely indistinguishable. Joining the pieces (the padding add-on strings are &lt;b&gt;bold&lt;/b&gt;):&lt;br&gt;
&lt;pre&gt;&lt;font color=&quot;#ff0000&quot;&gt;GET /4319199/[a4e]Ghost_in_the_Shell_TV_01-26.4319199.TPB.torrent&lt;b&gt;?nVM2UGfcG533un4ym70eT2&lt;br&gt;9r0WwBLYdmFCNN+UTV/hiJ7EAXdFU5KfdWHpkB5lXaCmITsACKOPVyjmpbaOB+CrI5&lt;/b&gt; HTTP/1.1
Host: torrents.thepiratebay.org
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208&lt;br&gt; Firefox/3.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: https://thepiratebay.org/recent
Cookie: language=pt_BR; country=BR; PHPSESSID=ad6cb7e414c8dc88e0c2444f6215165a
&lt;/font&gt;&lt;font color=&quot;#0000ff&quot;&gt;
HTTP/1.1 200 OK
Content-Type: application/x-bittorrent
Etag: &quot;2198642509&quot;
Last-Modified: Mon, 28 Jul 2008 22:28:59 GMT
Server: lighttpd
Content-Length: 91601
Date: Mon, 28 Jul 2008 22:37:56 GMT
X-Varnish: 108010229 107999438
Age: 253
Via: 1.1 varnish
Connection: keep-alive
&lt;b&gt;Set-Cookie: p=68eOfxOC7JwBYcMe1RJWC4Z5PV/lJzqJORW8KROPMH9zQhszSjFnRp2tsNWEoyabWAloneUaoz&lt;br&gt;MxYtx4hoM9MZUKE/7wGzC3ZKLEZdppG4og3W; expires=Mon, 28-Jul-2008 22:37:56 GMT; path=/;&lt;br&gt; domain=torrents.thepiratebay.org&lt;/b&gt;

&lt;i&gt;(binary torrent data)&lt;/i&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;/p&gt;
&lt;h2&gt;Solution&lt;/h2&gt;
&lt;ol&gt;
  &lt;li&gt;Use a constant padding in the &lt;code&gt;.torrent&lt;/code&gt;
files. This messes things a bit, but stills ineffective. The only
advantage is &lt;span style=&quot;font-weight: bold;&quot;&gt;not&lt;/span&gt;
messing up with the server &lt;img src=&quot;misc/smileys/sad.png&quot; title=&quot;Sad&quot; alt=&quot;Sad&quot; /&gt;&lt;/li&gt;
  &lt;li&gt;Patch the &lt;a href=&quot;http://www.lighttpd.net/&quot;
 target=&quot;_blank&quot;&gt;lighttpd&lt;/a&gt; server so it sends a
non-lasting &lt;a href=&quot;http://en.wikipedia.org/wiki/HTTP_cookie&quot;
 target=&quot;_blank&quot;&gt;cookie&lt;/a&gt; with a random size.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Thanks&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.megahospedagem.com.br/&quot;
 target=&quot;_blank&quot;&gt;MEGA Hospedagem&lt;/a&gt;, for the network
resources provided for this tiny research &lt;img src=&quot;misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; /&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.warchalking.com.br/&quot;
 target=&quot;_blank&quot;&gt;http://www.warchalking.com.br/&lt;/a&gt;,
for the inspiration &lt;img src=&quot;misc/smileys/wink.png&quot; title=&quot;Eye-wink&quot; alt=&quot;Eye-wink&quot; /&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;a name=&quot;TPB&quot;&gt;
 </description>
 <category domain="http://sysd.org/stas/taxonomy/term/23">database</category>
 <category domain="http://sysd.org/stas/taxonomy/term/18">hack</category>
 <category domain="http://sysd.org/stas/taxonomy/term/30">music</category>
 <category domain="http://sysd.org/stas/taxonomy/term/7">network</category>
 <category domain="http://sysd.org/stas/taxonomy/term/20">perl</category>
 <category domain="http://sysd.org/stas/taxonomy/term/24">php</category>
 <category domain="http://sysd.org/stas/taxonomy/term/32">video</category>
 <category domain="http://sysd.org/stas/taxonomy/term/8">web</category>
 <pubDate>Thu, 31 Jul 2008 11:05:20 -0300</pubDate>
</item>
<item>
 <title>Formulário CEP/CPF/CNPJ</title>
 <link>http://sysd.org/stas/node/150</link>
 <description>&lt;p align=&quot;center&quot;&gt;
&lt;object classid=&quot;clsid:d27cdb6e-ae6d-11cf-96b8-444553540000&quot; codebase=&quot;http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0&quot; width=&quot;423&quot; height=&quot;200&quot; id=&quot;brloc&quot; align=&quot;middle&quot;&gt;
&lt;param name=&quot;allowScriptAccess&quot; value=&quot;sameDomain&quot; /&gt;
&lt;param name=&quot;movie&quot; value=&quot;/brloc/brloc.swf&quot; /&gt;&lt;param name=&quot;quality&quot; value=&quot;high&quot; /&gt;&lt;param name=&quot;bgcolor&quot; value=&quot;#ffffff&quot; /&gt;&lt;embed src=&quot;/brloc/brloc.swf&quot; quality=&quot;high&quot; bgcolor=&quot;#ffffff&quot; width=&quot;423&quot; height=&quot;200&quot; name=&quot;brloc&quot; align=&quot;middle&quot; allowScriptAccess=&quot;sameDomain&quot; type=&quot;application/x-shockwave-flash&quot; pluginspage=&quot;http://www.macromedia.com/go/getflashplayer&quot; /&gt;
&lt;/object&gt;
&lt;br&gt;
&lt;small&gt;&lt;i&gt;(tente preencher os campos acima; a informa&amp;ccedil;&amp;atilde;o &amp;eacute; atualizada instantaneamente)&lt;/i&gt;&lt;/small&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;br&gt;
Este projeto &amp;eacute; o sucessor do&amp;nbsp;&lt;a
 href=&quot;http://sysd.org/stas/node/99&quot;&gt;CEP-2-City&lt;/a&gt;.
&amp;Eacute; um formul&amp;aacute;rio &lt;i&gt;online&lt;/i&gt; que:&lt;br&gt;
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Verifica a validade do n&amp;uacute;mero &lt;a
 href=&quot;http://pt.wikipedia.org/wiki/Cadastro_de_Pessoas_F%C3%ADsicas&quot;
 target=&quot;_blank&quot;&gt;CPF&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Verifica a validade do n&amp;uacute;mero &lt;a
 href=&quot;http://pt.wikipedia.org/wiki/CNPJ&quot; target=&quot;_blank&quot;&gt;CNPJ&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;A partir do &lt;a
 href=&quot;http://pt.wikipedia.org/wiki/Sistema_endere%C3%A7amento_postal_no_Brasil&quot;
 target=&quot;_blank&quot;&gt;CEP&lt;/a&gt;, deduz o endere&amp;ccedil;o
completo (Cidade/Estado/Bairro/Rua)&lt;/li&gt;
  &lt;li&gt;A partir do CEP, deduz o c&amp;oacute;digo &lt;a
 href=&quot;http://pt.wikipedia.org/wiki/Discagem_direta_a_dist%C3%A2ncia#Lista_de_c.C3.B3digos_DDD_brasileiros_por_estado_e_seus_principais_munic.C3.ADpios&quot;
 target=&quot;_blank&quot;&gt;DDD&lt;/a&gt; da regi&amp;atilde;o &lt;img src=&quot;misc/smileys/wink.png&quot; title=&quot;Eye-wink&quot; alt=&quot;Eye-wink&quot; /&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
O banco de dados utilizado &amp;eacute; compilado a partir de diversas
fontes. Se n&amp;atilde;o constar a informa&amp;ccedil;&amp;atilde;o da
rua, ent&amp;atilde;o somente a cidade &amp;eacute; retornada. A
interface com o banco de dados foi implementada usando &lt;a
 href=&quot;http://en.wikipedia.org/wiki/Perl&quot; target=&quot;_blank&quot;&gt;Perl&lt;/a&gt;
e &lt;a href=&quot;http://en.wikipedia.org/wiki/PHP&quot; target=&quot;_blank&quot;&gt;PHP&lt;/a&gt;,
e pode ser acessada via &lt;a
 href=&quot;http://en.wikipedia.org/wiki/Common_Gateway_Interface&quot;
 target=&quot;_blank&quot;&gt;CGI&lt;/a&gt;, &lt;a target=&quot;_blank&quot;
 href=&quot;http://en.wikipedia.org/wiki/Adobe_Flash&quot;&gt;Flash&lt;/a&gt;
ou &lt;a href=&quot;http://en.wikipedia.org/wiki/Ajax_%28programming%29&quot;
 target=&quot;_blank&quot;&gt;AJAX&lt;/a&gt;. O sistema de busca
&amp;eacute; extremamente eficiente, e n&amp;atilde;o necessita de &lt;a
 href=&quot;http://en.wikipedia.org/wiki/MySQL&quot; target=&quot;_blank&quot;&gt;MySQL&lt;/a&gt;.
O tamanho do banco de dados &amp;eacute; cerca de 60 MB, e a
performance chega a milhares de consultas por segundo.
&lt;/p&gt;
&lt;p&gt;Portanto, eis uma solu&amp;ccedil;&amp;atilde;o bastante
s&amp;iacute;mples, flex&amp;iacute;vel e eficaz para o
cadastro&amp;nbsp;de clientes. J&amp;aacute; utilizei este sistema numa
pesquisa que conduzi, e asseguro que me poupou bastante tempo. Para realizar as consultas, basta acessar a seguinte URL (com a devida substituição do CEP): &lt;a href=&quot;http://sysd.org/brloc/brloc.php?cep=05437000&quot; target=&quot;_blank&quot;&gt;http://sysd.org/brloc/brloc.php?cep=05437000&lt;/a&gt;, e processar a &lt;code&gt;string&lt;/code&gt; retornada com a função &lt;a href=&quot;http://br2.php.net/manual/pt_BR/function.parse-str.php&quot; target=&quot;_blank&quot;&gt;parse_str()&lt;/a&gt; (em PHP).
&lt;/p&gt;
&lt;p&gt;
Se tiver interesse no banco de dados em si, &lt;a href=&quot;http://sysd.org/stas/feedback&quot;&gt;entre
em contato&lt;/a&gt;!
&lt;/p&gt;
</description>
 <category domain="http://sysd.org/stas/taxonomy/term/25">actionscript</category>
 <category domain="http://sysd.org/stas/taxonomy/term/22">city</category>
 <category domain="http://sysd.org/stas/taxonomy/term/23">database</category>
 <category domain="http://sysd.org/stas/taxonomy/term/20">perl</category>
 <category domain="http://sysd.org/stas/taxonomy/term/24">php</category>
 <category domain="http://sysd.org/stas/taxonomy/term/8">web</category>
 <pubDate>Wed, 15 Aug 2007 20:31:52 -0300</pubDate>
</item>
</channel>
</rss>

