<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://www.placenet.org/benoit/index.php/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
  <title>Harvard Business School of Echec - Tag - iptables</title>
  <link>http://www.placenet.org/benoit/index.php/</link>
  <atom:link href="http://www.placenet.org/benoit/index.php/feed/tag/iptables/rss2" rel="self" type="application/rss+xml"/>
  <description></description>
  <language>fr</language>
  <pubDate>Wed, 12 Nov 2008 14:03:18 +0100</pubDate>
  <copyright></copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>loc-srv</title>
    <link>http://www.placenet.org/benoit/index.php/post/2007/09/10/loc-srv</link>
    <guid isPermaLink="false">urn:md5:a7720603b6155abccdac86c28ee0961a</guid>
    <pubDate>Mon, 10 Sep 2007 22:44:00 +0200</pubDate>
    <dc:creator>Benoît Dejean</dc:creator>
        <category>iptables</category><category>linux</category>    
    <description>    &lt;p&gt;So this weekend, i used a DSL without any NAT, so my laptop was assigned a public IP by DHCP. My ulog log was spitting a lot, mainly on &lt;code&gt;tcp port loc-srv / 135&lt;/code&gt;. Instead of sending REJECT, i opened my iptables and started the following ruby program to actually open all these connections. When someone sends me a SYN, I reply politely.&lt;/p&gt;

&lt;pre&gt;
require 'socket'
require 'etc'

nobody = Etc.getpwnam('nobody')
loc_srv = Socket::getservbyname('loc-srv')

Dir.chroot('/var/run/empty')
Dir.chdir('/')

server = TCPServer.new(loc_srv)

Process::UID.change_privilege(nobody.uid)

print &amp;lt;&amp;lt;&amp;quot;EOF&amp;quot;
uid/euid #{Process.uid}/#{Process.euid}                                                                                                        
chrooted in #{Dir.pwd}                                                                                                                         
listening on address #{server.addr.inspect}                                                                                                    
EOF

clients = []

loop do
  begin
    client = server.accept_nonblock
  rescue Errno::EAGAIN, Errno::ECONNABORTED, Errno::EPROTO, Errno::EINTR
    IO.select([server])
    next
  end

  # remember client so the connection stays opened                                                                                             
  clients &amp;lt;&amp;lt; client
  print &amp;quot;#{client.peeraddr.inspect} connected
&amp;quot;
end
&lt;/pre&gt;



&lt;p&gt;This script needs to be started with some privileges in order to bind on 135, but then it drops its priv and chroot to somewhere safe. That was very instructive, after ~10minutes, &lt;code&gt;ss | grep -c loc-srv&lt;/code&gt; was reporting more than 280 connections from ~80 differents hosts.&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;What a storm. I'm definitely safe under my GNU+Linux umbrella &lt;img src=&quot;/benoit/themes/default/smilies/smile.png&quot; alt=&quot;:)&quot; class=&quot;smiley&quot; /&gt;&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;And Ruby is fun &lt;img src=&quot;/benoit/themes/default/smilies/smile.png&quot; alt=&quot;:)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;</description>
    
    
    
      </item>
    
</channel>
</rss>