1 00:00:00,000 --> 00:00:01,040 Thank you. 2 00:00:05,080 --> 00:00:08,420 So, a machine being up for four minutes 3 00:00:08,420 --> 00:00:12,180 and already transferred four gigabytes of traffic. 4 00:00:12,400 --> 00:00:13,360 What could that be? 5 00:00:13,920 --> 00:00:15,980 Something screwed the network stack? 6 00:00:16,280 --> 00:00:18,020 Something strange with that machine? 7 00:00:18,320 --> 00:00:19,760 If you are on this machine, 8 00:00:19,960 --> 00:00:22,280 and it perhaps is not your own machine, 9 00:00:22,560 --> 00:00:26,020 you really, really should get suspicious at this point. 10 00:00:26,120 --> 00:00:27,660 That might be a honeypot. 11 00:00:27,660 --> 00:00:31,500 We show you how you find out and what to do about that. 12 00:00:36,880 --> 00:00:39,660 So, who of you knows what a honeypot is? 13 00:00:39,880 --> 00:00:41,040 Just for... 14 00:00:41,920 --> 00:00:45,000 Okay, so nearly everybody knows what a honeypot is, 15 00:00:45,100 --> 00:00:47,420 so I can do a very quick introduction. 16 00:00:48,140 --> 00:00:53,320 On this page, you see the typical setup of a generation two honeypot. 17 00:00:53,600 --> 00:00:57,440 A honeypot is, according to the definition by the HoneyNet org, 18 00:00:57,660 --> 00:01:03,180 a concept to monitor the tools, tactics, and motives of the placard community. 19 00:01:03,620 --> 00:01:07,920 So, basically, they want to see what you do once you've rooted one of their boxes, 20 00:01:08,200 --> 00:01:10,900 what tools you use, what commands you use, 21 00:01:11,000 --> 00:01:13,100 where do you connect, and what are your actions. 22 00:01:14,240 --> 00:01:16,980 As you can see, in the orange box, 23 00:01:17,160 --> 00:01:20,400 the HoneyNet typically consists of two main components. 24 00:01:21,040 --> 00:01:23,220 In the upper part, you see the HoneyWall. 25 00:01:23,760 --> 00:01:25,420 That's a transparent bridge. 26 00:01:25,620 --> 00:01:27,240 That means it has no upload. 27 00:01:27,660 --> 00:01:32,160 It doesn't decrypt the TTL over a bypassing packet. 28 00:01:32,440 --> 00:01:37,500 And, basically, you only do data capture and data control on this device. 29 00:01:38,180 --> 00:01:41,700 Data capture means that you run TCP dump on this box. 30 00:01:42,000 --> 00:01:46,480 So, you can log every packet, what's going inside and outside of your network. 31 00:01:47,580 --> 00:01:52,580 You also collect all data that your honeypots are producing on this box. 32 00:01:53,720 --> 00:01:57,000 On the other hand, the HoneyWall does data control. 33 00:01:57,660 --> 00:02:03,400 That means you install SnortInline, an intrusion prevention system on this system. 34 00:02:04,340 --> 00:02:07,240 SnortInline is a modification of Snort. 35 00:02:07,720 --> 00:02:12,500 So, basically, what it does, it filters all the outgoing traffic. 36 00:02:12,600 --> 00:02:17,240 It searches for exploits and can block them or it can modify them 37 00:02:17,240 --> 00:02:24,640 so that you, as you've owned one of these boxes, can't do any harm to an outgoing box. 38 00:02:24,880 --> 00:02:26,360 It's mainly used for... 39 00:02:27,660 --> 00:02:34,280 for legal actions so that you don't have to feel that someone who hoots one of those honeypots 40 00:02:34,280 --> 00:02:36,180 can do some damage to another side. 41 00:02:37,820 --> 00:02:42,420 The other data control that's done by the HoneyWall is something like a traffic limitation. 42 00:02:43,320 --> 00:02:50,440 So, for example, they do traffic shaping so that you've got only perhaps 10 kilobytes per second of output. 43 00:02:50,760 --> 00:02:53,760 Or they do some kind of traffic restriction. 44 00:02:54,080 --> 00:02:57,640 Basically, only 25 TCP connections per day, for example. 45 00:02:59,280 --> 00:03:04,740 So, apart from the HoneyWall, on the downside you see the honeypots. 46 00:03:04,900 --> 00:03:09,640 The honeypots are the main interesting part of the honeypot... of the main honeynet. 47 00:03:10,600 --> 00:03:16,100 A honeypot is basically a tool that should be probed, attacked, or compromised. 48 00:03:17,100 --> 00:03:25,960 So, you just install a normal system, for example, a Linux box, a Windows box, a Solaris, a BSD, whatever comes to mind. 49 00:03:26,200 --> 00:03:27,220 You do... 50 00:03:27,660 --> 00:03:30,100 You do not very much change things on this box. 51 00:03:30,360 --> 00:03:35,240 Basically, you just add some logging capabilities, and then you install normal services. 52 00:03:35,760 --> 00:03:41,680 You connect those honeypots through the HoneyWall to the internet, and then you just watch what happens. 53 00:03:43,280 --> 00:03:47,040 In order to learn the tools, tactics, and motives of the packet community, 54 00:03:47,440 --> 00:03:51,300 you have to do something so that you can watch their actions. 55 00:03:51,880 --> 00:03:57,340 For example, the TCP dump is completely useless if the intruder uses something like... 56 00:03:57,660 --> 00:03:58,200 SSH connection. 57 00:03:58,540 --> 00:04:04,460 You only see, then, the encrypted traffic, and without the appropriate key, you can't decrypt anything. 58 00:04:04,980 --> 00:04:12,400 So, basically, you have to do other things to watch the attackers who own your honeypots. 59 00:04:13,920 --> 00:04:16,500 The main tool used nowadays is ZEBAC. 60 00:04:16,800 --> 00:04:17,440 Oops. 61 00:04:17,860 --> 00:04:23,800 ZEBAC has the capabilities to monitor all activities on the honeypot. 62 00:04:24,020 --> 00:04:26,940 So, basically, it claims that. 63 00:04:26,940 --> 00:04:28,680 It can lock everything. 64 00:04:29,040 --> 00:04:32,040 We'll show later in this talk that this claim isn't true. 65 00:04:33,460 --> 00:04:41,640 With the help of ZEBAC, the operator of the honeypot is able to control everything that you do on one of those boxes. 66 00:04:42,420 --> 00:04:46,860 If you do an SSH connection to the honeypot, he'll see everything you type. 67 00:04:47,180 --> 00:04:51,260 If you do something like a secure copy, he will notice everything. 68 00:04:51,760 --> 00:04:56,360 If you decrypt your burnt-out protected binary, 69 00:04:56,940 --> 00:05:01,260 he'll notice the password and can also decrypt your burnt-eye-included binary. 70 00:05:02,740 --> 00:05:03,700 How does he do it? 71 00:05:06,780 --> 00:05:08,760 Basically, ZEBAC is a kernel module. 72 00:05:09,540 --> 00:05:13,360 There are variants of ZEBAC for Linux. 73 00:05:13,640 --> 00:05:19,160 It's the main all-out-of-account implementation only for 2.4 kernels. 74 00:05:19,380 --> 00:05:22,780 Then there's also an implementation for OpenBSD. 75 00:05:22,940 --> 00:05:26,080 For Windows, it's only a Ruby 1.0 implementation. 76 00:05:26,940 --> 00:05:32,140 We've got also for Solaris or some other operating systems implementations of ZEBAC. 77 00:05:32,540 --> 00:05:39,140 In this talk, we'll mainly cover ZEBAC for Linux because Linux is the main honeypot used nowadays. 78 00:05:40,800 --> 00:05:42,660 So, how does ZEBAC work? 79 00:05:43,140 --> 00:05:46,040 In the first version, ZEBAC was based on a DAW. 80 00:05:46,200 --> 00:05:49,680 A DAW is, perhaps, everyone here knows what a DAW is. 81 00:05:49,920 --> 00:05:52,020 It's one of the most known rootkits nowadays. 82 00:05:53,460 --> 00:05:56,920 In the current version, version 2.1.2, 83 00:05:56,940 --> 00:06:04,100 everything is re-implemented and ZEBAC is a complete new system. 84 00:06:04,520 --> 00:06:08,180 What it basically does is it hijacks the system call sysread. 85 00:06:08,360 --> 00:06:13,680 So, every time one of your programs or any program calls read, 86 00:06:13,940 --> 00:06:17,140 then ZEBAC does the following. 87 00:06:17,740 --> 00:06:22,540 It passes the data to the original system call. 88 00:06:22,920 --> 00:06:25,380 The result is copied into another buffer. 89 00:06:25,380 --> 00:06:28,940 To the buffer is added something like a ZEBAC header. 90 00:06:29,400 --> 00:06:32,540 Then everything is copied into an SKBuffer structure. 91 00:06:32,940 --> 00:06:37,540 The structure is copied or handled to the driver. 92 00:06:37,800 --> 00:06:40,720 And the driver sends everything to the outside. 93 00:06:41,620 --> 00:06:44,280 The sending is done in a covered way. 94 00:06:45,120 --> 00:06:47,240 Because you use the SKBuffer structure, 95 00:06:48,320 --> 00:06:54,260 all the PK-based firewall rules won't notice that anything is going wrong. 96 00:06:54,260 --> 00:06:56,760 So, if ZEBAC is running on the box, 97 00:06:56,880 --> 00:06:58,700 and you fire up TCP dump, 98 00:06:58,940 --> 00:07:02,260 none of these ZEBAC packets will e-notice one of them. 99 00:07:03,220 --> 00:07:08,120 It basically modifies prognet death in order to hide its presence. 100 00:07:08,340 --> 00:07:09,540 It fidgets with the counters. 101 00:07:09,880 --> 00:07:14,780 And so, you can't see that ZEBAC is sending anything to another box. 102 00:07:16,420 --> 00:07:20,400 The packages that are hidden are identified by a magic number. 103 00:07:20,720 --> 00:07:22,340 That's a 30-bit value. 104 00:07:22,340 --> 00:07:26,900 They are identified by being UDP-tagged. 105 00:07:27,060 --> 00:07:31,320 And a special port number for UDP, basically. 106 00:07:32,380 --> 00:07:34,360 In order to hide ZEBAC, 107 00:07:34,440 --> 00:07:36,520 or the presence of ZEBAC on the host, 108 00:07:36,680 --> 00:07:39,080 there are some things that are currently done. 109 00:07:39,580 --> 00:07:42,320 For example, ZEBAC loads as a kernel module. 110 00:07:43,140 --> 00:07:45,420 And in the basic installation, 111 00:07:45,660 --> 00:07:47,940 it has just got one random name 112 00:07:47,940 --> 00:07:52,000 consisting only of some numerical values. 113 00:07:53,260 --> 00:07:55,240 After once, the second module is loaded. 114 00:07:55,520 --> 00:07:56,740 It's Cleaner.o. 115 00:07:57,540 --> 00:07:59,740 That's also part of the Adore rootkit. 116 00:08:01,000 --> 00:08:04,460 Cleaner.o has basically only one function. 117 00:08:04,620 --> 00:08:07,700 It unlocks the next module in the module structure list. 118 00:08:08,100 --> 00:08:09,840 And then unloads itself. 119 00:08:10,060 --> 00:08:12,520 So, basically, after Cleaner.o is loaded, 120 00:08:13,080 --> 00:08:15,880 ZEBAC is unloaded from the module list. 121 00:08:15,960 --> 00:08:21,340 And so, something like lsmod won't see that there's any other package showing up. 122 00:08:23,280 --> 00:08:23,760 Whoops. 123 00:08:24,560 --> 00:08:27,300 So, now we are going to demonstrate our toolkit 124 00:08:27,300 --> 00:08:29,960 to give you a first impression on what we did. 125 00:08:30,160 --> 00:08:33,000 And then, after a step-by-step, we will install 126 00:08:33,000 --> 00:08:35,580 and we will show you how everything works. 127 00:08:37,780 --> 00:08:41,540 So, we have the honeypot run by an evil entity. 128 00:08:41,920 --> 00:08:44,820 In this case, Thorsten is running it on his notebook. 129 00:08:45,860 --> 00:08:49,780 We have a logging server run by an evil entity, too, 130 00:08:49,860 --> 00:08:52,240 which, in this case, I'm on my notebook. 131 00:08:52,340 --> 00:08:54,100 And we have the attacker's machine, 132 00:08:54,320 --> 00:08:55,760 which is run by a good hero. 133 00:08:55,960 --> 00:08:58,000 In this case, me, my notebook. 134 00:08:59,820 --> 00:09:02,080 I'm now logged in on the honeypot. 135 00:09:02,600 --> 00:09:04,620 And for demonstration purposes, 136 00:09:05,020 --> 00:09:08,100 I'll start a web server there, which is badly vulnerable. 137 00:09:22,880 --> 00:09:25,040 So, this web server, 138 00:09:27,080 --> 00:09:30,820 basically, you can upload a binary and it executes it 139 00:09:30,820 --> 00:09:36,180 if you use the secret post parameter exploit. 140 00:09:38,120 --> 00:09:39,440 This is in simple vulnerability. 141 00:09:39,660 --> 00:09:42,080 You could go for more difficult ones, 142 00:09:42,160 --> 00:09:43,780 but for the demonstration purposes, 143 00:09:43,900 --> 00:09:45,740 we have this very vulnerable web server. 144 00:09:47,140 --> 00:09:47,460 . 145 00:09:48,120 --> 00:09:48,760 . 146 00:09:50,660 --> 00:09:51,300 . 147 00:09:51,300 --> 00:09:53,720 Now, I work on my own machine. 148 00:09:56,080 --> 00:10:00,640 First, because this machine has to act as the logging server, 149 00:10:00,940 --> 00:10:04,980 I have the window getting the logging packets 150 00:10:04,980 --> 00:10:06,360 sent by the honeypot. 151 00:10:09,040 --> 00:10:10,240 This is this one. 152 00:10:11,460 --> 00:10:14,740 Thorsten will now type something on the honeypot. 153 00:10:15,840 --> 00:10:19,560 And, as you can see, we have basically keystroke logging here. 154 00:10:25,220 --> 00:10:32,200 Okay, now I'll start an attack on the honeypot by uploading a binary to the vulnerable server. 155 00:10:39,380 --> 00:10:47,960 This binary is built on demand and basically contains our attack tool, which was uploaded 156 00:10:47,960 --> 00:10:50,740 via a call to the server now. 157 00:10:57,640 --> 00:11:00,940 And now we are connected already to our attack server. 158 00:11:01,240 --> 00:11:10,400 As you might have seen, there did some logging taking place because the uploaded tool was 159 00:11:10,400 --> 00:11:16,720 basically a SHA archive extracting itself and executing the attack server, which is 160 00:11:16,720 --> 00:11:17,600 written in Python. 161 00:11:18,380 --> 00:11:22,960 Basically, if you're willing to code C or do something else dirty, you could get around 162 00:11:22,960 --> 00:11:23,260 that. 163 00:11:23,640 --> 00:11:29,040 I'm now connected with the server, with our attack server called Keebess, and can execute 164 00:11:29,040 --> 00:11:33,800 arbitrary commands, for example, listing the root directory of the honeypot. 165 00:11:34,200 --> 00:11:38,760 And as you see in the lower window, there's no further logging taking place. 166 00:11:40,380 --> 00:11:42,300 I can get information on the machine. 167 00:11:42,700 --> 00:11:47,580 You might notice that now I'm still running with the UID of the server. 168 00:11:47,580 --> 00:11:50,320 I can get information on the web server, nobody, 65534. 169 00:11:52,250 --> 00:11:57,560 I can read files on the server, as long as nobody can read them, for example, etcpassvd, 170 00:11:57,700 --> 00:12:00,000 without any logging still taking place. 171 00:12:01,020 --> 00:12:02,520 I can upload files. 172 00:12:05,500 --> 00:12:08,900 And I can execute files without any further logging. 173 00:12:09,060 --> 00:12:14,720 In this case, I'll execute a vulnerable suid script replaced on the server for demonstration 174 00:12:14,720 --> 00:12:15,360 purposes. 175 00:12:16,000 --> 00:12:17,560 And then again, we get a log. 176 00:12:17,560 --> 00:12:21,720 We get a little bit logging, because this, again, is written in Python, and we are too 177 00:12:21,720 --> 00:12:31,480 lazy to convert it to C. And now, wonder, we used the vulnerable suid already to execute 178 00:12:31,480 --> 00:12:34,460 a second Keebess server, now running as root. 179 00:12:34,700 --> 00:12:42,960 I'll demonstrate by connecting with a second client to the server, now running on a different 180 00:12:42,960 --> 00:12:43,400 port. 181 00:12:44,460 --> 00:12:47,540 And I, again, can execute all kinds of commands. 182 00:12:47,540 --> 00:12:49,020 There, without further logging. 183 00:12:49,220 --> 00:12:55,680 You might notice that now the effective user ID is zero, so this Keebess server is running 184 00:12:55,680 --> 00:12:56,140 as root. 185 00:12:56,500 --> 00:13:00,020 We can read files, now only readable by root, like shadow. 186 00:13:00,380 --> 00:13:02,560 It is a shadow without any logging. 187 00:13:03,040 --> 00:13:10,800 And we can send special commands, like the nosquare command, with just some logging, 188 00:13:10,880 --> 00:13:16,700 but basically we'll get warning messages because Keebess, because the ZBAC toolkit is completely 189 00:13:16,700 --> 00:13:20,500 out of his mind and gets too much data and can't log anything. 190 00:13:22,000 --> 00:13:27,400 And now we have the nice information of a cleanup routine, and we can jump there with 191 00:13:27,400 --> 00:13:29,000 a tool we uploaded before. 192 00:13:30,700 --> 00:13:37,460 And now we get some warnings because the GNU people are bigots, and there's no honeypot 193 00:13:37,460 --> 00:13:37,860 anymore. 194 00:13:39,840 --> 00:13:46,540 As you can see, I'm now, again, on the honeypot, and there's no logging taking place, no keys 195 00:13:46,540 --> 00:13:47,060 stroke logging. 196 00:13:47,280 --> 00:13:50,480 And if Thorsten works on the honeypot, no keystroke logging still. 197 00:13:50,780 --> 00:13:56,900 We have removed the ZBAC toolkit from the kernel with nearly no logging data. 198 00:14:01,500 --> 00:14:06,400 Okay, so much for the teaser, now for the background. 199 00:14:07,460 --> 00:14:09,500 Who are we and why do we do that? 200 00:14:09,720 --> 00:14:15,600 We are both from the Laboratory for Dependable Distributed Systems at Aachen University. 201 00:14:15,860 --> 00:14:16,520 We have been here for a long time. 202 00:14:16,520 --> 00:14:19,760 Thorsten is a research student, and I'm a research assistant. 203 00:14:20,380 --> 00:14:22,700 And this laboratory is running a honeynet. 204 00:14:23,640 --> 00:14:29,900 And we wanted to see if this is really a good thing, and if we can trust the data on there, 205 00:14:30,080 --> 00:14:33,180 and for the heck of it, if we can bring it down. 206 00:14:36,060 --> 00:14:42,480 The authors of ZBAC, just for information, this is not a picture of the author of ZBAC, 207 00:14:42,520 --> 00:14:44,700 which is a really nice guy, and a smart one, too. 208 00:14:44,760 --> 00:14:45,900 But that's ZBAC himself. 209 00:14:46,060 --> 00:14:46,500 This is a picture of ZBAC. 210 00:14:46,520 --> 00:14:55,180 At least the ancient Egyptians saw them, because it's an ancient Egyptian name, claiming that 211 00:14:55,180 --> 00:15:03,420 even if ZBAC is being disabled, one would be able to log how it is being disabled. 212 00:15:03,840 --> 00:15:10,480 And we had our issues with that assumption, and tried if we can attack it, and we were 213 00:15:10,480 --> 00:15:11,060 able to. 214 00:15:13,020 --> 00:15:13,620 Okay. 215 00:15:15,900 --> 00:15:16,500 Thank you. 216 00:15:17,860 --> 00:15:21,660 I think we did this demo already, with the vulnerable server. 217 00:15:23,200 --> 00:15:25,780 So now we come to detecting ZBAC. 218 00:15:26,780 --> 00:15:32,000 So, as you've seen in our demonstration, we are basically able to detect the presence 219 00:15:32,000 --> 00:15:33,180 of ZBAC on the hosts. 220 00:15:33,300 --> 00:15:40,060 We can avoid the complete logging, and we are also able to disable ZBAC once we are 221 00:15:40,060 --> 00:15:40,900 rooted on our box. 222 00:15:41,120 --> 00:15:45,200 So, basically, we are able to compromise the honeypot completely. 223 00:15:45,700 --> 00:15:46,500 We don't know how long this is going to take. 224 00:15:46,500 --> 00:15:49,680 So, now I'll give a step-by-step introduction to how we did it. 225 00:15:49,820 --> 00:15:54,140 And at first, we want to talk several ways to detect ZBAC. 226 00:15:54,740 --> 00:15:57,680 If you think about ZBAC, ZBAC is basically a rootkit. 227 00:15:57,840 --> 00:16:04,080 So, our results can also be extended to some kind of rootkit detection. 228 00:16:05,340 --> 00:16:11,860 If you think about this whole task, then there come several ways into mind. 229 00:16:12,160 --> 00:16:15,820 At first, as I've explained, there's the honey wall. 230 00:16:16,040 --> 00:16:16,480 And there's the honeypot. 231 00:16:16,500 --> 00:16:19,460 The honey wall is running in front of the complete honey net. 232 00:16:19,900 --> 00:16:24,920 And it does some kind of data logging and data restriction. 233 00:16:25,400 --> 00:16:29,180 So, basically, you could find some ways to detect the honey wall. 234 00:16:29,380 --> 00:16:34,220 And if you detect the honey wall, then this is a strong sign that there's also a host 235 00:16:34,220 --> 00:16:35,280 which is ZBAC running. 236 00:16:36,580 --> 00:16:39,280 Detecting the honey wall is left as an exercise for you. 237 00:16:39,380 --> 00:16:45,120 If you need some information on this, just look at one of the two FAQ issues. 238 00:16:46,000 --> 00:16:46,480 The first one is the honey net. 239 00:16:46,480 --> 00:16:50,000 I think four or five months ago, there are some hints. 240 00:16:50,180 --> 00:16:53,320 So, it's basically just a few tall scripts that you have to write. 241 00:16:55,100 --> 00:17:01,300 As I said before, the logging takes place by putting all data that's logged by the suite 242 00:17:01,300 --> 00:17:06,340 into a buffer and then sending this over the line to the logging host. 243 00:17:06,560 --> 00:17:13,680 So, basically, if we do much reading, then we should be able to fill up the complete 244 00:17:13,680 --> 00:17:15,620 line and see some latency effects. 245 00:17:16,760 --> 00:17:21,820 Also, ZBAC has to fiddle with the network counters because it communicates directly 246 00:17:21,820 --> 00:17:22,520 with the driver. 247 00:17:22,740 --> 00:17:29,160 You have to adjust the drivers so that the output of fconfig and any other tools is consistent 248 00:17:29,160 --> 00:17:30,340 with the system. 249 00:17:31,380 --> 00:17:36,460 So, if we take a closer look at the network traffic counters, we will also probably find 250 00:17:36,460 --> 00:17:37,500 some signs of ZBAC. 251 00:17:38,760 --> 00:17:42,740 A very obvious way is the modification of the syscall table. 252 00:17:43,260 --> 00:17:46,020 Basically, there are some pointers which are changed. 253 00:17:46,480 --> 00:17:48,300 And, perhaps, we can detect it. 254 00:17:49,360 --> 00:17:56,220 With the help of Cleaner.o, ZBAC also unloads itself and tries to hide itself, so we should 255 00:17:56,220 --> 00:17:58,100 be able to find a hidden module in memory. 256 00:17:58,580 --> 00:18:02,500 And perhaps we can do some other things in memory in order to detect ZBAC. 257 00:18:03,100 --> 00:18:07,500 I'm going to step-to-step on these five points and explain what we've done. 258 00:18:08,100 --> 00:18:10,140 At first, we take a look at the latency. 259 00:18:10,880 --> 00:18:12,840 Perhaps you all know the dd command. 260 00:18:13,420 --> 00:18:14,540 It's a very easy tool. 261 00:18:14,720 --> 00:18:16,460 And, with the help of this command, we can detect the latency. 262 00:18:16,480 --> 00:18:20,260 And, with the help of the dd command, we can, within perhaps 10 seconds, detect that 263 00:18:21,000 --> 00:18:24,860 ZBAC is running on a host, and we'll just show you this. 264 00:18:25,540 --> 00:18:27,740 The command is something like dd. 265 00:18:28,260 --> 00:18:32,740 As input file, we take dev0 and output file defnall. 266 00:18:33,020 --> 00:18:40,180 So basically, we copy just inside the system some from dev0 to defnall with a block size 267 00:18:40,180 --> 00:18:40,560 of 1. 268 00:18:40,940 --> 00:18:42,700 And then we should see some effects. 269 00:18:44,260 --> 00:18:49,200 So basically, Maximilian will now do this demonstration. 270 00:18:54,800 --> 00:19:00,820 So we booted the HoneyNet because we just removed the Honeypot software for demonstration. 271 00:19:01,260 --> 00:19:04,980 We installed the HoneyNet, and we started SSHD. 272 00:19:06,120 --> 00:19:08,160 We are doing that now. 273 00:19:09,960 --> 00:19:10,680 Okay. 274 00:19:10,680 --> 00:19:11,140 Okay. 275 00:19:11,960 --> 00:19:12,680 Okay. 276 00:19:12,700 --> 00:19:13,240 All right. 277 00:19:13,400 --> 00:19:16,660 Basically, I shut it down, SSH, for purposes. 278 00:19:17,220 --> 00:19:20,300 So we are on DEF CON network, and probably it's not secure. 279 00:19:20,940 --> 00:19:21,100 So... 280 00:19:28,200 --> 00:19:28,640 Yeah. 281 00:19:31,460 --> 00:19:31,900 Okay. 282 00:19:32,080 --> 00:19:33,620 Now, ZBAC is running on the host. 283 00:19:36,780 --> 00:19:39,540 And at first, you should ping. 284 00:19:40,100 --> 00:19:41,960 So at first, we just do a ping. 285 00:19:42,040 --> 00:19:42,680 So at first, we just do a ping. 286 00:19:42,680 --> 00:19:48,360 machine to this machine. We've got connected through a direct connection, just a cross 287 00:19:48,360 --> 00:19:52,940 cable. And as you see, we've got a latency of about 0.3 milliseconds. 288 00:19:53,460 --> 00:19:59,940 So now we start DD in the background and do this kind of ping again. As you see on the 289 00:19:59,940 --> 00:20:11,760 output, there's some latency. We can't type anything. It should take a few seconds. And 290 00:20:11,760 --> 00:20:16,920 a factor of 10 or something like this, we've got more than 2 milliseconds now. So we've 291 00:20:16,920 --> 00:20:25,080 got a latency effect. And basically within 10 seconds, we were able to detect that there's 292 00:20:25,080 --> 00:20:25,880 something going on. 293 00:20:29,880 --> 00:20:35,980 So at the next step to detect the presence of ZVEC as another approach, we take a look 294 00:20:35,980 --> 00:20:41,160 at the network traffic counters. As I said before, ZVEC just fiddles with 295 00:20:41,160 --> 00:20:41,740 ProcNet. 296 00:20:41,740 --> 00:20:51,200 It basically changes the output of the TX packets inside ProcNet dev. And then if we 297 00:20:51,200 --> 00:20:55,500 compare this output to the output of fconfig, then we should see also some differences. 298 00:20:56,080 --> 00:21:02,500 For the purpose of this, we wrote some kernel module. The kernel module is basically a modification 299 00:21:02,500 --> 00:21:10,520 of ZVEC. I just removed a lot of lines and basically changed only two lines. And now, 300 00:21:10,640 --> 00:21:11,640 as you can see, 301 00:21:11,640 --> 00:21:23,940 we have the TX bytes counter. We've got about 20.6 kilobytes. 302 00:21:25,700 --> 00:21:32,340 We are connected to the box via an SSH connection, so basically we have about two kilobytes or 303 00:21:32,340 --> 00:21:41,060 so per second on additional TX bytes output. Now we insert into the kernel this dev checker. 304 00:21:41,060 --> 00:21:45,740 Dev checker basically changes the output of ProcNet dev back to its original values. 305 00:21:46,040 --> 00:21:53,700 And if we now start something like the DDE command in the background, we see that we've 306 00:21:53,700 --> 00:22:01,960 basically now 70.4 megabytes. And if we now, we've got 22. So within a few seconds, 307 00:22:02,040 --> 00:22:11,000 we've got more than five megabytes of data. If we now unload the module, we see those 308 00:22:11,060 --> 00:22:15,100 latency effects again because DDE is running in the background. 309 00:22:15,400 --> 00:22:24,620 So if we now RLMOD the module from the kernel, then we should see that the network counter 310 00:22:24,620 --> 00:22:25,300 goes back again. 311 00:22:28,600 --> 00:22:32,420 So I think the latency now went up to infinity. 312 00:22:35,580 --> 00:22:36,620 And now it works. 313 00:22:40,560 --> 00:22:50,560 And you see the transmit counter is now 22 megabytes. And if we unload our module, it 314 00:22:50,560 --> 00:22:57,240 went back down to 42 kilobytes. So that's something fishy with the transmit counter, 315 00:22:57,480 --> 00:22:57,820 obviously. 316 00:23:03,840 --> 00:23:04,540 Okay. 317 00:23:04,600 --> 00:23:06,600 And the third approach to detect the TX bytes. 318 00:23:06,600 --> 00:23:11,100 To detect the presence of Zilbeck is based on the syscall table. As you already perhaps 319 00:23:11,100 --> 00:23:21,040 know, the syscall table is just a table with every syscall. And each syscall points to 320 00:23:21,040 --> 00:23:26,040 somewhere in the memory. It's something like a function pointer, nothing more. As you see 321 00:23:26,040 --> 00:23:30,780 on the left side, we've got sysexit, sysread, syswrite, sysopen. So syswrite is the one 322 00:23:30,780 --> 00:23:33,560 that's hijacked via Zilbeck. 323 00:23:34,360 --> 00:23:36,580 If Zilbeck loads now into memory, it's going to be the same thing. 324 00:23:36,600 --> 00:23:37,480 Yeah. 325 00:23:37,560 --> 00:23:48,260 Depicted as this mod.12345.0. It just changes the pointer from the sysread to the other 326 00:23:48,260 --> 00:23:54,240 module. And so we should see that the pointers from the sysread, syswrite, and sysopen are 327 00:23:54,240 --> 00:23:56,040 not in the neighborhood. 328 00:23:57,160 --> 00:24:04,580 We just wrote in a small kernel module. Before the loading of Zilbeck, the counters of sysread, 329 00:24:04,580 --> 00:24:11,620 the memory locations of sysread and syswrite were very close together. And after reading, 330 00:24:11,680 --> 00:24:20,620 you see that sys... Oh, I think that's wrong. The upper part should be syswrite. The other 331 00:24:20,620 --> 00:24:26,400 is sysread. That's now in another memory location. And so that there's something fishy 332 00:24:26,400 --> 00:24:27,000 going on. 333 00:24:30,580 --> 00:24:31,260 So... 334 00:24:32,440 --> 00:24:34,560 So, Zilbeck currently is... 335 00:24:34,560 --> 00:24:43,680 It's implemented as a loadable module because seemingly setting up a honeypot has to be 336 00:24:43,680 --> 00:24:51,360 idiot-proof and patching your kernel isn't acceptable. A kernel module, probably we can 337 00:24:51,360 --> 00:24:56,500 find it, even if it's hidden. And if we can find it, we can start to extract the variables 338 00:24:56,500 --> 00:25:03,840 inside the kernel module, and probably we might be even able to disable it. Every module 339 00:25:03,840 --> 00:25:10,600 in Linux starts with a module header, which is defined in includeLinuxModuleH. And this 340 00:25:10,600 --> 00:25:16,720 module header starts with the struct, with the size of the struct of the module header, 341 00:25:16,860 --> 00:25:23,760 which is 96 in current Linux implementations, with pointers to the name of the module and 342 00:25:23,760 --> 00:25:28,820 to the next module. So, these are two pointers into kernel space, and the one even has to 343 00:25:28,820 --> 00:25:33,820 point to another valid module structure, and the name pointer has to point to something 344 00:25:33,820 --> 00:25:40,060 like some ASCII string, and some other pointers further down, which should point into kernel 345 00:25:40,060 --> 00:25:47,240 space, too. Then function pointers to the startup function and the shutdown function 346 00:25:47,240 --> 00:25:54,240 of the module, which should point into the module space. And some integers have only 347 00:25:54,240 --> 00:26:02,980 a very small, reasonable space of values of usually one, two, or three. And with all these 348 00:26:02,980 --> 00:26:09,540 values, we can probably fingerprint memory locations which look like a module header. 349 00:26:10,320 --> 00:26:16,020 That's not that hard, because the module header and the whole module is allocated 350 00:26:16,020 --> 00:26:23,920 by the kernel's vMalloc function, and this function aligns all memory allocated via two 351 00:26:23,920 --> 00:26:32,320 page boundaries, so every 4K is the only position where a module header can start. This means 352 00:26:32,320 --> 00:26:42,680 we only have to check every 4K or every page for a module header, and vMalloc only starts 353 00:26:42,680 --> 00:26:49,560 allocating malloc at vMalloc start, which is a kernel constant, and only reserves memory 354 00:26:49,560 --> 00:26:59,480 for vMalloc-reserved bytes. So, a very simple loop, about 128 megabytes of kernel memory 355 00:26:59,480 --> 00:27:02,300 in 4K steps, helps us to do this. 356 00:27:02,320 --> 00:27:08,600 Next, we have to check out the possible locations of a module header, and we'll now shortly 357 00:27:08,600 --> 00:27:29,480 demonstrate that. Thorsten now says we don't. But at least I can show you. The lsmod outputs 358 00:27:29,480 --> 00:27:31,320 five modules. 359 00:27:33,660 --> 00:27:40,820 But if we start ModuleHunter, which was published in a recent FRAC article, we see another module, 360 00:27:40,900 --> 00:27:49,580 which is SMPCMCIA, which is our kernel module in this case. So, if we are able to find this 361 00:27:49,580 --> 00:27:53,880 module, we have the techniques in ModuleHunter, we should be able to extract the variables. 362 00:27:55,440 --> 00:28:00,680 ZBAG is very sophisticated, or at least a little bit sophisticated, in hiding its variables 363 00:28:00,680 --> 00:28:07,420 and its variables. Whenever ZBAG is recompiled, this Perl program, or the fragment of a Perl 364 00:28:07,420 --> 00:28:14,580 program, changes the location of the variables used by ZBAG in a block of allocated memory. 365 00:28:14,800 --> 00:28:24,440 Basically, ZBAG has a huge block zeroed out. It's about between 512 bytes and, I think, 366 00:28:24,460 --> 00:28:27,380 1K. That's random, the size of this block. 367 00:28:27,380 --> 00:28:33,560 And the variables used by ZBAG are randomly placed in this block at every compilation. 368 00:28:37,580 --> 00:28:45,960 So, if we start looking into this block, we can use heuristics to decide, or to at least guess, 369 00:28:46,180 --> 00:28:54,200 do an educated guess, which value might be which variable. For example, this might be an IP 370 00:28:54,200 --> 00:28:57,360 address. But if it would be an IP address, it is in moving order. So, it's a very, very simple 371 00:28:57,380 --> 00:29:03,140 multicast address, which is quite unlikely that a multicast address is the address of the 372 00:29:03,140 --> 00:29:09,860 logging server. So, perhaps it's the magic value used by ZBAG to hide its packets. 373 00:29:10,340 --> 00:29:17,440 And a full code might be a magic value. Another number like this, this is a valued IP address. 374 00:29:17,640 --> 00:29:25,260 So, it might be the address of the ZBAG logging server. This might be a port number, the port 375 00:29:25,260 --> 00:29:27,200 number using for the logging server. 376 00:29:28,800 --> 00:29:36,380 And these short values might be parts of a MAC address, just byte-sized, which looks 377 00:29:36,380 --> 00:29:37,720 very much like a MAC address. 378 00:29:44,040 --> 00:29:51,380 So, by searching for the kernel module, and then using the heuristics, we can get quite 379 00:29:51,380 --> 00:29:57,080 good results in guessing if ZBAG is there, and what are the kernel variables. 380 00:30:04,700 --> 00:30:14,560 So, we have written a Python tool, which passes the kernel structures at one time. The most 381 00:30:14,560 --> 00:30:23,600 difficult part is finding the syscall table, because the Linux people have removed in their 382 00:30:23,600 --> 00:30:27,360 wisdom the kernel symbol for the system call table. 383 00:30:27,360 --> 00:30:29,760 Because nobody needs the address of the system call table. 384 00:30:30,800 --> 00:30:36,180 And we locate them by looking for other kernel symbols, and from there tracing the address 385 00:30:36,180 --> 00:30:37,360 of the system call table. 386 00:30:38,520 --> 00:30:42,080 Then here, the system call table is finally found. 387 00:30:43,020 --> 00:30:47,480 This message has a typo. It's not this white, which is probably hijacked, but this red, 388 00:30:47,700 --> 00:30:48,680 which is hijacked. 389 00:30:49,120 --> 00:30:54,180 We showed, Torsten showed you when the values are far apart, there's something probably 390 00:30:54,180 --> 00:30:54,500 wrong. 391 00:30:54,500 --> 00:31:01,720 And then our heuristics guessing that there is a module which should be ZBAG, named sound 392 00:31:01,720 --> 00:31:02,440 PCMCIA. 393 00:31:03,040 --> 00:31:04,080 And we guess. 394 00:31:04,280 --> 00:31:10,120 At MAC fragments, for example, probably all these ones are not MAC fragments. 395 00:31:10,460 --> 00:31:20,960 But I assure you that 3D, 3F, 5E, and I think 7B, some of them are fragments of the MAC 396 00:31:20,960 --> 00:31:23,400 address of this computer acting as a . 397 00:31:23,400 --> 00:31:26,380 And that computer is the Honeywell, the Senders MAC address. 398 00:31:26,640 --> 00:31:33,340 And this FFFFFFF is actually the MAC address we use for sending out ZBAG logging data. 399 00:31:33,720 --> 00:31:39,920 So while we can't get the exact variables of the ZBAG kernel module, we can reduce the 400 00:31:39,920 --> 00:31:43,020 space you have to try to a very small one. 401 00:31:44,340 --> 00:31:46,400 And we have a lot of possible port addresses. 402 00:31:46,800 --> 00:31:53,380 And in fact, we used 1111 as a source port address and 2222 as a destination port address. 403 00:31:53,400 --> 00:32:04,360 address. In most instances, we get a lot less variables, a lot less possible guesses, but 404 00:32:04,360 --> 00:32:08,740 you know there's a demonstration effect of Murphy's Law. If you do a demonstration, the 405 00:32:08,740 --> 00:32:16,440 heuristics will draw a bad day. The possible IP addresses, they're again in this list of 406 00:32:16,440 --> 00:32:22,380 about two dozen addresses. This is the address of our logging server, and after that is the 407 00:32:22,380 --> 00:32:29,360 address of the honeypot, so we already again guessed the right IP address. And the magic 408 00:32:29,360 --> 00:32:34,140 value we actually used is in this list of possible magic value. At least it should be there. 409 00:32:34,180 --> 00:32:38,780 Yeah, there. Deadbeat. Okay. 410 00:32:47,560 --> 00:32:48,960 Oh, messed that up. 411 00:32:57,020 --> 00:33:05,320 So, how to disable ZBAG? There's a very nice and easy way. The authors of ZBAG thought, 412 00:33:05,420 --> 00:33:11,260 oh, it should be disableable, and so they placed, being good designers of kernel modules, 413 00:33:11,560 --> 00:33:18,540 a nice little cleanup function in there, which does everything we would need. It de-hijacks 414 00:33:18,540 --> 00:33:22,300 the read pointer, cleans nicely up. 415 00:33:22,380 --> 00:33:28,520 It runs everything, and exits the module. And if we are able to get the address of the cleanup 416 00:33:28,520 --> 00:33:34,920 function, we just call that cleanup function and ZBAG cleans up after itself, and it is away. 417 00:33:35,960 --> 00:33:41,900 And as you might remember that we were able to locate the module header, and the module 418 00:33:41,900 --> 00:33:46,520 header is a pointer to the cleanup function. So, basically getting rid of ZBAG is more or less 419 00:33:46,520 --> 00:33:51,860 trivial. Find the module header, get the address of the cleanup function, jump in the cleanup 420 00:33:52,440 --> 00:33:55,580 that was a kernel jumper module we uploaded 421 00:33:55,580 --> 00:33:58,420 in our demonstration, which does nothing more than 422 00:33:58,420 --> 00:34:00,280 jump to an address in the kernel, 423 00:34:00,440 --> 00:34:02,440 and you are all set and done. 424 00:34:03,500 --> 00:34:05,700 The obvious way, if you don't think about 425 00:34:05,700 --> 00:34:08,800 the cleanup function, is reconstruct this read pointer 426 00:34:08,800 --> 00:34:12,300 and let it point again back to the original kernel function 427 00:34:12,300 --> 00:34:15,580 for doing so, but the tricky part is getting the address 428 00:34:15,580 --> 00:34:17,420 of the original kernel function. 429 00:34:17,560 --> 00:34:19,240 There are ways to reconstruct that 430 00:34:19,240 --> 00:34:21,160 from the kernel binary itself, 431 00:34:21,160 --> 00:34:22,160 but they are tricky. 432 00:34:22,840 --> 00:34:27,720 Or you could find, you can poke into the ZBAG module itself 433 00:34:27,720 --> 00:34:30,900 because it still has a pointer to the original read function, 434 00:34:31,100 --> 00:34:33,160 but why do that if you can't clean up? 435 00:34:33,700 --> 00:34:37,240 If you are really crazy, or if somebody decided 436 00:34:37,240 --> 00:34:39,880 to use ZBAG not as a kernel module, 437 00:34:40,160 --> 00:34:41,900 but to compile it into the kernel, 438 00:34:42,020 --> 00:34:46,040 you just look to the actual, this read function, 439 00:34:46,120 --> 00:34:48,680 which is in there, probably Torrent by ZBAG, 440 00:34:48,760 --> 00:34:50,620 and overwrite it at one time 441 00:34:50,620 --> 00:34:51,080 with a clean. 442 00:34:51,160 --> 00:34:51,840 Read function. 443 00:34:52,820 --> 00:34:56,080 That's not that trivial, because you have to get 444 00:34:56,080 --> 00:34:57,860 all the pointers and the jumps right, 445 00:34:58,040 --> 00:35:00,380 leading from your new read function, 446 00:35:00,540 --> 00:35:02,780 which is untainted, to the rest of the kernel, 447 00:35:02,880 --> 00:35:03,860 but it should be possible. 448 00:35:06,100 --> 00:35:09,200 So, after we've seen some ways to detect ZBAG, 449 00:35:09,320 --> 00:35:13,520 and now we take a look at how to avoid logging at all. 450 00:35:13,840 --> 00:35:18,480 So, basically, we have some problems. 451 00:35:19,500 --> 00:35:20,740 There are some data, 452 00:35:21,160 --> 00:35:23,860 that the operator of the honeypot is always logging. 453 00:35:24,120 --> 00:35:25,900 For example, the network traffic. 454 00:35:26,340 --> 00:35:29,740 We have to connect remote to the honeypot, 455 00:35:29,900 --> 00:35:33,220 because it's not under our physical control, 456 00:35:33,400 --> 00:35:35,940 so we have to use some kind of network, 457 00:35:36,120 --> 00:35:39,360 and all network traffic has to flow through the honey wall, 458 00:35:39,560 --> 00:35:43,360 so basically, the operator can catch all traffic there, 459 00:35:43,500 --> 00:35:45,800 so we can't do anything against this. 460 00:35:46,440 --> 00:35:48,340 Also, ZBAG is loaded on the box, 461 00:35:48,540 --> 00:35:50,540 so before we can unload it, 462 00:35:51,160 --> 00:35:53,280 the operator will see all calls to read. 463 00:35:53,420 --> 00:35:55,200 Everything we've done via read, 464 00:35:57,340 --> 00:36:00,800 he is able to log, and he can analyze this later. 465 00:36:02,280 --> 00:36:03,900 And there are some other data, 466 00:36:04,600 --> 00:36:07,380 that the operator can obtain. 467 00:36:07,760 --> 00:36:11,980 For example, if we use some of our tools, 468 00:36:12,140 --> 00:36:14,320 and then write them on disk, 469 00:36:14,540 --> 00:36:17,380 then the operator can, after he has seen 470 00:36:17,380 --> 00:36:18,700 that we've compromised this box, 471 00:36:18,960 --> 00:36:21,140 then he can do something. 472 00:36:21,160 --> 00:36:21,940 He can do some kind of forensic, 473 00:36:22,060 --> 00:36:25,160 and reconstruct all data that we left on the disk. 474 00:36:25,420 --> 00:36:28,620 So basically, we want to find a way that we can, 475 00:36:30,720 --> 00:36:35,360 as far as we want, to keep everything in memory, 476 00:36:35,580 --> 00:36:37,880 and not write anything to disk at all. 477 00:36:38,520 --> 00:36:41,580 There are some syslog data that we can't control, 478 00:36:41,720 --> 00:36:44,660 because the services are perhaps logging something, 479 00:36:44,900 --> 00:36:47,280 and the operator will also get these values, 480 00:36:47,360 --> 00:36:48,840 and he can analyze them. 481 00:36:49,440 --> 00:36:50,800 So, what can we do? 482 00:36:50,800 --> 00:36:51,980 What can we do against logging? 483 00:36:53,080 --> 00:36:54,860 For logging off the network traffic, 484 00:36:55,200 --> 00:36:56,600 there's an obvious way. 485 00:36:56,840 --> 00:36:59,880 We simply use encryption whenever possible. 486 00:37:01,440 --> 00:37:03,920 Because when there's encrypted network traffic, 487 00:37:04,100 --> 00:37:05,500 the operator can log everything, 488 00:37:05,660 --> 00:37:07,420 but without the appropriate key, 489 00:37:07,540 --> 00:37:09,120 he can't decrypt anything. 490 00:37:09,520 --> 00:37:11,140 So we have to encrypt everything, 491 00:37:11,740 --> 00:37:13,800 and the only problem with this approach 492 00:37:13,800 --> 00:37:16,180 is how to deliver our initial exploit. 493 00:37:16,780 --> 00:37:18,080 At the initial exploit, 494 00:37:18,220 --> 00:37:20,780 if we don't use any kind of connection, any kind of, 495 00:37:20,780 --> 00:37:21,980 any kind of encryption, 496 00:37:22,620 --> 00:37:24,900 then the operator will see this exploit, 497 00:37:25,140 --> 00:37:27,820 and we've got, we lost our zero day. 498 00:37:28,000 --> 00:37:31,620 So, perhaps we use, should use something like 499 00:37:31,620 --> 00:37:35,180 an HTTPS connection, or something secure, 500 00:37:35,620 --> 00:37:38,260 so that this connection is also encrypted, 501 00:37:38,440 --> 00:37:40,040 and the operator can't see anything. 502 00:37:40,580 --> 00:37:43,280 For this purpose, we used in our demonstration 503 00:37:44,060 --> 00:37:47,200 an HTTPS server, so basically, 504 00:37:47,320 --> 00:37:50,720 no one can see something with the help of TCP. 505 00:37:50,780 --> 00:37:51,980 TCP dump, or similar tools. 506 00:37:53,420 --> 00:37:55,620 Another possible way to disable 507 00:37:55,620 --> 00:37:58,140 the logging off network traffic would be 508 00:37:58,140 --> 00:38:00,040 if we could compromise the Honeywall. 509 00:38:00,300 --> 00:38:02,720 If we have got root on the Honeywall, 510 00:38:02,880 --> 00:38:05,860 we could erase everything, all logging data, 511 00:38:06,120 --> 00:38:09,460 but usually, the Honeywall is extremely secured, 512 00:38:10,440 --> 00:38:13,000 often with GAR security and similar patches, 513 00:38:13,200 --> 00:38:14,720 and it has no IP address, 514 00:38:15,040 --> 00:38:17,540 so it's basically a hard task to find it, 515 00:38:17,560 --> 00:38:18,840 and to get root on this box. 516 00:38:19,100 --> 00:38:20,540 So, probably, 517 00:38:20,780 --> 00:38:21,940 you have to find other ways. 518 00:38:23,820 --> 00:38:26,960 With, and then, with the help of ZBIG, 519 00:38:27,100 --> 00:38:29,960 the operator can see everything what we do via read. 520 00:38:31,380 --> 00:38:33,300 So, what programs do use read? 521 00:38:33,600 --> 00:38:36,700 Nearly every program that uses some kind of interaction. 522 00:38:37,360 --> 00:38:39,900 Most programs, you'll see, use read to, 523 00:38:39,960 --> 00:38:43,840 to read some kind of configuration files, 524 00:38:44,020 --> 00:38:47,060 or user input, so we have to avoid read at all. 525 00:38:48,380 --> 00:38:50,340 A nice example for avoiding read, 526 00:38:50,780 --> 00:38:51,940 would be network programs. 527 00:38:52,220 --> 00:38:56,400 Network programs use receive to read from a socket, 528 00:38:56,500 --> 00:39:00,260 so, basically, if we can use receive instead of read, 529 00:39:00,360 --> 00:39:02,860 there's some way to avoid everything. 530 00:39:06,710 --> 00:39:10,980 The problem is why is every program using read? 531 00:39:11,120 --> 00:39:13,000 And why doesn't encryption help? 532 00:39:13,300 --> 00:39:17,020 If you have a connection from the internet to SSH daemon, 533 00:39:17,360 --> 00:39:20,700 sure, the SSH daemon is reading from a socket, 534 00:39:20,760 --> 00:39:24,420 but the whole communication from the internet is encrypted 535 00:39:24,420 --> 00:39:26,960 and so is the communication over the socket 536 00:39:26,960 --> 00:39:30,000 it's decrypted inside the SSH daemon 537 00:39:30,000 --> 00:39:33,560 so even if SSH is reading from the socket 538 00:39:33,560 --> 00:39:37,240 that shouldn't help the operator of the honey net 539 00:39:37,240 --> 00:39:41,680 because he's just seeing the encrypted data 540 00:39:41,680 --> 00:39:46,540 the problem is that SSH can't do anything at all 541 00:39:46,540 --> 00:39:48,260 it starts all the time 542 00:39:48,260 --> 00:39:50,980 external programs, even for copying files 543 00:39:50,980 --> 00:39:56,080 and usually it has a bash or another shell behind that 544 00:39:56,080 --> 00:40:00,400 and SSH has to communicate with that shell 545 00:40:00,400 --> 00:40:03,400 and that is done by using a Unix pipe 546 00:40:03,400 --> 00:40:07,560 and this Unix pipe has two file descriptors 547 00:40:07,560 --> 00:40:11,180 at its end, the SSH, the end, and the bash end 548 00:40:11,180 --> 00:40:14,800 and the bash is reading the keystrokes via that file descriptor 549 00:40:14,800 --> 00:40:16,140 and these are unencrypted 550 00:40:16,140 --> 00:40:18,160 so basically if we could merge 551 00:40:18,260 --> 00:40:21,100 SSH, the end, and bash into a single program 552 00:40:21,100 --> 00:40:22,920 and get rid of that pipe 553 00:40:22,920 --> 00:40:24,900 no logging would take place 554 00:40:27,300 --> 00:40:31,640 so before taking a look at how we can avoid the users of reach 555 00:40:31,640 --> 00:40:35,520 we just take a short look at what is actually logged by ZEBEC 556 00:40:35,520 --> 00:40:38,320 on the right you can see ZEBEC.ha 557 00:40:38,320 --> 00:40:42,760 and this isn't just the structure 558 00:40:42,760 --> 00:40:45,240 that basically consists of the ZEBEC header 559 00:40:45,240 --> 00:40:47,580 there are some values that are logged 560 00:40:47,580 --> 00:40:48,140 for example 561 00:40:48,260 --> 00:40:48,880 the magic number 562 00:40:48,880 --> 00:40:50,220 the version number 563 00:40:50,220 --> 00:40:50,760 type number 564 00:40:50,760 --> 00:40:53,520 there is some information about the count time 565 00:40:53,520 --> 00:40:54,240 the PID 566 00:40:54,240 --> 00:40:55,000 the UID 567 00:40:55,000 --> 00:40:57,260 the file descriptor 568 00:40:57,260 --> 00:41:01,840 and then the 12 first bytes of the program that's calling read 569 00:41:01,840 --> 00:41:04,100 and the length of the total ZEBEC packet 570 00:41:05,260 --> 00:41:10,660 so the operator gets quite a few information about everything 571 00:41:10,660 --> 00:41:11,760 for example 572 00:41:11,760 --> 00:41:13,020 the PID and UID 573 00:41:13,020 --> 00:41:15,600 so he knows who is just calling read 574 00:41:15,600 --> 00:41:17,860 and what PID and UID it has 575 00:41:18,680 --> 00:41:19,300 so what he has to do 576 00:41:19,300 --> 00:41:20,860 but also it sees the file descriptor 577 00:41:20,860 --> 00:41:23,180 but perhaps we can fit it with the file descriptor 578 00:41:23,180 --> 00:41:24,020 for example 579 00:41:24,020 --> 00:41:24,540 we can 580 00:41:25,160 --> 00:41:25,680 yeah 581 00:41:25,680 --> 00:41:27,920 they're free standard file operators 582 00:41:27,920 --> 00:41:28,580 a zero one 583 00:41:28,580 --> 00:41:28,960 and two 584 00:41:28,960 --> 00:41:30,400 perhaps we can fiddle them 585 00:41:30,400 --> 00:41:34,360 so just use the one for 586 00:41:35,840 --> 00:41:38,300 one of our standards out or something like this 587 00:41:38,300 --> 00:41:40,120 and yeah 588 00:41:40,120 --> 00:41:41,740 we can just play with these 589 00:41:42,580 --> 00:41:47,100 and it also locks the 12 bytes of the program that's calling read 590 00:41:47,100 --> 00:41:48,240 perhaps we can also 591 00:41:48,240 --> 00:41:48,960 also fiddle with this. 592 00:41:49,100 --> 00:41:50,780 For example, if we rename the binary, 593 00:41:51,040 --> 00:41:53,540 if you just copy to another location or something like this, 594 00:41:53,740 --> 00:41:56,680 if you use a name that starts with, 595 00:41:56,740 --> 00:41:58,420 at first, 12 space characters, 596 00:41:58,560 --> 00:42:01,060 and then the real program name or something similar. 597 00:42:03,420 --> 00:42:06,300 So, if we want to avoid read, 598 00:42:06,500 --> 00:42:10,580 the first thought is that we should make read unreliable. 599 00:42:11,100 --> 00:42:12,700 As we've seen in our demonstration, 600 00:42:12,980 --> 00:42:14,760 in our second demonstration, I think, 601 00:42:14,900 --> 00:42:16,840 if we start dd in the background, 602 00:42:16,840 --> 00:42:19,000 then we generate lots of packets, 603 00:42:19,260 --> 00:42:23,880 then we've got some kind of denial of service 604 00:42:23,880 --> 00:42:24,720 against the Honeywall. 605 00:42:24,920 --> 00:42:26,900 It doesn't react to something like this. 606 00:42:27,450 --> 00:42:30,440 So, basically, if we just put enough data 607 00:42:30,930 --> 00:42:34,360 through the read system calls, we make it unreliable. 608 00:42:34,680 --> 00:42:36,040 As we've seen at the demonstration, 609 00:42:36,460 --> 00:42:39,900 there were some error messages about lost packets. 610 00:42:40,400 --> 00:42:44,180 These were basically error messages made by Zyvec, 611 00:42:44,320 --> 00:42:46,300 because Zyvec was unable 612 00:42:46,300 --> 00:42:47,140 to send some packets. 613 00:42:48,340 --> 00:42:51,640 So, we made the read by Zyvec unreliable. 614 00:42:51,800 --> 00:42:56,580 But, basically, we can't control which information are lost. 615 00:42:56,820 --> 00:42:59,180 So, basically, if we start dd in the background, 616 00:42:59,500 --> 00:43:02,920 we are sure that some packets are lost, 617 00:43:03,000 --> 00:43:04,500 but we don't know which packets are lost. 618 00:43:04,700 --> 00:43:07,060 So, this is an unreliable approach. 619 00:43:07,640 --> 00:43:15,440 A better approach is that we just quit using read. 620 00:43:16,300 --> 00:43:20,060 So, we can use mmap to directly map some files into memory. 621 00:43:20,380 --> 00:43:21,720 We just map them into memory 622 00:43:21,720 --> 00:43:23,500 and can then work with them as normal. 623 00:43:23,820 --> 00:43:26,880 So, basically, we can nearly live without read. 624 00:43:27,780 --> 00:43:28,880 There are some problems. 625 00:43:29,120 --> 00:43:30,800 For example, we can't use devices. 626 00:43:30,960 --> 00:43:32,820 We can't map devices into memory. 627 00:43:33,100 --> 00:43:35,500 We can't use Unix pipes or similar things. 628 00:43:35,800 --> 00:43:37,940 We are just stuck with files. 629 00:43:38,120 --> 00:43:39,500 But, perhaps, we can exploit this 630 00:43:39,840 --> 00:43:44,060 and avoid reading and avoid the read system for a while. 631 00:43:45,040 --> 00:43:47,440 So, it's very hard to monitor mmap 632 00:43:47,440 --> 00:43:52,460 because with mmap I will just map two gigabytes of contents 633 00:43:52,460 --> 00:43:57,820 into my memory and no one wants to transfer two gigabytes 634 00:43:57,820 --> 00:44:00,640 or such a small link just to log something. 635 00:44:04,680 --> 00:44:07,460 So, how can I live without read? 636 00:44:07,780 --> 00:44:10,320 The first thing I have to say goodbye to my shell. 637 00:44:10,500 --> 00:44:12,680 The shell is designed to read anything 638 00:44:12,680 --> 00:44:13,960 from its standard in, 639 00:44:13,960 --> 00:44:15,640 so I can't use it. 640 00:44:16,120 --> 00:44:18,160 I need something like mentioned before 641 00:44:18,160 --> 00:44:19,820 with directly talked to the network, 642 00:44:20,080 --> 00:44:23,220 encrypted, and executes directly your commands. 643 00:44:24,020 --> 00:44:27,100 The nice thing is that the command used in Unix 644 00:44:27,100 --> 00:44:29,160 to execute actually a program exec 645 00:44:29,160 --> 00:44:32,280 does not call read, at least in Linux, 646 00:44:32,460 --> 00:44:34,840 so it doesn't use the internal kernel read call. 647 00:44:35,800 --> 00:44:39,420 But if you execute a program, it might import libraries, 648 00:44:39,420 --> 00:44:41,980 and some of those libraries are read. 649 00:44:43,120 --> 00:44:45,320 Some are mapped into the memory. 650 00:44:45,480 --> 00:44:48,080 I wasn't able to find out the system behind that, 651 00:44:48,140 --> 00:44:50,180 but probably there is a system behind that. 652 00:44:50,400 --> 00:44:54,480 So people might guess which program you have been started by exec 653 00:44:54,480 --> 00:44:56,780 by seeing the libraries being imported, 654 00:44:57,020 --> 00:44:59,180 and if the program you are executing 655 00:44:59,180 --> 00:45:03,280 is reading config files by seeing the config files being read. 656 00:45:04,640 --> 00:45:06,580 We can mess with the process name. 657 00:45:06,780 --> 00:45:10,040 We just can copy and rename the binary. 658 00:45:10,980 --> 00:45:11,940 For example, 659 00:45:11,980 --> 00:45:18,000 if we rename cat to sudo 660 00:45:19,680 --> 00:45:24,360 and then cat something which looks like a sudoers file, 661 00:45:25,380 --> 00:45:29,420 probably the forensic expert looking at the log file 662 00:45:29,420 --> 00:45:32,580 will think we were successfully executing the sudo program. 663 00:45:32,900 --> 00:45:36,460 I think sudo is executed by everybody, 664 00:45:36,720 --> 00:45:38,960 by world on usual Linux systems. 665 00:45:39,060 --> 00:45:40,300 On parallel Linux systems, 666 00:45:40,320 --> 00:45:41,840 it's just executable by the... 667 00:45:42,920 --> 00:45:45,180 I'm not so much into Linux, I'm more into VBSD. 668 00:45:47,120 --> 00:45:48,140 So the results. 669 00:45:48,400 --> 00:45:51,500 We can read files unnoticed by mapping them into memory. 670 00:45:51,940 --> 00:45:55,800 We can possibly execute programs unnoticed 671 00:45:55,800 --> 00:46:01,200 by calling exec if they don't pull into any libraries 672 00:46:01,200 --> 00:46:02,260 we have read into memory. 673 00:46:02,840 --> 00:46:04,880 Since file names are not locked, 674 00:46:05,560 --> 00:46:06,920 there's a file descriptor locked, 675 00:46:07,000 --> 00:46:10,280 but not the name associated with the file descriptor. 676 00:46:10,400 --> 00:46:11,880 So we can give the impression, 677 00:46:11,980 --> 00:46:13,240 of reading certain files. 678 00:46:13,460 --> 00:46:16,420 If we have to create a file in TMP, 679 00:46:16,640 --> 00:46:18,480 which looks like a password file, 680 00:46:18,800 --> 00:46:19,900 and cat that, 681 00:46:20,140 --> 00:46:24,380 the forensic analyst will see something 682 00:46:24,380 --> 00:46:26,280 which looks like a password file 683 00:46:26,280 --> 00:46:30,060 and probably guess that it was just the password file, 684 00:46:30,280 --> 00:46:33,940 and it will take him some time to find out it wasn't. 685 00:46:35,020 --> 00:46:37,620 And we can give the impression 686 00:46:37,620 --> 00:46:40,420 that we are executing programs which we can't execute 687 00:46:40,420 --> 00:46:41,960 because they are only executable by us. 688 00:46:41,980 --> 00:46:44,060 They are only executable by higher-privileged users. 689 00:46:45,900 --> 00:46:49,180 So we implemented all of this into the KBase tool, 690 00:46:50,400 --> 00:46:52,240 which is proof of concept code. 691 00:46:52,520 --> 00:46:53,920 And the nifty thing about it, 692 00:46:53,960 --> 00:46:57,240 it's a network attack tool which is entirely written 693 00:46:57,240 --> 00:46:59,180 in a very high-level language in Python. 694 00:46:59,840 --> 00:47:01,960 So it's very, very portable. 695 00:47:02,340 --> 00:47:05,540 You don't have to compile it for an architecture or so, 696 00:47:05,660 --> 00:47:07,440 as long as there's a Python interpreter 697 00:47:07,860 --> 00:47:10,800 on the target machine at once. 698 00:47:13,580 --> 00:47:15,880 And if there's no Python interpreter 699 00:47:15,880 --> 00:47:18,140 and you are willing to move a lot of data 700 00:47:18,140 --> 00:47:18,900 around the network, 701 00:47:19,000 --> 00:47:20,540 you just can bundle the program 702 00:47:20,540 --> 00:47:21,940 with the Python interpreter itself 703 00:47:21,940 --> 00:47:23,940 and push the interpreter on the target machine 704 00:47:23,940 --> 00:47:25,420 like you would do with a C program 705 00:47:25,420 --> 00:47:27,560 where you put the C coin to the target machine. 706 00:47:29,240 --> 00:47:32,420 It can do everything you can expect from a shell, 707 00:47:32,600 --> 00:47:35,160 not Bash, but perhaps Azure, something, a basic shell, 708 00:47:35,300 --> 00:47:36,780 and it's very highly dynamic. 709 00:47:38,300 --> 00:47:41,500 It's noteworthy that the GUAC recently published, 710 00:47:41,500 --> 00:47:44,000 a tool which had some of the same ideas 711 00:47:44,980 --> 00:47:46,820 in the latest FRAC. 712 00:47:47,060 --> 00:47:52,940 It's, I think, it's Keeping Your Zero Days Safe Part Two 713 00:47:52,940 --> 00:47:54,060 or something is the name of it. 714 00:47:54,220 --> 00:47:56,800 And he has a tool which is able to transfer binary 715 00:47:56,800 --> 00:47:59,180 to a target machine and execute it there 716 00:47:59,780 --> 00:48:01,700 without ever writing it to disk. 717 00:48:01,760 --> 00:48:04,320 Basically, that's what KBase is doing too, 718 00:48:04,460 --> 00:48:05,860 but on a very different level 719 00:48:05,860 --> 00:48:08,460 because we were able to do different things 720 00:48:08,460 --> 00:48:09,560 with our high-level language. 721 00:48:10,520 --> 00:48:12,540 KBase use TCP sockets for networking, 722 00:48:12,780 --> 00:48:14,700 but it could use anything else 723 00:48:14,700 --> 00:48:15,940 because it's modular designed. 724 00:48:16,380 --> 00:48:18,100 For example, if you deliver, 725 00:48:18,680 --> 00:48:21,000 you exploit and still have an open socket 726 00:48:21,000 --> 00:48:24,380 or something like that, you could use that. 727 00:48:25,000 --> 00:48:28,480 On top of that TCP, we implement a crypto layer. 728 00:48:28,780 --> 00:48:33,680 The crypto layer is generating the key pair 729 00:48:33,680 --> 00:48:36,960 by Diffie-Hellman, and that's enough in our case. 730 00:48:37,160 --> 00:48:38,480 Diffie-Hellman is, 731 00:48:39,560 --> 00:48:42,140 would be fall to a man-in-the-middle attack. 732 00:48:43,300 --> 00:48:45,960 But the Honeywall up to now, 733 00:48:46,120 --> 00:48:48,720 or the Honeywalls we know are only passive devices 734 00:48:48,720 --> 00:48:51,800 and Diffie-Hellman is safe against passive devices. 735 00:48:52,320 --> 00:48:56,540 And later we used an AES for providing the crypto 736 00:48:56,540 --> 00:48:59,200 and the crypto layer also contains compression 737 00:48:59,200 --> 00:49:02,420 and random length padding to make it difficult 738 00:49:02,420 --> 00:49:05,500 for a forensic analyst seeing the network traffic 739 00:49:05,500 --> 00:49:07,500 to guess at the commands we were sending 740 00:49:07,500 --> 00:49:08,520 by the length of them. 741 00:49:09,560 --> 00:49:13,440 The main problem is to get entropy for Diffie-Hellman 742 00:49:13,620 --> 00:49:18,100 because we can't read from diff random on the honeypot. 743 00:49:18,300 --> 00:49:20,600 That would be locked by Zeybek 744 00:49:20,600 --> 00:49:24,340 and the forensic analyst would be able to reconstruct 745 00:49:24,600 --> 00:49:26,700 our whole Diffie-Hellman key exchange 746 00:49:26,700 --> 00:49:28,200 if he had that random numbers. 747 00:49:29,200 --> 00:49:33,220 We solved this problem today by using other techniques 748 00:49:33,220 --> 00:49:36,660 like ThreadRaces and hashing the whole content 749 00:49:36,660 --> 00:49:38,240 of TMP and Vaar. 750 00:49:39,560 --> 00:49:46,440 on, and that is no really high security crypto entropy, but it should be enough to frustrate 751 00:49:46,440 --> 00:49:47,400 a forensic analyst. 752 00:49:47,980 --> 00:49:54,480 On top of the crypto layer, we have a Python-specific KBase layer, which basically communicates 753 00:49:54,480 --> 00:49:56,620 by sending objects across the network. 754 00:49:59,300 --> 00:50:05,480 The KBase layer can send multiple commands at once, and the commands can work on multiple 755 00:50:05,480 --> 00:50:06,180 objects. 756 00:50:06,180 --> 00:50:15,420 So, for example, you can send wide these two dozen files, read this one file, and delete 757 00:50:15,420 --> 00:50:20,760 that ten files, all in one KBase command, or in one KBase data packet. 758 00:50:21,080 --> 00:50:26,440 And the asynchronous commands at the moment are not implemented, but the protocol supports 759 00:50:26,440 --> 00:50:30,680 them because asynchronous communication, implementing them, is really basically a pain 760 00:50:30,680 --> 00:50:31,140 in the ass. 761 00:50:35,000 --> 00:50:36,160 The nice thing about the KBase layer is that it's very easy to use. 762 00:50:36,160 --> 00:50:40,760 The nice thing is the KBase server, when you inject it on the target machine, it knows 763 00:50:40,760 --> 00:50:46,180 only a single command, or a single Python object you can use, at command. 764 00:50:46,800 --> 00:50:53,780 So if this server falls into the hands of a forensic analyst, he will learn very little. 765 00:50:53,860 --> 00:50:58,300 Because of Diffie-Hellman, there are no keys in the server, and there's only this 766 00:50:58,300 --> 00:50:59,880 very simple command, at command. 767 00:51:00,780 --> 00:51:06,140 And the code for all additional and interesting commands for exploiting the KBase layer is 768 00:51:06,140 --> 00:51:10,880 the honeypot, are pushed into the server at runtime. 769 00:51:11,280 --> 00:51:17,540 The client is basically having the code for the advanced commands, compiles them to Python 770 00:51:17,540 --> 00:51:22,860 bytecode, and pushes this bytecode object over the line into the server, but they only 771 00:51:22,860 --> 00:51:24,180 exist in RAM. 772 00:51:24,420 --> 00:51:29,180 And if you are very unlucky, they might exist on swap space, you have to keep that in mind. 773 00:51:31,860 --> 00:51:36,060 That is a very nice thing of developing a server, actually. 774 00:51:36,140 --> 00:51:40,660 Because you never have to restart the server, because on every connect, when you use the 775 00:51:40,660 --> 00:51:45,560 client, just all the code is pushed into the server, so basically the server is reloaded. 776 00:51:46,880 --> 00:51:52,540 The commands we have implemented are reading and writing using memory mapping, so without 777 00:51:52,540 --> 00:51:59,460 this read and this write, secure deletion, so overwriting a file, truncating it to zero 778 00:51:59,460 --> 00:52:02,120 bytes, renaming it, and then deleting it. 779 00:52:03,080 --> 00:52:04,980 Direct execution via exec. 780 00:52:04,980 --> 00:52:07,800 Exec listing directories, getting system info. 781 00:52:08,040 --> 00:52:14,140 It would be nice to implement the execution without any help of the server. 782 00:52:14,240 --> 00:52:19,040 That would be the user-lent exec library, but implementing it in poor Python would be 783 00:52:19,040 --> 00:52:19,740 very difficult. 784 00:52:21,580 --> 00:52:28,680 Yeah, more information on the design of CBAG and KBase can be found in an academic paper, 785 00:52:28,840 --> 00:52:30,580 which should be on your CD-ROM. 786 00:52:31,120 --> 00:52:34,680 Also on your CD-ROM should be the Nosebreak program. 787 00:52:34,680 --> 00:52:37,060 Which is able to find ZBAG in memory. 788 00:52:37,460 --> 00:52:44,140 The KBase toolkit itself, when the CD-ROM was created, it was in a shape we were very 789 00:52:44,140 --> 00:52:48,800 afraid to give it away, like this code you write in the early morning hours. 790 00:52:49,300 --> 00:52:55,380 But under this URL, you can download the KBase toolkit, and you can download videos of our 791 00:52:55,380 --> 00:53:01,380 demonstrations showing how we use ZBAG and KBase, and get rid of ZBAG and so on. 792 00:53:01,720 --> 00:53:03,100 So are there any questions? 793 00:53:03,380 --> 00:53:03,660 Okay. 794 00:53:06,020 --> 00:53:06,560 Yeah? 795 00:53:19,320 --> 00:53:23,000 The question was that we said that hijacking 796 00:53:23,000 --> 00:53:28,920 NMAP would be very difficult, but ZBAG could hijack XSEC and that stuff. 797 00:53:29,340 --> 00:53:30,200 Yeah, you're right. 798 00:53:31,680 --> 00:53:33,640 So we have to avoid using XSEC. 799 00:53:33,660 --> 00:53:35,720 We have to avoid using XSEC as much as possible. 800 00:53:35,880 --> 00:53:40,980 One solution would be to use userland XSEC, which is by the Gwag, and it's a library 801 00:53:41,420 --> 00:53:48,180 with executors and binary without ever using this kernel's XSEC function. 802 00:53:48,420 --> 00:53:50,020 That would be very hard to hijack. 803 00:53:50,080 --> 00:53:54,840 The problem is that this is C code, and we basically have to push then a binary object 804 00:53:54,840 --> 00:54:00,960 to the honeypot machine, which works as long as it's the right Linux version. 805 00:54:02,000 --> 00:54:02,960 Actually, the... 806 00:54:02,960 --> 00:54:03,640 Yeah. 807 00:54:03,660 --> 00:54:12,660 The current development version of ZBAG uses also the suite, the XSEC, and the receives 808 00:54:12,660 --> 00:54:17,760 those calls, so it monitors more of those calls, but it's not yet publicly released. 809 00:54:18,060 --> 00:54:18,720 It's in better status. 810 00:54:24,400 --> 00:54:25,000 Okay. 811 00:54:25,220 --> 00:54:26,560 So no more questions? 812 00:54:27,800 --> 00:54:30,480 So just download it and check for honeypots. 813 00:54:33,660 --> 00:54:34,140 Thanks everyone.