1 00:00:00,000 --> 00:00:01,820 Good morning, DEF CON. Can you hear me? 2 00:00:03,820 --> 00:00:04,180 Yeah? 3 00:00:05,200 --> 00:00:07,500 Well, thanks for coming this morning, Sunday morning at 10. 4 00:00:09,220 --> 00:00:13,680 It's not too many of you, but hopefully those of you that are here 5 00:00:14,580 --> 00:00:20,100 are either very interested in OpenVMS or just had nothing better to do. 6 00:00:23,560 --> 00:00:27,380 Right, so the goal, first of all, I want to let you know 7 00:00:27,380 --> 00:00:29,200 that we know absolutely nothing about OpenVMS. 8 00:00:30,000 --> 00:00:31,380 But we do know how to break it. 9 00:00:33,300 --> 00:00:39,260 The goal of this talk is to prove to you that even though an operating system 10 00:00:39,260 --> 00:00:44,440 that has been considered very, very secure and reliable for 30 years 11 00:00:45,180 --> 00:00:48,280 can be broken, and actually can be broken quite easily. 12 00:00:49,580 --> 00:00:53,140 Some of the bugs that we found were very trivial to find, 13 00:00:54,180 --> 00:00:57,260 a little more, a little harder to exploit. 14 00:01:00,000 --> 00:01:01,080 But were quite easy to find. 15 00:01:03,640 --> 00:01:06,320 Anyone here an OpenVMS user? 16 00:01:08,000 --> 00:01:08,580 Good. 17 00:01:08,660 --> 00:01:09,740 Anyone from HP? 18 00:01:13,260 --> 00:01:13,840 No? 19 00:01:17,040 --> 00:01:19,920 Right, the OpenVMS user can take a short nap. 20 00:01:20,690 --> 00:01:25,580 The talk is broken into three parts. 21 00:01:25,840 --> 00:01:28,100 There will have a lightweight introduction to OpenVMS, 22 00:01:28,750 --> 00:01:29,820 where we'll just cover the... 23 00:01:30,000 --> 00:01:30,640 Some of the history. 24 00:01:30,740 --> 00:01:32,700 Some of the fundamentals of the operating system. 25 00:01:33,420 --> 00:01:34,940 History of bugs, et cetera. 26 00:01:35,620 --> 00:01:39,520 Then we'll have Christa and my colleague Klaus 27 00:01:40,260 --> 00:01:43,060 talk about the VACs and alpha architecture, 28 00:01:43,340 --> 00:01:46,220 and in particular how they managed to exploit that. 29 00:01:49,880 --> 00:01:52,700 And how they managed to write shellcode for it. 30 00:01:53,640 --> 00:01:55,520 The challenges that they faced 31 00:01:55,520 --> 00:01:57,200 and how they managed to overcome those challenges. 32 00:01:58,300 --> 00:01:59,500 And most importantly, 33 00:01:59,500 --> 00:02:02,320 And finally, the last part will show you the root prompt. 34 00:02:06,120 --> 00:02:07,260 So let's go right ahead. 35 00:02:08,960 --> 00:02:11,900 OpenVMS was developed in the late 70s by Digital, 36 00:02:13,060 --> 00:02:15,180 and it has some of the standard features 37 00:02:15,180 --> 00:02:19,160 that nowadays are considered, well, standard 38 00:02:19,160 --> 00:02:20,820 for an operating system, 39 00:02:21,020 --> 00:02:22,360 but then they were quite innovative. 40 00:02:23,380 --> 00:02:25,520 So all of the standards such as multi-user, 41 00:02:25,520 --> 00:02:28,940 multi-processing, virtual memory, real-type processing, 42 00:02:29,780 --> 00:02:32,420 transaction processing, those were pretty cool at the time. 43 00:02:34,040 --> 00:02:37,460 As far as the ownership goes, Digital developed it 44 00:02:37,460 --> 00:02:40,340 and owned it up until 98 when Compaq took over, 45 00:02:40,940 --> 00:02:43,280 and then the HP owns it today. 46 00:02:48,440 --> 00:02:50,140 Initially, it was called VaxVMS. 47 00:02:52,020 --> 00:02:54,020 Vax was the hardware that ran on, 48 00:02:54,080 --> 00:02:55,500 and it was developed at the same time 49 00:02:55,520 --> 00:02:56,560 as the operating system, 50 00:02:56,700 --> 00:02:58,080 probably the first time that that happened. 51 00:02:59,320 --> 00:03:02,400 Then the Vax name dropped, and it was just called VMS, 52 00:03:02,980 --> 00:03:04,900 and then later OpenVMS in the 90s 53 00:03:04,900 --> 00:03:09,000 when the open standards gained more and more popularity. 54 00:03:10,360 --> 00:03:12,420 VMS is not similar to Unix in any way. 55 00:03:13,340 --> 00:03:16,780 However, it does share some similarities with Windows NT, 56 00:03:17,760 --> 00:03:19,760 because one of the developers, Dave Cutler, 57 00:03:19,920 --> 00:03:22,500 who initially developed VMS, 58 00:03:22,720 --> 00:03:25,340 was then called at Microsoft to develop 59 00:03:25,520 --> 00:03:25,920 Windows NT. 60 00:03:26,240 --> 00:03:29,220 It runs on three hardware architectures, 61 00:03:29,820 --> 00:03:33,180 Vax, which is a 32-bit system, CISC, 62 00:03:34,160 --> 00:03:35,980 and also Alpha and Itanium. 63 00:03:38,540 --> 00:03:41,360 Krista and CMN will talk more about 64 00:03:41,360 --> 00:03:42,820 the Vax and Alpha later on. 65 00:03:43,940 --> 00:03:45,680 It is considered secure and reliable, 66 00:03:45,800 --> 00:03:47,420 even more so than OSX. 67 00:03:50,420 --> 00:03:52,660 So why would we want to hack OpenVMS? 68 00:03:52,800 --> 00:03:55,360 Well, first of all, nobody hacks it. 69 00:03:55,520 --> 00:03:58,560 And it's considered very secure, unbreakable. 70 00:04:00,070 --> 00:04:06,260 It runs critical operations in financial systems. 71 00:04:06,710 --> 00:04:09,660 Lots of banks and the majority of stock exchanges 72 00:04:09,660 --> 00:04:11,680 have some OpenVMS systems running. 73 00:04:13,210 --> 00:04:15,400 It runs your SCADA infrastructure systems, 74 00:04:16,050 --> 00:04:19,240 your railway, your electricity boards. 75 00:04:19,890 --> 00:04:22,560 They're all controlled by OpenVMS systems. 76 00:04:25,520 --> 00:04:29,560 In the UK, the NHS system uses it a lot 77 00:04:30,080 --> 00:04:31,400 for their back-end system. 78 00:04:31,720 --> 00:04:35,480 And in other areas, you can find it, 79 00:04:35,500 --> 00:04:37,260 such as manufacturing, Intel uses it, 80 00:04:37,840 --> 00:04:40,260 and education and the military also use it. 81 00:04:42,060 --> 00:04:44,640 It is also certified by the Department of Defense 82 00:04:44,640 --> 00:04:45,220 for its security. 83 00:04:46,800 --> 00:04:49,280 It's challenging and it's a lot of fun. 84 00:04:51,940 --> 00:04:55,380 If you want to try out OpenVMS, 85 00:04:55,440 --> 00:04:55,500 you can do that. 86 00:04:55,500 --> 00:04:58,600 You can get an account online 87 00:04:59,000 --> 00:05:01,960 with the guys at Death Row, which we've used. 88 00:05:02,140 --> 00:05:04,000 And it's pretty cool because they give you access 89 00:05:04,000 --> 00:05:06,220 to a cluster of both alpha and vac systems. 90 00:05:08,000 --> 00:05:10,240 And they also encourage security research 91 00:05:10,240 --> 00:05:11,480 so you can play around with it. 92 00:05:12,460 --> 00:05:15,020 And they also have a small deck net 93 00:05:15,020 --> 00:05:16,600 so you can play around with deck nets as well. 94 00:05:17,800 --> 00:05:20,300 There's also this crazy guy in Germany, which is great. 95 00:05:20,400 --> 00:05:24,260 He runs a vacs cluster in his basement. 96 00:05:25,500 --> 00:05:26,820 And he'll give you access for free. 97 00:05:28,400 --> 00:05:29,700 If you're particularly interested 98 00:05:29,700 --> 00:05:31,900 in testing out the Itanium features, 99 00:05:32,080 --> 00:05:35,740 then HP will give you a limited access to Itanium. 100 00:05:38,480 --> 00:05:40,240 So as far as getting the software goes, 101 00:05:40,280 --> 00:05:43,920 the best way to do that is to go through the Hobbist program, 102 00:05:45,140 --> 00:05:49,560 which is a cheap way of getting a license. 103 00:05:50,260 --> 00:05:52,700 And for, at least in the UK, for 30 bucks 104 00:05:53,100 --> 00:05:54,920 and a local subscription of 100. 105 00:05:55,640 --> 00:05:56,380 Dollars a year. 106 00:05:56,460 --> 00:05:59,000 You can get a valid OpenVMS license. 107 00:06:00,940 --> 00:06:02,220 We use emulators. 108 00:06:03,220 --> 00:06:06,120 There's a free version of Personal Alpha available. 109 00:06:06,420 --> 00:06:08,500 It has limited functionalities such as 110 00:06:08,500 --> 00:06:12,240 you can only use 128 megabytes of RAM, 111 00:06:12,940 --> 00:06:15,040 one Ethernet card, and four hard disks. 112 00:06:15,460 --> 00:06:16,640 But it's absolutely fine. 113 00:06:16,780 --> 00:06:18,000 It runs fine on my laptop. 114 00:06:18,220 --> 00:06:20,460 It is Windows only, so if you're looking at running it 115 00:06:20,460 --> 00:06:23,200 on any other platforms, it won't work. 116 00:06:24,560 --> 00:06:25,480 There's also Shaft. 117 00:06:25,480 --> 00:06:26,880 There's ARIN, which emulates VAC system. 118 00:06:27,280 --> 00:06:28,480 There's a demo version available. 119 00:06:29,060 --> 00:06:33,200 And SIM, which is, again, emulates VACs. 120 00:06:33,580 --> 00:06:36,780 It's free and it runs on most operating system. 121 00:06:37,220 --> 00:06:39,100 If you do go out and buy your own hardware, 122 00:06:39,260 --> 00:06:42,220 be aware that size can be pretty big, 123 00:06:42,300 --> 00:06:43,280 so do check with the wife. 124 00:06:47,300 --> 00:06:50,320 The user environment, well, it does run an X server 125 00:06:50,320 --> 00:06:52,980 with CD, so Unix users will be familiar with that. 126 00:06:53,600 --> 00:06:55,460 Although it is pretty hard to get it right. 127 00:06:55,460 --> 00:06:57,580 It's running on an emulator and it really isn't worth it. 128 00:06:59,020 --> 00:07:01,740 The DCL, which is the default shell of VMS, 129 00:07:01,900 --> 00:07:04,460 is what you'll be interacting with. 130 00:07:06,300 --> 00:07:08,840 It is case insensitive, so if you're a Unix user, 131 00:07:09,740 --> 00:07:10,620 that's different. 132 00:07:10,940 --> 00:07:13,800 And you can't run commands explicitly. 133 00:07:14,200 --> 00:07:20,720 You have to either use run or define a foreign command 134 00:07:21,280 --> 00:07:22,460 before you can run a binary. 135 00:07:26,560 --> 00:07:32,780 Back in 88, 89, a couple of worms 136 00:07:34,060 --> 00:07:35,240 propagated through DECnet. 137 00:07:35,980 --> 00:07:37,140 They were relatively simple. 138 00:07:37,220 --> 00:07:41,480 They just exploited weak passwords on finger and FTP. 139 00:07:42,380 --> 00:07:43,980 But they did cause a lot of havoc, 140 00:07:44,500 --> 00:07:46,780 bringing down thousands of VMS systems 141 00:07:46,780 --> 00:07:48,260 in a short period of time. 142 00:07:50,520 --> 00:07:55,440 As far as vulnerabilities reported in open VMS, 143 00:07:55,460 --> 00:07:57,000 there aren't that many. 144 00:07:57,340 --> 00:08:01,120 And most reported vulnerabilities are pretty old. 145 00:08:01,520 --> 00:08:04,040 And you can't find much information on them. 146 00:08:04,600 --> 00:08:06,920 Pretty much the only source where you'll find that 147 00:08:06,920 --> 00:08:08,240 is textfiles.com. 148 00:08:15,720 --> 00:08:17,500 Quick vulnerability graph. 149 00:08:17,940 --> 00:08:19,380 These are very rough figures. 150 00:08:20,720 --> 00:08:24,180 But they kind of show that open VMS was way below 151 00:08:27,560 --> 00:08:28,620 the average. 152 00:08:28,920 --> 00:08:30,740 We're looking at increasing that a little bit. 153 00:08:34,760 --> 00:08:37,600 So, VMS survived DEFCON 9. 154 00:08:38,520 --> 00:08:42,940 A bunch of guys set up these alpha clusters running VMS 155 00:08:43,640 --> 00:08:45,180 back in 2001. 156 00:08:46,500 --> 00:08:50,800 And apart from someone compromising the telnet password 157 00:08:50,800 --> 00:08:54,540 of the system admin logging in, no one managed to break 158 00:08:54,540 --> 00:08:55,360 into those systems. 159 00:08:55,460 --> 00:08:57,900 So, the VMS users were really proud of that. 160 00:08:59,720 --> 00:09:03,940 One of the great things of VMS, which can bite back though, 161 00:09:04,120 --> 00:09:06,740 is it's very fine grain controlled. 162 00:09:07,720 --> 00:09:11,440 So, you don't need the system user for everything. 163 00:09:14,060 --> 00:09:16,500 When is the last time that you saw a VMS exploit? 164 00:09:19,660 --> 00:09:22,300 Well, if you want to get an account on VMS 165 00:09:22,300 --> 00:09:24,660 to run our exploits that we'll show later on, 166 00:09:25,460 --> 00:09:27,140 you can try the usual stuff. 167 00:09:27,520 --> 00:09:30,020 Try some default accounts and weak passwords. 168 00:09:31,160 --> 00:09:33,260 The system user never locks out. 169 00:09:33,760 --> 00:09:37,480 The passwords are also capital by default. 170 00:09:38,120 --> 00:09:40,800 You can change that, but it is a pain. 171 00:09:41,000 --> 00:09:46,000 So, the chances are that you'll have no case. 172 00:09:48,300 --> 00:09:52,840 The default password hash algorithm is pretty weak as well. 173 00:09:52,940 --> 00:09:54,140 So, you could try to crack that. 174 00:09:55,600 --> 00:09:58,360 And some default accounts that you can try, 175 00:09:58,460 --> 00:10:02,780 a system field, operator default backup, et cetera. 176 00:10:06,020 --> 00:10:08,260 Some important files that you want to be looking at 177 00:10:08,260 --> 00:10:10,080 are the vmsimages.dat. 178 00:10:10,140 --> 00:10:14,740 It's a binary file, and it lists all the VMS images, 179 00:10:14,840 --> 00:10:18,100 programs, and their respective privileges. 180 00:10:18,260 --> 00:10:21,160 So, if you want to start breaking some of the software, 181 00:10:21,240 --> 00:10:24,800 you want to look at this file, look through it, and grip. 182 00:10:24,800 --> 00:10:30,100 Through the images that run with certain high privileges. 183 00:10:34,140 --> 00:10:37,420 We have the rightslist.dat, which again is a binary file, 184 00:10:37,480 --> 00:10:41,340 and it's not readable by default by a normal user. 185 00:10:42,580 --> 00:10:47,180 And it contains all the user list and their rights. 186 00:10:49,320 --> 00:10:51,680 The system user authorization file, 187 00:10:51,680 --> 00:10:54,860 which is like the password file in Unix, 188 00:10:55,980 --> 00:10:58,740 contains the users and the hashed passwords. 189 00:11:01,780 --> 00:11:04,560 This is a binary file, but if the administrator 190 00:11:05,880 --> 00:11:07,580 has converted that to a text file, 191 00:11:07,780 --> 00:11:11,100 it will have created a .list file in the same directory, 192 00:11:11,340 --> 00:11:13,260 and by default that will be readable by everyone. 193 00:11:13,420 --> 00:11:14,220 So, check out that file. 194 00:11:15,480 --> 00:11:19,160 When you log into a VMS system, it executes the login.com script. 195 00:11:20,080 --> 00:11:23,400 So, check that out for malicious lines of code. 196 00:11:25,080 --> 00:11:28,220 Or, if you have the right access then, 197 00:11:28,340 --> 00:11:30,140 you can run some commands in there, 198 00:11:30,180 --> 00:11:31,720 put some evil commands. 199 00:11:40,080 --> 00:11:44,320 The WASP is an open source web server for VMS. 200 00:11:44,840 --> 00:11:46,860 It was specifically written for VMS, 201 00:11:46,860 --> 00:11:51,040 and it's the default choice for running a web server. 202 00:11:51,240 --> 00:11:53,120 It's pretty fast and reliable. 203 00:11:54,360 --> 00:11:56,280 But, unfortunately, the initial release 204 00:11:56,280 --> 00:11:57,920 was really full of security holes, 205 00:11:58,020 --> 00:12:00,960 which allowed you to compromise the system fully. 206 00:12:01,700 --> 00:12:04,180 Loads of bugs, such as full directory traversal, 207 00:12:04,200 --> 00:12:07,160 completely bypassed the ACLs on the system. 208 00:12:08,380 --> 00:12:11,680 And, by default, it had some sample CGI scripts, 209 00:12:11,880 --> 00:12:14,920 which could be compromised to, again, gain access to the system. 210 00:12:15,540 --> 00:12:16,840 There are still all sorts of things, 211 00:12:16,840 --> 00:12:18,160 but not all versions out there I have found. 212 00:12:18,720 --> 00:12:21,240 So, if you come across a VMS system on the internet 213 00:12:21,760 --> 00:12:22,620 running a web server, 214 00:12:22,720 --> 00:12:25,520 do check out that they're running WASD. 215 00:12:25,660 --> 00:12:26,520 Maybe it's outdated. 216 00:12:27,380 --> 00:12:31,780 If you run across a website running on a VMS system, 217 00:12:32,360 --> 00:12:36,840 do check out the dash character for directory traversal. 218 00:12:40,700 --> 00:12:43,400 Use your stuff for enumerating users on the network 219 00:12:43,400 --> 00:12:45,920 through SMTP, Verify, eXPN, Finger, 220 00:12:45,920 --> 00:12:47,200 all those work. 221 00:12:47,380 --> 00:12:48,860 Again, you can try default accounts, 222 00:12:50,100 --> 00:12:53,360 or you can try some easy-to-guess accounts, 223 00:12:53,480 --> 00:12:55,440 such as Postmaster, Default, et cetera. 224 00:12:57,780 --> 00:12:59,680 Again, you can do that through the files 225 00:12:59,680 --> 00:13:00,780 that I've mentioned before, 226 00:13:01,040 --> 00:13:03,280 the rightslist.dat and sysuaf.dat. 227 00:13:06,760 --> 00:13:09,540 The way that OpenVMS protects the files 228 00:13:09,540 --> 00:13:13,920 is using three main ways. 229 00:13:15,540 --> 00:13:15,900 The first way is to run a web server, 230 00:13:17,480 --> 00:13:19,220 one of them is through the UIC, 231 00:13:19,380 --> 00:13:21,340 which is a user identification code 232 00:13:21,340 --> 00:13:23,840 that's made up of the group ID and the user pair. 233 00:13:26,380 --> 00:13:28,240 It isn't necessarily unique, 234 00:13:28,780 --> 00:13:30,800 although it is preferably unique. 235 00:13:31,260 --> 00:13:33,300 And group ID 1 to 10 by default 236 00:13:33,300 --> 00:13:34,680 belong to system users, 237 00:13:34,940 --> 00:13:36,280 although you can change that. 238 00:13:38,080 --> 00:13:41,140 There are many privileges on OpenVMS, 239 00:13:41,380 --> 00:13:45,300 and again, you can use those to control, 240 00:13:45,300 --> 00:13:48,900 access to files in a more fine manner. 241 00:13:49,940 --> 00:13:53,120 You can also add specific ACL files, 242 00:13:53,360 --> 00:13:54,940 and those will take priority 243 00:13:56,080 --> 00:13:57,980 over any other protection. 244 00:14:00,280 --> 00:14:02,880 As I said, there are really loads of privileges 245 00:14:02,880 --> 00:14:04,020 on OpenVMS. 246 00:14:06,720 --> 00:14:09,240 VMS users will tell you that for this reason, 247 00:14:09,340 --> 00:14:10,760 VMS is much more secure. 248 00:14:11,800 --> 00:14:14,160 But unfortunately, although the default 249 00:14:14,160 --> 00:14:16,700 usually are very restrictive, 250 00:14:17,360 --> 00:14:19,240 there are many of these privileges 251 00:14:19,240 --> 00:14:22,820 that directly enable you to get system privileges. 252 00:14:24,760 --> 00:14:28,140 So it is very similar to then having root directly. 253 00:14:35,500 --> 00:14:40,580 There's high usage of logical names in VMS systems. 254 00:14:40,680 --> 00:14:43,020 These are like aliases to shorten up 255 00:14:43,020 --> 00:14:46,000 the really long paths that they have. 256 00:14:47,860 --> 00:14:49,680 They have a record management service 257 00:14:49,680 --> 00:14:54,760 which lists all the files in a database form. 258 00:14:56,020 --> 00:14:58,260 It's also pretty cool that they have 259 00:14:58,260 --> 00:14:59,840 file versioning by default, 260 00:15:00,000 --> 00:15:01,840 so each new file that you create 261 00:15:02,700 --> 00:15:06,060 has an appendix, 1, 2, 3, etc., 262 00:15:06,060 --> 00:15:08,300 and can go up to thousands. 263 00:15:10,280 --> 00:15:12,040 This is just an example of what 264 00:15:12,040 --> 00:15:15,060 VMS path looks like. 265 00:15:21,840 --> 00:15:23,800 Files are owned by a user group. 266 00:15:24,020 --> 00:15:24,900 We have four permissions. 267 00:15:25,260 --> 00:15:27,660 We have read, write, execute, and delete, 268 00:15:27,820 --> 00:15:29,840 and these are applied to four groups, 269 00:15:30,520 --> 00:15:32,060 system, owner, group, and world. 270 00:15:32,840 --> 00:15:35,400 Again, we have privileges such as bypass, 271 00:15:35,500 --> 00:15:37,380 which will allow you to bypass all privileges, 272 00:15:37,580 --> 00:15:38,000 read all. 273 00:15:38,340 --> 00:15:39,880 Again, you can read everything, 274 00:15:39,880 --> 00:15:43,020 system privileges and group privileges, 275 00:15:44,100 --> 00:15:46,320 which again gives you complete access. 276 00:15:46,860 --> 00:15:50,560 We have ACLs as well for fine-grained control, 277 00:15:50,760 --> 00:15:51,920 which I mentioned earlier, 278 00:15:52,100 --> 00:15:55,300 and every file can have an optional ACL, 279 00:15:55,500 --> 00:15:57,740 and that takes priority over everything else. 280 00:16:01,700 --> 00:16:05,580 Krista is now going to talk about his research 281 00:16:05,580 --> 00:16:07,080 and his bugs that he found. 282 00:16:18,400 --> 00:16:20,220 Okay, I'm going to talk about 283 00:16:20,220 --> 00:16:22,620 a couple of bugs I found in the finger client, 284 00:16:23,480 --> 00:16:25,400 and I find it a bit interesting 285 00:16:25,400 --> 00:16:27,740 that 20 years after the big Internet forum 286 00:16:27,740 --> 00:16:28,620 exploited finger, 287 00:16:30,100 --> 00:16:32,500 a supposedly secure operating system 288 00:16:32,500 --> 00:16:35,820 like OpenVMS is still absolutely trivial 289 00:16:35,820 --> 00:16:36,980 to own with the finger, 290 00:16:37,080 --> 00:16:37,820 binary. 291 00:16:40,820 --> 00:16:42,680 So finger, when you finger a user, 292 00:16:42,700 --> 00:16:45,800 it will try to open two files for that user, 293 00:16:46,060 --> 00:16:48,740 the .plan file and the .project file. 294 00:16:50,220 --> 00:16:52,320 The problem is on OpenVMS, 295 00:16:52,500 --> 00:16:55,400 the finger client runs with high privileges, 296 00:16:55,500 --> 00:16:56,820 and it follows links, 297 00:16:57,040 --> 00:16:59,640 so what you can do is you can link your .plan file 298 00:17:00,160 --> 00:17:01,420 to a file you want to read, 299 00:17:01,480 --> 00:17:02,460 and then finger yourself, 300 00:17:02,780 --> 00:17:04,980 and finger will try to open that file for you 301 00:17:04,980 --> 00:17:06,920 and display the content. 302 00:17:06,920 --> 00:17:12,120 I don't have a demo for it, 303 00:17:12,160 --> 00:17:13,800 because it's such an easy bug. 304 00:17:17,440 --> 00:17:19,400 The next bug is a bit more interesting, 305 00:17:19,500 --> 00:17:21,300 because it can actually give you a root prompt. 306 00:17:23,000 --> 00:17:25,960 So at first I thought about trying to find 307 00:17:25,960 --> 00:17:27,580 a buffer overflowing finger, 308 00:17:27,700 --> 00:17:30,240 but I figured that they probably fixed all of them, 309 00:17:30,380 --> 00:17:34,100 so I checked for some former string vulnerabilities instead, 310 00:17:35,040 --> 00:17:36,780 and found that I could, 311 00:17:36,780 --> 00:17:38,140 could trigger former string vulnerabilities 312 00:17:38,780 --> 00:17:40,460 through the use of the .plan file 313 00:17:40,460 --> 00:17:41,740 and the .project file, 314 00:17:41,900 --> 00:17:44,200 and also through the command line. 315 00:17:45,540 --> 00:17:48,960 I choose to use the .plan file in my exploit. 316 00:17:58,280 --> 00:18:00,940 This is a screenshot of finger misbehaving a bit. 317 00:18:01,200 --> 00:18:03,740 What I'm doing first is I'm using the installed program 318 00:18:04,840 --> 00:18:06,340 to list the privileges 319 00:18:06,780 --> 00:18:07,600 of the finger image, 320 00:18:08,120 --> 00:18:09,620 and as you can see, 321 00:18:09,720 --> 00:18:13,200 I hope it runs with system privilege 322 00:18:13,200 --> 00:18:14,360 and world privilege. 323 00:18:15,420 --> 00:18:19,880 What I'm doing next is I'm opening my .plan file, 324 00:18:20,080 --> 00:18:22,640 and you can see a couple of former string characters in there, 325 00:18:23,440 --> 00:18:25,140 and then I finger my user, 326 00:18:25,300 --> 00:18:28,460 and when finger tries to process my .plan file, 327 00:18:28,700 --> 00:18:30,240 it triggers the former string vulnerability. 328 00:18:33,060 --> 00:18:34,660 So to exploit this vulnerability, 329 00:18:34,860 --> 00:18:35,960 you're going to need, uh, 330 00:18:36,780 --> 00:18:37,200 shell code, 331 00:18:37,380 --> 00:18:38,760 and to write a shell code, 332 00:18:38,840 --> 00:18:40,940 you need to know a little bit about that platform. 333 00:18:41,900 --> 00:18:44,100 VAG stands for Virtual Address Extension. 334 00:18:44,500 --> 00:18:46,180 It's a 32-bit platform. 335 00:18:46,500 --> 00:18:49,220 It has an executable stack, at least in OpenVMS. 336 00:18:49,460 --> 00:18:51,180 I don't know about other operating systems. 337 00:18:53,530 --> 00:18:55,080 It has four privilege modes, 338 00:18:55,260 --> 00:18:56,940 and OpenVMS uses all of them. 339 00:18:57,680 --> 00:18:59,720 It's a CISC platform. 340 00:19:00,100 --> 00:19:02,200 It has instructions for absolutely everything. 341 00:19:03,530 --> 00:19:05,900 And the platform has been discontinued, 342 00:19:05,900 --> 00:19:09,160 but you can still get a lot of information online, 343 00:19:09,380 --> 00:19:12,280 so it's not a problem finding documentation. 344 00:19:15,800 --> 00:19:19,300 This slide isn't very useful for use-land exploitation, 345 00:19:19,800 --> 00:19:23,200 but at least according to the documentation, 346 00:19:24,600 --> 00:19:27,000 the top two gigs of virtual memory 347 00:19:27,000 --> 00:19:29,300 is reserved for the kernel. 348 00:19:29,360 --> 00:19:33,300 Below that, you have P1 space with DCL stacks, 349 00:19:33,640 --> 00:19:34,720 symbol tables, et cetera. 350 00:19:34,720 --> 00:19:38,100 And finally, you have P0 space, 351 00:19:38,300 --> 00:19:40,600 where your program is loaded in for execution. 352 00:19:48,780 --> 00:19:50,440 The first problem I ran into 353 00:19:50,440 --> 00:19:52,560 trying to develop a shell code is that 354 00:19:53,140 --> 00:19:54,240 I'm a Unix user, 355 00:19:54,420 --> 00:19:56,120 and I found OpenVMS environment 356 00:19:56,120 --> 00:19:57,880 to be very, very hard to work in. 357 00:19:58,580 --> 00:20:00,500 And I didn't like the tools at all, 358 00:20:00,540 --> 00:20:01,840 especially the debugger. 359 00:20:02,400 --> 00:20:03,920 So to speed up development, 360 00:20:03,920 --> 00:20:07,720 I installed NetBC in my emulator 361 00:20:07,720 --> 00:20:10,420 and used GCC and GDB instead. 362 00:20:13,260 --> 00:20:15,080 My first idea for a shell code 363 00:20:15,080 --> 00:20:17,020 was to use libc-based shell code. 364 00:20:17,340 --> 00:20:19,400 And the calling standard is pretty simple. 365 00:20:19,540 --> 00:20:21,200 So what you do is you push all the arguments 366 00:20:21,200 --> 00:20:22,840 onto the stack in reverse order, 367 00:20:23,640 --> 00:20:25,600 and then use the call s instruction 368 00:20:25,600 --> 00:20:27,260 to call a function address 369 00:20:27,260 --> 00:20:28,640 with the number of parameters 370 00:20:28,640 --> 00:20:30,640 you want to pass to the function. 371 00:20:31,200 --> 00:20:33,580 The call instruction does a few things. 372 00:20:33,920 --> 00:20:35,580 It saves registers if the 373 00:20:36,300 --> 00:20:38,020 called function requires it. 374 00:20:38,440 --> 00:20:40,260 It saves the flag register 375 00:20:40,260 --> 00:20:42,320 and the return address on the stack. 376 00:20:45,000 --> 00:20:47,660 Return values are passed 377 00:20:48,420 --> 00:20:50,360 back in a register as well. 378 00:20:50,580 --> 00:20:52,520 So it's very, very simple and it works, 379 00:20:52,640 --> 00:20:54,120 but sometimes you don't have access 380 00:20:54,120 --> 00:20:57,160 to a good libc function to call. 381 00:20:58,200 --> 00:20:59,540 And if that happens, 382 00:20:59,580 --> 00:21:01,020 you have to use system services. 383 00:21:01,340 --> 00:21:03,760 System services are a bit like 384 00:21:03,760 --> 00:21:05,320 system calls in Unix. 385 00:21:06,800 --> 00:21:10,940 So this is a simple libc-based shell code example. 386 00:21:11,340 --> 00:21:13,040 I think what it does is 387 00:21:15,360 --> 00:21:17,400 it just calls systems 388 00:21:17,400 --> 00:21:19,580 and executes a program for me. 389 00:21:23,040 --> 00:21:26,420 Then I developed a shell code 390 00:21:26,420 --> 00:21:28,460 that uses system services. 391 00:21:28,820 --> 00:21:31,080 And again, to call a system service, 392 00:21:31,140 --> 00:21:32,200 you push all the arguments 393 00:21:32,200 --> 00:21:33,660 onto the stack in reverse order, 394 00:21:33,760 --> 00:21:36,480 then you call a function that executes 395 00:21:36,480 --> 00:21:41,680 a chmk, chme, or chms instruction 396 00:21:41,680 --> 00:21:42,880 with an operand. 397 00:21:43,340 --> 00:21:45,560 This operand is just a number 398 00:21:45,560 --> 00:21:47,560 that lets OpenVMS know 399 00:21:47,560 --> 00:21:49,820 which system service you want to call. 400 00:21:51,520 --> 00:21:53,380 A major drawback with this approach 401 00:21:53,380 --> 00:21:55,500 is that system services usually 402 00:21:55,500 --> 00:21:56,660 takes a lot of arguments, 403 00:21:56,940 --> 00:22:00,420 and they also take the arguments 404 00:22:00,420 --> 00:22:02,080 in the form of descriptors. 405 00:22:02,080 --> 00:22:04,880 So instead of passing a string, 406 00:22:04,980 --> 00:22:06,860 you pass a string descriptor 407 00:22:06,860 --> 00:22:09,460 to the system call. 408 00:22:11,240 --> 00:22:15,140 This is what a descriptor looks like, basically. 409 00:22:15,200 --> 00:22:16,960 The top one is a string descriptor. 410 00:22:17,620 --> 00:22:23,440 Since you have to write position-independent code, 411 00:22:23,580 --> 00:22:25,660 you have to update all these fields at runtime, 412 00:22:26,260 --> 00:22:28,100 and that leads to the shell code 413 00:22:28,100 --> 00:22:29,020 growing even larger. 414 00:22:31,360 --> 00:22:33,440 There are a few things you can do 415 00:22:33,440 --> 00:22:35,220 to make exploitation a bit easier. 416 00:22:35,620 --> 00:22:37,820 Like, for example, you can exploit symbols. 417 00:22:38,720 --> 00:22:40,300 Symbols are executable, 418 00:22:40,440 --> 00:22:44,040 and this is really important on alpha in particular, 419 00:22:44,200 --> 00:22:46,160 because they have a non-executable stack. 420 00:22:47,280 --> 00:22:49,200 There are also string descriptors, 421 00:22:49,320 --> 00:22:52,120 and as such, they can contain 422 00:22:52,120 --> 00:22:53,920 pretty much any characters, 423 00:22:54,040 --> 00:22:54,980 including null bytes. 424 00:22:55,720 --> 00:22:58,020 And that makes writing the payload 425 00:22:58,020 --> 00:22:58,940 much, much easier. 426 00:23:01,540 --> 00:23:03,560 We haven't actually found a really good way 427 00:23:03,560 --> 00:23:05,660 of finding the right service numbers, 428 00:23:05,800 --> 00:23:07,980 so the way we do it is 429 00:23:07,980 --> 00:23:10,400 we write a small program that calls one service, 430 00:23:10,600 --> 00:23:12,460 and then we set a breakpoint 431 00:23:13,020 --> 00:23:18,980 on the chmk, chms, and chme instructions, 432 00:23:19,540 --> 00:23:22,060 run it in debugger until the breakpoint hits, 433 00:23:22,620 --> 00:23:25,020 and then we just look at the operand 434 00:23:25,020 --> 00:23:26,280 for that instruction, 435 00:23:26,280 --> 00:23:27,640 and get the number that way. 436 00:23:28,200 --> 00:23:32,180 This doesn't work on the alpha platform, unfortunately, 437 00:23:32,420 --> 00:23:34,940 because they don't support this particular feature 438 00:23:34,940 --> 00:23:35,980 in their debugger. 439 00:23:37,060 --> 00:23:39,200 So on alpha, you pretty much have to 440 00:23:39,200 --> 00:23:41,160 single-step through the entire program. 441 00:23:44,220 --> 00:23:47,360 Interesting system services to call from your payload 442 00:23:47,360 --> 00:23:51,980 are system services that create processes, 443 00:23:52,360 --> 00:23:53,720 modify user records, 444 00:23:53,920 --> 00:23:55,820 or grant privileges 445 00:23:56,280 --> 00:23:57,100 to a process, 446 00:23:57,320 --> 00:23:59,100 and these are just a few examples. 447 00:23:59,780 --> 00:24:01,440 You can find a lot more 448 00:24:02,100 --> 00:24:05,340 if you read the documentation provided by HP. 449 00:24:07,960 --> 00:24:10,140 So here's a bit of an interesting note. 450 00:24:10,360 --> 00:24:12,460 When I was getting familiar with VAX, 451 00:24:12,660 --> 00:24:15,720 I tried to exploit a really, really simple stack overflow, 452 00:24:16,660 --> 00:24:18,800 and I knew I hit the return address 453 00:24:18,800 --> 00:24:20,520 with the address of my payload, 454 00:24:21,220 --> 00:24:23,160 but the program just kept crashing 455 00:24:23,160 --> 00:24:25,080 without even trying to execute my payload. 456 00:24:26,280 --> 00:24:28,180 And I discovered that it was because 457 00:24:28,180 --> 00:24:30,000 the flag register, 458 00:24:30,120 --> 00:24:33,420 which is saved below the return address on the stack, 459 00:24:34,280 --> 00:24:37,080 contains a byte that is defined, 460 00:24:37,280 --> 00:24:38,920 as MB said, 461 00:24:39,120 --> 00:24:40,340 it has to be zero, 462 00:24:40,460 --> 00:24:42,180 otherwise the program will crash 463 00:24:42,180 --> 00:24:43,280 when it tries to return. 464 00:24:45,070 --> 00:24:46,680 So I thought, well, 465 00:24:46,860 --> 00:24:49,660 I knew that Morris exploded 466 00:24:50,110 --> 00:24:54,360 a bug in the FingerD service 467 00:24:54,360 --> 00:24:56,380 in his internet worm, 468 00:24:58,420 --> 00:25:00,820 but it turns out that he didn't have to use 469 00:25:00,820 --> 00:25:02,700 any magic tricks or anything like that, 470 00:25:03,880 --> 00:25:07,460 because his bug was triggered through a call to gets, 471 00:25:07,640 --> 00:25:09,440 so he didn't have to worry about null bytes. 472 00:25:11,140 --> 00:25:13,440 So my conclusion to this is that 473 00:25:13,440 --> 00:25:16,100 there are probably a lot of really, really stupid bugs 474 00:25:16,100 --> 00:25:19,540 on this platform that are really, really hard, 475 00:25:19,640 --> 00:25:21,220 if not impossible to exploit, 476 00:25:21,420 --> 00:25:23,120 but then again, 477 00:25:23,200 --> 00:25:24,340 you don't have to worry too much 478 00:25:24,340 --> 00:25:25,760 about it because you still have 479 00:25:25,760 --> 00:25:27,240 a lot of special cases like 480 00:25:29,800 --> 00:25:31,060 gets, for example, 481 00:25:31,060 --> 00:25:33,100 or pointers on the stack that can overwrite 482 00:25:33,100 --> 00:25:35,200 and entire other bug clauses 483 00:25:35,200 --> 00:25:36,500 like form string vulnerabilities. 484 00:25:39,360 --> 00:25:42,300 So just to summarize before I show you my demo, 485 00:25:42,580 --> 00:25:46,080 my bug is a very, very simple 486 00:25:46,080 --> 00:25:47,340 form string vulnerability. 487 00:25:47,760 --> 00:25:49,200 I used a .plan file 488 00:25:50,060 --> 00:25:52,300 to hold my form string 489 00:25:52,300 --> 00:25:53,720 and my shell code. 490 00:25:54,340 --> 00:25:57,160 I used a system service to modify my user record, 491 00:25:58,300 --> 00:26:01,800 and this particular service will send a log message, 492 00:26:03,920 --> 00:26:05,820 so it's not very stealthy. 493 00:26:07,080 --> 00:26:09,520 My username is hard-coded into the exploit, 494 00:26:10,300 --> 00:26:11,680 so if you have a different username, 495 00:26:11,880 --> 00:26:13,680 the exploit is not going to work for you, 496 00:26:13,740 --> 00:26:15,200 but that's not my problem. 497 00:26:17,880 --> 00:26:20,320 So let me show you the exploit. 498 00:26:34,120 --> 00:26:36,340 Okay, so I'm logging in as my user 499 00:26:36,340 --> 00:26:37,240 on my box. 500 00:26:38,140 --> 00:26:39,580 No, it doesn't work. 501 00:26:40,660 --> 00:26:41,180 Oh. 502 00:26:48,500 --> 00:26:49,900 I don't think so. 503 00:26:52,520 --> 00:26:53,220 What's this? 504 00:26:53,720 --> 00:26:54,000 What? 505 00:27:09,700 --> 00:27:17,080 Okay, what we'll do is we'll carry on with CMN's talk, 506 00:27:17,180 --> 00:27:18,920 and then at the end we'll try and get these videos working. 507 00:27:34,900 --> 00:27:35,520 Yes? 508 00:27:35,900 --> 00:27:37,000 If you can see the screen, 509 00:27:37,040 --> 00:27:37,540 . 510 00:27:37,540 --> 00:27:37,800 . 511 00:27:38,680 --> 00:27:39,300 . 512 00:27:40,780 --> 00:27:41,400 . 513 00:27:41,400 --> 00:27:41,620 . 514 00:27:41,620 --> 00:27:41,640 . 515 00:27:41,640 --> 00:27:42,620 . 516 00:27:42,620 --> 00:27:43,500 . 517 00:27:50,480 --> 00:27:51,100 . 518 00:27:51,100 --> 00:27:51,200 . 519 00:27:51,200 --> 00:27:51,440 . 520 00:27:53,220 --> 00:27:57,380 The alpha architecture, which we also took a look at. 521 00:27:58,160 --> 00:28:01,580 As we all know, it's a 64-bit architecture, RISC. 522 00:28:02,140 --> 00:28:07,100 And you can find a lot of information about the instruction using MSDN. 523 00:28:07,580 --> 00:28:10,460 It's very good organized, so it's really neat. 524 00:28:11,220 --> 00:28:17,460 You have to keep in mind to flush the instruction cache when writing shell code for this architecture, 525 00:28:18,620 --> 00:28:21,640 especially when writing self-modifying code, of course. 526 00:28:23,580 --> 00:28:29,080 As we mentioned earlier, you can use Personal Alpha, which is a free emulator, if you want to play around with it. 527 00:28:29,940 --> 00:28:34,300 We did not manage to boot BSD, and we never tried Linux. 528 00:28:34,660 --> 00:28:43,100 But you can also build the new binutils with AlphaTarget and create your shell code in your local PC. 529 00:28:43,940 --> 00:28:50,680 However, as Krister mentioned, it does not work with the function pointers the way it does in Unix, 530 00:28:50,740 --> 00:28:53,020 because it's not a simple address that you jump to. 531 00:28:53,220 --> 00:28:56,360 You have to construct a function descriptor instead. 532 00:28:57,600 --> 00:29:02,640 And to fully understand that, you really need to take a look at the OpenVMS calling standard. 533 00:29:05,560 --> 00:29:10,720 The vulnerability that I found resists in the command line interface library. 534 00:29:12,260 --> 00:29:18,400 It's used by a lot of applications, so it's widespread and got a lot of targets. 535 00:29:19,140 --> 00:29:21,920 It fails to handle crafted command lines. 536 00:29:23,220 --> 00:29:28,180 This vulnerability has been verified on OpenVMS Alpha 8.3 in the default install. 537 00:29:28,620 --> 00:29:32,360 And basically, it gives you total control of the program counter. 538 00:29:34,340 --> 00:29:41,660 To trigger this vulnerability, you simply find a target program that uses the command line interface. 539 00:29:41,980 --> 00:29:48,160 And while you're at the prompt, you paste or type 511 characters. 540 00:29:49,040 --> 00:29:51,700 And then the up arrow key three times. 541 00:29:51,880 --> 00:29:53,160 And then you manually type. 542 00:29:53,220 --> 00:29:53,920 And then you manually type the return address. 543 00:29:54,700 --> 00:29:55,740 Just wait for it. 544 00:29:57,220 --> 00:30:01,680 Here's a screen dump of a crash in the TCP IP program. 545 00:30:03,180 --> 00:30:05,360 And here's a similar crash in the install program. 546 00:30:05,920 --> 00:30:09,940 As you can see, the return address is a bunch of Bs. 547 00:30:10,600 --> 00:30:19,800 And at the end of the screen dump, we get an error message saying that we don't have enough privileges to dump core for this process, 548 00:30:20,040 --> 00:30:21,440 which is quite interesting. 549 00:30:21,520 --> 00:30:22,180 Since that... 550 00:30:23,940 --> 00:30:27,900 Implied that we have a set of privileges that is interesting. 551 00:30:29,280 --> 00:30:31,940 As I said, we have multiple targets with this vulnerability. 552 00:30:32,480 --> 00:30:38,920 For instance, we have the install program, which has the privileges to run kernel code. 553 00:30:39,880 --> 00:30:45,280 We have the TCP IP program, which has the privileges to perform physical I.O. 554 00:30:45,520 --> 00:30:50,560 And we have the Telnet client, which gives you the operator privileges. 555 00:30:50,840 --> 00:30:53,000 You can use that for roll sockets and stuff like that. 556 00:30:58,040 --> 00:31:03,600 Yeah, now that we have control of the program counter, we obviously need some shellcode. 557 00:31:06,620 --> 00:31:11,440 So the C calling standard is complex, as we mentioned before. 558 00:31:11,620 --> 00:31:18,540 So you actually need to know pretty much about it. 559 00:31:18,600 --> 00:31:20,760 And there is a document that covers everything. 560 00:31:20,860 --> 00:31:21,360 Everything on manager. 561 00:31:23,220 --> 00:31:28,420 The stack is not executable, but as Christian mentioned, we could execute code in logicals. 562 00:31:28,420 --> 00:31:29,840 That's useful for local exploitation. 563 00:31:30,200 --> 00:31:33,400 When it comes to remote, we have to do other tricks. 564 00:31:33,600 --> 00:31:37,680 Perhaps copy the code to an executable location or similar things. 565 00:31:38,360 --> 00:31:46,180 And, yeah, flushing the instruction cache is important for self-modifying code. 566 00:31:47,740 --> 00:31:48,520 Okay, cool. 567 00:31:48,600 --> 00:31:49,000 I'll try that. 568 00:31:50,260 --> 00:31:51,880 My exploit doesn't need... 569 00:31:51,880 --> 00:31:53,040 I don't really need to get... 570 00:31:53,220 --> 00:31:58,960 To know the location of the shellcode, but that's sometimes the case. 571 00:31:59,140 --> 00:32:05,420 So you obviously need to get PC code running in some cases. 572 00:32:12,100 --> 00:32:14,440 The PC register can't be directly read. 573 00:32:14,560 --> 00:32:17,980 It's a bit of a fiddle to get this running. 574 00:32:18,100 --> 00:32:20,660 But the shellcoder's handbook has a really nice solution, 575 00:32:21,580 --> 00:32:22,100 which... 576 00:32:23,220 --> 00:32:26,160 Stores the IMB instruction with the opcode of 86 577 00:32:26,160 --> 00:32:29,360 and then overwrites the branch instruction in the second loop 578 00:32:29,360 --> 00:32:33,020 and saves the PC register in the 16th register 579 00:32:33,020 --> 00:32:35,140 before the shellcode continues to execute. 580 00:32:37,860 --> 00:32:39,720 To do something really useful, 581 00:32:39,960 --> 00:32:42,820 you need to be able to call system services 582 00:32:42,820 --> 00:32:46,380 or as system calls in Unix. 583 00:32:47,180 --> 00:32:50,600 You pass the six first arguments in the A registers 584 00:32:50,600 --> 00:32:52,580 and then you push additional... 585 00:32:53,220 --> 00:32:54,380 additional arguments onto the stack. 586 00:32:55,220 --> 00:32:58,520 You also keep an argument counter in the 25th register 587 00:32:58,520 --> 00:33:03,020 and the system service index in the zero register. 588 00:33:04,820 --> 00:33:10,000 Keep in mind that the index vary from OpenBSD versions. 589 00:33:10,240 --> 00:33:12,400 You really have to make sure that you have the right index 590 00:33:12,400 --> 00:33:14,080 for the target that you are exploiting. 591 00:33:15,560 --> 00:33:18,100 And the instructions used to jump into kernel mode 592 00:33:18,100 --> 00:33:22,040 and run execute the system service contains null bytes, 593 00:33:22,040 --> 00:33:26,020 which even the IMB instruction does. 594 00:33:26,140 --> 00:33:28,940 It's a bit tricky to get stuff null-free. 595 00:33:31,880 --> 00:33:36,060 The create process system call is interesting for exploitation 596 00:33:36,060 --> 00:33:39,680 since it allows us to execute an arbitrary binary 597 00:33:39,680 --> 00:33:40,800 on the file system. 598 00:33:41,220 --> 00:33:43,840 And when this binary is executed, 599 00:33:44,000 --> 00:33:46,800 we inherit the current privileges of the process. 600 00:33:47,740 --> 00:33:50,700 This particular code doesn't do a clean exit, 601 00:33:50,820 --> 00:33:51,260 so... 602 00:33:51,260 --> 00:33:51,600 So... 603 00:33:52,040 --> 00:33:54,980 It'll actually crash when the program has been executed. 604 00:33:59,900 --> 00:34:02,980 So, where do we inject the shell code? 605 00:34:04,320 --> 00:34:07,360 We could use the command line in the overflow, 606 00:34:08,220 --> 00:34:11,200 but that suffers from a lot of heavy input restrictions, 607 00:34:11,960 --> 00:34:14,920 control codes and stuff like that in the command line interface. 608 00:34:15,940 --> 00:34:21,040 I also use Telnet to automate this exploitation, 609 00:34:21,300 --> 00:34:22,020 and you get... 610 00:34:22,020 --> 00:34:24,220 You get some input restrictions there as well, 611 00:34:24,320 --> 00:34:27,000 but you can easily overcome them with the terminal settings. 612 00:34:29,260 --> 00:34:32,380 What I did was that I populated a target process 613 00:34:32,380 --> 00:34:33,780 with data in certain areas, 614 00:34:33,920 --> 00:34:36,840 and then crashed it and scanned the core dump, basically, 615 00:34:36,940 --> 00:34:39,400 to see where the data was located. 616 00:34:41,760 --> 00:34:46,020 You can use the analyze program to take a look at core dumps, 617 00:34:46,020 --> 00:34:48,840 to eval registers, dump certain area of memories, 618 00:34:48,980 --> 00:34:50,980 and assemble instructions. 619 00:34:54,640 --> 00:34:58,180 You can also use the analyze program to get a nice list 620 00:34:58,180 --> 00:35:00,740 of the different memory segments in the process. 621 00:35:01,120 --> 00:35:05,480 This gives you hints about where you could search 622 00:35:05,480 --> 00:35:07,220 for the data you have injected. 623 00:35:10,860 --> 00:35:13,560 I first found my string or my shell code 624 00:35:13,560 --> 00:35:15,600 in the command line interface data segment, 625 00:35:15,840 --> 00:35:17,700 but I couldn't execute it there. 626 00:35:17,740 --> 00:35:18,620 I got an access violation, 627 00:35:18,960 --> 00:35:21,400 so I decided to fiddle a little with the input restrictions, 628 00:35:21,400 --> 00:35:22,680 and tried to make a shell code 629 00:35:22,680 --> 00:35:26,040 that copies the shell code to another location, 630 00:35:28,420 --> 00:35:32,540 and removed some input filtering in the Telnet client. 631 00:35:35,260 --> 00:35:37,200 I ended up with a shell code 632 00:35:37,200 --> 00:35:40,380 that only uses the LDA instructions, 633 00:35:40,640 --> 00:35:43,100 since I got an opcode that was accepted 634 00:35:43,100 --> 00:35:44,080 by the input filtering. 635 00:35:44,600 --> 00:35:46,640 However, this didn't work, 636 00:35:46,720 --> 00:35:50,340 since I didn't even have permissions to read at that, 637 00:35:51,820 --> 00:35:55,700 in the command line interface data segment. 638 00:35:55,960 --> 00:35:59,080 So, it didn't really help me much, 639 00:35:59,240 --> 00:36:02,740 but it's a nice code to use in other exploits. 640 00:36:05,600 --> 00:36:09,800 So, we can actually use and execute code in logicals, 641 00:36:09,800 --> 00:36:13,240 with nulls even, so you just have to upload your shell code 642 00:36:13,240 --> 00:36:16,040 into a logical, and then dump there to execute it. 643 00:36:18,280 --> 00:36:19,280 When analyzing 644 00:36:21,620 --> 00:36:24,320 when finding the address of the shell code, 645 00:36:24,400 --> 00:36:26,140 you can use the analyze program as well, 646 00:36:26,760 --> 00:36:29,700 and they use the clue process logical command 647 00:36:29,700 --> 00:36:32,560 to get the direct address of the shell code, 648 00:36:32,640 --> 00:36:33,780 but you need system for this, 649 00:36:33,920 --> 00:36:36,640 so if you don't have the possibilities 650 00:36:36,640 --> 00:36:41,260 to increase those permissions when researching, 651 00:36:41,520 --> 00:36:44,360 you could simply just scan the core dump as well. 652 00:36:49,780 --> 00:36:50,240 Yeah. 653 00:36:50,380 --> 00:36:54,220 So, what I did was that I wrote a proof of concept exploit 654 00:36:54,220 --> 00:36:57,760 that calls the creative process system service. 655 00:36:58,340 --> 00:37:02,280 I first uploaded the shell code using a tool 656 00:37:02,280 --> 00:37:04,420 that simply just adds it to logical 657 00:37:04,420 --> 00:37:05,660 and spawns a sub-process, 658 00:37:06,920 --> 00:37:10,740 and then I wrote a little program called file.exe, 659 00:37:10,800 --> 00:37:17,220 which simply just prints the privileges 660 00:37:17,220 --> 00:37:18,400 of the current process. 661 00:37:20,240 --> 00:37:22,200 I need to wait to see what kind of privileges 662 00:37:22,200 --> 00:37:23,460 you gain from the target. 663 00:37:25,940 --> 00:37:29,780 Unfortunately, we got some problems with the video, so... 664 00:37:36,420 --> 00:37:37,520 What's going on? 665 00:37:37,920 --> 00:37:38,340 That's fine. 666 00:37:39,980 --> 00:37:40,460 Yeah? 667 00:37:43,940 --> 00:37:45,140 Do you have... 668 00:37:45,140 --> 00:37:46,700 Hopefully we've got a tip. 669 00:37:50,240 --> 00:37:50,880 Just do that. 670 00:37:53,940 --> 00:37:55,200 Just do that. 671 00:37:57,060 --> 00:38:01,760 Yeah, I gotta tell you this, 672 00:38:01,780 --> 00:38:02,020 . 673 00:38:02,020 --> 00:38:03,000 Okay. 674 00:38:04,260 --> 00:38:04,940 Okay. 675 00:38:05,800 --> 00:38:06,480 Okay. 676 00:38:06,480 --> 00:38:07,120 Okay. 677 00:38:30,420 --> 00:38:30,600 Thank you. 678 00:38:37,120 --> 00:38:37,380 Any more tips? 679 00:38:41,300 --> 00:38:41,900 What? 680 00:38:43,880 --> 00:38:44,620 Yes, sir. 681 00:38:45,480 --> 00:38:46,080 Okay. 682 00:38:51,620 --> 00:38:52,520 It worked? 683 00:38:52,820 --> 00:38:53,020 Yeah. 684 00:38:54,600 --> 00:38:55,200 Okay. 685 00:38:57,400 --> 00:38:58,260 Thank you. 686 00:38:58,920 --> 00:39:03,220 Okay, so this is my proof of concept code exploit. 687 00:39:03,520 --> 00:39:06,680 We start by attacking the install program. 688 00:39:07,120 --> 00:39:11,180 So we connect to the target machine, 689 00:39:11,400 --> 00:39:16,540 and I first delete the privilege file that is generated by the file.exe program, 690 00:39:17,260 --> 00:39:21,580 and then just run it and take a look at what kind of privileges we have, 691 00:39:21,640 --> 00:39:22,780 and it's only the default. 692 00:39:31,600 --> 00:39:33,940 Then we load the shell code into the logical, 693 00:39:34,200 --> 00:39:36,100 spawns the subprocess for us, 694 00:39:37,380 --> 00:39:40,580 then we run the install program and trigger the vulnerability. 695 00:39:40,900 --> 00:39:44,440 Now the install program will crash when the shell code is executed, 696 00:39:44,580 --> 00:39:48,780 since it doesn't handle the exit after that. 697 00:39:49,780 --> 00:39:54,140 So now we just have to take a peek into the briefs.txt file 698 00:39:54,140 --> 00:39:57,420 to see what privileges the program has when it was executed. 699 00:39:58,840 --> 00:40:02,820 And as you can see, we got kernel privileges now, 700 00:40:02,960 --> 00:40:04,640 so we can actually run kernel code. 701 00:40:14,020 --> 00:40:21,920 And this exploit also works for a lot of other targets, 702 00:40:21,980 --> 00:40:22,920 as I mentioned. 703 00:40:23,100 --> 00:40:27,980 In this case, we are attacking the TCP IP program the same way. 704 00:40:28,260 --> 00:40:31,400 Okay, so... 705 00:40:35,720 --> 00:40:36,920 Still have the default. 706 00:40:36,920 --> 00:40:38,640 Default set of privileges for this user. 707 00:40:44,480 --> 00:40:45,600 Load the shell code, 708 00:40:46,220 --> 00:40:47,180 spawn a subprocess, 709 00:40:50,560 --> 00:40:52,400 and then the TCP IP program, 710 00:40:54,080 --> 00:40:55,100 trigger the vulnerability, 711 00:40:56,080 --> 00:40:57,640 and the program will crash. 712 00:41:00,220 --> 00:41:02,360 And we peek into the privilege file 713 00:41:02,360 --> 00:41:05,180 to see that we gained, actually, 714 00:41:05,340 --> 00:41:06,900 physical IO privileges, 715 00:41:06,920 --> 00:41:07,240 and we can see that we gained a lot of privileges. 716 00:41:13,660 --> 00:41:14,100 Yeah. 717 00:41:19,940 --> 00:41:22,500 I can show you the last one as well. 718 00:41:22,700 --> 00:41:25,520 It's for the Telnet program. 719 00:41:29,280 --> 00:41:31,920 So we run the exploit again with Telnet as target, 720 00:41:32,940 --> 00:41:35,400 just as we did before. 721 00:41:36,460 --> 00:41:36,900 Just as we did before. 722 00:41:47,060 --> 00:41:47,900 All right. 723 00:41:57,920 --> 00:41:58,780 Let's hug one another here. 724 00:41:58,780 --> 00:42:00,080 So, try to get created all the painful components 725 00:42:00,080 --> 00:42:01,780 and fruit problems. 726 00:42:01,780 --> 00:42:02,680 All right. 727 00:42:06,400 --> 00:42:06,420 Thank you. 728 00:42:15,620 --> 00:42:17,100 And now we got 729 00:42:17,100 --> 00:42:18,940 Oprah privileges as well. 730 00:42:20,820 --> 00:42:22,040 Okay, I think that 731 00:42:22,040 --> 00:42:23,880 Krister is going to show his 732 00:42:25,920 --> 00:42:27,860 video of his exploit as well. 733 00:42:55,120 --> 00:42:57,260 So, I'm logging on to my 734 00:42:57,260 --> 00:42:59,200 books with my normal user. 735 00:43:03,020 --> 00:43:05,200 And I tried to set 736 00:43:05,200 --> 00:43:06,440 all privileges for 737 00:43:06,440 --> 00:43:08,180 my process and it's not 738 00:43:08,180 --> 00:43:11,740 working. And I look at what 739 00:43:13,080 --> 00:43:15,000 privileges I do have, and I 740 00:43:15,000 --> 00:43:16,560 just have the default ones. 741 00:43:21,660 --> 00:43:23,160 So, I compile the exploit. 742 00:43:30,840 --> 00:43:32,880 And I link the exploit. 743 00:43:34,940 --> 00:43:36,400 And run it. 744 00:43:38,240 --> 00:43:41,440 So, at this point, the exploit has run. 745 00:43:42,180 --> 00:43:44,720 And I've modified my user record. So, 746 00:43:44,820 --> 00:43:46,480 next time I'm logging in, I'm going to 747 00:43:46,480 --> 00:43:51,620 have full privileges. So, let's try that. 748 00:44:07,420 --> 00:44:09,600 So, I'm enabling all privileges. 749 00:44:10,800 --> 00:44:13,100 And then I show all privileges. 750 00:44:13,320 --> 00:44:16,280 And you can see I've got a lot more privileges now. 751 00:44:20,000 --> 00:44:21,440 Actually, I've got all of them. 752 00:44:24,740 --> 00:44:26,520 So, I think that's it. 753 00:44:30,520 --> 00:44:31,580 Any questions? 754 00:44:31,900 --> 00:44:32,540 Okay. 755 00:44:33,760 --> 00:44:34,400 Okay. 756 00:44:35,780 --> 00:44:36,420 Okay. 757 00:44:38,080 --> 00:44:38,560 Thank you. 758 00:44:38,880 --> 00:44:39,360 . 759 00:44:39,360 --> 00:44:41,840 It seems like this is a privilege escalation 760 00:44:41,840 --> 00:44:42,120 attack. 761 00:44:42,580 --> 00:44:46,240 Did you find any vulnerabilities you can take advantage of without having an actual 762 00:44:46,880 --> 00:44:48,200 account in the first place? 763 00:44:49,860 --> 00:44:50,660 These are local. 764 00:44:51,180 --> 00:44:52,940 These are local, yes. 765 00:44:53,920 --> 00:44:55,560 Yeah, but . 766 00:44:57,160 --> 00:44:57,640 Okay. 767 00:45:04,200 --> 00:45:04,680 Okay. 768 00:45:04,740 --> 00:45:05,400 Thank you. 769 00:45:06,420 --> 00:45:06,720 Thank you.