1 00:00:00,000 --> 00:00:03,640 They're going to be doing a talk on attacking Oracle from the Metasploit project. 2 00:00:06,480 --> 00:00:11,960 All right, thanks. Let's get started. Thanks for either staying up late or waking up early. 3 00:00:13,140 --> 00:00:20,200 So this is me, Chris Gates, part of the Metasploit project, pen tester by day, blogger, security twit, all the other stuff. 4 00:00:20,320 --> 00:00:22,880 If you want to know more, ask me or bust out your Maltego license. 5 00:00:25,060 --> 00:00:30,200 My name is Mario Ceballos. I'm kind of known as MC within the framework. 6 00:00:32,600 --> 00:00:39,520 I'm sorry, now? Okay, again, my name is Mario Ceballos, known as MC from within the framework. 7 00:00:40,520 --> 00:00:44,840 I do a lot of vulnerability research, exploit development. Some of that stuff ends up in the framework. 8 00:00:45,040 --> 00:00:50,660 A lot of it doesn't. My primary focus is on auxiliary modules and code execution vulnerabilities. 9 00:00:51,240 --> 00:00:52,840 And for a day job, I... 10 00:00:52,880 --> 00:00:53,380 All right, do pen testing. 11 00:00:56,800 --> 00:01:00,920 So a quick disclaimer. This is not our employers. Everyone has to do that one. 12 00:01:01,140 --> 00:01:06,420 And then the other disclaimer is, with the exception of some SQL injection that Mario found, most of this stuff is not new. 13 00:01:06,540 --> 00:01:07,700 It's been around for quite a while. 14 00:01:08,320 --> 00:01:14,980 It's been really hard to put all these random SQL files and Perl scripts and everything together to kind of put a whole attack together. 15 00:01:15,380 --> 00:01:22,540 So what we did, one of the things I was kind of going for when we did this was to put a process in place for pen testing 16 00:01:22,880 --> 00:01:27,580 in Oracle, and Mario's going to talk a bit about some of the other things he did and why he built this stuff. 17 00:01:27,780 --> 00:01:30,220 But that was the big thing, is we didn't invent or discover it. 18 00:01:30,260 --> 00:01:33,800 We just tried to streamline the process and make it easier for all of us that are doing pen testing. 19 00:01:35,780 --> 00:01:36,900 So why are we focused? 20 00:01:37,040 --> 00:01:40,120 So lots of pen tests, I've seen lots of potential Oracle clients. 21 00:01:41,160 --> 00:01:52,020 From my experience, and everyone's experience is going to differ, people are either falling into the, I have a DBA and his own personal hell is making sure he's doing this Oracle stuff, or they don't. 22 00:01:52,020 --> 00:01:52,860 And I'd say, oh, you got Oracle stuff. 23 00:01:52,860 --> 00:01:55,180 If you've got Oracle on your network, who's in charge of the MetaLink account? 24 00:01:55,340 --> 00:01:56,320 And they'd be like, what's a MetaLink account? 25 00:01:57,940 --> 00:02:05,520 So with the Oracle business model of allowing free downloads, but no updates without paying, we started seeing lots of default installs out on the network. 26 00:02:06,160 --> 00:02:11,340 And privilege escalation is easy and data theft is easy, but you know, it's Metasploit, so we want shells. 27 00:02:15,480 --> 00:02:22,780 So why we did this, there's not a lot of, actually, I don't know of any support in any of the for pay frameworks that will go after any, like, 28 00:02:22,820 --> 00:02:22,840 support in any of the for pay frameworks that will go after any, like, support in any of the for pay frameworks that will go after any, like, 29 00:02:22,860 --> 00:02:24,100 SQL injection vulnerabilities in Oracle. 30 00:02:24,720 --> 00:02:27,720 Saint will do some of the memory corruption stuff that's in the default packages. 31 00:02:28,500 --> 00:02:31,220 But maybe Core does now, I haven't seen it. 32 00:02:31,600 --> 00:02:33,780 And some of the other open source tools that do that are in Guma. 33 00:02:34,140 --> 00:02:36,200 I'm not sure it's still being worked on. 34 00:02:36,540 --> 00:02:37,660 Orisploit, that's not public. 35 00:02:38,080 --> 00:02:44,500 And then some commercial tools that focus more on doing VAs against Oracle and less on exploitation. 36 00:02:48,200 --> 00:02:50,820 All right, so I, okay, now, right, cool. 37 00:02:51,180 --> 00:02:52,820 So some of the current Metasploit support. 38 00:02:52,860 --> 00:02:55,940 We have is more on, again, the memory corruption vulnerabilities. 39 00:02:57,060 --> 00:03:00,560 This stuff's kind of supported by myself and a few other developers. 40 00:03:01,000 --> 00:03:09,740 We got coverage for things like Oracle secure backup, WebLogic, WebLogic overflow, a couple of TNS listener version, 41 00:03:09,960 --> 00:03:13,220 or TNS listener process overflows in different pieces. 42 00:03:14,400 --> 00:03:22,260 We also have some auxiliary modules that we kind of stuck in there at first using a file format mix and to take advantage of some of the SQL injection flaws that 43 00:03:22,860 --> 00:03:24,320 we're going to be talking about. 44 00:03:25,980 --> 00:03:31,960 Those are kind of obsolete now, I kind of removed those Tuesday and kind of rewrote those to use a new mixin' we're going to get into. 45 00:03:32,180 --> 00:03:41,920 And a really cool NTLM stealer, which doesn't really inject anything, but kind of tells the Oracle instance to pretty much mount an SMB share on our side. 46 00:03:42,120 --> 00:03:50,780 And then we pretty much relay that hash and log back in to the, you know, the Oracle instance as the credentials we received from DBMS. 47 00:03:52,860 --> 00:03:54,360 So, I'm sorry. 48 00:03:54,960 --> 00:03:55,620 All right. 49 00:03:55,660 --> 00:03:56,860 So, cool. 50 00:03:57,060 --> 00:03:58,500 So, new Metasploit support. 51 00:03:59,940 --> 00:04:06,240 I think sometime last year I kind of wrote a TNS mixin' to support one of the, a couple of TNS overflows that I was writing. 52 00:04:07,860 --> 00:04:15,600 Doing all that work up front pretty much helped me out to do a lot of other things that weren't really exploit related. 53 00:04:19,040 --> 00:04:21,700 And again, so that mixin', which pretty much is just, 54 00:04:21,740 --> 00:04:22,740 creates a dynamic. 55 00:04:22,740 --> 00:04:31,440 TNS packet, it's used for our SID enumeration tool, our brute force enumeration tool, our, what else we got there? 56 00:04:32,740 --> 00:04:38,780 A lot, what happened is that we ended up getting a full blown TNS command.PL port into the framework. 57 00:04:39,400 --> 00:04:49,560 But the big thing about this talk here is an injection of our Oracle mixin', which pretty much is what allows us to do all the magic we're probably going to show you here in a second. 58 00:04:51,400 --> 00:04:52,600 A couple of dependencies. 59 00:04:52,600 --> 00:04:55,740 We're wrapped around the Oracle instant client for the direct database access. 60 00:04:56,280 --> 00:05:05,720 We're using a really lightweight API for the database execution of our SQL statements and we're using an OCA Ruby driver. 61 00:05:06,440 --> 00:05:09,320 It's kind of broke with the newer versions of Ruby 1.9. 62 00:05:09,440 --> 00:05:09,680 Right. 63 00:05:09,920 --> 00:05:10,400 So. 64 00:05:10,700 --> 00:05:12,400 It doesn't work on Windows yet either. 65 00:05:12,540 --> 00:05:12,740 So. 66 00:05:12,940 --> 00:05:13,420 Right. 67 00:05:13,500 --> 00:05:13,720 Sorry. 68 00:05:13,720 --> 00:05:14,180 Yeah. 69 00:05:14,440 --> 00:05:18,000 So anybody who can get that stuff, I mean, I usually develop under Linux or OS 10. 70 00:05:18,160 --> 00:05:18,980 I don't touch Windows. 71 00:05:19,540 --> 00:05:20,780 I might attack it. 72 00:05:22,600 --> 00:05:27,900 And Eric, I mean, Chris has a link here to the install P2, right? 73 00:05:28,020 --> 00:05:28,340 So. 74 00:05:30,880 --> 00:05:36,480 So with the mixin' we kind of, with the mixin' I kind of create a couple of methods that are really simple to use. 75 00:05:36,620 --> 00:05:37,320 Straight forward. 76 00:05:37,720 --> 00:05:38,520 Connect, disconnect. 77 00:05:39,280 --> 00:05:46,380 Those two methods are used for our brute force module that looks for default known accounts given a correct SID. 78 00:05:46,980 --> 00:05:50,000 The per exec method does just that. 79 00:05:50,020 --> 00:05:51,000 It takes a statement. 80 00:05:51,120 --> 00:05:52,500 It makes sure that it's correct. 81 00:05:53,080 --> 00:05:55,520 Sends it off to the remote service. 82 00:05:56,560 --> 00:06:02,980 And if things are correct, you know, it spits out a pretty nice format of what you just sent off. 83 00:06:06,260 --> 00:06:09,760 This is just a quick example of the output of our. 84 00:06:10,320 --> 00:06:15,960 So what we've done is essentially made a really simple SQL client from within the framework to talk to the database. 85 00:06:16,440 --> 00:06:20,600 So, yeah, you can do some administrative tasks that we've gotten from Carlos Perez. 86 00:06:20,700 --> 00:06:22,480 And I think Rory, if you're in the room. 87 00:06:22,500 --> 00:06:27,520 But it's kind of used for more of the evil stuff that we're doing. 88 00:06:30,160 --> 00:06:31,040 All right. 89 00:06:31,360 --> 00:06:36,880 So from a tag methodology point of view, we need four things to connect to an Oracle database. 90 00:06:37,120 --> 00:06:38,600 We need to know what IP it's on, obviously. 91 00:06:39,040 --> 00:06:41,700 What port it's listening on, if it's on its default 1521. 92 00:06:42,460 --> 00:06:48,080 The service identifier, which is kind of the unique name for the Oracle database. 93 00:06:48,220 --> 00:06:48,960 And a username and password. 94 00:06:49,140 --> 00:06:50,200 So that makes sense, right? 95 00:06:51,220 --> 00:06:52,200 So from it. 96 00:06:52,200 --> 00:06:54,380 First thing, locate Oracle systems. 97 00:06:54,960 --> 00:06:57,180 So we got NMAP information disclosure. 98 00:06:57,440 --> 00:07:02,380 So maybe as you're doing some other pen testing or some web app work, you'll see that there's some Oracle errors coming back. 99 00:07:02,560 --> 00:07:04,180 Or you'll just kind of stumble across it. 100 00:07:04,220 --> 00:07:04,620 Or Google. 101 00:07:04,800 --> 00:07:08,980 So if you're doing an organization, you may see if they have any kind of public presence via Google. 102 00:07:10,060 --> 00:07:15,880 Starting with, like, I know with 4.9 and NMAP, it will now return the TNS listener version. 103 00:07:16,340 --> 00:07:17,580 Which is actually really handy. 104 00:07:17,720 --> 00:07:19,720 Up until, you know, that, it was really hard. 105 00:07:19,800 --> 00:07:21,380 You would just get an open Oracle port. 106 00:07:21,380 --> 00:07:25,780 Which wouldn't really tell you too much what version it was, what status that thing was in. 107 00:07:25,920 --> 00:07:27,960 So the new NMAP is actually really handy for that. 108 00:07:28,440 --> 00:07:30,460 And you can also look for other common Oracle ports. 109 00:07:31,720 --> 00:07:33,740 So 1158 is your enterprise manager console. 110 00:07:33,840 --> 00:07:37,280 Your 5560, your SQL plus web portal. 111 00:07:39,020 --> 00:07:41,300 Plenty of Google dorks if you want to locate Oracle systems. 112 00:07:42,120 --> 00:07:45,620 The red database security guy wrote some really good white papers on using those. 113 00:07:47,120 --> 00:07:48,460 Sometimes they come pre-owned. 114 00:07:48,560 --> 00:07:49,400 I don't know if you can see that one. 115 00:07:49,460 --> 00:07:50,980 But I found that one doing some Google dorks. 116 00:07:51,380 --> 00:07:52,260 Logged in with Scott Tiger. 117 00:07:52,360 --> 00:07:53,020 And he was already DBA. 118 00:07:53,500 --> 00:07:55,360 So someone got to that one before I did. 119 00:07:57,820 --> 00:08:02,900 Happens actually quite a bit if you, not that I would ever encourage you to go look for open Oracle boxes. 120 00:08:03,040 --> 00:08:05,740 But if you do, you'll probably find quite a lot of them are already owned. 121 00:08:07,060 --> 00:08:08,880 So determining version is obviously key. 122 00:08:09,080 --> 00:08:12,220 We need to know, we need to know what version things are. 123 00:08:12,280 --> 00:08:15,360 So we know what exploits and SQL injection things to tailor toward it. 124 00:08:15,940 --> 00:08:17,880 So what we do here, you know what? 125 00:08:17,940 --> 00:08:19,000 I'm all in Mario's slide. 126 00:08:19,240 --> 00:08:19,400 Go ahead. 127 00:08:19,400 --> 00:08:19,560 Okay. 128 00:08:21,040 --> 00:08:25,940 So what we do here is we send a TNS version packet with the TNS mix in. 129 00:08:26,240 --> 00:08:28,240 And it just parses out the results. 130 00:08:28,480 --> 00:08:32,880 And I haven't come across any issues with this ever not working for me. 131 00:08:33,040 --> 00:08:33,780 So that's pretty handy. 132 00:08:33,940 --> 00:08:36,600 Oracle needs to know, the instant client needs to know the version it's talking to. 133 00:08:36,740 --> 00:08:39,680 So it can do its handshake and make sure that it's allowed to talk. 134 00:08:41,580 --> 00:08:46,340 Mario's also at some point going to be pushing out some code that will query dbnsmp.exe that will do some information leakage. 135 00:08:46,340 --> 00:08:49,280 Which will help us see installed paths for Oracle. 136 00:08:49,800 --> 00:08:52,560 I think we also pushed out the TNS command one, right? 137 00:08:52,620 --> 00:08:55,400 There's also a port of tnscommand.pearl. 138 00:08:55,520 --> 00:08:56,900 It's now tnscommand.rb. 139 00:08:57,500 --> 00:09:02,920 Which will allow you to basically send whatever commands or information you want to via TNS. 140 00:09:03,260 --> 00:09:04,620 Which is pretty handy. 141 00:09:04,800 --> 00:09:06,180 There's a video I'll be pushing out later. 142 00:09:06,320 --> 00:09:10,740 Which you can set log files to whatever and do the old school Oracle 9 hacking with that. 143 00:09:12,340 --> 00:09:13,280 I think that's it. 144 00:09:13,680 --> 00:09:15,780 Oh, we have also all these scanner modules. 145 00:09:15,780 --> 00:09:17,960 Also have the report mixing built in. 146 00:09:18,080 --> 00:09:21,340 So if you want to use the database stuff, you can actually output that stuff to a database. 147 00:09:22,040 --> 00:09:22,840 You want to talk about that? 148 00:09:22,880 --> 00:09:26,140 Well, the big piece of that is because eventually we're going to go to the dbautopone stuff. 149 00:09:26,280 --> 00:09:28,660 So it makes things really easy to own massive stuff. 150 00:09:30,340 --> 00:09:31,060 So, yeah. 151 00:09:31,200 --> 00:09:32,080 So we get the data. 152 00:09:32,160 --> 00:09:32,620 We save it. 153 00:09:32,700 --> 00:09:34,500 And we get ready for some mass exploitation. 154 00:09:38,500 --> 00:09:39,220 Alright, cool. 155 00:09:39,360 --> 00:09:40,600 So determining the SID. 156 00:09:41,040 --> 00:09:42,400 This is the crucial thing. 157 00:09:42,820 --> 00:09:45,180 You can usually come across a username and password. 158 00:09:45,180 --> 00:09:48,420 Either social engineering or finding it on someone's desk or whatever. 159 00:09:48,660 --> 00:09:50,880 What's sometimes hard to find is that SID. 160 00:09:51,520 --> 00:09:52,400 It's critical. 161 00:09:52,540 --> 00:09:54,440 If you don't know the SID, you could know everything else. 162 00:09:54,500 --> 00:09:56,160 It could be a vulnerable Oracle box. 163 00:09:56,280 --> 00:09:58,800 If you can't connect to it, you can't do anything with it. 164 00:09:59,140 --> 00:10:04,200 So we've got a few modules that we built that actually help with that process. 165 00:10:05,380 --> 00:10:13,280 The first one is so with 9.2.0.8 and below, if you just send a status packet at it, it will actually give you the answer back. 166 00:10:13,440 --> 00:10:13,960 It will say, hey. 167 00:10:13,960 --> 00:10:15,740 My SID is ACMS. 168 00:10:15,820 --> 00:10:17,140 My service name is ACMS. 169 00:10:17,400 --> 00:10:18,700 And I've got all this other stuff running. 170 00:10:19,820 --> 00:10:22,320 After that, you'll get a listener protected. 171 00:10:22,660 --> 00:10:26,700 So the little code at the bottom there is showing that it was against an Oracle 10 box. 172 00:10:26,900 --> 00:10:27,800 And it's not going to give you anything. 173 00:10:29,740 --> 00:10:34,100 So if we won't give it to us directly, we've got a few other methods that we can kind of go after it. 174 00:10:34,840 --> 00:10:37,900 First thing we do is we can brute force for default SIDs. 175 00:10:38,220 --> 00:10:41,380 So we take the SID list from Red Database Security. 176 00:10:41,880 --> 00:10:43,120 Feel free to add to it. 177 00:10:43,120 --> 00:10:44,420 Mine's growing every day. 178 00:10:44,920 --> 00:10:48,020 And it just rips through and asks the Oracle instance, oh, are you Oracle? 179 00:10:48,080 --> 00:10:49,440 Are you DBMS? 180 00:10:49,640 --> 00:10:50,240 Are you Oracle 9? 181 00:10:50,460 --> 00:10:50,680 Whatever. 182 00:10:50,920 --> 00:10:55,680 And if it's right, it will give you a different error message back and parse that out for you. 183 00:10:58,420 --> 00:11:02,300 Or we can query other components that actually will contain the Oracle SID. 184 00:11:03,560 --> 00:11:05,800 The Enterprise Manager will show it to you. 185 00:11:06,340 --> 00:11:10,140 There's a couple Java servlets that will actually have the Oracle in the HTML. 186 00:11:10,140 --> 00:11:16,360 And what we've done is wrote some auxiliary modules that will actually run through the class C and check and see if they're there and then log those for you. 187 00:11:16,440 --> 00:11:20,360 So in this case at the bottom, we can see that the servlet spy is running. 188 00:11:20,560 --> 00:11:23,740 And we run the module and it found that the SID was Oracle. 189 00:11:25,380 --> 00:11:32,160 So if Enterprise Manager console is running, this is what you'll see if you just browse to the web page. 190 00:11:32,360 --> 00:11:39,780 But if you're auditing a big network or you're trying to automate some of these things, you don't want to browse to every page and then write down the answer. 191 00:11:40,140 --> 00:11:48,260 So we've got an OAS SID module down there at the bottom that will actually go through and parse out that HTML and give you the answer. 192 00:11:49,820 --> 00:11:51,200 Do you want to talk about some of the other modules? 193 00:11:51,440 --> 00:11:55,560 Well, I just want to kind of emphasize that we are logging everything. 194 00:11:55,680 --> 00:12:00,440 We're using another mixin called the report mixin and log everything to a local MySQL database or SQLite database. 195 00:12:00,600 --> 00:12:05,780 So as you're going through the network scanning and looking for potential targets, everything is saved. 196 00:12:06,960 --> 00:12:08,280 We don't want to waste any data. 197 00:12:08,360 --> 00:12:09,280 We don't want to rescan it. 198 00:12:09,320 --> 00:12:09,800 We don't have to. 199 00:12:10,140 --> 00:12:13,300 And, you know, unfortunately, we don't want to get caught either, though, too. 200 00:12:14,220 --> 00:12:14,620 All right. 201 00:12:18,120 --> 00:12:20,240 Next step, username and password. 202 00:12:20,700 --> 00:12:32,380 So, like I said, if you can't come across it by any other means or you've been had your scope restricted enough that you're going to have to do something that in the real world will get you caught, we have a login root script. 203 00:12:32,580 --> 00:12:37,100 We'll actually throw all the default Oracle usernames and passwords at the database. 204 00:12:37,100 --> 00:12:41,540 And if you get one that defines one that's right, it will actually, you know, log that for you. 205 00:12:42,620 --> 00:12:45,840 Again, using the reports mixin. 206 00:12:45,960 --> 00:12:50,240 So as we progress with DB autopone, all that stuff should automatically do stuff for you. 207 00:12:50,900 --> 00:12:56,640 And I should have updated the slide, but the actual output from the DB notes, we also saved the SID that we used. 208 00:12:56,760 --> 00:12:59,180 So, again, we don't have to go back and rescan. 209 00:13:00,100 --> 00:13:01,080 That's actually really important. 210 00:13:03,700 --> 00:13:04,260 All right. 211 00:13:04,300 --> 00:13:06,460 So privilege escalation via SQL injection. 212 00:13:08,240 --> 00:13:12,780 If anyone's unaware, there is a ton of default Oracle packages with SQL injection. 213 00:13:13,620 --> 00:13:20,720 Most of it is executable by public, which means if I can get any username and password, I can call that SQL injection. 214 00:13:21,320 --> 00:13:29,260 I'm not going to give a SQL injection 101 class, but the regular SQLI means you need to have a connect privilege. 215 00:13:29,360 --> 00:13:34,860 And if you don't have that, there's a cursor SQL injection that works in 9 and 10, requires a little bit less privileges. 216 00:13:35,960 --> 00:13:36,440 All right. 217 00:13:40,800 --> 00:13:43,780 I'll put out some more notes on that later. 218 00:13:45,240 --> 00:13:45,820 Go ahead. 219 00:13:46,320 --> 00:13:47,020 All right. 220 00:13:47,120 --> 00:13:51,580 So I guess we're going to step through a really generic module that we wrote. 221 00:13:53,620 --> 00:13:57,220 What we're highlighting here, okay, well, everything in black is just metadata of the module. 222 00:13:57,280 --> 00:13:57,800 It's just information. 223 00:13:58,780 --> 00:14:01,940 You can see the name of it, we're actually, we kind of picked this. 224 00:14:02,000 --> 00:14:05,380 The SIS.LTEFINDRICSET is the actual vulnerable package. 225 00:14:05,640 --> 00:14:06,440 And we're going to use the SIS.LTEFINDRICSET. 226 00:14:06,440 --> 00:14:09,540 Procedure that we're going to be exploiting in a short demo here 227 00:14:09,540 --> 00:14:15,600 We kind of chose this because a lot of other talks used the same injection method. We just put our own little twist to it 228 00:14:17,920 --> 00:14:24,400 The red is our actual I hate to say the word but our payload is what we want aren't you know our injection to to 229 00:14:24,400 --> 00:14:27,100 Perform and by default we grant the DBA 230 00:14:27,900 --> 00:14:31,820 Privileges to the user that we've used to log in and potentially exploit 231 00:14:33,320 --> 00:14:33,760 right 232 00:14:35,820 --> 00:14:40,400 What's what's handy, but what's handy about that is it doesn't always have to be grant DBA to Scott 233 00:14:40,400 --> 00:14:43,720 So if you just need to change your permission on a table or a file or something 234 00:14:43,720 --> 00:14:48,500 You can actually just use your sequel injection to do that versus grant and DBA because a lot of things as Mario's gonna talk 235 00:14:48,500 --> 00:14:53,560 About a grant DBA across the wire or in memory might flag on some things 236 00:14:55,960 --> 00:14:58,560 And it's fun just to grant DBA to your buddies too when you don't need it 237 00:15:00,940 --> 00:15:03,740 So now this part the nice thing about running your DBA is that you don't have to run your DBA 238 00:15:03,760 --> 00:15:08,500 Using the framework that we get a lot of access to other API to do some obfuscation of like 239 00:15:09,060 --> 00:15:14,920 Variable names function names and the name equals is just doing that we kind of randomize 240 00:15:14,920 --> 00:15:18,640 The function name in our what we what we declared as a function 241 00:15:19,280 --> 00:15:24,540 The off ID current user as is pretty much just a run this as whoever invoked it 242 00:15:25,520 --> 00:15:30,020 pragma autonomous transaction again, this is just a cookie cutter create and 243 00:15:30,020 --> 00:15:33,020 We create a replace function the problem 244 00:15:33,760 --> 00:15:40,380 Is that it's pretty much a but a problem that does a very member, right? It's been so long that I've done this stuff, man 245 00:15:41,340 --> 00:15:41,700 a 246 00:15:42,880 --> 00:15:46,660 Fork and join of the main process to the sub process 247 00:15:47,220 --> 00:15:49,480 It's been a long time since I wrote one of these so I'm sorry 248 00:15:49,940 --> 00:15:56,000 Then we just jump into our actual actual we begin execute immediate our foo and then return something 249 00:15:56,620 --> 00:16:01,500 You know fortunately returning a zero because we're returning and we want to return a number on top, but we're hackers 250 00:16:01,500 --> 00:16:03,260 We don't really care about the errors. We don't return shit 251 00:16:03,760 --> 00:16:04,740 And then we end it 252 00:16:07,440 --> 00:16:12,220 And then the actual vulnerable call to or the actual call to the vulnerable package 253 00:16:12,220 --> 00:16:19,040 And this again in this isn't it's assist LT find a rig set at which I think to find the LT has to do 254 00:16:19,040 --> 00:16:22,300 Was the workspace manager to find a rig set procedure? 255 00:16:23,160 --> 00:16:24,020 deals with 256 00:16:25,420 --> 00:16:27,920 versioning of a table name and 257 00:16:27,920 --> 00:16:31,200 The injection happens in the first argument, which is a table name 258 00:16:31,980 --> 00:16:33,680 the next thing we do is we 259 00:16:33,680 --> 00:16:37,100 Well, so we actually throw our injection. We we call it 260 00:16:38,020 --> 00:16:44,440 By calling our function and then we go back and we try to be somewhat clean and remove any residue that we left 261 00:16:44,440 --> 00:16:45,780 So we drop our function 262 00:16:46,820 --> 00:16:49,660 And you know, it's really simple. I mean, it's really 263 00:16:50,320 --> 00:16:55,800 The sequel is like maybe all together eight lines of code after we've done all the heart, you know 264 00:16:55,800 --> 00:16:56,860 All the work has been done up front 265 00:16:57,940 --> 00:17:03,040 So all you really got to do is when you're auditing these things is just focus on the vulnerability and then 266 00:17:03,040 --> 00:17:04,340 You can own a lot of stuff 267 00:17:06,260 --> 00:17:06,900 Anything else? 268 00:17:08,020 --> 00:17:13,780 The big thing for that is as you create new as you want to pour over the public sequel injection 269 00:17:13,780 --> 00:17:16,500 That package is really the only thing that you need to change 270 00:17:17,100 --> 00:17:20,520 Everything else is going to stay the same and you just need to change the package 271 00:17:20,520 --> 00:17:25,000 So instead of having to worry about all the pro code all the stuff that's handling all the connects disconnect 272 00:17:25,000 --> 00:17:27,700 You just need to worry about the actual injection. You're trying to exploit 273 00:17:28,420 --> 00:17:32,700 So hopefully that's pretty easy for everyone as they you know fuzz all the things and look at the Oracle 274 00:17:33,180 --> 00:17:35,280 CPUs, that's all you have to change one line of code 275 00:17:39,600 --> 00:17:42,580 All right, so everyone's probably seen this if you're familiar with the framework 276 00:17:43,400 --> 00:17:46,280 And these are also the four things I talked about that we needed to connect 277 00:17:46,880 --> 00:17:53,520 Set our remote host to set our IP the port our user password and the SID and then lastly we have that that payload 278 00:17:53,520 --> 00:17:57,780 Our sequel injection variable of whatever we want to run. So in this case, we're going to grant DBA to Scott 279 00:17:59,360 --> 00:17:59,720 Yeah 280 00:18:01,640 --> 00:18:04,660 And so this is kind of what it looks like when you're running it 281 00:18:04,660 --> 00:18:10,760 So again, we set our set our sequel it runs it creates the first function which is going to be some random function name 282 00:18:12,660 --> 00:18:15,420 Perform the actual injection and then remove the function 283 00:18:15,420 --> 00:18:19,520 So we clean up some that stuff still be in the transaction logs, but we're not leaving 284 00:18:19,520 --> 00:18:22,380 We're not leaving anything hanging for someone to find later 285 00:18:24,580 --> 00:18:25,240 Hopefully not 286 00:18:26,500 --> 00:18:29,580 And so that we can kind of see did it work it did you know now? 287 00:18:29,580 --> 00:18:34,240 After the injection Scott is now DBA. Yay, we can start on with the other fun 288 00:18:37,220 --> 00:18:41,660 Well, which works but you know, I'm a little more paranoid than most when I'm hacking so 289 00:18:43,740 --> 00:18:47,380 So, you know the previous slides it was really easy to take some code else public, you know 290 00:18:47,380 --> 00:18:49,480 Make it work and it did cool stuff 291 00:18:49,480 --> 00:18:51,680 but you know when you do that you kind of 292 00:18:51,680 --> 00:18:58,360 Let everything down and you get caught the screenshot of pretty much is a screenshot of the base interface that SAR attacked 293 00:18:58,880 --> 00:18:59,300 actually 294 00:18:59,300 --> 00:19:06,340 What you know signature flagged what function what package or procedure was called and what you know what it did? 295 00:19:08,820 --> 00:19:09,660 That's not fun 296 00:19:11,020 --> 00:19:16,120 So, yeah, you get caught real fast doing you know pretty much, you know hacking naked 297 00:19:17,860 --> 00:19:20,760 So I kind of saw that this, you know 298 00:19:20,760 --> 00:19:24,860 I kind of put in a couple of examples in the framework to do just bypassing snort 299 00:19:25,820 --> 00:19:28,180 They have some static signatures for these particular 300 00:19:28,180 --> 00:19:29,620 This particular bug 301 00:19:30,860 --> 00:19:32,880 Really easy on the Metasploit side 302 00:19:32,880 --> 00:19:41,000 We just kind of base 64 encode our entire entire, you know intact our entire function and then our call to the vulnerable 303 00:19:41,920 --> 00:19:44,020 package or procedure and 304 00:19:44,020 --> 00:19:48,200 Then on the DBMS side we use some UTL tricks to actually decode it 305 00:19:48,200 --> 00:19:53,400 And if you know you read from right to left we take that, you know, those is which you know 306 00:19:53,400 --> 00:19:55,920 It could be the package or the functioning whatever 307 00:19:56,600 --> 00:19:58,100 We read that back through the database 308 00:19:58,180 --> 00:20:01,340 So we take the 64 decode that the decode library the database has 309 00:20:01,880 --> 00:20:06,420 We throw that back in the string then we go ahead and execute that that works fine for almost any 310 00:20:07,300 --> 00:20:11,140 signature based ideas that's looking for these type of attacks a 311 00:20:12,040 --> 00:20:17,240 Little overkill anybody does real SQL can see that I'm not that good at it. I just don't want to get caught 312 00:20:18,220 --> 00:20:18,740 I just don't want to get caught 313 00:20:18,740 --> 00:20:21,660 That works on 10 and 11, not on 9 314 00:20:22,900 --> 00:20:23,880 I'll have to fix that 315 00:20:27,760 --> 00:20:28,160 I'll have to fix that 316 00:20:28,180 --> 00:20:34,260 Well, I mean we can add that evasion but if anybody's familiar with the Centrigo Hedgehog suite 317 00:20:34,900 --> 00:20:36,500 it's a like a 318 00:20:37,300 --> 00:20:41,340 Database hips and they have an Oracle agent that it's really cool 319 00:20:41,860 --> 00:20:45,580 It caught the x white because it kind of decodes everything from memory 320 00:20:46,760 --> 00:20:48,720 so over the network we came clean 321 00:20:49,520 --> 00:20:50,440 but the 322 00:20:51,240 --> 00:20:53,440 hips just flagged us and 323 00:20:54,020 --> 00:20:56,100 Gave up all of our access and you know 324 00:20:56,100 --> 00:20:58,160 And you know now the response team is like what the hell happened? 325 00:20:58,180 --> 00:21:02,220 Now we know who it is when they did it how they did it and then what they did 326 00:21:03,800 --> 00:21:09,660 Again, I'm not picking on Hedgehog. I just you know, that's what they claim they do this and they do that fairly well 327 00:21:13,060 --> 00:21:16,540 But we we can we can beat that stuff sometimes 328 00:21:18,260 --> 00:21:21,880 This slide is probably the hardest side for me to put in here because it's probably the most important 329 00:21:21,880 --> 00:21:24,000 It's just kind of bring brings back to yes 330 00:21:24,000 --> 00:21:28,100 And before I even get into it it kind of bring you back to the essence of you know what their framework is? 331 00:21:28,180 --> 00:21:28,660 about really 332 00:21:28,660 --> 00:21:33,320 So on the main side you see there's like these three things it's good for the the pen tester 333 00:21:33,320 --> 00:21:36,000 It gets for the researcher and it's good for people who write signatures 334 00:21:37,360 --> 00:21:43,320 Up to this point, you know, we're good for the pen tester and you know forthcoming slides is good for the pen tester 335 00:21:43,320 --> 00:21:45,420 but this one slide is is 336 00:21:45,980 --> 00:21:53,680 really why I wrote the stuff was to actually find other vulnerabilities or you know extend other vulnerabilities and you know fuzz and 337 00:21:55,100 --> 00:21:58,160 Yeah, and so what it did give me a really quick way of doing this stuff 338 00:21:58,180 --> 00:22:04,920 So again, it's Hedgehog again. We're attacking Hedgehog and I think in 06 there was a 339 00:22:05,580 --> 00:22:11,760 CVE that came out for the DBS meta packet metadata package having SQL vulnerabilities 340 00:22:12,620 --> 00:22:14,940 Then I think maybe a month two months later 341 00:22:14,940 --> 00:22:20,440 I'm not sure how long but there was this pro script that actually exploited one of the functions in the package 342 00:22:21,640 --> 00:22:22,140 so 343 00:22:22,720 --> 00:22:28,020 When I when I actually wrote that initial exploit that we were just pointing stuff over to make sure people had coverage for 344 00:22:28,020 --> 00:22:33,160 Certain things we ran this I ran this exploit against the Hedgehog and you know, it sought flawless 345 00:22:33,160 --> 00:22:38,940 You know what Hedgehog says that they're you know, they're able to catch Oday and you know things like that 346 00:22:38,940 --> 00:22:44,380 Well, even though it doesn't so much Oday is that there's other vulnerabilities within the same package that they're not covering 347 00:22:45,600 --> 00:22:46,120 so 348 00:22:47,060 --> 00:22:51,600 So I'd probably spend about you know using the new mixin and about me 349 00:22:51,600 --> 00:22:56,820 I don't know an hour worth of scrubbing the actual contents of the 350 00:22:56,820 --> 00:23:00,940 The package itself what a quick little fuzzer, you know 351 00:23:00,940 --> 00:23:06,220 And came up with like three other injects that for the same package that bypassed the hips 352 00:23:07,880 --> 00:23:10,340 Yeah, and you know again, I'm not I'm not picking on them 353 00:23:10,340 --> 00:23:13,020 but you know just don't trust your vendor to cover your butts when 354 00:23:13,020 --> 00:23:18,420 You know, I'm using old stuff and not even doing any evasion not doing any encoding 355 00:23:19,460 --> 00:23:24,160 Anything just coming through the network hacking naked and it still didn't see me although it did catch the grant DBA 356 00:23:24,640 --> 00:23:26,180 But the response team is you know 357 00:23:26,180 --> 00:23:27,940 They're like, what the hell causes grant DBA 358 00:23:28,880 --> 00:23:34,000 Which was some old, you know injection flow that they should have had covered for 359 00:23:36,320 --> 00:23:40,460 Yeah, so nothing against Pete Finnegan or Alvin Kornburt because they're I'm like 360 00:23:41,260 --> 00:23:43,180 They're all sharp cash. They do real DBA stuff 361 00:23:46,440 --> 00:23:51,420 So this is kind of a list of the initial push that we put out and the respective CVS 362 00:23:52,640 --> 00:23:54,740 That's by not by far. Not all the stuff 363 00:23:54,740 --> 00:23:56,440 stuff we have. We just wanted to do an initial push, 364 00:23:56,600 --> 00:23:58,520 let the community take a look at how 365 00:23:58,520 --> 00:24:00,560 we were doing this, how we were pushing out the SQL injection. 366 00:24:02,140 --> 00:24:02,520 What's 367 00:24:02,520 --> 00:24:03,900 in there is a good 368 00:24:05,160 --> 00:24:06,560 breadth of regular SQL 369 00:24:06,560 --> 00:24:08,060 injection, cursor SQL injection, 370 00:24:08,380 --> 00:24:10,140 and some of those modules are using 371 00:24:11,140 --> 00:24:12,540 Mario's, I'll call it IDS 372 00:24:12,540 --> 00:24:14,340 evasion, but it's not totally IDS evasion. 373 00:24:14,700 --> 00:24:16,540 But it should give everyone in the community that 374 00:24:16,540 --> 00:24:18,380 wants to start porting the rest of that SQL injection 375 00:24:19,000 --> 00:24:20,720 the ability to take a look at those modules, 376 00:24:20,860 --> 00:24:22,520 change the one line of code that they need to change, 377 00:24:22,520 --> 00:24:24,680 and push those back out to 378 00:24:24,680 --> 00:24:26,480 us, and we'll push them back out into the framework 379 00:24:26,480 --> 00:24:27,580 for everyone to use. 380 00:24:31,940 --> 00:24:32,600 Also, that's 381 00:24:32,600 --> 00:24:33,600 a good, it covers 382 00:24:33,600 --> 00:24:36,520 both 9s, both 10s, and 11s. 383 00:24:36,760 --> 00:24:38,600 So you should have something to play with 384 00:24:38,600 --> 00:24:40,420 for whatever you've got in your lab. 385 00:24:42,120 --> 00:24:42,700 So some 386 00:24:42,700 --> 00:24:44,840 post-exploitation stuff. 387 00:24:46,760 --> 00:24:47,980 I think this one's mine. 388 00:24:48,100 --> 00:24:49,860 So we could 389 00:24:49,860 --> 00:24:51,940 argue whether the data is more 390 00:24:51,940 --> 00:24:52,320 important. 391 00:24:52,520 --> 00:24:54,380 I think in most cases, the data actually 392 00:24:54,380 --> 00:24:56,460 is more important to us. So if we're DBA 393 00:24:56,460 --> 00:24:58,560 in the box, we now have 394 00:24:58,560 --> 00:25:00,340 access to pretty much any table or any data 395 00:25:00,340 --> 00:25:02,300 that we want. And if 396 00:25:02,300 --> 00:25:04,360 you're getting tasked to do a good pen 397 00:25:04,360 --> 00:25:06,380 test, this is where you need it to be, because 398 00:25:06,380 --> 00:25:08,160 you wanted to show them, I got access to this data. 399 00:25:08,720 --> 00:25:10,260 But using the SQL.RB 400 00:25:10,260 --> 00:25:12,360 thing, we can basically run commands, we can check 401 00:25:12,360 --> 00:25:13,940 access, we can make sure things are working right. 402 00:25:17,380 --> 00:25:17,780 So 403 00:25:18,420 --> 00:25:20,100 data's nice. This is Metaspoil. 404 00:25:20,200 --> 00:25:21,120 Everyone loves shells. 405 00:25:21,620 --> 00:25:22,780 So I love 406 00:25:22,780 --> 00:25:24,660 shells. I love breaking into stuff. So 407 00:25:24,660 --> 00:25:26,840 several published methods that have been around 408 00:25:26,840 --> 00:25:28,700 a while for actually running 409 00:25:28,700 --> 00:25:30,880 OS commands on the database, once 410 00:25:30,880 --> 00:25:32,700 you've got DBA access. 411 00:25:33,100 --> 00:25:34,820 So you can do it via Java. You can make 412 00:25:34,820 --> 00:25:36,080 some Java packages and classes. 413 00:25:36,880 --> 00:25:37,740 Xproc backdoors. 414 00:25:38,400 --> 00:25:41,020 Run OS commands via DBMS scheduler. 415 00:25:41,280 --> 00:25:42,720 Or, I mean, you can really roll 416 00:25:42,720 --> 00:25:44,820 your own. You can run any PL, SQL, or Java 417 00:25:44,820 --> 00:25:46,660 you want. And now 418 00:25:46,660 --> 00:25:48,680 with the post-exploitation modules we're pushing out, 419 00:25:48,760 --> 00:25:51,060 you can see that it's really easy just to write your own post-exploitation 420 00:25:51,120 --> 00:25:52,640 stuff. Use that prepare 421 00:25:52,640 --> 00:25:54,640 exec method in the 422 00:25:54,640 --> 00:25:56,560 API to run whatever you want. So 423 00:25:56,560 --> 00:25:57,500 it's pretty powerful. 424 00:25:58,800 --> 00:26:00,500 So the first one we'll talk about is 425 00:26:00,500 --> 00:26:02,760 Win32 exec. This is 426 00:26:02,760 --> 00:26:04,760 actually in the framework now. What you need to do 427 00:26:04,760 --> 00:26:06,440 is grant JavaSys privs 428 00:26:06,440 --> 00:26:08,400 to whatever user you're 429 00:26:08,400 --> 00:26:09,160 running as. 430 00:26:10,500 --> 00:26:12,680 From there, we can run the Win32 exec module 431 00:26:12,680 --> 00:26:14,820 to just run OS commands, and that's 432 00:26:14,820 --> 00:26:16,520 via Java. So net user ads, 433 00:26:16,740 --> 00:26:18,060 you can TFTP your Trojan over, 434 00:26:18,720 --> 00:26:19,920 do FTP batch scripts, 435 00:26:21,120 --> 00:26:22,720 I've also got a video out on the net of doing 436 00:26:22,720 --> 00:26:24,780 a net user ad to Metasploit, and then 437 00:26:24,780 --> 00:26:26,760 if we're on the LAN, we can do a PS exec 438 00:26:27,640 --> 00:26:28,560 to Meterpreter shell, 439 00:26:29,280 --> 00:26:30,300 which is pretty handy. 440 00:26:32,060 --> 00:26:32,620 Yeah, so 441 00:26:32,620 --> 00:26:34,620 that's kind of what it looks like. We set the command to whatever 442 00:26:34,620 --> 00:26:36,780 OS command we want to run, so we're adding 443 00:26:36,780 --> 00:26:38,080 a user DBA and a password. 444 00:26:39,240 --> 00:26:40,820 Creates the class, creates the procedure, 445 00:26:41,080 --> 00:26:42,840 runs the command, and it cleans up. It's not 446 00:26:42,840 --> 00:26:44,500 in the screenshot, but those also delete the 447 00:26:44,500 --> 00:26:46,780 Java classes that we create there, too. 448 00:26:47,620 --> 00:26:48,460 Anything to add on there? 449 00:26:48,660 --> 00:26:50,800 Yeah, I guess the stuff takeaway from 450 00:26:50,800 --> 00:26:52,620 this is that, you know, it's cool that 451 00:26:52,620 --> 00:26:54,520 we got the data, and if you're doing a pen test, 452 00:26:54,700 --> 00:26:56,640 the data's probably the important thing to show, but 453 00:26:57,080 --> 00:26:58,780 you know, if you want to escalate 454 00:26:58,780 --> 00:27:00,520 to the network a little more, it's probably better to 455 00:27:00,520 --> 00:27:02,500 break out of the Oracle sandbox 456 00:27:02,500 --> 00:27:04,720 and get to the operating system. And again, 457 00:27:04,800 --> 00:27:06,300 this is just one way of doing it. 458 00:27:10,640 --> 00:27:12,600 So some examples, some things you can do. 459 00:27:13,060 --> 00:27:14,480 You can echo over your 460 00:27:14,480 --> 00:27:16,640 FTP batch script via 461 00:27:16,640 --> 00:27:18,660 a util file, and then you can use 462 00:27:18,660 --> 00:27:20,700 DBMS schedule to run some things, and I did a 463 00:27:20,800 --> 00:27:22,800 video of this. It's 464 00:27:22,800 --> 00:27:24,480 on the Vimeo site, and 465 00:27:24,480 --> 00:27:26,060 the URL for that will be at the end. 466 00:27:26,400 --> 00:27:28,800 Just showing you some examples of some things you can do. 467 00:27:29,880 --> 00:27:30,760 Because Oracle 468 00:27:30,760 --> 00:27:32,600 is awesome, and it installs Perl with 469 00:27:32,600 --> 00:27:34,720 every install, on any 470 00:27:34,720 --> 00:27:36,620 kind of the Nix environments, you can actually just 471 00:27:36,620 --> 00:27:38,700 use the same util file and echo over a Perl shell, 472 00:27:39,320 --> 00:27:40,540 and then execute that. 473 00:27:40,720 --> 00:27:42,640 So that's something handy if you're on any kind 474 00:27:42,640 --> 00:27:43,700 of Unix environments. 475 00:27:45,300 --> 00:27:45,740 Good? 476 00:27:46,480 --> 00:27:47,220 Do you want to say something? 477 00:27:47,720 --> 00:27:49,160 Yeah, I did have a 478 00:27:49,740 --> 00:27:50,520 Nix variant. 479 00:27:50,800 --> 00:27:52,380 Of the Win32 exec stuff, it's 480 00:27:53,140 --> 00:27:55,340 not too clean, because everything has to be 481 00:27:55,340 --> 00:27:57,560 at the absolute path of what you want to execute. 482 00:27:58,620 --> 00:28:01,200 It does work, and you can use some 483 00:28:01,720 --> 00:28:03,820 server-side scripting, or decoding, like 484 00:28:03,820 --> 00:28:05,580 UU encode, UU decode, to do a lot of 485 00:28:06,120 --> 00:28:06,860 nasty stuff, too. 486 00:28:07,200 --> 00:28:09,820 So again, I'm a little paranoid when I hack. 487 00:28:12,520 --> 00:28:12,920 Evil. 488 00:28:13,820 --> 00:28:15,600 All right, so some other things we can do, 489 00:28:15,680 --> 00:28:17,820 external proc factors via directory 490 00:28:17,820 --> 00:28:20,380 traversals. So if you find yourself on an old Oracle 491 00:28:20,380 --> 00:28:24,620 box, you can actually use this method to just 492 00:28:24,620 --> 00:28:26,440 directory traverse out into either Windows 493 00:28:26,440 --> 00:28:30,920 LAN for MSV, CRT, DLL, or a libc, if you're on any 494 00:28:30,920 --> 00:28:34,440 kind of Linux environment or Nix environment, and 495 00:28:34,440 --> 00:28:36,800 we'll actually just allow you to invoke system commands 496 00:28:36,800 --> 00:28:37,280 that way. 497 00:28:37,460 --> 00:28:39,860 We'll be pushing that module out next week, once I 498 00:28:39,860 --> 00:28:41,500 make sure that it's cleaned up and working. 499 00:28:42,340 --> 00:28:43,460 That's kind of what it looks like. 500 00:28:43,580 --> 00:28:47,680 You set the path to wherever your Oracle binary or 501 00:28:47,680 --> 00:28:50,200 bin directory is, which you can use. 502 00:28:50,200 --> 00:28:52,720 You use your SQL.rb module to actually find that out for you. 503 00:28:52,760 --> 00:28:54,200 It's just one quick kind of look up. 504 00:28:56,200 --> 00:28:59,440 Just navigates out and calls it and lets you run your commands. 505 00:28:59,680 --> 00:29:01,260 Again, we're just using a net user add. 506 00:29:01,420 --> 00:29:04,020 Pretty simple, but sky's the limit on whatever OS commands you 507 00:29:04,020 --> 00:29:04,460 want to execute. 508 00:29:07,080 --> 00:29:09,700 Just showing that it worked, I added a Metasploit user. 509 00:29:09,900 --> 00:29:11,120 I also added him to the admin group. 510 00:29:11,420 --> 00:29:12,100 No big deal. 511 00:29:14,860 --> 00:29:18,060 Alex from Digital Security Research Group, who's actually 512 00:29:18,060 --> 00:29:19,780 put out a lot of SQL injection code. 513 00:29:19,780 --> 00:29:23,300 We've got a same external product backdoor, but in this 514 00:29:23,300 --> 00:29:25,960 case, instead of directory traversal-ing out, you can 515 00:29:25,960 --> 00:29:28,180 actually just copy the binary into your Oracle bin 516 00:29:28,180 --> 00:29:31,500 directory, so when Oracle patched the old vulnerability, 517 00:29:31,720 --> 00:29:32,840 it didn't really fix this one. 518 00:29:33,200 --> 00:29:37,260 This works on all the newer Oracles, so late 10Gs and 519 00:29:37,800 --> 00:29:42,160 Oracle 11 and 11.6 and 11.7, so it works pretty good, and 520 00:29:42,160 --> 00:29:43,380 we'll be pushing that out as well. 521 00:29:45,940 --> 00:29:46,560 All right. 522 00:29:46,600 --> 00:29:49,760 So the guys from our JPEG team, they're going to be 523 00:29:49,760 --> 00:29:49,800 doing a demo of this. 524 00:29:49,800 --> 00:29:51,780 So I'm going to have Dennis back in 2005 push out some code 525 00:29:51,780 --> 00:29:55,760 that would actually allow you to grab a binary from a remote 526 00:29:55,760 --> 00:30:00,880 web server and pull that back down into the, or back onto the 527 00:30:00,880 --> 00:30:03,960 OS, and then we can use the Win32 exec module to actually 528 00:30:03,960 --> 00:30:04,820 execute that binary. 529 00:30:05,500 --> 00:30:07,280 We'll be showing you a demo of that in a second. 530 00:30:08,940 --> 00:30:10,600 Again, DBMS scheduler backdoors. 531 00:30:10,780 --> 00:30:11,520 Alex sent that in. 532 00:30:11,580 --> 00:30:13,140 We'll be adding that to the SYN very soon. 533 00:30:14,700 --> 00:30:16,240 And he's going to talk about this in the end. 534 00:30:16,420 --> 00:30:17,040 Oh, yeah. 535 00:30:17,120 --> 00:30:19,320 I kind of alluded to this earlier, but this Oracle 536 00:30:19,700 --> 00:30:20,800 NTLM scheduler is the shit. 537 00:30:23,020 --> 00:30:25,500 I mean, all you really need is a user that has connect and 538 00:30:25,500 --> 00:30:28,860 resource privileges, and you just force, you know, use some 539 00:30:28,860 --> 00:30:32,520 CTX context, or ctxcontext.sys. 540 00:30:33,380 --> 00:30:35,520 Man, it's awesome, because you don't really have to inject 541 00:30:35,520 --> 00:30:37,020 anything, you just need a valid account. 542 00:30:37,320 --> 00:30:41,460 And again, you kind of go, you don't get back into the 543 00:30:41,460 --> 00:30:43,280 database, you go straight to the operating system using, 544 00:30:43,680 --> 00:30:45,320 you know, pass the hash type of stuff. 545 00:30:46,040 --> 00:30:46,840 Yeah, Alex rocks. 546 00:30:49,320 --> 00:30:53,640 That's actually a really good attack when, I mean, by default, 547 00:30:53,680 --> 00:30:56,640 Oracle will run a system, but a lot of people recommend to 548 00:30:56,640 --> 00:30:59,820 actually make it be an admin, run it as a different domain 549 00:30:59,820 --> 00:31:01,860 account, so this is a good example of, you know, obviously 550 00:31:01,860 --> 00:31:05,380 system doesn't have any domain cred, so your SMB relay is not 551 00:31:05,380 --> 00:31:06,860 going to work, because there's no way to log into that. 552 00:31:07,020 --> 00:31:10,000 But if it's running as an admin, you can now do the half 553 00:31:10,000 --> 00:31:12,120 LMs and SMB relay type stuff. 554 00:31:12,360 --> 00:31:14,920 And he wrote, actually, a whole white paper on why you would do 555 00:31:14,920 --> 00:31:17,780 that, so I highly recommend you go read it, because it's really 556 00:31:17,780 --> 00:31:19,300 good, and it's really, really solid. 557 00:31:19,320 --> 00:31:19,440 It's slick. 558 00:31:20,060 --> 00:31:22,240 I never even thought of that, and the way he did it, so. 559 00:31:29,460 --> 00:31:29,780 Yeah. 560 00:31:31,000 --> 00:31:31,600 Yeah, go ahead. 561 00:31:31,760 --> 00:31:32,180 Yeah, yeah. 562 00:31:32,280 --> 00:31:34,200 If the instance is running as a domain user or a domain 563 00:31:34,200 --> 00:31:34,820 account, yeah. 564 00:31:35,160 --> 00:31:35,900 That's when it works. 565 00:31:35,960 --> 00:31:38,360 By default, it'll go by system, and you have to go and click 566 00:31:38,360 --> 00:31:40,580 and free that, so it runs like an administrator user or 567 00:31:40,580 --> 00:31:41,020 something like that. 568 00:31:41,220 --> 00:31:43,980 So, yeah, it only works then, of course. 569 00:31:44,940 --> 00:31:45,420 But, yeah. 570 00:31:45,700 --> 00:31:45,920 Yeah. 571 00:31:46,240 --> 00:31:48,560 That's that special case when you, when they've actually done 572 00:31:48,560 --> 00:31:51,460 some hardening, and it's not running as system, so some of 573 00:31:51,460 --> 00:31:52,900 those other tricks aren't going to work for you. 574 00:31:57,600 --> 00:31:59,480 Mario says no, so I'm going to listen to him. 575 00:31:59,600 --> 00:32:00,140 No, no, no. 576 00:32:00,320 --> 00:32:00,660 Oh, it will? 577 00:32:00,780 --> 00:32:01,380 Yeah, it will. 578 00:32:01,500 --> 00:32:01,740 I'm sorry. 579 00:32:01,800 --> 00:32:02,120 Yes, it will. 580 00:32:03,000 --> 00:32:03,600 There you go. 581 00:32:04,820 --> 00:32:05,280 All right. 582 00:32:05,300 --> 00:32:08,780 So, one of the other modules that Mario pushed out is a simple 583 00:32:08,780 --> 00:32:09,720 CGI scanner. 584 00:32:11,540 --> 00:32:13,960 So, it'll help you kind of look for some of those vulnerable 585 00:32:14,760 --> 00:32:16,940 servlets and things that we were looking for earlier when we were 586 00:32:16,940 --> 00:32:19,080 trying to identify our SIDS. 587 00:32:19,480 --> 00:32:21,040 Just a little extra bonus. 588 00:32:21,380 --> 00:32:22,780 I mean, that's about it, right? 589 00:32:23,000 --> 00:32:23,280 Yeah. 590 00:32:23,280 --> 00:32:23,580 Yeah. 591 00:32:23,580 --> 00:32:24,020 Nothing special. 592 00:32:24,180 --> 00:32:24,320 Just. 593 00:32:27,240 --> 00:32:27,680 Okay. 594 00:32:28,740 --> 00:32:31,920 So, I guess before we get into Chris' demo, the way ahead, again, 595 00:32:32,820 --> 00:32:36,280 it goes back to the researching piece of what the framework is 596 00:32:36,280 --> 00:32:36,500 about. 597 00:32:37,240 --> 00:32:41,840 The reason why I kind of wrote this stuff was the same packages 598 00:32:41,840 --> 00:32:43,940 are vulnerable to overflows. 599 00:32:44,840 --> 00:32:46,920 It's not no secret that there's a lot of them out there. 600 00:32:46,940 --> 00:32:51,960 There's hundreds of packages, you know, that are executed by 601 00:32:51,960 --> 00:32:52,300 public. 602 00:32:53,000 --> 00:32:57,000 But, you know, under Windows, the point being is that, yeah, we 603 00:32:57,000 --> 00:32:57,900 have exploits for them. 604 00:32:58,740 --> 00:32:59,800 Eventually, we'll push them out. 605 00:32:59,880 --> 00:33:01,600 I kind of got them scattered about. 606 00:33:01,680 --> 00:33:02,420 They're not really clean. 607 00:33:04,680 --> 00:33:05,220 So, yeah. 608 00:33:05,460 --> 00:33:06,420 So, yeah. 609 00:33:07,140 --> 00:33:07,960 Overflow is where it's at. 610 00:33:08,640 --> 00:33:08,960 Okay. 611 00:33:09,780 --> 00:33:12,180 I'll add a little more to that because what's handy about this is 612 00:33:12,180 --> 00:33:15,080 if you've looked at any of the POCs for a lot of the memory 613 00:33:15,080 --> 00:33:16,460 corruption bugs that get pushed out. 614 00:33:17,400 --> 00:33:20,300 They're kind of confusing to look at and it's hard to 615 00:33:20,300 --> 00:33:21,140 reimplement that. 616 00:33:21,260 --> 00:33:23,840 So, what's really cool about the mixin and the stuff that Mario 617 00:33:23,840 --> 00:33:27,640 wrote is you don't have to worry about the setup, the connect or 618 00:33:27,640 --> 00:33:28,140 any of the other stuff. 619 00:33:28,220 --> 00:33:29,420 The mixin is doing that for you. 620 00:33:29,520 --> 00:33:32,620 All you really have to worry about now is the actual string that's 621 00:33:32,620 --> 00:33:33,160 doing the overflow. 622 00:33:33,420 --> 00:33:35,360 And that's kind of what this slide is supposed to be showing you 623 00:33:35,360 --> 00:33:39,700 that all the back end stuff is now handled for you by Metasploit. 624 00:33:39,800 --> 00:33:41,640 You don't need to worry about all that. 625 00:33:42,300 --> 00:33:44,880 You just need to focus on doing the vulnerability, you know, and 626 00:33:44,880 --> 00:33:45,660 exploit dev stuff. 627 00:33:48,340 --> 00:33:48,920 All right. 628 00:33:48,940 --> 00:33:49,580 So, I have a demo. 629 00:33:50,660 --> 00:33:53,680 I'm a little gun shy so I recorded it. 630 00:33:53,720 --> 00:33:53,960 Sorry. 631 00:33:56,820 --> 00:33:57,360 All right. 632 00:33:57,400 --> 00:34:00,460 So, the first thing we're going to do is run the TNLS listener 633 00:34:01,120 --> 00:34:03,660 version command which is going to give you the version of the TNS 634 00:34:04,900 --> 00:34:09,100 listener which is usually the same as the DB version but not always. 635 00:34:10,440 --> 00:34:12,440 Next thing we're going to do is try to do the sit enum. 636 00:34:13,080 --> 00:34:15,140 Because this is a 10 box, it's going to fail. 637 00:34:17,120 --> 00:34:19,700 But I just wanted to kind of show what kind of what it looks like 638 00:34:19,700 --> 00:34:20,420 when you try to run it. 639 00:34:20,500 --> 00:34:22,760 So, we've got a listener protected which we knew was going to happen 640 00:34:22,760 --> 00:34:23,540 because it was Oracle 10. 641 00:34:24,700 --> 00:34:27,120 Next thing we're going to try to do is try to brute force the SID. 642 00:34:27,960 --> 00:34:30,360 I added in a sleep variable. 643 00:34:31,180 --> 00:34:34,480 So, if you're doing this across the LAN, .1 is probably good. 644 00:34:34,560 --> 00:34:36,860 If you've got to go across a WAN, if you're kind of going after someone 645 00:34:36,860 --> 00:34:40,680 remote, you may need to LinkedIn that out to kind of help with some 646 00:34:40,680 --> 00:34:41,300 false positives. 647 00:34:44,680 --> 00:34:46,900 Now we're doing the account brute forcing. 648 00:34:49,080 --> 00:34:51,880 What's handy about this is it runs pretty fast and we actually just left 649 00:34:51,880 --> 00:34:54,780 the output so you could see that something was going on because sometimes 650 00:34:54,780 --> 00:34:56,760 it could take a long time over the net. 651 00:34:57,240 --> 00:35:01,320 And it writes all that out to a log file in your data word listing. 652 00:35:01,420 --> 00:35:05,360 So, you can actually query that later to make sure that it's there. 653 00:35:05,980 --> 00:35:07,640 So, you can see we found two accounts. 654 00:35:08,020 --> 00:35:09,940 These are the two default accounts for Oracle 10. 655 00:35:10,080 --> 00:35:11,220 So, DBSNP and Skype. 656 00:35:11,280 --> 00:35:11,500 This is Scott Tiger. 657 00:35:11,920 --> 00:35:13,900 We'll go after Scott because he's going to have the connect and 658 00:35:13,900 --> 00:35:14,980 resource privileges. 659 00:35:17,860 --> 00:35:19,580 So, this is the SQL.RB module. 660 00:35:19,820 --> 00:35:22,140 This allows us to kind of check our work, make sure that all the things that 661 00:35:22,140 --> 00:35:24,900 we found, the SID and the account are actually working. 662 00:35:26,040 --> 00:35:27,780 And it just allows you to run simple queries. 663 00:35:27,980 --> 00:35:31,180 And then this is kind of what Carlos is extending to do some of the admin 664 00:35:31,180 --> 00:35:31,480 checks. 665 00:35:32,540 --> 00:35:35,400 So, we just fill in our gaps, you know, the SID we found, the username 666 00:35:35,400 --> 00:35:35,800 and password. 667 00:35:36,600 --> 00:35:41,260 We're going to check his privileges and see what kind of permissions he's 668 00:35:41,280 --> 00:35:41,460 got that he has. 669 00:35:41,880 --> 00:35:43,080 So, he's got connect and resource. 670 00:35:49,020 --> 00:35:52,540 So, the next thing we need is we need to escalate him to DBA so we can do 671 00:35:52,540 --> 00:35:53,220 some fun things. 672 00:35:53,900 --> 00:35:56,240 So, we're just going to use the LTFindRigsetCursor method. 673 00:36:00,340 --> 00:36:02,820 I did my best to put where I got most of this stuff. 674 00:36:03,000 --> 00:36:05,480 So, if I missed something, just send me an email and I'll be happy to add it 675 00:36:05,480 --> 00:36:05,900 for you guys. 676 00:36:07,100 --> 00:36:09,940 Again, so we're just sending our SQL to grant DBA to Scott, filling in all 677 00:36:09,940 --> 00:36:10,300 the gaps. 678 00:36:10,480 --> 00:36:10,920 And that's it. 679 00:36:11,620 --> 00:36:12,300 Creates the method. 680 00:36:12,480 --> 00:36:13,140 Creates the function. 681 00:36:13,540 --> 00:36:14,040 Executes it. 682 00:36:14,140 --> 00:36:14,940 And then deletes itself. 683 00:36:15,560 --> 00:36:16,620 Go back and check again. 684 00:36:16,760 --> 00:36:17,360 Now he's DBA. 685 00:36:21,060 --> 00:36:24,760 To use all the Win32 exec and Win32 upload, we need to have the JavaSys 686 00:36:24,760 --> 00:36:25,480 privs added. 687 00:36:25,940 --> 00:36:27,680 So, we just do that real quick on the command line. 688 00:36:28,420 --> 00:36:29,040 So, it's there. 689 00:36:38,480 --> 00:36:41,200 So, the next thing we're going to do is we're going to do the Win32 upload. 690 00:36:41,200 --> 00:36:44,800 Because I already had a demo showing doing it across SMB. 691 00:36:45,200 --> 00:36:47,100 You don't always have SMB access. 692 00:36:47,340 --> 00:36:48,240 So, let's try to do it remotely. 693 00:36:49,460 --> 00:36:56,300 So, we're going to grab a interpreter binary from my web server and write it to the C drive 694 00:36:56,300 --> 00:36:57,900 on the Oracle instance. 695 00:37:13,380 --> 00:37:14,860 I'm just showing that it's not there. 696 00:37:14,980 --> 00:37:15,940 You'll have to trust me. 697 00:37:17,380 --> 00:37:18,080 It wasn't. 698 00:37:19,520 --> 00:37:23,500 This is the remote box that's actually going to catch the callback on the web server. 699 00:37:24,440 --> 00:37:27,440 So, we'll just use the exploit multi handler to catch the callback. 700 00:37:39,440 --> 00:37:40,340 All right. 701 00:37:40,360 --> 00:37:40,820 So, we're listening. 702 00:37:40,940 --> 00:37:42,620 We're ready to run it on the other end. 703 00:37:49,380 --> 00:37:50,300 All right. 704 00:37:50,320 --> 00:37:53,040 So, it's creating the Java source file. 705 00:37:53,200 --> 00:37:55,100 It's creating the Java procedure. 706 00:37:55,100 --> 00:37:59,720 Actually downloading the binary from the web server and putting it on the remote box. 707 00:38:00,240 --> 00:38:01,340 And then cleaning up. 708 00:38:02,240 --> 00:38:03,360 So, we delete all that stuff. 709 00:38:05,140 --> 00:38:06,240 And you can see it's there. 710 00:38:07,320 --> 00:38:08,340 Again, you'll have to trust me. 711 00:38:08,380 --> 00:38:09,060 I could have just put it there. 712 00:38:09,200 --> 00:38:09,640 But it works. 713 00:38:13,620 --> 00:38:17,180 Then we're going to use the Win32 exec module to actually execute the OS. 714 00:38:19,080 --> 00:38:19,460 What? 715 00:38:22,020 --> 00:38:22,400 No. 716 00:38:24,180 --> 00:38:25,240 You can talk to HC. 717 00:38:25,360 --> 00:38:28,180 I mean, he has that whole post and all those tricks of how to make the meterpreter shell 718 00:38:28,180 --> 00:38:28,920 not flag on AV. 719 00:38:32,880 --> 00:38:34,780 So, we called it math.exe. 720 00:38:34,800 --> 00:38:35,580 And so, we're just running it. 721 00:38:35,660 --> 00:38:37,540 And then you can see it's running it and cleaning it up. 722 00:38:37,620 --> 00:38:39,380 And then on the remote side, we've got the shell. 723 00:38:40,080 --> 00:38:40,440 That's it. 724 00:38:41,960 --> 00:38:42,240 Yeah. 725 00:38:42,320 --> 00:38:46,760 So, what we've done is we just created an extension to the framework to do other stuff. 726 00:38:46,820 --> 00:38:51,260 Just to help the pen tester and the researcher and hopefully the security community as far 727 00:38:51,260 --> 00:38:52,380 as the defensive side to do. 728 00:38:52,400 --> 00:38:55,340 So, that's what we're going to use to see some of the stuff that could happen and it 729 00:38:55,340 --> 00:38:56,140 probably will happen.