So, I think I've got about 30 minutes of slides. Then I'm actually, I'm going to try and do a little bit of demo. And I guess there will be a question and answer period in another room afterwards. Like the track one Q&A room. I actually don't know where that is. Alright. Let's go. Hello. Drink what? Who's got the whiskey? Good deal. Alright. My name is Ben Kurtz. I'm here to talk to you about funk. And generally speaking, the use of functional programming for scripting network traffic. Oh, there we go. Before we get started, I'd like to point out that funk is currently an open source project hosted on SourceForge. I'd encourage anyone here with a laptop to go to this address and get a subversion check out right now. So you can follow along without straining your eyes. This looks fuzzy to me, but... Um... It's... It's a lot of fun. It's surprisingly addictive. And you'll definitely get more out of looking at the full source than just listening to me talk about it. Although, a little bit of both is probably the best. So, you may be wondering, what's this funk? WTF? Well, funk's an engine for the scripting of network traffic written in the functional programming paradigm using the Scheme programming language. With the chicken Scheme2C compiler, any script written for funk can be compiled to straight C code or to a native binary. This makes funk useful for deployment on an embedded system or an appliance, as well as for plinking around with your laptop. A lot of people have been asking me why I named it funk. I like funk. The only other suggested name was Colonel Kurtz's Chicken of Darkness. And that doesn't make an awesome acronym, so... Yeah, we funk. Alright, so... Yeah. These are some of the overarching goals of funk. In short, I wanted the core of the engine to be very simple, but extensible to any network protocol regardless of complexity. The most important idea, the take-home idea here, is that funk creates a generic interface to every network protocol. Hey, secret sauce. This lets you keep your fuzzing logic separate from your protocol logic. I'm on a schedule here. That is, you can write completely abstract fuzzing methodologies and then apply them to any protocol. Even protocols you don't know about at the time you write the fuzzing methodology. When support for the protocol is added, all of your fuzzing methods can be applied to the new protocol immediately without making any changes. This lets you play that combinatorical marketing game. How many fuzzing variants, how many testing variants does our product It's the number of fuzzing methodologies times the number of fields in all protocols times the number of combinations of fuzzing methodologies you can make. The numbers go up very quickly. You see a lot of people making claims 1 million, 2 million, 3 million different tests. That's just multiplication. I sat down and tried to come up with every way to fuzz an individual field I could come up with. If you look at the PROTOS site P-R-O-T-O-S they've got a couple dozen too. I'm not introducing a new fuzzing methodology at all. That's not the problem I'm solving. There's half a dozen other fuzzing talks at DEF CON this year that are different fuzzing methodologies or the pros and cons of one over the other. FUNC is a delivery system for fuzzing or any type of network scripting you want to do. It basically just removes the protocol logic from the equation. What can it do right now? It doesn't have to be just fuzzing logic. The current implementation of FUNC can be used for flooding, spoofing any other type of traffic generation. I have a lot of fun with it just messing around. Work is ongoing. We're heading towards scripting responses to network events. Using currying some lambda chaining. Comment just for that dude. Which will make FUNC useful for more complicated applications like firewalls, intrusion detection systems or rapidly prototyping servers. It can also easily be used to fuzz file formats simply by piping its output into a file instead of a network. As far as FUNC is concerned the difference between a file and a packet is just where the buffer gets sent. So, we're getting there. Tough crowd. Oh, alright. Alright. Joke bombed. I drank. That's a rule. Oh, dude. This is gonna end in tears, I know it. You know, what's really ironic is that the slide says, which I've just disproven. But, I have designed and implemented several of these protocol agnostic traffic generators. I think that actually everyone I've talked to about this has everyone who works in this space has attempted something like this before. Sometimes they've written something very protocol specific for IP. Sometimes they've attempted a general solution. It's a little trickier than you'd think at first whack. People have ended up writing and rewriting code that, you know, deals with protocols. I've messed up more than my share of these already. But, well, in that space anyway I've learned from my mistakes and now you can too. So, my most successful design featured an XML based protocol definition language. It was a domain specific programming language that I designed myself. The system was overly complicated and written in C++. Which might be a coincidence. And it might not. Although the system had its flaws, it was, you could say, imperfect. It did sell a few units and it did make some money. And there was demand for it. It made some people happy anyway. But, the biggest flaw was that the hand-rolled protocol definition language used a regular grammar. That is, it wasn't Turing powerful. Mainly because I'm lazy. This made it extraordinarily bad at handling special cases in network protocols. Things like checksums of pseudo-headers or type-linked value fields. Or any kind of dynamic protocol where there's like a type field that actually determines what the rest of the fields mean. Like OSPF, there's six packet types and you'd tell from the common header which type you're in. Or ICMP, DHCP, a lot of protocols are like that. But, using a regular grammar made it extraordinarily oh, I just said that, sorry. Because this couldn't be dealt with in the because the checksums couldn't be dealt with in the protocol definition, special cases had to be added to the engine code itself, which made a mess. It was difficult to extend, it was difficult to maintain, and sometimes when we added a protocol, we ran into a gotcha. Like something else we had to add to the engine and it just became stringy. It did work well enough, but it kind of haunted me. You know, even after I was like away from it, I knew that wasn't the right way to do it. And I kept pecking away at it in the back of my brain for a couple years really. And eventually I stumbled on something that changed the way I thought about the problem entirely. And yeah. Oops. Chicken scheme! So, you know, you could write your very own Turing-powerful programming language and use it to define your protocols. Or we could use one that already exists. Since I am way too lazy to do it the hard way again, I picked chicken scheme, which is uniquely suited for network traffic generation. Chicken is one of the many implementations of the scheme as a programming language. Scheme is a derivative of Lisp, which many people believe stands for button. Yay! Um, there are other hurdles in convincing people that scheme is awesome. I actually have to admit that I myself was always turned off by the parentheses. I was turned off by just its general craziness. I've always been a C++ programmer, or Java, or straight C. I started in AppleSoft Basic. All imperative stuff. A lot of object oriented, you know. And, uh, these are actually the questions I would ask scheme programmers. I'd be like, why do you use scheme? I kind of had the general impression that they were sort of elitist, you know. But, I came to scheme through this particular problem. And I spent a long time looking for an optimal solution for it. And, uh, I'm firmly, firmly convinced that this is a good way to go. And why is that? Well, scheme supports the functional programming paradigm. And func makes heavy use of functional programming. Functional programming means functions have no side effects. Or, they should have no side effects. They should avoid, depending on state, and mutable data. Uh, there are many, many differences between functional programming and other paradigms. Imperative, object oriented, and so on. Uh, but the most important thing functional programming gives us is support for higher order functions. Uh, higher order functions, uh, are functions that can take functions as arguments, and return functions as results. Uh, I'm gonna say that once more. Higher order functions can take functions as arguments, and return functions as results. Uh, you don't really have to remember that, though. Um, scheme is a functional programming language that supports first class functions. First class functions means that, uh, a higher order function can go anywhere another first class value can go. A first class value is like a number. Um, so basically you can define a function anywhere you can put a number in scheme, which uh, gives you a real through the looking glass feel. It's a completely different thing. Um, in scheme, the key word to define a function is lambda, named for lambda calculus, which I won't claim to understand fully. Um, I've defined an anonymous function in the first bullet. Uh, just to give you an example of the syntax. Uh, it's, it takes no arguments, that's what the empty parens mean, and it returns the string yay. So when that function is evaluated, it'll say, yay! Scheme makes it really easy to define new functions during execution. Uh, like, not at compile time, but during execution. Uh, bind them to variables, and pass them as arguments. Uh, provably, any program written in scheme can also be written in C++ or in Java, since they're all Turing powerful languages. Uh, but that just says that it can be done, not how efficiently or how cleanly it can be done. Uh, a really short program in scheme can't necessarily be written as a short program in C++. Uh, and vice versa in some cases. So, uh, I guess my point is, uh, different languages describe programming, or different languages describe programs in different ways. Uh, that is, they use different metaphors. Uh, and some of them are better suited to efficiently, uh, better suited to efficiently handling certain classes of problems than others. Uh, it's a matter of choosing the right tool for the right, uh, the right tool for the job. Um, it, it really is, uh, a very different way of thinking about it, but I think it's, uh, it's uniquely suited for the problem of, uh, traffic generation. And, uh, I'll show you some code and, uh, a couple of examples to back that up in a little bit. Uh, there are other advantages to using Scheme. Um, although perhaps not as common as C++, uh, Scheme has been around for decades and is widely used. Uh, Festival and GIMP use it, uh, to name a couple, but, uh, it turns up all over. Um, sometimes it's a scripting language, sometimes it's what the engine is implemented in. Uh, in this case, both. Uh, it's a minimalist language, uh, the entire standard, uh, at the moment is 50 pages long, uh, which is about the length of my attention span. Um, so, you know, I actually read it. Uh, which is a little bit different than the C++ standard, which I might use to keep me warm in winter. Um, Scheme, it's extremely portable. Uh, there are interpreters for every architecture, and there are compilers that will generate C and will generate Java bytecode. And that's from the same, the same code can be translated into C, can be translated into Java bytecode. Um, or run in a Scheme interpreter. Um, uh, another thing, Scheme interpreters are required to optimize tail recursive calls to minimize the use of the stack. Uh, tail recursion just means it's a recursive function where the last thing the function does is call itself. So it's like, the tail of the function is, is, uh, what recurses. Uh, but optimized tail recursion makes it okay to use recursion, uh, to do things like iterate over lists. Um, which leads to more compact code, and, uh, it's really nice once you get over the, uh, the knee-jerk, uh, recursion phobia that you develop from years of using C++ or Scheme, or pretty much anything else. Scheme has other benefits. Uh, it does do automatic memory management, which, uh, prevents buffer overflows. Uh, and the Scheme language is closure-based, uh, which means that a Scheme function captures the state of its environment at the point of closure, uh, preventing further modification. That's a little bit dicey to understand. I'm not going to explain that entirely. But, uh, this helps support the no-side-effects goal of the functional programming paradigm. Uh, and it makes callbacks a lot less scary, which is, uh, the moral of the story. Uh, Scheme also has a very fast prototyping and development time, uh, according to a JPL study comparing C, C++, Java, and Lisp. Why Chicken specifically? Uh, there are many Scheme implementations. I chose Chicken because it's one of the most actively developed and one of the most highly optimized. Um, actually, the, uh, the main developer of Chicken, the guy who wrote the, uh, Chicken Scheme to C compiler, um, will actually respond to emails. Even really stupid questions. Uh, and he's a very nice dude. Uh, but most importantly, um, Chicken is a Scheme to C compiler, which means that anything written in Chicken Scheme can be compiled into highly optimized straight C, and you could distribute it as, uh, C files. Uh, but you can also compile it into native binaries. Uh, Chicken can also be extended with libraries called Eggs, uh, that can combine uh, Scheme code and straight C code, um, and they'll compile into, uh, shared libraries that, uh, you can use from a Scheme interpreter, uh, and you can also link against them, uh, in compiling. Uh, and it, and it can integrate with code written in any other language through, uh, Swig. Additionally, uh, it integrates with standard build environments. Um, if anyone actually pulled down a copy of the Func source, you can, uh, you can check out my Make files for examples of how, uh, it integrates with Autocon from GMake. The more I drink, the more I stutter. Alright. Oh. Here comes the flop sweat. When picking a core technology, I could have also gone with Python, which some of the cool kids are using these days. Actually, every other general purpose fuzzer I've seen is written in Python. Uh, at least the ones that actually work. Uh, Python has some functional programming features like limited lambda support. I stress limited. Uh, but it's incredibly slow in every benchmark I looked at, usually coming in at 30 times slower than C, and I am being charitable. Uh, I like Python. I use it for a lot of my general purpose scripting, you know, but I want Func to work efficiently on limited hardware, uh, perhaps even OpenWRT. Uh, so efficiency, or lack thereof, is a deal breaker. Uh, when you could choose chicken instead and generate optimized C, um, Python seems a little foul. Also, Python has stupid white- that was a Bob joke too, I'm gonna Alright. God, what is that? Yeah, it's- I'll say. Alright. Also, Python has stupid white space, uh, which I find just as irritating, if not more, than stupid parentheses. Uh, but if that's all that's preventing you from using a scheme, there is actually a syntax extension to scheme available that will let you use white space instead of parentheses. Uh, I just don't know anyone that actually uses it. Doing it to you in your ear hole. Alright, now the fun bit. Alright, during the development of Funk, I've written three libraries for chicken so far. BitCat, uh, CRC16, and RawSockets. Uh, these extensions are available in the Funk SourceForge project, and also in Chicken's online egg repository at callcc.org. Uh, BitCat is a bit string concatenator, um, which is useful if you have a lot of, uh, you know, 13-bit fields, 1-bit fields, 32-bit fields that you need to stick together in a byte buffer. Um, CRC16 is just the CRC16 algorithm. And, uh, RawSockets is a, uh, an interface to, uh, the packet socket interface on, um, on uh, BSD or UNIX platforms. Uh, currently I've tested it on Linux and also on OSX. Uh, I did not write a packet socket driver for Windows. Um, I don't actually have a Windows box. But, hey, you know, if someone wants to contribute to the pro- uh, to the project, I'd be, uh, I'd be absolutely thrilled. Um, also, it's, it's not a wrapper for RawSockets, it's a wrapper for PacketSockets. I don't know if anyone else is with me on this. I think, um, since PacketSockets are, like, more raw than RawSockets, I think a name change is in order, but, hey. Alright, so just a reminder, the main goal here is to provide an abstract interface to network protocols that allow for the easy addition of any other protocol. So it's important to keep everything consistent and abstract. The crux of the biscuit. The most important thing in this whole scheme is how protocols are defined. Uh, it was an overly limited protocol definition language that crippled my last attempt, after all. So, what is it we want our protocol definitions to do? Uh, well, we need an ordered list of fields and their associated bit lengths. That's a given. But, uh, we would also like fields to default to reasonable values. Uh, because it keeps our actual scripts short. Uh, sometimes these values have to be calculated. Like, uh, the total packet length field in the IP protocol is an example. Um, or CRCs, or, uh, checksums. Uh, but we might also have to define some protocol-specific logic about how a packet is generated. Uh, this is usually something that relates the values of particular fields together. Um, checksums, uh, TLV fields, stuff like that. Uh, we also need a couple of other things, like a way of validating field values. Uh, since this is a tool that will be used for testing, we are most definitely going to be lying. Uh, and sending out invalid values. Uh, however, I am, uh, planning on building a GUI on top of this, and the ability to tell if a particular field value is valid or not, uh, will be a requirement for the GUI. Um, and that is a decision that should be made by the protocol. Um, when you define the protocol, the protocol knows what fields are value, or, what fields are valid and what aren't. No more whiskey. Um, we also define a serializer for each field. Uh, the serializer just translates a field value, uh, from the string we get from the user. Uh, for example, 192.168.1.1. It just translates that to its corresponding binary. So that's, uh, that's all a serializer does. So, here's an example of a protocol definition in func. Um, if anyone downloaded this, this is in ethernet. uh, scm. Uh, what's on the screen here deals with the entire ethernet protocol. Uh, ethernet is a simple protocol of only three fields. Uh, for each field we assign a name, a bit length, and, uh, procedures that will validate and serialize the field. Uh, so this is where the, uh, the, the first class function thing comes in handy. Uh, I don't know if you can see this, but, so we have three fields. Desk mac, source mac, and packet type. Desk mac and source mac are, uh, are, their bit length is 48 bits, and I'm telling I'm defining the validator, uh, I'm setting it to the mac validator, and I'm setting the serializer to the mac serializer. Which are, um, special functions that deal with uh, uh, mac addresses. You know, the, uh, hex, hex, colon, hex, hex, colon format. Um, and the packet type field is set to 16 bits, uh, but I'm not defining a validator, I'm not defining a serializer. If you don't define a validator or a serializer, it defaults to a, um, uh, a hex validator and a hex serializer that both, uh, they're actually functions that generate functions that serialize and validate hex fields based on the bit length of the field. So, this is one of those, uh, things that's just made a lot easier by using functional programming. Uh, further down, we also assign default values for all three fields. Um, my defaults are not exactly reasonable. I'm setting, uh, the destination mac address to 1, 2, 3, 4, 5, 6, and, uh, the source mac to AABBCC. Um, but the packet type, I'm just setting to IP because that's what it ends up being most of the time. Um, and the other thing to look at in this is the, uh, those put op calls at the, sorry, the, uh, put op calls at the bottom. Um, those are actually registering three internal protocol operations with func. Um, generate, validate, and make layer. Uh, these three operations are, are, it's a requirement that, uh, every protocol, uh, provide these three operations. Uh, generate actually produces a byte buffer that can be sent out on the wire, uh, or saved to a file. Uh, validate reports on which fields contain correct values. Um, it actually returns a, uh, a list of booleans telling you whether or not each field is, uh, valid. Uh, and make layer which creates an instance of a protocol layer and fills in any unspecified values with the appropriate defaults. Um, but it's not really that much work. Uh, for most cases, the default generator is sufficient. Um, the code for the default generator is in, uh, default hyphen, uh, fuckins FCNS dot scheme. Uh, if anyone has, uh, you know, pulled this aversion. Uh, so what the default generator does, uh, it does actually most of the work of, uh, the entire engine. Uh, and all it does is it iterates over each field. And, uh, here's where some, some more functional programming comes in. Uh, fields can contain either actual values, 192.168.1.1, right? Um, or they can contain functions. Uh, because you can put a function anywhere you can put a number or a string. They can contain functions that will return a value when a value is evaluated. Uh, so, if the field contains a function, first, uh, the default generator evaluates it. And then it, it goes forward with that value. So, uh, then the value is converted to binary, uh, using that field's serializer. And that binary is appended to the outgoing buffer using the, uh, the bitcat library. The, the bitstring concatenator. Is that legible? Yep. So, the default generator can be completely overridden or it can be extended. Uh, the current IP implementation registers its own generator with func's operation table, which is called ip4-generator. Um, which is in the, uh, ip4.scm file. Uh, all the IP generator does is call the default generator, uh, with header checksum defaulting to zero. Uh, calculates the checksum of the result, and inserts the checksum in the header checksum field. this code makes use of the CRC16 egg, but otherwise this is all the code it took to generate correct IP checksums. That's like three lines of ham. So, I was pretty happy with that. Uh, as I mentioned, every field value can be replaced with a lambda, a procedure that will evaluate to a value. In the IP protocol, the default value for total length is a procedure that will calculate the correct total length for the packet. Um, so this is a list of default values, like you saw for Ethernet, where I was setting the MAC address to 1, 2, 3, 4, and so on. Uh, IPs get a lot more fields. Uh, so I couldn't fit the whole thing on one slide. But, uh, this is an ip4.scm. Um, so you can see for the total length field, I'm not giving it a value, but I'm actually just defining a function right there. Um, which gets passed in all this other information about the packet that's been generated so far, and what the fields are, and so on. And, uh, this will actually by default, just calculate the correct total length for the packet and, uh, and set that. Cool beans. So, uh, to generate an actual packet, all we have to do is, uh, stack some protocol layers. And send them out. This is all it takes to generate a packet with default values. Uh, you can see in, um, that top section, I'm, uh, setting my packet to a list of a instantiated Ethernet layer, an instantiated IP layer, and an instantiated TCP layer. And I'm not overriding any of the defaults. Um, then I have to find a function, which is the generate my packet. Uh, where you give it a, um, a length, and it just adds a, uh, data section, which is that byte length, it's just filled in with Fs. Uh, and this is where the raw sockets egg comes in. Uh, I just open up the eth0 interface, uh, generate a packet with, uh, 8 bytes of data, then generate a packet with 16 bytes of data. This is a, uh, simple example. So, where do we go from here? Um, in the short term, we're already working on the ability to read, parse, and respond to incoming packets. Uh, we're also looking at file format and binary fuzzing, uh, sooner rather than later. Uh, and further out, I'd like to see func extended with a visual script designer so that packets can be generated without touching a scheme. Uh, I'd also like to use this to drive visualizations of network events. Uh, if you're interested in learning more about scheme, check out these books. Uh, the wizard book, that's the first one, but probably the most definitive one. Uh, it's available, it's available in its entirety online at that link. And, uh, oops. So, that's the end of the slides. Um, I, I, I'm going to attempt a demo. Um, but actually if you look at the slides, online, I've included 10 extra slides or so. Uh, which contain instructions on how to set up a, uh, a func development environment. Um, which is uh, the same thing I'm using. So, uh, if you check those out online, um, it's got all the info you need. Um, if you're interested in talking to me about func, uh, just come up and ask. I'll be hanging out in the, uh, prototype hacker space in, uh, 1.14. Um, playing some Wii boxing. Alright. So. How do I turn this on? Oh, good work. I'm a cheap date, I'm sorry. Alright. Did I show up alright? So for development environment, I use Eclipse with, uh, a particular plugin for Scheme that will let you connect to a, uh, a redevelop print loop. Um, which actually if you do a subversion check out, um, the make files will just build it for you. You might want to set UID um, if you're using func, uh, because opening a packet socket requires root. Um, so as I said before, any script you, you write using func um, you can run through the interpreter, uh, and you can also compile them to binaries. So I'm just gonna do, uh, a couple of quick, uh, examples. So the first thing I'm gonna do I'm gonna fire up my, uh, Scheme interpreter. So that shows up there. So, my first example um, I'm actually gonna send it out over the loopback. Uh, rather than ethernet. Uh, so I also, I also have just, uh, BSD style loopback headers to find, uh, in a separate file. Uh, so I'm gonna instantiate a loopback layer. I'm going to make an IP layer, but I'm going to override the source IP and set it to, uh, 127.0.0.2 and, uh, the dest IP to 127.0.0.2. Uh, then this is the same general to generate my packet, uh, I showed you before. And this is actually the same example. I'm gonna generate a packet with, um, 8 bytes of data and a packet of 16 bytes of data. Alright. So, all you have to do to run it bombs away. And, there's my packets. Uh, I'm not doing anything with sequence numbers or hacks right now. Um, but you can see that the TCP generated and the checksum's good. Alright. Simple example. Um, I hope that was clear. Here's a slightly better example. This one's a bit more fuzzing oriented. It's, it's the same as the previous example. Uh, but I've defined some extra functions. Uh, I've defined a function that fills in a, uh, u8 vector. Uh, which is equivalent to an unsigned char star in C. Um, and this will, and you just give it a length and it will fill in a, uh, a buffer of the given length with, uh, random data. Uh, and I've defined a lambda called make random fields. Um, which has the right, um, signature to be, uh, to be passed in as a field value. Uh, and all that does is it reads the bit length of the field that it's put in and fills that many bits with random data. I mean this is, it seems, I don't know, I mean you get used to it, but it's very different, it's a very different way of thinking about it than you would be thinking about it, uh, if you're writing this in C. Uh, so this is, uh, the same, it's pointed at the loopback. If I wanted to point it at ethernet, uh, basically all you have to do is, you know, uncomment that and then comment this, you know. Uh, the same generate my packet, except now I've replaced the function that fills in, uh, fills it in with f so I've replaced it with make random u8 vector. Um, and then I've also defined another function that just generates, uh, n packets filled with random data. Um, and it also sets the size of the data segment, uh, to a random number. So I'll run that, um, and you can see some evidence of that running on the bottom. And that's generated a random number of randomized packets. Uh, you can see that the data segments at the bottom, this one's 22 bytes, this one's 16, this one's 48, this one's 32, and the actual data itself has been randomized. Alright? So, that's what the randomized data segment, but, uh, what if you wanted to randomize a field value? Um, well we can just use that function I showed you a moment ago. And instead of passing in 127 dot 0 dot 0 dot 2 for the destination IP, I'm gonna pass in a lambda. I'm gonna pass in make random field. ... So I just ran that. Check that out. Completely randomized destination addresses. ... And that's all it takes. ... So, some other interesting things to look at, uh, interesting things to look at. ... Um, some of the egg code. It's pretty cool. ... ... ... So there's some scheme up top. Then you can just break into straight C. ... And, uh, this is the egg that opens up a packet socket. Um, which allows you to even set the fields of, uh, Ethernet. Uh, completely avoiding the TCP IP stack. And I realize that this is you're probably not gonna get a handle on this just from me talking right now, so I would really strongly encourage you to go just check out the source. ... So it went from scheme to straight C. Defining a couple functions. And then back to scheme to define, uh, interfaces to the functions, uh, error messages, that sort of thing. ... ... ... ... So, were you raising your hand? Uh, yes. ... Nope. ... ... ... ... ... So, actually, at the moment, I just took it up through the TCP stack. The next thing I'm going to be looking at seriously is ASN1, because, frankly, that was the thing that broke my previous one. DHCP would be easy, but it's kind of a pain in the butt because there's, like, 65 different variants. Yeah. Seth is flipping me off. Sorry? Absolutely. Hey, I'm absolutely looking for people to help flesh this out and implement more protocols. So, if that's something you're interested in, definitely. Sorry? I think he wants me dead. Yep. Yep. I'm sorry? Right. You can totally screw with it. Actually, that's a very good question. I'm going to come back over here. He asked, how strongly is the networking stack itself, how strongly is it hard-coded? And how easy is it to screw with that? To go back to our simple example, a little bit down further. Okay. Define my packet. If I wanted to do something stupid or something crazy, I could do two IP layers in a row, just like that. That's it. Sorry? Yep. That would be IP. IP and IP. And then TCP on top of that. And the engine itself doesn't really care. You're just giving it a list of protocols. So, you could do two loopback headers followed by two IPs followed by a TCP and things should work out fine. Well, I mean, as far as the engine's concerned, I don't think that's going to mean anything to anybody. But, like I said, this is, it's designed to be a testing tool. So, we have to be allowed to break rules everywhere. One more. I really can't hear you. Okay. Yeah, that's a good question. Actually, that was something I wasn't going to get into, but hey, I ended early, so we'll go there. Oh, he asked, how easy is it for, if you set a lambda to a particular field value, like how easy is it, or for the data segment, how easy is it to get access to other field values? And I think, we should pull open the protocol definitions for that. This is actually some, so here's the definition for TCP. Okay. okay. So, the arguments that the generator gets are the same arguments that the lambdas you would set to a field get. And this is kind of, this is like an interface, but it's hard to enforce interfaces in Scheme, which is actually its main drawback. So, you kind of just have to, behave correctly. But that's something you kind of have to, you just have to deal with it. But the arguments here, what they mean, packet is the packet that's been generated so far. It contains the byte buffer that's been aggregated up to this point. Fields is a list of the field definitions that come in from the protocol. So, you can look up fields by name, you can get their bit length, and you can get their generator and serializer, or their serializer and validator from this. Vex is a list of vectors for all of the values of the fields that have been evaluated so far. And then the data segment is accessible from every layer at all times. And you have to do that in order to figure out things like total header length. So, yeah, basically you can get to everything else, you know, from everywhere. Sorry? Yeah? Okay. So, in this example, I actually just wrote a function that calls into the framework to send a packet out. So, you could define timing in your own function. But I'm not currently providing anything that deals with the timing. Actually, one thing that I'm very interested in doing, is instead of generating packets directly to the wires, generating a PCAP file. Or, and also parsing PCAP for later playback. So, when I get into that, I'll have to respect timestamps in PCAP files, and have some kind of timing loop. But that would be a missing bullet point from the future work slide. It definitely doesn't do that right now. But hey, if that's something you're interested in, we should definitely talk about it. So, anyone else? Oh, yeah, maybe I should start drinking more. Okay, well, personally, I run Gen2 and I run LSX. So, I know that this works on Gen2, but I'm not doing anything funky. I'm using standard Linux interfaces. So, it works on Gen2, it works on LSX. For future work, I definitely need to port it to Windows for the socket generator. So, I think that's my time. Oh, that was five minutes. Oh, okay, cool. Three minutes. Anyone else? Oh. So, I can just randomly flip through some of the protocol definitions. Ethernet, relatively simple, about a page long. IP4. This is the checksum code. If you're not used to Scheme, basically, I'm just setting a buffer to the result of the default generator and setting a variable called checksum to the calculated CRC16 checksum of that buffer. And then U8 vector copy is about equivalent to memcopy. And see. This is a little bit more of a mess. Actually, as of two days ago, I kind of... There was a rule that the lambdas you pass in for field values would return strings that then had to get serialized. But I actually made it possible for you to pass in a lambda that just generates a U8 vector, and then it bypasses the serialized one. So, if anybody actually can read Scheme, this definitely can be rewritten to be like a line long now. But the more I work on this, the smaller the code gets. Oh, actually, hey, one other thing. The other thing that's cool about this, I completely forgot, is that you can... Just compile these to C files. Demo one and demo two is the non-randomized one and the randomized one. And then they just show up in the bin directory. So actually... I'll just restart this so it's cleared out. And check this out. This is the first demo. This is the one that generates one 8-byte packet and one 16-byte packet. Oh. Requires some sudo. But, hey, there they are. All right? So... That's no longer Scheme. That's actually a compiled file. I'm pulling in a lot of libraries. Regular expression stuff. So it ends up being about a 137K. But that could be anything. Like the cost of additional scripting over just pulling in the libraries is minimal. For example, a slightly more complicated example is the randomized field one, which is demo two. You can see the packets show up in Wireshark. All right? And that comes in at 141K. So...