Welcome to the annual DEF CON convention. This meeting was held in exciting Las Vegas, Nevada from July 9th through the 11th, 1999. This is video tape number 24, Introduction to Scanning. How's everyone doing? I'm Modify. I'm a part of attrition.org staff. I'm going to be doing Intro to Scanners, basically showing NMAP and the flags and what shows up in the logs. So I'm going to start off. A scanner is a program that detects weakness in remote or local computer systems. Scanners attack TCP IP ports and servers and record the response. This is a program that detects weakness in remote or local computer systems. It records the response from the target host. Hosts, however, attacker must know how to interpret these scans. They're not going to show you what's vulnerable. They're not going to tell you what kind of exploit to use. Ports are monitor by the iNETd daemon, which is started at boot time. iNETd reads the ETSI iNETd comp file at boot time to determine which network services it is supposed to manage. These are all the services. You can comment them out and they won't be started at boot time by putting a pound sign before them. In simple terms, Port Scanners probe a host and attempt to establish connection. Whenever you develop a port, one after another. This provides a roadmap of available services on a certain computer and can be used to launch an attack against a system. We're going to be showing Nmap, which is found at www.insecure.org. This system is running Slackware 3.5 with kernel 2.0.34. As you can see, port scanning is a very popular reconnaissance tool amongst hackers. Some of the other scanning techniques I'd like to mention is RPC info and show mount. This shows the RPC services that are running on a host. As you can see, right off the bat, NFS. The other is show mount. This shows a list of exported file directories. And who can mount them. If we did have an export list, it would be showing what the directories and who owns, who's allowed to. And when it shows it, if they show like a root directory and sometimes you'll see anonymous. You can mount that by doing a mount-t nfs target-host colon whatever directory. Space slash mount. You cd into mount and you have controlled the system. From there, you can probably grab the password file and crack it or add your own entry. We're going to go into some of the flags of Nmap. You can learn more about Nmap by doing man nmap or nmap and type it to more. It gives you all the flags and what each one is associated to it. Some of the flags are nmap-st hostname is a TCP scan. It's not very stealthy. It shows up a lot in the logs. And I'll demo that right now. It gives you the port, the state, which all of them are open, the protocol, TCP, and the service. It gets the services just by adding those to the right. It gets the services by looking at Etsy services. But there's also an nmap file called nmap-services. What it does is it scans the ports and then matches those to its file. And all those have like a database of all the services, the ports. We'll run it again and take a look at the logs. As you can see, it's telling you what port it's connecting to, what service is running. And it also has the identification of who's doing the port scanning and where it's coming from. The next flag is an nmap. An nmap minus S, capital S, local host or target. What this is is it's a TCP SYN scan. This technique is often referred to as a half-open scan because you don't open a full TCP connection. In other words, you don't do three-way handshaking. It waits for SYN ACK from destination. If SYN ACK is received, then the port is open. If it's not, it's obviously closed. If reset is received, the port is closed. Rather than the ACK is established connection, it immediately resets to close the connection. This is scanning the same port. There's no ports here. But if we look into the logs, we get connection from unknown. It can't determine who's port scanning. The next flag is a stealth SYN. That's minus S, capital F. A SYN scan uses a bare SYN packet as the probe. Used when SYN scanning is not stealthy enough. Some programs watch for SYN packets such as SYNlogger and Courtney, just to name a few. We'll show that one. Yes, sir. It's been planned. I was going to put on some BGs, but... This is the stealth scan. Most... By the way, I don't have any extended logging on this machine, such as Abacus Sentry, or anything like that. But the conventional bar log messages, the scanner won't show up. The next one's a Christmas scan. Christmas scan turns on the fin, urge, and push flags. That's done by a minus S, capital X. Yes, you don't get anything coming up in your bar log messages. And the next one's a null scan. Null scan turns off all flags. Why Christmas? Uh, don't know. That's only Christmas. Oh, yeah. I actually wrote that. Oh. This is, uh, Fyodor. Fyodor. Uh, he wrote, uh, MNAP, actually. Uh... I just like Christmas scan because, you know, you've got almost all the flags there. You know, kind of a Christmas packet type of deal. And you don't have the, uh... You don't have the same packet in there. But, uh, there you go. Yeah, but... It's almost a Christmas packet. All right. Sorry. I just said it was... You're almost sending, you know, the Christmas packets, Christmas tree, light segment, uh, packets where you have all the flags enabled. So, uh... So that's just why I called it that. Sorry. This has kind of been prompt. I thought it was a radio scanning seminar. Someone just said, Hey, dude, do you have MNAP in that room? I thought I'd stop by. Well, come on. Pull up a speaker. Okay. Uh... The next one, uh, I'm gonna show is, uh, the ping scanning. Uh, ping scanning is used to determine what hosts are on the network are up. Sends an ICMP echo request to every machine on the network. Hosts that respond are up. I don't have a network up here, so it's only seeing my local computer here. It's... It sees my, uh, one IP address, one host up. Scan in zero seconds. Uh, the next one is, uh, minus P-T, capital P-T. It's, uh, TCP ping to determine what hosts are up. Instead of sending the ICMP echo request packets like in the previous one and waiting for a response, we send out a TCP act packets throughout the target network. Uh... Quitter a single machine and then wait for responses to return. Hosts that are up should respond with a reset. To set the destination port, it's, uh... Uh... Nmap minus P-T and then whatever port you want, uh, to scan. Uh... The default port is A80. So we'll just leave it at A80. Those are from... From Barlog messages. Uh, the next scan is, uh, minus S-U. This is a UDP scan. This method is used to determine which UDP ports are open to... On a host. Sends a zero byte UDP packet to each port on the target machine. If we receive an ICMP port unreachable message, then the port is closed. Um... The UDP scan takes considerably longer because of, uh... Um... The kernel limitations for sending out ICMP error messages. Um... This is defined in RFC 1812, section 4.3.2.8. Yeah, it's beautiful. They ignore the RFC. That's why. Another thing. Send back an error response for every packet you send immediately. There's no radiation at all. It's beautiful. On Solaris, it takes, uh, considerably longer. Um... Linux is, I think, 80 messages. Or 80 per 4 seconds. And... Solaris is limited to about 2 messages per second. Um... Some of the, uh, UDP services you may find are, uh... Call to the dead cows, back orifice, trivial FTP, NFS, SNMP... Um... Uh... Uh... Uh... Uh... Uh... Uh... Uh... Uh... Uh... Uh... Uh... Uh... Uh... Uh... Uh... Uh... Uh... Uh... Uh... Uh... Uh... Sorry? Exactly, just put class 16 at the end of the IDR. All right. Thank you. Yeah, by default, if you don't specify any courses, exactly, one through 1,024, plus the ones in the services file that comes with NMAP, which is basically your normal SD-SAC services, plus the backwards and the other ones that you might want to keep a watch out for. You can add your own services if you want. It was created by basically taking a shitload of SD-SAC services and putting them together. But if you find new services that you think should be in there, you don't just drop an email, of course, you can add it to your own. And that's through the file. By default, it only uses the one that's included. As you can see, it took a considerable amount of time, but we had the port state and protocol and service for the UDP to scan. The next one is the FTP bounce. In older FTP servers, it would allow proxy connection. An example, a user could connect to an FTP server and send a file anywhere on the internet from that FTP server. This method uses the FTP proxy to bounce a TCP scan off the server to the victim. So basically, you're scanning from another host. And that's, I'll put up the syntax. And then you put up the FTP bounce host. And then the target. And that's how it's run. I don't have two machines connected, so I can't show it to you. The next one is, the minus capital O flag. This option activates remote host identification by TCP IP fingerprinting. It takes advantage of nuances found in each OS's TCP IP stack to determine what OS is running. Send specifically crafted packets to a host. This information is used to generate a fingerprint, which is then used to match from a database of known OS fingerprints. So it shows us all the ports that are available, and then we have TCP sequence prediction. It's truly random. It would be very difficult to hijack. Hijacking using trusted relationship exploitation. Remote operating system guess. Linux 2.0.32-34. And I am using .34, so that is accurate. It shows one IP address and scan in two seconds. The next one is... Login option. Login. Login. Login. Login. Login. Login. Login. Login. Login. They certainly can. I mean, if you have a proxy, sometimes even those transparent proxies are in between. Anything that rewrites the packet headers is going to screw you up because we rely on a bunch of real low-level details like the ordering they put TCP options and the time-to-lives that they use. And, you know, just a ton of those low-level flags. So if you have anything in between you and them, like a masquerading host or whatnot, that rewrites the packets, you're in trouble. You can still sometimes figure it out, but, you know, it's hard for Nmap to automatically figure it out. You have to kind of compare the fingerprints you get with the Nmap fingerprints file. There are a few cases where, you know, it can report... Okay, his question is if there's a network device between you and them. Like, a router shouldn't cause you any trouble at all, but mostly it's masquerading hosts or, you know, those IP transparent proxying like Linux has. Anything that rewrites the, you know, TCP or IP headers, has the potential to screw you up because it kind of pollutes it. Some of the aspects will then look like the host in between you and them. But it shouldn't generally cause extra ports to be shown. Okay, do I do that? Yes, it absolutely does. You know, it takes a little bit more effort, you know, in that you have to compare the fingerprints but if you see something like, hey, the TCP window size is 0x2297, you know, that gives you a good clue. Look in the Nmap fingerprints file and see what machines have used that TCP initial window size and you can often figure out both who's at the very end and what's sitting between you and that host. Yes? Can you go back to the computer market and say, like, where is this 17-minute area? I don't know. Yeah, there's actually going to be a presentation by Craig Rowland, I believe. I'm not sure at what time. Okay, at 6 p.m. And he's been working on the Abacus project which kind of helps you detect some sorts of scans. Of course, Nmap has a lot of, I don't know what he's shown you so far, but it has a lot of extra features in order to counterattack those machines. For example, you can spoof the IP address you use and you can also send decoys out. So they'll say, hey, it looks like 10 different IP addresses scanned me. You know, who was the person actually scanning? You can also sometimes trick Port Sentry into firewalling the wrong hosts, like if you have it on defensive mode. So you'll fake a port scan as coming from their main gateway. All of a sudden they say, oh, no, a port scan. You know, I'm going to drop their packets. But there goes their network connectivity. So you have to be very, very careful in deploying reactive capabilities because always remember the scans could be spoofed. Just because you logged a scan, it could be someone scanning you or it could be someone who wants you to think that someone's scanning you. So take everything in your logs with a grain of salt, of course. Yo. You know, there are various things that, you know, with the network that can in some cases cause it to fluctuate. You know, one of the biggest things is that people have, like I said, a masquerading gateway between them. So you're getting kind of pollution of one system in between. You can also have cases, where, hey, you know, if they specially configured it with a kernel parameter that changes, like Solaris has a parameter that'll change the TCP sequence predictability. We have that one covered in NMAP, but there are other examples where people can, you know, change their kernel parameters and make it look different. Generally, you should. But if you can find a host that doesn't always give you the same response, just send me mail, preferably with the IP address, if you can, and I'll, you know, see if I can address that. You know, sometimes some, like, Windows machines are really bad about this. You know, they're just not deterministic in a lot of ways. You know, you would think, if I send the same packet to them, I'll always get the same packet back, the same type of packet. But no, sometimes you'll get completely different flags set. You know, it's like, you know, maybe they have some uninitialized memory or whatnot, but I've seen some very bizarre characteristics where a Windows machine will look one way the first time, then you'll scan the same machine, you know, and it'll respond to the same packet differently. But yeah, there are some cases like that. I think so. Yeah, it definitely does. If it doesn't detect a host, like if in that example he just did, if it hadn't detected the host, it would've given a URL you can go and enter it in, and then I'll add it to the global database so that, you know, Nmap should be able to scan that sort of system. And we've already, we have hundreds of them in there, you know, from your normal Linux, you know, all the kernels, VBSD, OpenBSD, to really, really obscure shit, you know. They're special little printers, you know, all sorts of, you know, network cameras. You know, anything with an IP stack is fair game as far as I'm concerned. So send it in and I'll add it. . It's just hyping capital O. The last one I just did was a minus O and then a log file. to dc7.txt, and it just writes out to a file that I name. It's just like doing nmap minus lowercase s, uppercase s, localhost, and then direct it to a file with two greater than symbols. The next one's port ranges. You can actually set the port ranges you want to scan. And you get the listing of what the port ranges are. What services are running on those particular ports if they're open. The minus f is a fast scan. It only scans for services listed in etsy services file. I know it's not. I found it to be, you know, it does IO multiplexing through select and such, and I found that produces a significantly faster results because you don't have to waste kernel time scheduling all the threads when really all we need to do is multiplex the IO. They're actually automatically randomized. They're actually randomized. The next one is decoy scanning. He mentioned that. It causes a decoy scan to be performed which makes it appear the remote host, that the host you specify as decoys are scanning a target network too. The IDS might report five to ten port scans from unique IP addresses, but they won't know which ones are decoys and which one is the IP scanning them. The syntax for that is, well he's typing it in, let me just mention a couple quick things about decoys, a couple hints that people may find useful. One, a very popular and very excellent tool for detecting sin scans and such that I recommend is ScanLogD by Solar Designer. However, you know, you come into denial of service issues, you know, if you try and detect too many scans, I mean you don't want me to just give them, you know, 100,000 fake IPs and fill up your logs. So by default, and use all your memory space, so by default ScanLogD only logs the first five addresses that are scanned from. So I recommend always use at least five decoys and you can use ME as a parameter saying my IP in order, otherwise it randomizes, you know, which order is you and which is the decoys. You know, if you have six or seven of them and then you say capital M, capital E, you know, me, then ScanLogD will only log. The first five addresses and you'll generally be home free. Another quick decoy hint is, and this is probably obvious to most of you, but I've been amazed how many times I get people from, you know, Yahoo and Microsoft, you know, people don't use, you know, www.yahoo.com as your decoy. I mean, let's see, I got a scan from Microsoft.com, Yahoo.com, and dialup33.uu.net. You know, you ruined your decoy there. I've seen that a lot, you know. How did I get caught? I used five decoys. Well, you know, you got to have a clue. Same with hosts that aren't up, you know. They're just made up IP addresses. They don't even route and you wonder why they figured out, you know, who it was doing it. You know, you do have to show a little sense here. The last one is, that I'm going to mention, is minus G and that sets the source of the source port number used in the scan. Because many firewalls, you'll let through the DNS port or FTP data on port 20, so you can spoof a DNS packet and scan inside. That's minus G. And the target, and that's the syntax. Yeah, just a quick note. You know, that's more useful than it even looks. I mean, I'm sure none of you administrators do it, but you'd be amazed how many people just, oh, crap, we installed the new firewall and DNS isn't working. We got to let these DNS packets through. Oh, well, let's just, anything from source port 53 has got to be DNS, right? You know, just let it through. And, oh, shit, you know, FTP's not working because you can't make the FTP data connect. Well, a quick firewall rule. You know, so, you know, I've been completely flabbergasted by how often just adding hyphen G 53 for UDP scans or hyphen G 20 for TCP scans, you know, suddenly gets straight through. Right, that's a great tool. It's kind of on the lines as Firewalk. I don't know if any of you saw that by route. You can check that out at packet.com. But does anyone have any questions? Oh, yeah, let's kick ass. A guy, let's see, what's his name? Yeah, it comes with an X version for people who like GUIs. A guy wrote it. Fuck. Forgot his name right offhand. But anyway, it's a great tool. It's a great tool. It's a great tool. It's a great tool. It's called NmapFE. If you go to the web page, it has links to it. Yeah, if you're into that, it uses GTK, and it's a real pretty interface, and it allows you to point and click. Because some people bitch at me saying, hey, you know, there's like 28 options, and I have to read the man page every time I use it. So here you can just, you know, they're intuitively placed, and you can click your buttons and such. You know, to check that out. The last thing I want to mention is really try to attend Craig Rowan. Speak. Speech. The Abacus Sentry IDS is really nice. It'll detect port scans and dump them in your host.denial file, so they can't even reach you. It's really nice. But does anyone have any questions? You said 6, right? You said 18? Oh, yeah. 1800 hours, 6 o'clock. In the back. Oh, you're talking about like a time-based attack, like slow? So that. One thing that would be useful in that respect is like a really slow scan, you know, that take a week or two, and, you know, scan port by port, so you stay under the thresholds. You know, there's also distributed scans, you know, scan from six machines and coordinate the results. Personally, though, my technique, you know, I don't have a lot of experience with port scans, but I do have a lot of experience with port scans, which is distribute widely available, easy-to-use tools to do this, so that all the script kiddies, that way they don't see anything abnormal. They'll say, huh, this looks like the 20 other scans, you know, that are in my log from today. You know, so since these tools are so widely available, it allows, people are less concerned about seeing a port scan. You know, they see it every day. It's kind of like a trace route. And also, you can use the decoys. It's very difficult, you know, to trace that back if they see 10 or 20 different IP addresses doing the scanning, as long as you've chosen the decoys well, of course. So I am probably going to add the slow scan, but I haven't yet, just because I'm not very patient, and I don't want to wait a week for my scan results. I think we're going to wrap it up now. CDC. He's about to start with VO2K. If you need to email either one of us, modify at attrition.org or theodore at insecure.org or dhp.com. Thanks a lot.