All right, I'm Raphael. I work for a company called ArcSight, and for a living, I do enterprise security management or log analysis and correlation. And somehow over time, what happened to me was that I got kind of bored of the textual log files and parsing and everything, so I somehow developed a passion for visualization, and that's what I want to talk about today. So the rough outline is going to be that I want to introduce the problem very quickly. I'm going to show you what graphing really is and what I mean by that, and then I'm going to show you a tool that I developed over time, and some of you might have seen my talk last year where I introduced Afterglow a little bit. Over the last year, I have made quite some improvements on the tool and there are new features in there which are quite interesting, and I've gotten some really good feedback from you guys on what I should change and how you utilize the tool and how you use it. I'm going to show you how you can use this tool to actually visualize your own data. And what I want to do in the end, which is kind of the main part, is I want to go through a firewall log file and show you some of the things you can do with it and how you can visualize it. Just to send that up front, and you might have heard that from me already, but I need to do it because of legal issues. IP addresses and host names showing up in event graphs and descriptions are obfuscated or changed. The addresses are completely random. And any resemblance with well-known addresses or host names are purely coincidental. So don't try to play with these IP addresses and think it's me's. You're screwing someone else. All right. Well, the motivation for doing visualization or looking at graphs is really the question here. What would you rather look at? Do you want to look at the left-hand side or the right-hand side? I prefer the right-hand side because I can't even read the font on the left-hand side. And I guess this is something probably everyone has heard by now, but a picture is really worth 1,000 log entries. And I hope to be able to prove that in the next 50 minutes if I'm not going over time. All right. So how does graphing work or what do I mean by that? There are basically two steps if you simplify it a little bit. You have a device that generates a log file or maybe events. You record them. And you want to make a visual on the right side. Some kind of representation, a bar chart or a link graph or a tree map or something. What you have to do is you take that log file on the left side and you need to parse that thing. You need to figure out where are my source addresses in there, where are the destination addresses, where are the ports. So you need to parse it out and figure out all those things. And then you throw it into an event visualizer, whatever that is. You can use Afterglow, which I will show in a second. And you generate a graph. What I'm going to look at for graphs today is I don't want to cover all the different types of graphs that are out there or visuals. There's bar charts and pie charts and linear line charts and so on. What I want to cover is just these two types. There are link graphs and tree maps. Link graphs are basically you have a couple of nodes or three nodes and they're connected to each other and they show you a certain relationship. Tree maps, they look a little complicated when you look at them the first time. You might not quite understand what they are. But I want to introduce them to you and show exactly what they are in a second. Now if you take link graphs, a lot of times you will see graphs that show you communications between different IP addresses. You see that this machine talked to all these other machines. But the interesting thing is that you can actually reconfigure these graphs to also show you other things in a log file. So what I have here is a snort event. You don't have to be able to read this. But I basically take five fields out of this snort event. The event name, the IP addresses, and the ports. And there are different ways to configure a graph now. The regular way would be that you take the source address, then the event name, and then the destination address. So you will see things that what has this IP address done to other machines. However, if you configure this graph a little differently, if you say, well, let's visualize it the way that I have a source address, a destination address, and then the destination ports, you will suddenly see port scans. Because you see source machine going to some other machine on all kinds of ports. So that you wouldn't see that in the first configuration where you see a source IP, a name, and then a destination IP. Because you're not showing the destination ports. So the point of this slide is really you can configure these graphs all kinds of ways. And depending on the configuration, you will see different things. Now, let's have a look at tree maps. And I'm not sure how many people are familiar with those. But they're really useful for a lot of cases. So let's assume this rectangle that I have here is all your network traffic. Everything you see on the wire. Now, what I want to do, I want to see how many percent are UDP or TCP. Basically, I want to see the transport protocol here. And what I do is I just configure the tree map to use the transport protocol as a parameter. So what happens, I have 20% UDP, 80% TCP. And it just partitions it that way. So 20% in the rectangle is UDP here. Now, if I change the configuration, do not just be the protocol, the transport protocol. But I also want to see the service. So what happens then is basically this space is subdivided now. And the protocols are shown inside. So for UDP, you might see things like DNS or SNMP. And this is probably like a ratio of 90 to 10. And then on the other side, the TCP. You see the partitioning to all the TCP protocols you have. So you can set up a hierarchy. And the hierarchy is going to be displayed inside of this tree map. And you could go deeper. I could say now that I want to see the target port or the source IP address. And it will just be subdivided inside of these little rectangles. And it will show the percentage again. And you will see a real example later on what you can really do with this. Now, let's switch this. Switch over to Afterglow, which you will find either on the CD or on SourceForge. There are two versions right now. It's a little confusing. I apologize for that. There's basically a version 1.x. Currently, the one on CD is 1.56. And it's basically a Perl script that generates your link graphs. And then in the version 2.0, I started coding in Java and I used the library. And I thought I would be able to get all the capability or functionality from 1.x. into that new Java framework. But it turns out the library I'm using is a little buggy. And the author was not really responsive. I traded a few emails. And so far, I haven't gotten any patches for the bugs that I found. So for now, there are two versions. I'm sorry. Hopefully, at some point, there's a 3.0 which combines everything. So what you will also find in Afterglow is when I started playing with the log files, I needed to write parsers because otherwise, I couldn't really visualize my log files. So what I decided to do is the parsers I'm writing, I just put under the Afterglow distro as well. There are three parsers. One for the BSD packet filter. One for tcpdump. And I updated that to 3.9 recently. So if you're using an earlier version of tcpdump, it might not quite parse it out anymore. And then one for sendmail. If you look at the parsers quickly, it might actually be quite useful even if you don't want to do visualization. Here's an example of how to use tcpdump to CSV. So what it basically does is you pipe tcpdump into it. That's just a long comment line on top. And then you tell it what fields you want to extract from the original tcpdump output. And here, what I said is basically I want to see the source IP, the destination IP, and the source port. And if you want to know the names or the fields that are available, look at the source code. There's a list of all of them. So what this thing also does for you, it takes care of connections. If you look at a connection or if you look at a tcpdump and you see a client connecting to a server, you will see a request going over the wire. And the source address is the client. The destination address is the server. But then immediately followed by that, you will see a response. And now the source address seems to be coming from the server. Going to the client. If you visualize that, you will suddenly see that there was a bidirectional communication. So you're thinking that the server actually connected back to the client, which a lot of times you don't really want to do. You want to see the real connections. Who was connecting to whom and not the bidirectional thing. So the parser takes care of that for you. It will keep state and remember what initial setups it saw. It uses some heuristics. If it sees a by itself, then it's probably the session setup. If there's a that's the response. So it keeps a hash of all those connections and inverts the output if necessary. Then the sendmail parser. Sendmail is, they have certainly not designed this thing with logging in mind. What they do is for every email, they generate two log entries. One entry tells you this email came from someone. And then the other entry tells you it went to these people. And the way you connect them is the message ID, which is in bold here. So what I did is I just wrote a Perl script that basically remembers all those message IDs. And whenever it finds the combo of two went froms, it will output one entry showing you the two went froms in one line. So you can actually visualize connections now. And then the third one is the packet filter to CSV. And I'm going to use that in a little bit so I won't waste any time on it right now. Now, Afterglow, and we saw a similar diagram already on how do you graph something. So basically you have a device outputting some log file. You have a parser. Either you use one of the three that I provide or you use awk or something, or Perl to parse the logs into a CSV file. And that file you pump into Afterglow. And Afterglow outputs not a graph directly, but a graph description. So it basically uses the dot description from the GraphVis library. And it just says, okay, there are these nodes, A, B, C, D, E, and they're connected that way. So you have a node from A to B, one from B to C, and so on. So it just gives the description. And then you use some kind of a grapher. And I usually use GraphVis to generate the graphs because what that does, it does all the layouting. So it figures out where to place all the nodes so the overlaps of the edges and the edges are not too high. And you can kind of identify groups and so on. And I didn't want to tackle that problem because other people have done that. So what are some of the features of Afterglow? Well, it generates link graphs. Then what you can do is you can filter nodes. Well, you can say, well, I can do that with grep-v. Yes, you can. But it's a little nicer to actually configure it in Afterglow. And what you can do is you can either do it on a name. So I can say, I don't want to see any node that contains Windows, let's say. Or you can say, based on the number of times that node was seen, I only want to see nodes that have been seen more than 10 times or more than 100 times or something. So you can kind of filter noise out. Then you can do fan-out filtering. A fan-out of a node on the right side there, that blinking node, has a fan-out of three. So there are three connections going to other nodes. So you can specify when you draw a graph that you only want to see things that have a fan-out of x. So let's say only everything that has more than five connections going out you want to visualize. And you might already have in your mind what you want to do with this. And it's basically detecting port scans very, very quickly and filtering the noise. And then you can color everything. You can color the edges and the nodes. And finally, you can do clustering, which is very useful as well, because especially if you start visualizing firewall log files, you have these hundreds of machines or thousands of machines connected to your network. You're not interested in every single one because that graph is just going to be cluttered. So you want to cluster all those together. And I will show you what I did with that. If you start Afterglow, you can use "-h." And I think the usage is actually up-to-date. I hope. These are not all the parameters that are there, but the most important ones. The most important one in here is "-c," where you provide a configuration file. And I will show you a few of those files in a second. Then you can use "-d," and that basically adds the count of how many times a node showed up into the node itself. So you can kind of figure out what was more severe than other things because you might have seen them a lot of times. Then there's an easy way to change the edge length. You just say "-e," and then give a number. That's basically the default edge length that it uses to have the nodes separated. Then you can also use "-n," if you're not interested in node labels at all. You just get rid of them. And sometimes that's really useful to just see kind of patterns in there if you're not interested in seeing all the labels and knowing exactly what it is, but just kind of figure out what does this look like. And then you have "-o." It's a horrible way. I even named it here, omit threshold. It's basically how many times does a node have to show up to actually be in the graph. That's what I kind of described before, number of occurrences. And then you have a "-f," and a "-g," which is used for the fan-out filtering. And you can specify two different fan-out filters, one for the source nodes, how many connections does that guy need to have, and one for the event node, so the middle node, how many connections does that guy have to have to show up. And "-f is for the source, and "-g is for the event node. Now we're getting into the property file, and this is really where you configure everything for Afterglow. Let's start out with coloring. What you do is, in the file, you basically see color, dot, and then either source, event, target, or edge. And then you give a Perl expression. This gets really evil here. The easiest Perl expression is just a string. You just say, red. And the source, for example, is going to be red all the time. Then, if you want to get a little more sophisticated, use the next line, color.event equals red if, and then I provide some kind of an expression there. And Afterglow keeps track of the current log entry in the at fields array. So if I do this here, $fields 1, that means that the second column starts at zero, the second column has to be matching this regex, basically starting with 192 dot something. In that case, I would make the node red. And you can do all kinds of things here. It's really just doing an eval on this Perl expression, so whatever you want to do, you can read from files and all kinds of things. Then if you want to filter the nodes, you just use the color invisible. Same idea, you say invisible, then if the first column equals isAction, it won't be shown. Then the clustering works very similar. You just say cluster dot source, and then again you give a Perl expression. What this does now is it evaluates that for every node and basically returns or changes the node name. So if I have a whole bunch of 192, 168 addresses, and I want to cluster them together into one node, I can basically say that the cluster dot source equals, and then I just give some kind of a string. I can say 192, 168 dot x dot x if the field matches my regular expression, 192 dot 168 dot star. And that would be the node that is assigned now instead of all the others. So that's evaluated every time a node is drawn. We'll see an example of that in a second. So this is kind of my hello world example. My input data is on the upper left. There are four entries in my log file, A, B, A, C, B, C, and D, E. If you would just visualize that, you would get something on the lower left. The nodes are connected. The command to run Afterglow is on top, and I think there is a pipe missing in your slides on the top right, but you will realize that yourself. You cat the file, you pipe it into Afterglow, you give it a property file, and you use minus T. By default, Afterglow expects afterglow as a three-column input, basically the first column being the source, the second column being the event node, and the third column being the destination node. So it's always a three-tier thing here. But if you use minus T, you just give it a two-column input, and that's what I have here. So now to color these nodes, you can guess how that works, you just say color dot target is blue. And by the way, that's all my PowerPoint skills. I can't go any further. So target is blue. It's blue if the second column is not an E. So you look at all the target nodes, the ones that get an arrow pointing to them, they're blue. The E there is not blue because it's not E. Or it is E. Sorry, it's early. Then the source, I want to make green if it's not D. So that's that one guy there. And by the way, it's first match, and then it's done. So it doesn't go and devaluate the rest. And then everything and all the other sources are going to be red. And then whatever is left, I just say color is green. So I don't have to say color dot target now or anything. I just say color, and that applies to all the nodes. All right, so that's the easy example, and it's getting harder from here. I hope you're all still following. Okay? Good. All right, but let's quickly talk about Afterglow 2.0. So in case you want to play with it, it's a little simpler. You have two common line parameters. One is for the property file, and the other one optional is for the data file. You can also provide the data file inside of the property file if you choose to do so. It's taking CSV input again. That's kind of my mantra. I want to use CSV files because then you can use your own parsers. I don't have to care about your data set at all. You just give me the CSV file, and I try to draw you a graph. And the interesting thing about Afterglow 2.0 is that you have the tool generate the graph itself. So it doesn't just generate a description, and then you have to use some kind of grapher to actually visualize it. But it's a Java itself that generates the tree map right away. And what I can do with that is you have a little bit of interactivity. You can basically zoom in into different parts of this tree map if you want to look at close-ups. And you can change on what level of the hierarchy you want to use the color. So before, if you remember the example, my top-level hierarchy was the transport protocol. So you can say, I want to color this graph by the transport protocol. So you will just have basically two different colors in your graph. Or you can choose to color on the service, and then you will have all kinds of different colors just as in my example. So you can kind of play with where you want to use the color from, what depth in the hierarchy. And a simple output looks like this. All right, so let's get a little more practical. And let's see how we can visualize a firewall log file. And you've got to stop me if I'm going too fast here. So if I'm analyzing a firewall log file, there are a few steps I want to take. The first step is certainly I need to parse it. The second step, I probably want to look at what is coming into my network, what is allowed through the firewall. So I kind of know what is hitting me. So I can probably verify the ACL and figure out whether there are any gap or any holes of things that are coming into my network which shouldn't. Second, I probably want to look what is leaving my network. Everything is allowed to go out. And I'm actually quite surprised to see very big corporations in the U.S. still having no outbound ACLs and just letting everything out, which is, I don't know, great security. Then I usually look at outgoing blocked traffic. And that tells me that either I have misconfigured machines, which are not configured according to my policy because they should not be trying to connect outbound if they're not allowed to. Or maybe my firewall rule set is misconfigured and there's really a need for the service to communicate out. So if you have ever set up a firewall yourself and nothing worked anymore, you might have realized that you might have blocked ICMP and it doesn't do path empty discovery anymore or something like that. So communication is gone, especially in the older DSL worlds. And then if you're brave, you can also try to visualize or analyze the traffic that is blocked from coming in. And you will see all kinds of things in there. So the parsing part. I have a PF output here, a log file, just two lines. Then what you do is you cat that file and you use PF to CSV to parse it. And in this case, again, I want to use source IP, destination IP, destination port. And the output is just going to be those three fields delimited by a comma. Now this CSV output is the input for Afterglow. Well, putting it all together, you basically cat the log file, PF to CSV, give the fields you want, pipe that into Afterglow with a property file, and then pipe it into GraphVis. And there are basically four tools that GraphVis provides that use different layout algorithms. One is DOT, which uses hierarchical layout. And you will see that in a second in the first example I have. Then there is NITO, which does a organic layouting. So it tries to place the nodes optimal so there are not too many overlaps and similar things fall together. Sometimes, in a few cases, that doesn't work out too well. And there are two others. There's CIRCO, which uses a circular approach. It basically starts by putting all the nodes into the middle. And then there is apparently too much overlap there. So it starts to just move some of the nodes out and out. So it does concentric circles until it finds a layout where the nodes are placed in a decent distance to each other. And then there is 2PI, which uses some other weird algorithm to place things. So if you get stuck with the others, you can try 2PI and see what comes out of there. All right. So let's take the first use case we want to go after here. I want to look at all the traffic that got passed coming into my network. So what I do is I somehow grab all the passes in my log file. And don't do this literally. I just use this placeholder pass in. It really depends on how you filter for that in your log file. What I did in my log file is I grabbed everything that is coming in on my outer interface, which I think was XL1 or something. Then you pipe it into PFCSV. I get my source IP, destination IP, and destination port. And then I go into Afterglow, give it a properties file. I use minus D because I want to see the counts on the nodes. How many times did these things show up? If something showed up just once, I might just close my eyes and not think about it. And then I pipe it into dot. That's the hierarchical layouting. And that basically looks like this. So you have a node on top called external, which is already kind of strange because there is no external IP address or an IP address that's called external in my log file. So we'll figure out how we do that. And then you see all the machines in my network that were accessed. And then the bottom circles are the target ports or destination ports that you connected to. So how do we get the colors and the clustering? Well, use a few features to make this not too complicated. So the first thing we want to do is the clustering. So what I do is say the cluster.source, so all my source addresses, because I'm assuming the sources are in the Internet. That's what I'm looking for, everything that comes into my network. So the source is external. That's the cluster name that I want to give it. If it doesn't match my internal IP range. And match is a function that Afterglow provides you. And it basically, I told you before that there's this add fields array that it basically keeps track of the entries in the log file for the current entry that it looks at. The match just looks at all three of them and makes sure that, none of them matches. And if I mean source, it only looks at the first one. If I just said cluster, it would look at all three of them. So it always uses the one where it's evaluating currently. So this is a very simple way of clustering all my external nodes. Then I say, well, I want to have this thing read. So basically, if the field is external. I could also use matches here if I use external as a regex basically. But I chose to use field, which is another function that I have. That just returns the current field it looks at. And then you can compare that to something. Then the event, so that's the dark blue nodes there. I want to have them blue if they match my internal address range. I hope that all my nodes are going to be blue now. However, you see there are a couple of light blue ones in the bottom left. So I just, what I did there is, I say everything else that's not blue is light blue. And that's actually kind of interesting. Why do I have the light blue ones on the bottom left? Well, if you look a little closer, you see that my machines were connecting out to those guys in the internet. And they're using port 20. And that's an artifact of FTP because the way PF2CSV parses my file, it doesn't know that there is a back connection out from FTP. So that still stays in there. But it's kind of nice to see that. So I know that two machines in my network were actually FTPing back to me. So I don't have to go back out or sending traffic data out to the internet. And everything else is just red. And what I see in this graph now, if I look a little closer, I see all kinds of different ports. I see port 25. Yeah, I have a mail server. I have port 22. Yes, I do SSH administration on there. I have some echo requests. Well, hopefully that was me pinging those machines and no one else. I have FTP. I have web. I have HTTPS. I have some DNS. And then I have port 100. And it's actually a log file of mine. And I had that lying around for like two years. And I visualized it. And I'm like, what is port 100? And it showed up only 21 times. And I remembered, yes, that was my backdoor SSH access whenever I updated SSH on port 22. And I didn't quite know how to do that back then. If I bounced it, I always locked myself out. So I just had another SSH on port 100. So I could connect in there, bounce the one on 22, update it, and whatever. So I remembered it was all OK. So I was good. All right. So the next use case is a very simple one. I want to see everything that goes out of my network. And here, again, I'm using very loose syntax. You don't see the PF to CSV up there in the command. So if you run this literally, it won't work. But just instead of the graph pass out, plug your PF to CSV in there and the things you want to do. So basically, I look at all the things that are going out. And this is the graph that shows up. You can't read the node labels, I know. In the middle, it's an external node again. And everything connects to it. Those four machines or three machines, no, four of mine, the light blue ones, the circles that you see, they all connect out. And you see the red ones are all the target ports. I don't see much of concern in here. There is a lot of web traffic. There's some echo replies. So maybe I could actually filter that because I have people pinging me. So I might want to restrict them from knowing that my machines are up. I have some DNS traffic going out. And a little bit of the traffic is 123 NTP. That's probably okay if I'm syncing out with some external source. What I might want to do is verify what the target addresses of those NTP connections were, whether they were really NTP servers I configured and not some other machines. And someone is trying to tunnel something or so. Well, the next thing I want to try here is I want to look at all the traffic that gets blocked going outbound. And remember, this is either a misconfiguration of my internal machine or the ACL is misconfigured because there is a service that is needed by internal machines and it's not allowed. What comes up is this really nice cluster of nodes. What happened? There's a lot of target ports that are being blocked. So does that mean all my machines are misconfigured or the ACL is wrong? Probably not. Let's think about this. We have a client and a server. Simplified. I have some machines in my network which are the servers. The client is probably on the Internet. I have my firewall with two interfaces. If I have a connection, again, this request-response thing. And this is going to screw you up all the time. So always think about this when you have, if you've got a graph like this, whether there is something wrong. So what happened here is when I built my firewall rule set, I was not very consistent on what interface I'm logging. And I logged on the responses going outside. So not just did I not only log on the requests, I also started logging on different interfaces. So always think about, already when you set up your firewall, what do you log? Do you just log requests or responses as well? And on what interface do you log them? And it also depends on where you want to have your ACLs, on the internal interface or the external interface. A lot of firewalls don't give you that option. But especially if you start playing with IP tables or PF or anything else like more hand-woven firewalls, you will run into this problem. So think about it before you do it. So this is the reason why we have this huge cluster of nodes here. So what I did is I basically extended my PF to CSV. And unlike the TCP dump parser, I didn't want it to take care of the swapping right away and kind of transparently to me. But what I wanted is I just wanted to see, it should just tell me if it thinks that it should be switched. So if I say reversed as a parameter to PF to CSV, it will write an R in the last column. And it was really late in the night when I coded this. And I haven't changed it yet, so bear with me. All right. If it's reversed, if it thinks it should be reversed, it just writes an R in the last column. So if I do a grep minus V of an R in the end, I won't see all those responses. So if I filter out all the responses, and you could use any other method of getting rid of your responses in the log files. It's just one way to do it. Then I end up with a more sane graph here. It's still a lot of target ports if you think about it. Everything that's blocked going out, there really shouldn't be anything. But there are some artifacts, like very high port numbers, where the heuristic to actually determine whether it was reversed probably didn't kick in. It didn't have enough state to figure that out. You could probably go ahead and improve that heuristic. But I was kind of satisfied with the graph I got here. I can read this and kind of filter them manually. But there are some other interesting ports. One is 427, a service location. And what this told me is that I had four Macs standing in my network. And they're using, I'm not a Mac person, so I'm not quite sure what this service actually does. But it's some kind of an automatic setup service broadcasting, and it advertises itself to the network saying, hey, I have these services, I'm here. So this concerned me a little bit. And they actually showed up like 16,000 times in my log file. It's probably more than, that's probably almost all the blocked traffic that I had. If you had to go through a log file, this log file manually or textually, you would have seen about 16,000 of these guys. And somewhere intermingled, you probably would have gotten tired finding those other ones, the other ports that were blocked. So this helped a whole lot to actually find this, and hopefully none of this traffic was actually leaving the network and it was all blocked. All right, now we're looking at the blocked incoming traffic. Yes, it's going to be way messy. So I'm not even going to show you the graph that was computed by this. I decided to still tackle the problem and kind of figure out what is in the data center and what is in the data that actually tries to hit me. And one of the things is, it's always the low-hanging fruit, find your port scans. You can do it a thousand ways. I'm just going to show you how to do it here. So basically, I'm using the minus G capability. So remember, that was the fan-out filtering. And G looks at the event node, so the middle node. And if I say minus G2, that means everything that has a fan-out of 3 or higher or not 2 or 1, I don't want to see. All the ones of 3 or higher, I want to see. And everything that has more than 2 ports that we're connected to, I want to show them. So if someone would port scan me, I would see that because they hope the port scan is more than 2 ports or whatever threshold is set. It's actually very interesting what shows up on the right side in the graph. I didn't have a port scan, so I don't see any fan where things are hitting me. I have 3 nodes at most there, and there were people probably just trying to get to some well-known ports of mine, very specific targeting, port 80, 22, 443. And it's only about 3 or 4 attackers that really did this. So the kind of yellowish nodes that you see. So that's actually kind of interesting. And the data set was probably a couple of days in a very, very busy web server farm. So this is pretty good. How do you configure this? And actually, I cheated a little bit. If I look at port scans, I'm not necessarily interested in the things that hit me on ports above 1,024 because I usually don't have anything running there anyway. No services are up there. Maybe there is some Oracle running on 1521 or some other SQL server, and you might want to include those as an exception here. I didn't do so because I didn't have any. But what I wanted to do is I clustered my target node, the ports, and I wanted to make a cluster for all the ports bigger than 30,000. So it's basically say the node should be bigger 30,000, just that string, if the third column is more than 30,000. And then, so that's taking care of all the ports higher than 30,000. And then I say, well, everything else, if it's bigger than 1,024, I want to cluster it again. And then the rest I'll leave alone. I want to see those individual ones. And again, I used the minus G, and this basically gave me the graph on the right. This is kind of how you can find port scans. The same you can do with tree maps by basically what I did here is I set up the hierarchy as source IP, destination IP, destination port. So you will see a big rectangle for the source IP, and inside you will see all different destinations that that source went to. And inside of that, you'll see the different destination ports that were accessed. We can see the port scan. Exactly. It's very easy to find. There's just a lot of nodes there. And what you can do is you can actually zoom in, and now I just see this one source IP going to this destination IP, and I see all the destination ports. What is kind of interesting is there are all these random port numbers on the right side, and then on the left, about 50% of the traffic hit a port 6346. I think that's some kind of file number. It's file sharing. So someone really hit me hard on that port and didn't get in. Something else I usually do is I want to see whether there are any IP addresses that are spoofed or abused. And there is a bogon address space, basically all the IP addresses that are not assigned to anyone by IANA. So no one should be using them. No one has really allocated that space. That's published on the IANA web page. So make sure if you do this, you update your configuration. But I want to see all the connections coming from those IP addresses to my network because no one should be using those. So again, I just grabbed the blocks incoming. And I warn you right now, this config is going to be crazy. If you thought that it was complicated before, it's going to hit you. So what do you do in a configuration file? First, I need to let Afterglow know what is the bogon address space. So there is a command called variable. And then you just provide any Perl expression you want, any Perl command, and we'll just evaluate it. And if you assign, what I did here is I built my array ranges with all the stop nets that are in the bogon address space. You could put anything in there, any Perl code. It would evaluate it. It would assign the variables and keep them. And you can use them in further assignments and do all kinds of things. So I'm just defining a variable here or an array. Then for my color assignment, it gets a little complicated. So basically what I want to do is every value I get, I want to check every IP address. I want to check against the array and see whether it's in any of those subnets specified. And you basically start with, the subnet assignment here. So you check if the field is in the subnet that we are looking at right now. So it basically runs through all the entries in the array. And the array range is up here. So it goes through all these entries and checks whether the field that I'm looking at right now is in this subnet. If yes, it just returns one. And I'm basically counting in dollar value how many times and how many of those it was. It's always going to be one. My definition there is mutually exclusive of the individual entries. Anyways, so what it does then, it just says it's going to be read, the node, if it actually found it. So if value is set. So if you don't quite follow how this map thing works, just copy it and use it for your own things. And then what I want to do is I want to have everything else green. If it's not in my, or everything else that is in my internal array, my internal network is green. So I provide the match on my internal address space. And everything else is blue. We'll see in a second how that looks. But we're not quite done yet. Because what is going to happen with this graph, you'll see a lot, a lot, a lot of source IP addresses that connected. There's going to be a million individual nodes. So you won't be able to find those red ones that we just defined. So what we need to do is some clustering. This looks horribly complicated. But that's just because I was a little anal on what I want to see here. Basically, what I want to do is I want to cluster by class A network. I don't want to see each individual address. I just want to see what class A is connected to my network. That's basically what I do here with this regex replace. What you can do is it's a function I provide for Afterglow. And what it does, it just matches the regular expression I give there, the backslash, backslash, D plus. If that matches, so if it has a number, if it starts with a number, then it returns that number because I do a match there. So it will return the first octet and add the string slash eight. So I see that it is an eight class that I clustered. If it does not match my internal addresses, because I want to see if there's actually a source that's my internal address, and if it's not one of the bogan address spaces because I don't want to cluster those together. I want to see exactly what IP address hit me and not just, oh, it was in this class A. You follow me? It's early, I know. All right, and I do the same thing for my targets. Just for your own reference, these are the new features we just introduced. And this is how it looks. It's actually quite sane. So you will see the bogan address space is the red ones. Then you have the regular external addresses clustered by A class. You have my internal machines, the blue ones. Suddenly, it's actually interesting, suddenly there are more than my four machines from before. It's actually kind of funny. I didn't realize that earlier. But the interesting part is the red nodes, I had a lot of bogan address space. And this is real, I didn't make this up. But if you look, there are 10 addresses. There are 192, 168 addresses. There are some multicast addresses. But still, this was in a hosting environment, in a data center. And why would there be other things leaking over to my network from 192 spaces and 10 spaces? So maybe some other people that were hosting there were trying to play tricks and try to see what they can do. Spoofing IP addresses are just like leaking over to my connections. All right, I'm actually right on time. Before I give you the summary, I have one thing that I keep doing with Afterglow, which is kind of interesting. I basically run a Unix command on my box. It's just a while loop. And you'll find the command on, if you go to afterglow.sourceforge.net in the FAQ, I have a little command line. So basically what I want to do is I want to show the network traffic in my screen saver. It's kind of cool if people walk by your desk and they see the traffic that's on your box. Some people might start playing with you and sending you traffic so they show up in the notes. So don't encourage them. So basically what you do is you run a while loop, continuous, just never stop. Run tcpdump. Pipe it. The output into tcp to csv. Get the fields you want. And then just do like head minus 1,000 or something. So every 1,000 packets will actually continue. Then pipe that into Afterglow, into neato. And the output file that I usually write in neato is just a file with the date in there. Just add the date as a parameter to the file name. And then it will just write every 1,000 packets it will write a file. And then you can have a cleanup script that kills the ones that are older or just keep two around or something. Configure your screen saver to pick up the pictures from that directory and just slideshow them. And it's really cool. I like it. All right, so let's go to summary. We looked at Afterglow. You can do filtering. You can do coloring. You can do clustering if you get brave. And why would we do all that? Well, I hope I was able to show you some use cases where I was able to find my port 100 that I connected to or if you find the BOGO and address space. You find outliers. You find relationships among things. Who is talking on the network? And I know people in here that use Afterglow to find people that are connecting from countries of concern, things of that nature. Suspicious activity, basically. All right, so don't read log files. Visualize them. Thank you. I think I have time for a couple questions if anyone. Yes? Did you ever try clustering by country? Did I try cluster by country? Yes. Basically, what you can do is there is a mapping that's published that maps IP addresses to countries. So just block that in somewhere. Exchange your IP addresses by country. And automatically, you will have them clustered by country. Yes? Is there a reason why you can't use this with proxy logs as well? No, not at all. So I just gave you one example, firewall logs. I actually, yesterday, sitting in one of the sessions and sorry, I was a little bored. I was basically running Kismet and I quickly used an aux script to pick out the access points that are there, the machines connecting, and I visualized that quickly. So I see that all these machines go to this access point and suddenly you see this machine goes to the other access point. There's really cool things you can do. One quick question. Do you have any competition? I mean, who's second in IT? Do I have any competition? Lots. There are a few people. Greg Conti does some visualization with Ramint. There's a lot of university work that's done in visualization. There's a lot of organization of network traffic. I'm not sure if anyone has a very simple method of visualizing just open source. If you have any, let me know. Have you extended this to look at the amount of data that's going out in the direction of ? Have I extended this to look at the amount of traffic, things like amount of bandwidth and so on? So basically what you have to do, you have to do that yourself. So I kind of offload that work to you because I just visualize your CSVs, right? So you just write some kind of an aggregator that aggregates all the traffic. Use awk and do sums in there. It's not too complicated. Oh. All right, so questions, please go to the mic so they're recorded. Thank you. Can you weight the size of the nodes by the number of packets from them? Can I weigh them? Can you make them larger if there's a lot more traffic? Oh, can I make it larger? I didn't put that in. It shouldn't be too complicated to extend afterglow if you want to do that. It would take me a little bit of coding. Download it and extend it if you want. I might do it. That's actually a good idea. Thanks. How about parsing server logs? Parsing server, any kind of server logs? Yeah, any kind. Sure. You can, for example, Linux, you use syslog. It's a pain to write your parser because every line is different. Every entry has a different format. But you can visualize logins, for example. You just pick all your SSH messages or all your login messages. Pick the source address. Where did it come from? If it's locked, it's not always the case in server logs. Lock the username that's going to come in. You can do all kinds of things, really. This is giving you the toolbox to go off and do your own visualization of your logs. And please send me use cases if you have them. I'm collecting them. Server logs are very interesting in cases where you're not trying to go after the perimeter thread. Where things are coming out from the outside. But if you're looking more from insider problems, so people that are logging into machines that might not be allowed to, who accessed machines for, if you're doing compliance reporting or something, who got into my financial servers, what networks did they come from, things of that nature. Anyone else? Are you trying to make it real time? Great question. I was trying, yes. The real time problem is, that's kind of why I started to switch over to that library I'm using for Java. Because I wanted to have more control. The way I set up Afterglow right now is that it basically takes the log file, the CSV file and generates one graph. So I kind of lose state. The problem is, I mean, you can do what I told you about the TCP dump, the while loop, and then just get one picture after the other. The problem with that is, every picture you calculate is going to rearrange all the nodes because of the layouting. So what you have to do is you have to remember, you kind of do a sliding window, you remember the current layout, you feed that into the next layout, and you just add the new ones and then drop off things over time to get rid of them. It's not as easy as it sounds. Or maybe it already sounds complicated. But I was trying for a little bit. I just don't have the time to do it right now. But there are, I think, Dan Kaminski with Xovi does something of that nature. He tries to animate it. You can try to download that. It's slightly different what he does there. Okay. Thank you. All right. I think... What kind of limitations do you have on log file sizes? Your box. Okay. And Afterglow's memory.