News for hackers. Stuff that matters.
Re:What happens if you write a TCP stack in Python? by jvns on Tuesday August 12, 2014 @10:03AM (#8167750)
my favorite thing about writing blog posts is comments like this. Thank you! I didn't consider that the packet capture interface might do buffering. That might explain a lot of the problems I was having :)
Re:What happens if you write a TCP stack in Python? by tptacek on Tuesday August 12, 2014 @10:05AM (#8167757)
This is a great project. Keep playing with it! You might find that the serverside of TCP is more useful to have in Python than the clientside (having a userland IP/TCP serverside allows you to create fake hosts out of thin air).
Re:What happens if you write a TCP stack in Python? by danudey on Tuesday August 12, 2014 @12:39PM (#8168598)
This sounds super handy for situations like honeypots. Take a /24, assign the hosts you actually have, and then spoof the rest to another server which fakes open SMTP, HTTPS, etc. connections, or which replies to every connection attempt (slowly!) with a successful (if slow!) open.

There's an iptables module called tarpit[1], which takes advantage of some peculiarities of the TCP protocol to essentially prevent the remote host from closing the connection, which can force (conforming?) TCP clients to take 12-24 minutes to timeout every connection. It can make portscanning unpleasantly expensive and time-consuming.

[1] http://linux.die.net/man/8/iptables

Re:What happens if you write a TCP stack in Python? by milkshakes on Tuesday August 12, 2014 @01:03PM (#8168770)
this is in fact exactly how honeyd works: http://www.honeyd.org/
Re:What happens if you write a TCP stack in Python? by zerop on Wednesday August 13, 2014 @08:41AM (#8172566)
Thanks for mentioning Honeyd. Are there any more software like this.
Re:What happens if you write a TCP stack in Python? by blutoot on Tuesday August 12, 2014 @11:45AM (#8168263)
Your "userland TCP/IP" comment got me excited and I started digging around. I wonder if there's some benefit in trying to port something like TCP Daytona [1,2] in a high-level language like Python. I'm curious if that will somehow advance the adoption of SDNs.

[1] https://github.com/jamesbw/tcp-daytona [2] http://nms.lcs.mit.edu/~kandula/data/daytona.pdf

Re:What happens if you write a TCP stack in Python? by tptacek on Tuesday August 12, 2014 @12:04PM (#8168368)
Like writing your own emulator, writing a full TCP stack is a project that is intrinsically worth doing.

You can probably also come up with real-world applications for it (as a security tester, there are lots of applications for having full control over a TPC stack, regardless of how performant it is), but just having done it offers a huge learning return on a modest investment.

You probably don't fully grok what TCP even is until you've made congestion control work.

Re:What happens if you write a TCP stack in Python? by MagerValp on Wednesday August 13, 2014 @09:49AM (#8172844)
I just want to second this, I didn't fully understand networking until I wrote my own stack and threw packets on the wire. A simple stack with ARP/ICMP/IP/UDP can be written in a day and seeing your very own ping packets fly across the globe is pretty damn awesome.
Re:What happens if you write a TCP stack in Python? by eru on Tuesday August 12, 2014 @09:53PM (#8171104)
> (as a security tester, there are lots of applications for having full control over a TPC stack, regardless of how performant it is)

And sometimes you even want your stack to be slow, eg in a slow loris attack.

Re:What happens if you write a TCP stack in Python? by Sami_Lehtinen on Wednesday August 13, 2014 @12:55AM (#8171521)
Wrong. In these cases you want your stack to be as fast as possible. But you're introducing artificial delay on selected keypoints. If your attack code is slow, then you're basically attacking your self. Target is to consume (a lot if possible) more resources on the target side, than you're using on your own side.
Re:What happens if you write a TCP stack in Python? by tedchs on Tuesday August 12, 2014 @11:55AM (#8168313)
Software Defined Networking is about moving the control plane out of switching/routing devices and into general purpose servers, so that they can make better forwarding decisions such as improved convergence time. In the sense that I understand SDN, I don't think doing TCP in userspace is part of it.
Re:What happens if you write a TCP stack in Python? by blutoot on Tuesday August 12, 2014 @12:04PM (#8168369)
But if it can be done easily in a high-level language, then the control plane can be integrated better with a lot of applications written in the same language, no? I was thinking if that can serve as an impetus for SDN adoption.
Re:What happens if you write a TCP stack in Python? by corysama on Tuesday August 12, 2014 @01:28PM (#8168926)
You should have a look over here :)

https://github.com/SnabbCo/snabbswitch/wiki