sarnoldgreetings everyone; this is the last presentation of the day for the opening day of UMeet 2002
sarnoldand, wrapping up the presentations is dan kaminsky; he spent two years as a security engineer for cisco
sarnoldhe is here today to present some networking tools called paketto keiretsu
sarnoldso please welcome dan :)
DanKaminHello everyone :-)
DanKaminAs Seth mentioned, I recently released a package of tools I'm calling the Paketto Keiretsu
DanKaminIf you're looking for them, they can be found at this URL:  http://www.doxpara.com/paketto/paketto-1.0.tar.gz
DanKaminThough 1.01 should be out as soon as I fix an annoying build screwup :-)
DanKaminEssentially, I've been researching the following question:
DanKaminIf I take direct control of the network -- fabricate my own packets, build my own stacks with no particular respect for the original meaning of data fields...
DanKaminwhat could I do?
DanKaminCrashing machines isn't particularly interesting to me
DanKaminBut there's lots of interesting functionality that networks can't provide
DanKaminYet :-)
DanKaminWell, I didn't succeed in everything I set out to accomplish (for example, there's still no good way to quickly scan for open UDP ports), *but* I did find quite a bit of untapped potential within existing TCP/IP networks
DanKaminand that's what we're going to talk about today.
DanKaminProbably the most useful component of the Keiretsu is scanrand.
DanKaminscanrand is a stateless TCP scanner with the secondary capability to discover routes as well as endpoints
DanKaminIt can very quickly iterate across hosts, ports, and hops to provide a detailed view of available services and routes on a network
DanKaminBecause of its stateless infrastructure, "Very Quickly" takes on a bit of a new meaning
DanKaminDuring testing, scanrand was configured to examine the class B network of a major multinational corporation
DanKaminThis was done with their full consent, of course :-)
DanKamin65K hosts received a probe against their HTTP port
DanKamin8300 hosts responded affirmatively; many more responded negatively
DanKaminThis scan took approximately four seconds to complete.
DanKaminThe architecture of scanrand is actually quite simple.  Upon instantiation, the app splits into two halves:  One that sends a massive number of connection initations, or "SYNs"; another that receives those SYNs and parses out who claims to be up and who claims to be down.
DanKaminThere is no inter-process communication between these processes
DanKaminRather, everything that needs to be known about a scan request is parsed from the endpoint-provided scan reply.
DanKaminThis means that one machine can efficiently scan 65K endpoints, or even many, many more, without having to keep a progressively larger amount of memory occupied for the eventual responses that may or may not come
DanKaminsuch is the reason why previous attempts at very fast scanning -- even parallelized with sockets -- have topped out at 100 scans a second or so
DanKaminNow, one problem with a stateless approach is that if we're not keeping track of who we communicate with, somebody could notice "Heh, this guy is scanning us without any care for who he's scanning...lets send back fake replies"
viZarddan, can you wait a sec please? :)
DanKaminviZard sure :-)
viZardok, thanks. keep going
* DanKamin has never had live translation during a talk :-)
DanKaminThank you, viZard!
sarnold(and garoeda, providing translations in #taee as well... dutch, I believe. :)
DanKaminThank you too, garoeda :-)
DanKaminNow, this is a mere annoyance at best, but depending on what might get built using scanrand (particularly with database backends), this could be the channel for a serious security hole
DanKaminI come from a security background (I've done quite a bit of work with OpenSSH), so this is unacceptable :-)
DanKaminSo the solution is to use what I refer to as Inverse SYN Cookies
DanKaminIn TCP, When you send a SYN to request a connection, you receive either a SYN|ACK(the port is up) or a RST|ACK(the port is up) or a RST|ACK(the port is down) Both SYN|ACKs and RST|ACKs have lots more to them than just "Up" or "Down"...among other things, they contain all the addressing information we needed to be able to statelessly determine who we sent a request to and what port we were looking at
DanKaminBut also
DanKaminThey contain a 32 bit number of our own choosing from the SEQ#
DanKaminer
DanKaminfrom the SYN
DanKaminthis number is known as the Sequence Number, or SEQ#
DanKaminand it is *reflected* in the Acknowledgement Number, or ACK#, of any valid SYN|ACK or RST|ACK
DanKamin32 bits is enough to include a cryptographically strong variable that links a given response to a valid scan
DanKaminIn technical terms, we use SHA-1 in the HMAC, or Hashed Message Authentication Code, construction to create a 160 bit value corresponding to the combination of (source IP, source port, destination IP, destination port)
DanKaminThen the first 32 bits are chopped off and thrown into the SEQ#
DanKaminwhen the SYN|ACK or RST|ACK returns, we reverse the process(and decrement the ACK# by one, because the reflection is incremented) to see if this host actually received a scan from us
DanKaminHMAC involves a secret value known only to the scanner
DanKaminso this leaves a host with a choice -- reply with the valid information, or do not reply -- because anything invalid can be easily ignored.
DanKaminhttp://www.doxpara.com/read.php/docs/scanrand_logs.html
DanKaminHere you will find logs of Scanrand being used
DanKaminAs you can see in the local scan -- 254*20 ports are scanned on my local 100mbit LAN, and results are collated within 0.182 seconds
DanKaminOf note is the capacity to do passive hopcount estimation
DanKaminthis is a simple technique, but it's surprisingly successful
DanKaminSimply assume remote hosts started sending packets at some value modulo 32 -- 64, 128, 255(close enough)
DanKaminthen whatever difference you get from that value, that's the number of hops the packet took to get to you
DanKaminso when I scan Slashdot, it appears to be about 12 hops away
DanKaminwell, lets verify that -- but of course, it's me, so lets verify it statelessly :-)
DanKaminScanrand's stateless traceroute takes advantage of a heretofore ignored fact
DanKaminICMP errors contain more than just "something screwed up"
DanKaminThey also contain a full copy of the offending IP header and the first 8 bytes of the Layer 4 data contained inside
DanKaminTCP/UDP/ICMP
DanKaminSo, traceroute works as follows:
DanKaminThere exists in IP a value called the TTL
DanKaminThis stands for Time To Live
DanKaminTTL is SUPPOSED to refer to seconds, but its evolved to become hops the packet is allowed to travel through before its dropped
DanKaminSo if a TTL is 5, it will go 5 hops and then die
DanKaminsending back an ICMP Time Exceeded Message (which has the IP and TCP header, hint hint)
DanKaminSo a Traceroute just sends a packet with a TTL of 1, 2, 3, 4, 5, etc. until it gets all the way there
DanKamina stateless traceroute just sends all the iterations at once -- in the example's case, from 1 to 13 get sent
DanKaminwhen responses come back, we look at the IP and TCP headers contained inside to figure out who we were trying to scan
DanKaminin this case, every time we were looking at 66.35.250.150
DanKaminAt the end of the scan, we see that our estimation of 12 hops was a bit off--it was in fact 13 hops away
DanKaminbut as we'll see later, the estimation remains very useful
DanKaminLater examples demonstrate more advanced modes of Scanrand
DanKaminDNS resolution is presently synchronous, so it slows down operation...ideally, you'd use a tool that automagically takes in HTTP logs w/ IPs and replaces all the IPs with their DNS names
DanKaminthere's quite a few out there, if I remember right
* sarnold sets mode: +o DanKamin
DanKaminSmall technical difficulties out here, sorry for disappearing :-)
DanKaminOne of the more interesting things bout a combined port scanner and tracerouter is that we can do both at the same time
DanKaminThis is shown by the next entry in the scanrand logs (again, at http://www.doxpara.com/read.php/docs/scanrand_logs.html )
DanKaminThe returns are out-of-order, but as you can see, while first hops are all identical, the farther out we get, the more divergent our scan becomes
DanKaminthis is of course what we'd expect
DanKaminFuture versions of scanrand are going to explicitly support remote mesh discovery
DanKaminthis is going to involve source routing to a known point n hops away, setting TTL to n+1, then attempting to reach various addresses expected to be as far away as possible from eachother in remote routing tables
DanKaminthe speed of the stateless approach should render most networks traceable in astonishingly little time
DanKaminbut we'll see :-)
DanKaminOne thing of note is the fact that it is very feasible to split the scanning and receiving processes across machines
DanKaminso for example, one system could be designated the scan collector, while everyone else has their results forwarded to it
DanKaminThis is almost an alternate mode of source routing :-)
DanKaminand it's demonstrated in the final log entry
DanKaminNext up is paratrace, which is actually a fork of scanrand
DanKaminsplit off because it really does something different t
DanKaminthan it
DanKaminhttp://www.doxpara.com/read.php/docs/paratrace_logs.html
DanKaminWhile scanrand initiates new connections to search networks, paratrace uses existing connections
DanKaminThis is the only effective way to monitor policy routes, and can also penetrate through stateful firewalls
DanKaminThe idea is simple:  Traceroute is entirely a Layer 3 activity -- iterate the TTL, observe the ICMP Time Exceeded reply.
DanKaminIt doesn't matter what we have at Layer 4.
DanKaminSo if Layer 4 is valid TCP traffic, Traceroute doesn't care
DanKaminNow, TCP has the capacity to support redundant packets -- it's just expected as part of the unreliable network that IP offers
DanKaminin fact, this feature is used for a sort of in-session TCP ping, "tcp keepalive"
DanKaminEssentially, paratrace uses keepalives as the transport for a IP Traceroute
DanKaminThe results of which are seen in the logs
DanKaminpassive hopcount estimation is used to figure out just how far to iterate the parasitic traceroute.
DanKaminSwitching gears a bit, lets talk about Minewt.
DanKaminAs I mentioned, the original design goal of Paketto was to examine what could be done by directly manipulating the wire
DanKaminMinewt is a NAT gateway that operates entirely in software, directly manipulating the wire to instantiate itself
DanKaminIt uses no kernel resources, save for the raw network connectivity afforded through libnet/libpcap's manipulation of sockets and bpf.
sarnoldBPF?
DanKaminIndeed, not even the MAC address is shared with the kernel -- it literally looks like a new device showed up on the wire.
sarnolddoes linux do BPF? I thought it had netlink or similar in place of bpf...
DanKaminBPF is the Berkeley Packet Filter, a standardized interface for requesting network traffic that matches a standard form.
DanKaminAs sarnold points out, bpf itself is not directly implemented by all kernels
DanKaminLibpcap thus implements bpf in userspace when needed -- though I believe they have their own kernel interface for Linux
DanKaminThe main point is that the Paketto overall is quite insulated from the vagaries of various kernel networking interfaces; just give me frames, I'll do the rest :-)
DanKamin(vagaries = strangeness)
DanKaminSo, looking at the minewt logs at http://www.doxpara.com/read.php/docs/minewt_logs.html
DanKaminThis is what happens:
DanKamin./minewt -i 10.0.1.180 -I 10.0.1.190 -r 10.0.1.254 -v
DanKamin-i 10.0.1.180  == The IP that machines on my network should talk to is 10.0.1.180
DanKamin-I 10.0.1.190  == The IP that the outside world expects to be hearing from is 10.0.1.190
DanKamin-r 10.0.1.254  == The IP that I will be routing packets towards (the default gateway) is 10.0.1.254
DanKamin-v is just verbose
DanKaminNow, one thing to notice is that very quickly minewt starts picking up traffic and NATting it correctly
DanKaminMinewt is a stateful program, but it's a flexible one -- any outgoing packet, SYN, TCP Keepalive, or whatnot, contains the necessary state to start a session
DanKaminSo between that and the fact that minewt controls its own MAC addresses,
DanKaminit's actually possible to start minewt on one machine, kill it, then start it on another, and *no hosts lose connectivity*
DanKaminSpeedwise, minewt is quite fast -- sub-ms delay!
DanKaminFreeBSD is probably the fastest platform, but I've had few issues elsewhere.
DanKaminIn terms of queso/xprobe identification, minewt really offers only one service:  ICMP Echo -> ICMP Echo Reply
DanKaminIt uses the incoming ping to construct the outgoing ping reply, so I expect there is some form of ping that *only* minewt would generate
DanKaminI haven't tested this though.
DanKaminUpon receiving a ping, minewt dumps the present state table -- this is noted at the end of the logs.
DanKaminMinewt has two features which are moderately interesting
DanKaminFirst of all, Minewt implements what I refer to as MAC Address Translation
DanKaminThis feature really comes for free as part of the infrastructure.
DanKaminBecause I don't use the kernel, I can't take advantage of any of its niceties like the ARP cache
DanKaminARP exists to map L3(IP) to L2(MAC)
DanKaminNow, here's what's interesting
DanKaminthe way NAT works is to map the local port on an outgoing connection to the internal IP address that spawned it
DanKamineffectively
DanKaminNAT maps L4(Port) to L3(IP)
DanKaminand
DanKaminARP maps L3(IP) to L2(MAC)
DanKaminso transitively, we can have MAT map L4(Port) to the combination of L3(IP) and L2(MAC)
DanKaminand since we don't have the kernel ARP cache, we pretty much have to :-)
DanKaminThis has an interesting side effect
DanKaminWe now don't care what IP address the backend client picks
DanKaminif they want to be a 10.* IP, no problem
DanKaminIf they want to have the external IP address -- the *REAL* IP address -- no problem as well
DanKaminif ten of them want to have the external IP
DanKaminstill no problem
DanKaminbecause their MACs are all different
DanKaminthis means, in a limited set of circumstances, packet integrity can be maintained
DanKaminAn interesting question was asked:
DanKamin<Zanshin> So with minewt running you can hide behind this virtual router and not be traced back? Since when you quit the router is gone... or are there still any traces?
DanKaminMinewt is as effective as changing your MAC address and IP address.  If this will evade some tracing functionality, so will minewt.
DanKaminYou will almost always be traceable to your subnet, since minewt needs to route into something.
DanKaminAnother interesting feature that Minewt supports is Guerilla Multicast
DanKaminthis will be much more deeply explored in the next major build of Paketto
DanKaminBut the basic idea is to get around one of my big annoyances of modern networks:  One packet, one destination
DanKaminI want to send one packet, to many destinations, with the internet as it is today
DanKaminIn case you haven't noticed, the internet doesn't support multicast too well
DanKaminby which i mean at all :-)
DanKaminThe internet -- the IP routable universe -- is indeed locked on unicast
DanKaminbut we don't directly connect at the layer of IP -- we tend to use ethernet to interface with IP, and ARP translates Ethernet MACs to Internet IP's
DanKaminEthernet supports broadcast and multicast just fine -- MAC of FF:FF:FF:FF:FF:FF or 01:00:5E:??:??:??, respectively
DanKaminNow, remember how we use ARP to link MACs to IP?
DanKaminLets use ARP to link a *Unicast* IP, perfect for the Internet, to a *Broadcast/Multicast* IP address, perfect for everyone on our LAN
DanKaminThat way, when the upstream router wants to return packets, they'll ARP, see BC/MC, and send that to the switch -- which of course will split the frame out to everyone
sarnoldoooh :)
DanKaminAs is, there's little we can do with this besides sniff all traffic coming out of Minewt.  MUCH more interesting work with this technique is coming in future builds, however.
DanKaminThe Helix Community Source is expected to get quite the workout
DanKaminOne IP on a LAN will be designated the unicast IP that all shared transmissions are routed through
DanKaminAnd every viewing client will share the load of responding to packets -- UDP if necessary, TCP as needed
DanKaminBut that's 1.1 / 2.0 talk :-D
DanKaminThere's many, many things possible with raw networking
DanKaminquite a few of which I hope I don't have to write!
DanKaminWhile C has great support for directly connecting to the wire, other languages don't.  I'd like to bring programmers of those languages into the fold
DanKaminThus is the purpose of Linkcat, or lc.
DanKaminlc is basically netcat at layer 2 -- give me data, I throw it on the wire.
DanKaminnetcat throws it into a TCP session
DanKaminlinkcat literally throws it onto the ether
DanKaminhttp://www.doxpara.com/read.php/docs/lc_logs.html
DanKaminThis shows logs of linkcat allowing me to cut and paste an ICMP echo
DanKamintext-mode ethereal proves we're actually sending a valid packet
DanKaminlinkcat supports both a near-raw packet mode based on libpcap (you can throw tcpdump logs into linkcat for retransmission, though tcpreplay is a better tool for that)
DanKaminand the ASCII mode seen in the logs
DanKaminOf some note is the support for HMACs in Ethernet Trailers.
DanKaminIP has an explicit length field that says how much it cares about
DanKaminbut Ethernet lets you throw more on, up to the Maximum Transmission Unit(MTU) size
DanKaminso we can just throw extra data there -- including an optionally parsed cryptovariable that authenticates the data!
DanKaminSo if you ever wanted to sign your ARPs
DanKaminthis is one way to do it :-)
DanKaminMuch more work will be done using Ethernet Trailers in future builds -- this is a proof of concept
DanKaminLinkcat will sign arbitrary frames using a shared secret, as is.
DanKaminFinally, last, but not least.
DanKaminPretty pictures!
DanKaminhttp://www.doxpara.com/pics/index.php?album=phentropy/
DanKaminBased on the excellent research of Michel Zalewski (http://razor.bindview.com/publish/papers/tcpseq.html), phentropy provides three dimensionsal visualization of the randomness of arbitrary datasets
DanKaminusage is simple:
DanKaminphentropy data
DanKaminif it's ascii formatted,
DanKaminphentropy -a data
DanKaminOutput is quite interesting.
DanKaminbash_rand1 is probably the most directly useful -- this is a plotting of Bash's $RAND variable
DanKaminit exhibits notable planes and clumps -- not something you'd expect from genuinely random data
DanKaminbash_rand2 shows the dataset rotated
DanKaminThe tool used to do these renderings is exceedingly fast.  Released at SIGGRAPH 2002 and now available at openqvis.sourceforge.net, OpenQVIS renders *arbitrary* three dimensional datasets in realtime, using Pixel shader hardware found in advanced 3D cards
DanKaminIt's good to do more with 3D hardware than blow things up :-)
DanKaminIntentionally nonrandom input renders *really* interestingly.
DanKaminThe BSD Kernel looks akin to a Borg Cube.
DanKaminThe default background to Windows XP ends up looking like a set of three triangles.
DanKaminA comparison of the left channel and right channel of some music I wrote a while back turned out the most interesting -- it became a pipe, with an apparently near hollow interior (see  stereo_r_vs_l_8)
DanKaminLinkcat has a mode -- -o m-n -- to emit data suitable for phentropy to visualize
DanKaminIt will be very interesting over the next few months to see what phentropy/openqvis make of many datasets.
DanKaminIn terms of what phentropy represents... take four values from the data:  a, b, c, d.  In between those four are three deltas -- b-a, c-b, d-c.  Make those three an X,Y,Z point, and plot it
DanKaminThat's what each point is.
DanKaminNow, the set of all points can basically be interpreted as clustering behavior -- these are sections where deltas, no matter how they're distributed across the total range of values, always end up being similar
DanKamintruly random data should have no clusters
DanKaminvery nonrandom data (like the slashdot comments) should focus on only a few known zones
DanKaminSo that's that!
DanKaminLots more coming to Paketto for 2003,
DanKaminbut that's what we've got going now :-)
DanKaminIf you've got any questions, lemme know...but that's all I've got for ya now :-)
sarnoldDanKamin: great! :)
sarnoldDanKamin: many thanks for the presentation :)
DanKamin*bows*
sarnoldi'd like to thank dan, raciel, acs, and riel for giving top-notch presentations today
DanKaminThanks for the invite :-)
sarnoldand I'd like to thank all our translators, making uninet available to so many more people ;)
sarnoldand with that, I bid you all goodnight, because I've got a bus to catch! :)
DanKaminDon't miss da bus :-)
zanshinthanks for the presentation DanKarmin.
DanKaminYou're welcome... hopefully the tools will be of use!
zanshinI will reread it tomorrow.... it's 03:34 now.... going to sleep :0) night.
Stonperl -e 'print "CLAP "x1000'
DanKamin*laughs* nice, Ston
Ston=)))
DarkLinuxhola a todos
Stonhmm i think everybuddy is sleeping! :(
DanKaminAbout: GunStamp is a program which can be used whenever accurate timestamping of events are required. It syncronizes the computer clock to an external time source (a GPS) connected to a serial port, and then use this clock to timestamp events. The events are received as positive pulses (+5v - +15v) connected to the acknowledge interrupt on the parallel port. Timestamp accuracy should be within +/- 15us!
DanKaminWhoa!
StonDanKamin: thanks a test a cgi log bitchx output with your presentation :)
passg1bien o no
passg1que se hizo hoy por aca, no pude venir
Ducky_Phasi y usted
passg1me dejo el bus :(
passg1bien
Ducky_Phade que ciudad es
passg1medellin
garoedapfoe...my hands are broken
garoedatranslating is heavy suffering
garoedaanyway, what to do with the dutch logs?
DanKamingaroeda thank you so much :-)
DanKaminSend me a copy, send seth copy too
passg1hehe I better dont translate anything since I have an old and heavy IBM keyboard
StondaniZzZz: thanks you too :)
StonDanKamin: thanks you too :)
garoedasend ? via dcc or mail or ?
DanKamindan@doxpara.com
garoedaok, wrote it down, now, how to save it from Kvirc :-)

Generated by irclog2html.pl by Jeff Waugh - find it at freshmeat.net!