1 00:00:00,000 --> 00:00:06,500 My name is Michael Brooks, and I'm really glad to speak here at DEF CON. 2 00:00:06,740 --> 00:00:10,700 This is my first time speaking here, and so far I've had a blast. 3 00:00:12,140 --> 00:00:17,460 What we're talking about today is attack chaining within web applications, 4 00:00:17,800 --> 00:00:21,000 and particularly how CSRF can be used in attack chains. 5 00:00:21,940 --> 00:00:27,380 We'll be talking about high-impact exploits, as you will see. 6 00:00:27,380 --> 00:00:34,160 Also, at the end of this talk, there will be an O-Day of vulnerability being released with exploit code, 7 00:00:34,320 --> 00:00:36,460 as well as some other goodies. 8 00:00:40,600 --> 00:00:44,580 First of all, as a show of hands, who thinks CSRF is lame? 9 00:00:44,980 --> 00:00:48,920 Who thinks it is the lamest fly out there, that people even take it seriously? 10 00:00:51,060 --> 00:00:54,280 We got one. Wow, I'm surprised. 11 00:00:54,680 --> 00:00:57,360 Honestly, I thought CSRF... 12 00:00:57,380 --> 00:01:00,060 Even a year ago, I thought CSRF was the lamest vulnerability. 13 00:01:00,620 --> 00:01:06,920 I mocked the OWASP for putting it as number five on our top ten vulnerabilities. 14 00:01:07,500 --> 00:01:13,200 I laughed at CVE numbers relating to CSRF until I started doing my own research. 15 00:01:13,980 --> 00:01:20,880 Right here, this is a piece of HTML code, and it is sending a git request to cPanel web host manager, 16 00:01:21,080 --> 00:01:22,860 and it changes your root password. 17 00:01:23,160 --> 00:01:25,640 That is right. Remote root with CSRF. 18 00:01:25,640 --> 00:01:33,240 CSRF is a remotely exploitable flaw with the highest impact possible, 19 00:01:33,400 --> 00:01:35,500 and we will see more high-impact flaws with CSRF. 20 00:01:37,660 --> 00:01:40,560 It also affects embedded devices. 21 00:01:40,900 --> 00:01:44,100 In this case, I am sea surfing on a Motorola surfboard cable modem, 22 00:01:44,140 --> 00:01:47,120 and I'm able to knock you offline just by you visiting my website. 23 00:01:48,700 --> 00:01:49,240 Anyway. 24 00:01:50,860 --> 00:01:51,400 Now. 25 00:01:51,400 --> 00:01:55,720 What is the surface area problem in software? 26 00:01:58,380 --> 00:02:06,220 In code quality control, you can use software to detect how much of your code has been executed during a test. 27 00:02:06,700 --> 00:02:10,960 This is a way of gauging a surface area, how much surface has been tested. 28 00:02:11,500 --> 00:02:16,700 Now, humans are bound to make mistakes, and eventually they're going to make a mistake, 29 00:02:16,880 --> 00:02:18,700 a bug that a hacker can take advantage of. 30 00:02:18,940 --> 00:02:20,500 This is bugs per line of code. 31 00:02:20,500 --> 00:02:22,720 So what I am talking about is attack surface. 32 00:02:22,960 --> 00:02:28,180 I'm talking about places in the application where I could gain access. 33 00:02:28,300 --> 00:02:29,740 I could gain access to other flaws. 34 00:02:31,580 --> 00:02:32,140 Now. 35 00:02:32,180 --> 00:02:32,740 Okay. 36 00:02:34,960 --> 00:02:35,520 Now. 37 00:02:36,340 --> 00:02:36,900 Using... 38 00:02:37,660 --> 00:02:41,380 Many parts of the application are off limits to common users. 39 00:02:41,600 --> 00:02:43,080 For instance, administrative areas. 40 00:02:43,400 --> 00:02:47,220 However, these administrative areas can suffer from the exact same type of flaws. 41 00:02:47,440 --> 00:02:49,360 We're talking XSS, cross... 42 00:02:49,360 --> 00:02:53,320 SQL injection, and even worse, remote code execution flaws. 43 00:02:53,720 --> 00:02:58,660 But these flaws are exploitable using CSRF. 44 00:02:58,980 --> 00:03:04,560 In fact, there might be more of these flaws available in the open world due to some common misconceptions. 45 00:03:05,080 --> 00:03:07,100 For instance, thoughts of a developer. 46 00:03:07,540 --> 00:03:10,600 Why spend time validating input of someone I trust? 47 00:03:10,840 --> 00:03:11,460 He's the administrator. 48 00:03:11,700 --> 00:03:12,680 Why would he try and hack me? 49 00:03:13,320 --> 00:03:14,480 A password is acquired. 50 00:03:14,960 --> 00:03:16,880 That's enough to keep out an attacker. 51 00:03:18,020 --> 00:03:18,880 Thoughts of a hacker. 52 00:03:18,880 --> 00:03:20,800 Why should I look for a flaw I can't exploit? 53 00:03:21,180 --> 00:03:24,980 I mean, traditionally, when I went on a bug hunt, I would completely avoid the administrative area. 54 00:03:25,220 --> 00:03:27,920 There's no point in looking for a flaw there, because I can't reach it. 55 00:03:29,580 --> 00:03:30,320 Thoughts of users. 56 00:03:30,900 --> 00:03:34,480 Bah. Bah. Bah. Bah. Bah. 57 00:03:35,580 --> 00:03:37,440 Users don't matter, so... 58 00:03:38,320 --> 00:03:38,800 Okay. 59 00:03:39,020 --> 00:03:41,780 Now, how would we go about finding one of these flaws? 60 00:03:42,460 --> 00:03:47,360 And what we're using is a web application scanner called Wapiti. 61 00:03:47,780 --> 00:03:48,860 Otherwise known as Netatank. 62 00:03:49,660 --> 00:03:51,440 Wapiti is an open source scanner. 63 00:03:51,840 --> 00:03:57,300 However, there's a talk after this in track four for a Grendel scan. 64 00:03:57,640 --> 00:04:00,140 I highly recommend everyone check out this scanner. 65 00:04:00,220 --> 00:04:01,020 It is very good. 66 00:04:02,280 --> 00:04:06,640 Unfortunately, when I was doing this research, Wapiti is what I used. 67 00:04:07,460 --> 00:04:07,680 Okay. 68 00:04:08,000 --> 00:04:11,340 We'll go through some of the steps for setting up this scan. 69 00:04:13,000 --> 00:04:15,920 The type of software that we're attacking is TBDev. 70 00:04:15,920 --> 00:04:23,560 This is a software that's used in private BitTorrent communities, such as Oink, Rest in Peace, or Demonoid. 71 00:04:24,920 --> 00:04:27,560 These communities are secretive, because they're breaking the law. 72 00:04:27,820 --> 00:04:30,460 Which means, they get hacked, they can't go to the FBI. 73 00:04:30,840 --> 00:04:32,320 The FBI's looking for them. 74 00:04:34,520 --> 00:04:35,000 Okay. 75 00:04:36,540 --> 00:04:38,960 I do all of my auditing within a virtual machine. 76 00:04:39,420 --> 00:04:41,820 This way, I don't expose my workstation to attack. 77 00:04:42,180 --> 00:04:43,600 It can damage the machine. 78 00:04:43,820 --> 00:04:45,640 And I can easily restore with a copy. 79 00:04:45,640 --> 00:04:48,160 I can run multiple VMs at the same time. 80 00:04:49,020 --> 00:04:53,280 I also can finely tune configurations specifically for a task. 81 00:04:53,640 --> 00:04:54,660 And we'll talk more about that. 82 00:04:55,840 --> 00:04:58,600 Now, the first steps is to install TBDev. 83 00:04:58,800 --> 00:05:02,280 It installs fairly normally if you've ever installed a PHP MySQL application. 84 00:05:02,680 --> 00:05:04,380 You shouldn't have any trouble with TBDev. 85 00:05:05,390 --> 00:05:08,460 We need to create an administrative account as standard. 86 00:05:09,340 --> 00:05:10,900 In terms of the PHP... 87 00:05:11,640 --> 00:05:12,460 Go back. 88 00:05:12,660 --> 00:05:14,480 In terms of the PHP settings, 89 00:05:14,480 --> 00:05:17,000 we want to make sure that display errors is on. 90 00:05:17,120 --> 00:05:21,520 This is very important in all web application scanning. 91 00:05:21,860 --> 00:05:24,900 Many vulnerabilities are detected by the application reporting 92 00:05:25,480 --> 00:05:26,640 that an error has occurred. 93 00:05:26,800 --> 00:05:27,960 For instance, a MySQL error. 94 00:05:28,300 --> 00:05:30,880 This is crucial for the detection of some flaws. 95 00:05:31,040 --> 00:05:33,000 However, it doesn't matter for XSS. 96 00:05:33,240 --> 00:05:35,720 XSS is not looking for errors to take place. 97 00:05:37,020 --> 00:05:42,060 Also, for this case, I'm leaving MagicWiseGPC on. 98 00:05:42,060 --> 00:05:46,980 Although, I recommend also scanning your applications with MagicWiseGPC off. 99 00:05:47,740 --> 00:05:49,960 You'd have to know a bit more about how this works. 100 00:05:50,060 --> 00:05:53,840 But it's a security feature that can prevent many types of SQL injection. 101 00:05:54,560 --> 00:05:55,460 It's a good thing. 102 00:05:55,580 --> 00:05:57,120 This is being removed in PHP 6. 103 00:05:57,300 --> 00:05:58,220 And this is a very good thing. 104 00:05:58,420 --> 00:06:04,420 The reason why is because programmers will become overly reliant on the security of MagicWise. 105 00:06:04,620 --> 00:06:06,600 And MagicWise is not bulletproof. 106 00:06:06,820 --> 00:06:09,400 So, more flaws are becoming popular. 107 00:06:09,800 --> 00:06:11,740 I suggest scanning with both at this time. 108 00:06:13,780 --> 00:06:17,840 Scan it once with it on and then once again with it off. 109 00:06:20,040 --> 00:06:20,780 Anyway, yes. 110 00:06:21,240 --> 00:06:21,720 WPT. 111 00:06:21,920 --> 00:06:23,000 WPT is a great tool. 112 00:06:23,240 --> 00:06:24,880 It is a command line only application. 113 00:06:25,260 --> 00:06:26,520 It can be difficult to use. 114 00:06:26,700 --> 00:06:27,620 It's fairly solid. 115 00:06:27,960 --> 00:06:31,420 One advantage it has over Grendel scan is that it contains less bugs. 116 00:06:31,700 --> 00:06:34,720 However, Grendel blows it out of the water in terms of features. 117 00:06:37,280 --> 00:06:41,580 The first part of WPT is that because we're scanning an authentication 118 00:06:41,740 --> 00:06:44,240 area, we need the session ID of the administrator. 119 00:06:45,000 --> 00:06:49,720 This is a command line application here called getcookie.py. 120 00:06:52,440 --> 00:06:55,340 I'm giving it the location to the login form, in this case, 121 00:06:55,360 --> 00:06:57,080 slash login dot php. 122 00:06:57,600 --> 00:07:00,420 It's going to grab the HTML and tell me what's on the form. 123 00:07:00,720 --> 00:07:02,820 It's going to say there's a username and a password. 124 00:07:02,980 --> 00:07:06,140 I gave it the username, admin, and the password, password. 125 00:07:06,960 --> 00:07:11,220 Now, if you might notice something, 126 00:07:11,220 --> 00:07:15,060 the cookie's name is called pass, and it looks like an MD5 hash. 127 00:07:15,980 --> 00:07:20,800 In my mind, this is a red flag, but we'll get more to that later. 128 00:07:21,020 --> 00:07:24,200 This is the first indication that there may be a problem with the session handler. 129 00:07:26,400 --> 00:07:28,640 Now, if we use getcookie.py again, 130 00:07:28,900 --> 00:07:31,660 we'll actually get the exact same session value again, 131 00:07:34,560 --> 00:07:39,300 this 32 character of hex called pass. 132 00:07:39,720 --> 00:07:41,200 Again, this is not good. 133 00:07:41,220 --> 00:07:47,260 This is a lot of evidence supporting that they're using an immortal session identifier, 134 00:07:47,940 --> 00:07:50,620 which we'll talk about more in a bit. 135 00:07:50,980 --> 00:07:55,160 It turns out that it's true. 136 00:07:55,600 --> 00:08:01,200 Your session ID is the MD5 hash of your password. 137 00:08:01,900 --> 00:08:05,280 First of all, why are people still using MD5? 138 00:08:05,580 --> 00:08:08,300 It has been broken for four years, 139 00:08:08,660 --> 00:08:11,200 and yet people are still introducing it to their computers. 140 00:08:11,220 --> 00:08:17,020 This is a violation of OWASP's secure cryptographic storage. 141 00:08:17,160 --> 00:08:17,940 I believe it's number eight. 142 00:08:18,600 --> 00:08:20,100 But people are still doing it. 143 00:08:20,200 --> 00:08:21,200 Perhaps you don't know better. 144 00:08:21,780 --> 00:08:23,220 The SHA-2 family is secure. 145 00:08:23,480 --> 00:08:26,540 SHA-256, SHA-384, and SHA-512. 146 00:08:26,860 --> 00:08:27,640 Any of those. 147 00:08:27,700 --> 00:08:31,300 Very secure functions, and you won't have to worry about attack. 148 00:08:33,120 --> 00:08:36,780 But furthermore, we actually don't have to attack the MD5 hash. 149 00:08:37,020 --> 00:08:37,980 It is a password. 150 00:08:37,980 --> 00:08:44,580 It is an effect that their username and password is in clear text. 151 00:08:44,920 --> 00:08:46,520 We don't have to break the MD5 hash. 152 00:08:46,700 --> 00:08:48,540 It in itself is the session ID. 153 00:08:48,880 --> 00:08:51,780 So if we're able to steal this identifier, 154 00:08:52,100 --> 00:08:54,600 we'll be able to log on to the application indefinitely, 155 00:08:54,760 --> 00:08:56,560 or at least until they change their password. 156 00:08:57,420 --> 00:08:58,960 This is a broken session handler. 157 00:08:59,100 --> 00:09:00,120 Again, an OWASP violation. 158 00:09:04,380 --> 00:09:05,880 This we're going to save for later. 159 00:09:05,880 --> 00:09:07,920 We know we've already detected one vulnerability, 160 00:09:08,140 --> 00:09:09,520 and we haven't even started the scan. 161 00:09:10,620 --> 00:09:12,640 So now we're going to start the scan. 162 00:09:12,980 --> 00:09:13,760 And we're doing it with... 163 00:09:16,240 --> 00:09:19,000 Now, there's some considerations with this type of scanning. 164 00:09:19,460 --> 00:09:23,080 You have to worry about certain requests that may break the scan, 165 00:09:23,240 --> 00:09:25,620 or make the application no longer available. 166 00:09:25,980 --> 00:09:27,800 In many cases, you would want to avoid, 167 00:09:28,040 --> 00:09:30,920 such as a logout function, logout.php, 168 00:09:30,980 --> 00:09:31,920 which would destroy the session. 169 00:09:32,300 --> 00:09:34,760 In this case, logout.php is purely cosmetic. 170 00:09:34,760 --> 00:09:36,860 The session ID stays the same regardless. 171 00:09:37,640 --> 00:09:40,840 However, we have to avoid changing the password. 172 00:09:41,440 --> 00:09:45,360 So this dash X at the very bottom 173 00:09:45,360 --> 00:09:48,020 is excluding the my.php, 174 00:09:48,100 --> 00:09:49,880 which allows you to change your password. 175 00:09:51,240 --> 00:09:53,400 Anyway, it scans fairly quickly, 176 00:09:53,540 --> 00:09:54,720 and here are the results. 177 00:09:55,720 --> 00:09:59,900 We find a reflective XSS hole in reader.php. 178 00:10:00,060 --> 00:10:02,240 This is accessible by everyone. 179 00:10:02,660 --> 00:10:04,140 So now... 180 00:10:04,760 --> 00:10:06,500 This is actually very good news. 181 00:10:06,740 --> 00:10:07,880 Using this hole alone, 182 00:10:08,080 --> 00:10:11,580 we could potentially steal a user account 183 00:10:11,580 --> 00:10:12,740 of someone on the system. 184 00:10:12,940 --> 00:10:14,520 We could steal their session ID, 185 00:10:14,700 --> 00:10:17,760 and we could use that, again, indefinitely. 186 00:10:18,000 --> 00:10:19,920 We could hijack a user's account 187 00:10:19,920 --> 00:10:21,760 on this BitTorrent community indefinitely. 188 00:10:23,640 --> 00:10:25,260 However, it gets worse. 189 00:10:25,380 --> 00:10:26,840 There are more flaws that are found. 190 00:10:28,380 --> 00:10:29,360 The next flaw. 191 00:10:29,680 --> 00:10:31,500 Now, this is far more interesting. 192 00:10:31,780 --> 00:10:33,900 This is a stored XSS. 193 00:10:34,760 --> 00:10:35,100 This is the most persistent, 194 00:10:35,620 --> 00:10:37,700 and it is in the best place possible. 195 00:10:37,860 --> 00:10:39,440 It is in index.php. 196 00:10:39,620 --> 00:10:41,860 What this means is that you're able to change 197 00:10:41,860 --> 00:10:43,680 the very landing page. 198 00:10:43,900 --> 00:10:45,760 The very landing page of the application 199 00:10:45,760 --> 00:10:48,020 can be whatever you want it to be, 200 00:10:48,180 --> 00:10:50,360 including the ability to steal 201 00:10:50,360 --> 00:10:51,740 other people's session IDs 202 00:10:51,740 --> 00:10:53,320 or deface the page altogether. 203 00:10:53,860 --> 00:10:55,420 I'll show you an example. 204 00:10:56,680 --> 00:10:58,780 Now, there's a trick with this. 205 00:10:59,240 --> 00:11:02,680 This flaw is only accessible 206 00:11:02,680 --> 00:11:03,900 in the administrative area. 207 00:11:04,760 --> 00:11:06,320 You're thinking, well, damn, 208 00:11:06,600 --> 00:11:10,700 I'm not able to hit this flaw 209 00:11:10,700 --> 00:11:13,660 unless I'm able to use an administrative account. 210 00:11:15,520 --> 00:11:17,720 Well, that's where CSRF comes in. 211 00:11:17,960 --> 00:11:20,120 Another word for CSRF is session writing. 212 00:11:20,600 --> 00:11:24,280 When we look at the output of this scan, 213 00:11:25,780 --> 00:11:27,640 we know that it is already vulnerable. 214 00:11:27,780 --> 00:11:29,340 It is also vulnerable to CSRF. 215 00:11:29,740 --> 00:11:32,980 The reason why is because you can see 216 00:11:32,980 --> 00:11:34,740 it says news.php, 217 00:11:34,760 --> 00:11:36,220 and they're sending a git action. 218 00:11:36,980 --> 00:11:38,200 git action here. 219 00:11:38,420 --> 00:11:39,860 That is one parameter. 220 00:11:40,160 --> 00:11:42,340 Then it's sending a post of body, 221 00:11:42,480 --> 00:11:43,060 and that's it. 222 00:11:43,820 --> 00:11:45,700 In CSRF, you're looking for 223 00:11:47,540 --> 00:11:49,580 another value to accompany it, 224 00:11:49,660 --> 00:11:51,340 called a cryptographic no-once. 225 00:11:51,900 --> 00:11:54,500 In essence, this is a randomly generated number 226 00:11:54,500 --> 00:11:57,280 that the attacker is unable to guess. 227 00:11:58,280 --> 00:12:01,260 Not only is this a stored XSS hole, 228 00:12:01,340 --> 00:12:03,300 but it's also across CSRF. 229 00:12:03,300 --> 00:12:07,220 Now, if they were sanitizing for cross-site scripting, 230 00:12:07,260 --> 00:12:09,360 it would still be a CSRF flaw, 231 00:12:09,560 --> 00:12:10,460 and that would be, 232 00:12:10,540 --> 00:12:13,320 it would take the manifestation of the ability 233 00:12:13,320 --> 00:12:16,100 to post a news article to the front page. 234 00:12:16,420 --> 00:12:17,460 The news would say, like, 235 00:12:17,560 --> 00:12:20,280 oh, I don't know, 236 00:12:21,180 --> 00:12:22,540 administrators eat babies. 237 00:12:22,940 --> 00:12:24,740 I mean, you could put whatever you want. 238 00:12:25,160 --> 00:12:26,940 In this case, it is more powerful 239 00:12:26,940 --> 00:12:29,080 due to the stored XSS. 240 00:12:30,000 --> 00:12:32,520 Yeah, stored XSS in index.php. 241 00:12:34,340 --> 00:12:34,900 Anyway. 242 00:12:36,200 --> 00:12:37,140 Analyzing the results. 243 00:12:37,400 --> 00:12:39,280 Now, there's a way to verify that it is, 244 00:12:39,280 --> 00:12:40,360 in fact, CSRF. 245 00:12:40,580 --> 00:12:42,780 In this case, I built a very simple form, 246 00:12:42,960 --> 00:12:45,760 HTML form, that is recreating the request. 247 00:12:46,100 --> 00:12:47,860 It's sending the body value of owned, 248 00:12:47,980 --> 00:12:50,740 and I'm using JavaScript at the bottom 249 00:12:50,740 --> 00:12:53,700 to automatically submit the news article. 250 00:12:54,480 --> 00:12:58,320 This is the first step I had in exploit development, 251 00:12:58,540 --> 00:13:01,760 just to have some very simple proof of concept. 252 00:13:03,620 --> 00:13:06,640 If you're still unsure about XSS security, 253 00:13:07,000 --> 00:13:08,240 if you're a bit of a novice, 254 00:13:08,780 --> 00:13:13,000 I suggest the OWASP has some great information on it, 255 00:13:13,040 --> 00:13:14,720 including testing for OWASP, 256 00:13:14,780 --> 00:13:19,280 as well as a CSRF tester project. 257 00:13:20,640 --> 00:13:22,120 I'm not sure about that, 258 00:13:22,300 --> 00:13:24,520 but all the power to them. 259 00:13:24,840 --> 00:13:26,940 I think it's interesting. 260 00:13:27,360 --> 00:13:27,720 It's interesting. 261 00:13:28,540 --> 00:13:29,100 Okay. 262 00:13:29,720 --> 00:13:30,280 Now. 263 00:13:31,480 --> 00:13:32,880 This is where we start. 264 00:13:34,400 --> 00:13:37,500 We start building chains. 265 00:13:41,660 --> 00:13:42,240 Yeah. 266 00:13:42,380 --> 00:13:42,700 Okay. 267 00:13:42,820 --> 00:13:43,540 Go further ahead. 268 00:13:43,860 --> 00:13:44,220 All right. 269 00:13:45,080 --> 00:13:45,660 Now. 270 00:13:45,800 --> 00:13:47,060 In order to... 271 00:13:47,060 --> 00:13:51,060 The request is bouncing between the system. 272 00:13:51,240 --> 00:13:53,940 It is bouncing between your web browser, 273 00:13:54,040 --> 00:14:00,400 and it is bouncing off of a reflective XSS flaw. 274 00:14:00,640 --> 00:14:01,780 I mean, a reflective surface. 275 00:14:01,780 --> 00:14:03,060 Reflective like a mirror, even. 276 00:14:03,260 --> 00:14:04,380 Well, it's also able to... 277 00:14:04,380 --> 00:14:06,140 You can bounce a request off of it. 278 00:14:06,820 --> 00:14:08,300 However, there's a problem. 279 00:14:08,460 --> 00:14:12,900 When your request is sending from your web browser to the server, 280 00:14:13,560 --> 00:14:15,280 it's going to be hit by an add slashes, 281 00:14:15,300 --> 00:14:16,300 or magic quotes. 282 00:14:16,780 --> 00:14:18,260 In essence, what this means is 283 00:14:18,260 --> 00:14:21,480 you're going to have problems having JavaScript with quote marks. 284 00:14:22,560 --> 00:14:26,380 Luckily, JavaScript has a tool called string from chart code. 285 00:14:27,540 --> 00:14:28,820 But they don't have the inverse. 286 00:14:28,820 --> 00:14:34,940 So I had to write a function to encode all of my JavaScript before sending it through. 287 00:14:35,160 --> 00:14:36,700 And I'll show you the exploit code shortly. 288 00:14:37,620 --> 00:14:38,060 Okay. 289 00:14:38,620 --> 00:14:40,460 Now, this may seem a bit redundant. 290 00:14:40,660 --> 00:14:42,840 However, there's a method to my madness. 291 00:14:45,760 --> 00:14:49,660 We're using a mix of reflective XSS and social engineering 292 00:14:49,660 --> 00:14:51,480 in order to pull off this flaw. 293 00:14:52,120 --> 00:14:55,040 We have to get the administrator to click on a link 294 00:14:55,040 --> 00:14:57,400 in order for us to hit it. 295 00:14:57,400 --> 00:15:01,960 So the best way I thought of doing this 296 00:15:01,960 --> 00:15:06,840 is making the link appear as though it's coming from his own website. 297 00:15:07,140 --> 00:15:09,640 And that's where the reflective XSS comes into play. 298 00:15:10,940 --> 00:15:18,280 We send the administrator a private message on the system saying, 299 00:15:18,460 --> 00:15:24,340 hey, I think there might be a problem with your TV dev installation. 300 00:15:24,760 --> 00:15:26,600 This link just doesn't look quite right. 301 00:15:26,600 --> 00:15:30,520 You click on the link, and then the exploit code fires. 302 00:15:31,360 --> 00:15:35,060 This exploit code is an entirely self-contained URL. 303 00:15:35,500 --> 00:15:38,760 It is a fire-and-forget, does not require an external server, 304 00:15:38,960 --> 00:15:40,700 and is rather small. 305 00:15:42,700 --> 00:15:43,740 In fact... 306 00:15:47,480 --> 00:15:48,720 I'll show you the code right now. 307 00:15:50,740 --> 00:15:51,820 Bouncy, bouncy, bouncy. 308 00:15:52,260 --> 00:15:52,880 All right. 309 00:15:53,340 --> 00:15:55,500 I made this easy to use. 310 00:15:56,600 --> 00:15:56,860 I try to. 311 00:15:57,380 --> 00:15:59,640 I mean, this is written entirely in HTML and JavaScript. 312 00:16:00,440 --> 00:16:02,240 You don't need a web server to run it. 313 00:16:02,360 --> 00:16:04,260 You just have to run it on your local system. 314 00:16:05,160 --> 00:16:08,840 I figured even if you've never used exploit code before, 315 00:16:08,920 --> 00:16:09,860 you might be able to use this. 316 00:16:10,680 --> 00:16:14,060 I give some explanation of how it is used. 317 00:16:14,580 --> 00:16:18,080 All it requires is the target, 318 00:16:18,360 --> 00:16:20,760 the location of the TV dev install that you're looking for, 319 00:16:20,900 --> 00:16:24,060 the script that you'd want to execute on index. 320 00:16:24,060 --> 00:16:27,700 on the index.php. 321 00:16:27,860 --> 00:16:33,420 In this case, we're changing the inner HTML to an image. 322 00:16:33,580 --> 00:16:34,260 You'll see shortly. 323 00:16:35,160 --> 00:16:36,280 And then click generate attack. 324 00:16:36,780 --> 00:16:39,260 A URL is generated for us down here. 325 00:16:43,830 --> 00:16:44,700 All right. 326 00:16:45,600 --> 00:16:46,180 Now... 327 00:16:48,200 --> 00:16:49,940 This is what TV dev looks like. 328 00:16:50,790 --> 00:16:51,080 Simple. 329 00:16:51,080 --> 00:16:55,360 You could browse for torrents, search torrents, 330 00:16:55,360 --> 00:16:56,180 as well as a community. 331 00:16:56,980 --> 00:16:59,580 Now, to simulate it as if the administrator 332 00:16:59,580 --> 00:17:00,760 were to click on that link, 333 00:17:01,580 --> 00:17:02,920 I'm just going to paste it. 334 00:17:03,280 --> 00:17:04,800 If you look at the link, actually, 335 00:17:05,380 --> 00:17:06,540 it does look suspicious. 336 00:17:07,440 --> 00:17:10,160 You can see there are a lot of numbers, 337 00:17:10,260 --> 00:17:14,000 and it's commented or quoted out. 338 00:17:14,280 --> 00:17:16,200 It would look similar to shellcode. 339 00:17:16,300 --> 00:17:19,680 However, this is to evade the add slashes filtering. 340 00:17:19,980 --> 00:17:20,840 Now, enter. 341 00:17:21,500 --> 00:17:22,080 Redirecting you. 342 00:17:23,020 --> 00:17:23,940 It's defaced. 343 00:17:25,520 --> 00:17:26,000 Simple. 344 00:17:27,200 --> 00:17:28,480 It is still defaced. 345 00:17:28,520 --> 00:17:29,920 This is index.php. 346 00:17:30,160 --> 00:17:31,460 The page has been changed. 347 00:17:31,760 --> 00:17:33,500 The only way to reverse it is you'd have to 348 00:17:33,980 --> 00:17:36,320 log into the SQL database 349 00:17:36,320 --> 00:17:38,820 and actually delete the news article, 350 00:17:39,620 --> 00:17:40,580 which I'll do now. 351 00:17:41,000 --> 00:17:42,360 Empty. Okay. 352 00:17:46,940 --> 00:17:47,420 Okay. 353 00:17:54,300 --> 00:17:57,360 Let's talk a bit more about how would you want to 354 00:17:57,940 --> 00:18:00,000 gain access to the community in the first place. 355 00:18:01,520 --> 00:18:03,600 Many of these communities do require invites, 356 00:18:03,820 --> 00:18:05,760 and it would be nice to gain access to these. 357 00:18:09,320 --> 00:18:12,540 I'll show you a simple cookie-stealing code. 358 00:18:13,140 --> 00:18:14,460 The PHP is very simple. 359 00:18:14,660 --> 00:18:16,100 In fact, it's only two function calls 360 00:18:16,100 --> 00:18:17,580 and a single variable. 361 00:18:18,380 --> 00:18:20,280 The first line here is saying, 362 00:18:20,280 --> 00:18:23,960 get the file contents of a file we call cookie.txt. 363 00:18:24,800 --> 00:18:26,800 Whatever is in that file, we're going to pull it out. 364 00:18:27,780 --> 00:18:33,720 Then we're going to open that file for writing, 365 00:18:33,840 --> 00:18:36,560 and we're going to take whatever cookie, 366 00:18:36,840 --> 00:18:39,600 whatever get parameter we see as cookie, 367 00:18:39,820 --> 00:18:40,740 and we're going to write it. 368 00:18:41,200 --> 00:18:43,800 In essence, this is going to give you a... 369 00:18:43,800 --> 00:18:47,260 If you were to put this script on the index.php, 370 00:18:47,800 --> 00:18:49,200 everyone who is logged in, 371 00:18:49,200 --> 00:18:52,960 their cookie value would be entered into this file, 372 00:18:53,040 --> 00:18:54,680 separated by new lines. 373 00:18:54,900 --> 00:18:57,340 You could immediately log in as any one of those people. 374 00:18:57,940 --> 00:18:59,660 This is a very serious combination 375 00:19:00,140 --> 00:19:02,240 of having a broken session handler 376 00:19:02,240 --> 00:19:05,960 and being able to literally steal everyone's authentication 377 00:19:05,960 --> 00:19:10,100 on the system using this combination. 378 00:19:23,300 --> 00:19:23,780 Okay. 379 00:19:28,060 --> 00:19:29,580 We'll talk a bit more about defense. 380 00:19:31,660 --> 00:19:32,800 Yeah, one moment. 381 00:19:33,840 --> 00:19:34,460 All right. 382 00:19:36,980 --> 00:19:37,460 Okay. 383 00:19:38,240 --> 00:19:40,140 Limiting the access of the administrator account 384 00:19:40,140 --> 00:19:40,820 is a good idea. 385 00:19:41,040 --> 00:19:43,020 I mean, you shouldn't have cross-site scripting flaws 386 00:19:43,020 --> 00:19:45,320 in this area or other vulnerabilities. 387 00:19:45,740 --> 00:19:48,100 I mean, it's common in the Linux world to use 388 00:19:51,280 --> 00:19:56,620 chroot to limit the ability of super users. 389 00:19:57,940 --> 00:20:00,180 And it is also absolutely important to apply 390 00:20:00,180 --> 00:20:02,600 CSRF protection to administrative areas. 391 00:20:06,900 --> 00:20:08,760 CSRF is a popular attack against Google 392 00:20:08,760 --> 00:20:11,560 because since you don't have access to the source code, 393 00:20:12,000 --> 00:20:14,500 it is able to identify this flaw and write exploit code 394 00:20:15,180 --> 00:20:16,840 by merely looking at the requests. 395 00:20:17,260 --> 00:20:18,460 And looking at the... 396 00:20:18,460 --> 00:20:18,580 Yeah. 397 00:20:19,200 --> 00:20:19,700 Looking at the traffic. 398 00:20:21,360 --> 00:20:22,000 Many... 399 00:20:22,000 --> 00:20:22,260 Okay. 400 00:20:22,420 --> 00:20:26,180 Many CSRF protection mechanisms can be bypassed using XSS. 401 00:20:27,160 --> 00:20:30,820 Using XSS, you're able to read the page itself, 402 00:20:31,020 --> 00:20:33,880 which breaks the same-origin policy. 403 00:20:34,300 --> 00:20:36,660 Using XML HTTP requests, 404 00:20:36,880 --> 00:20:42,240 you're able to read the CRSRF cryptographic no-ones 405 00:20:42,240 --> 00:20:43,800 in order to bypass it. 406 00:20:43,960 --> 00:20:46,260 This is the same technique that the Sammy worm used. 407 00:20:46,540 --> 00:20:48,480 And I wrote exploit code to... 408 00:20:48,480 --> 00:20:49,760 I wrote a similar exploit code, 409 00:20:50,500 --> 00:20:52,280 actually utilizing some of its functions. 410 00:20:52,960 --> 00:20:53,780 What it did was... 411 00:20:53,780 --> 00:20:55,120 What it does is... 412 00:20:57,020 --> 00:20:57,500 It... 413 00:20:57,500 --> 00:20:58,800 Here, wait a minute. 414 00:20:59,080 --> 00:20:59,560 Pull it up. 415 00:21:00,240 --> 00:21:00,520 See... 416 00:21:00,520 --> 00:21:00,720 Yeah. 417 00:21:03,880 --> 00:21:04,360 It... 418 00:21:04,360 --> 00:21:07,660 It affects a open source... 419 00:21:08,260 --> 00:21:09,100 No, that's pretty bad. 420 00:21:10,520 --> 00:21:11,100 All right. 421 00:21:11,180 --> 00:21:11,380 Okay. 422 00:21:11,520 --> 00:21:12,280 It affects... 423 00:21:12,280 --> 00:21:14,380 There's an open source clone of this site, 424 00:21:14,880 --> 00:21:15,840 dig.com. 425 00:21:16,240 --> 00:21:17,240 It's called Plig. 426 00:21:17,240 --> 00:21:18,480 Plig is the open source copy. 427 00:21:19,320 --> 00:21:21,000 And if you're familiar with Dig, 428 00:21:21,060 --> 00:21:21,940 people post a link, 429 00:21:22,060 --> 00:21:23,880 and you vote up if you like it, 430 00:21:23,900 --> 00:21:25,060 or vote down if you don't like it. 431 00:21:25,540 --> 00:21:28,040 What my exploit code does is... 432 00:21:28,700 --> 00:21:29,580 When you... 433 00:21:29,580 --> 00:21:30,740 Upon viewing the link, 434 00:21:30,900 --> 00:21:32,560 it forces you to vote on. 435 00:21:32,720 --> 00:21:35,000 It forces you to vote up on a Plig link. 436 00:21:36,160 --> 00:21:38,440 Now, and this same attack could work against Dig 437 00:21:38,440 --> 00:21:40,960 if you had a cross-site scripting flaw against Dig. 438 00:21:41,280 --> 00:21:43,260 In fact, my source code... 439 00:21:43,260 --> 00:21:45,940 My exploit code could be modified to attack Dig. 440 00:21:47,880 --> 00:21:52,380 This has implications for mostly spammers, 441 00:21:52,460 --> 00:21:56,600 to which to redirect people to their spam site. 442 00:21:57,600 --> 00:21:58,560 Not very good. 443 00:22:03,480 --> 00:22:05,500 This attack was recently... 444 00:22:05,500 --> 00:22:09,140 I recently put it on my blog, rooksecurity.com, 445 00:22:10,200 --> 00:22:12,620 as well as other attacks I've posted on there. 446 00:22:12,960 --> 00:22:15,320 There's another flaw I found in Plig. 447 00:22:15,440 --> 00:22:17,100 It turns out they're a cap 448 00:22:17,240 --> 00:22:18,500 when the captcha implementation was broken, 449 00:22:18,640 --> 00:22:22,460 and I was able to find the captcha code. 450 00:22:22,660 --> 00:22:23,800 I wasn't attacking the image. 451 00:22:24,020 --> 00:22:26,040 I was attacking more of an issue 452 00:22:26,040 --> 00:22:27,860 of how the code was generated. 453 00:22:28,200 --> 00:22:30,560 I was able to predict what the code was able to be, 454 00:22:30,780 --> 00:22:33,060 which is another bad combination, 455 00:22:33,360 --> 00:22:34,780 the ability to create accounts 456 00:22:34,780 --> 00:22:37,220 and then also vote on links. 457 00:22:39,780 --> 00:22:41,880 Now, even with... 458 00:22:41,880 --> 00:22:43,420 Oh, yeah, the Plig autovoter. 459 00:22:43,580 --> 00:22:43,960 No. 460 00:22:44,900 --> 00:22:45,420 Okay. 461 00:22:45,420 --> 00:22:48,880 Say you have problems with cross-site scripting, 462 00:22:48,900 --> 00:22:51,240 and you have problems with CSRF, 463 00:22:51,400 --> 00:22:54,480 and you need a solution now. 464 00:22:54,640 --> 00:22:56,340 You need a more difficult solution now, 465 00:22:56,500 --> 00:22:58,980 or a solution that is difficult to bypass. 466 00:23:00,240 --> 00:23:03,840 The OWASP suggests even protecting it with a captcha. 467 00:23:04,440 --> 00:23:07,580 This value cannot be read by means of XSS, 468 00:23:07,840 --> 00:23:09,640 and would be a reasonable defense. 469 00:23:10,080 --> 00:23:12,320 Another method would be to use a side channel, 470 00:23:12,440 --> 00:23:14,680 such as emailing you a password 471 00:23:14,680 --> 00:23:17,700 via SMS, text message, or even email, 472 00:23:17,820 --> 00:23:19,220 and out of bad signal. 473 00:23:21,060 --> 00:23:21,500 Okay. 474 00:23:21,680 --> 00:23:23,320 Now, there's another problem with CSRF 475 00:23:23,320 --> 00:23:27,140 that really keeps it from being a series of... 476 00:23:28,640 --> 00:23:29,520 very widespread. 477 00:23:30,640 --> 00:23:32,400 One, when you're building a request, 478 00:23:32,640 --> 00:23:34,500 you have to know where that request is going. 479 00:23:34,620 --> 00:23:36,500 You have to know the path, and you have to know the server. 480 00:23:37,580 --> 00:23:38,020 However, 481 00:23:40,340 --> 00:23:42,700 Spy Dynamics released a very cool tool, 482 00:23:43,600 --> 00:23:44,480 a JavaScript... 483 00:23:44,680 --> 00:23:45,100 port scanner. 484 00:23:46,560 --> 00:23:49,360 Now, the port scanner uses two different methods 485 00:23:49,360 --> 00:23:51,840 for detecting services. 486 00:23:52,680 --> 00:23:55,000 One of them is onLoad and onError, 487 00:23:55,440 --> 00:23:57,800 and it's looking at the response times from requests. 488 00:23:58,580 --> 00:24:01,040 This method, I can't get to work reliably 489 00:24:01,040 --> 00:24:02,140 for a real-world exploit. 490 00:24:02,480 --> 00:24:04,900 However, there's another method used. 491 00:24:06,420 --> 00:24:08,240 What you're able to do is 492 00:24:08,240 --> 00:24:11,700 you're able to read a remote image on a system, 493 00:24:12,480 --> 00:24:14,340 and if you know the path 494 00:24:14,680 --> 00:24:14,980 of the image, 495 00:24:15,160 --> 00:24:16,800 you can read the file dimensions. 496 00:24:17,420 --> 00:24:18,740 And using this method, 497 00:24:18,880 --> 00:24:21,920 you are able to identify... 498 00:24:29,420 --> 00:24:30,880 embedded network hardware. 499 00:24:31,260 --> 00:24:33,980 In fact, this is a SNOM Linux... 500 00:24:35,420 --> 00:24:36,980 SNOM phone, VoIP phone. 501 00:24:37,060 --> 00:24:37,900 It's a SIP client. 502 00:24:38,160 --> 00:24:41,020 It's running an embedded Linux 2.4 system, 503 00:24:41,020 --> 00:24:45,060 and using this method, 504 00:24:46,640 --> 00:24:49,200 I'm able to detect this modem on the network... 505 00:24:49,200 --> 00:24:51,080 or able to detect this phone on the network 506 00:24:51,080 --> 00:24:53,120 and then hack it. 507 00:24:53,980 --> 00:24:54,500 Unfortunately, 508 00:24:55,600 --> 00:24:56,960 the exploit code is... 509 00:24:56,960 --> 00:24:58,460 I can't show you it right now. 510 00:24:58,840 --> 00:25:01,800 But it's a pretty cool system. 511 00:25:02,520 --> 00:25:04,180 What's actually made worse about this 512 00:25:04,180 --> 00:25:06,440 is that you're able to... 513 00:25:08,420 --> 00:25:08,940 by... 514 00:25:08,940 --> 00:25:11,000 you're able to attack and interrupt 515 00:25:11,020 --> 00:25:13,040 an internal network over someone's browser. 516 00:25:13,380 --> 00:25:15,980 And this particular CSRF flaw, 517 00:25:16,160 --> 00:25:18,300 literally every request on this system 518 00:25:18,300 --> 00:25:19,420 is vulnerable to CSRF, 519 00:25:19,580 --> 00:25:22,740 including the feature to update the firmware. 520 00:25:23,340 --> 00:25:28,480 Now, because SNOM is obeying the GNU public license, 521 00:25:28,720 --> 00:25:32,040 and all of their source code is available for the device, 522 00:25:32,200 --> 00:25:34,340 and you're able to build your own custom firmware, 523 00:25:34,520 --> 00:25:36,160 including a root-kitted firmware, 524 00:25:36,460 --> 00:25:39,100 and have your own root-kitted Linux system 525 00:25:39,100 --> 00:25:40,860 on an internal corporate network. 526 00:25:42,700 --> 00:25:44,040 In all honesty, 527 00:25:44,180 --> 00:25:46,240 I'm not very familiar with 528 00:25:46,240 --> 00:25:49,280 the building of hacked embedded systems. 529 00:25:49,700 --> 00:25:51,400 But if you are, please come talk to me. 530 00:25:51,500 --> 00:25:54,200 I'd like to build some back-to-work firmware. 531 00:25:54,380 --> 00:25:54,900 I think it would be fun. 532 00:25:55,600 --> 00:25:56,080 Particularly... 533 00:25:56,080 --> 00:25:58,240 Also, SNOM wasn't the only one. 534 00:25:58,660 --> 00:25:59,420 In fact, I... 535 00:26:00,700 --> 00:26:02,680 I bought two other VoIP phones, 536 00:26:02,760 --> 00:26:03,540 and they were also vulnerable. 537 00:26:03,880 --> 00:26:05,860 The D-Link phone, 538 00:26:06,120 --> 00:26:07,880 as well as Zoom. 539 00:26:08,140 --> 00:26:09,000 A Zoom phone. 540 00:26:10,460 --> 00:26:12,000 Another attack scenario 541 00:26:12,000 --> 00:26:14,120 that worked against all three phones 542 00:26:14,120 --> 00:26:16,060 was the ability to change 543 00:26:16,060 --> 00:26:17,540 what SIP server it was using. 544 00:26:17,940 --> 00:26:20,160 So you could force the phone 545 00:26:20,160 --> 00:26:21,700 into using a malicious SIP server, 546 00:26:21,860 --> 00:26:24,740 perhaps even intercepting calls. 547 00:26:25,000 --> 00:26:27,080 There's also proxy servers supported on many of them. 548 00:26:27,440 --> 00:26:30,300 The ability to listen in on telephone conversations. 549 00:26:36,780 --> 00:26:37,360 Okay. 550 00:26:39,000 --> 00:26:39,620 In all honesty, 551 00:26:41,300 --> 00:26:42,900 I'm done with CSRF. 552 00:26:43,360 --> 00:26:43,640 It's... 553 00:26:43,640 --> 00:26:44,840 I think it's interesting. 554 00:26:45,100 --> 00:26:46,160 I think that a lot of people 555 00:26:46,840 --> 00:26:49,680 have passed it off as being lame. 556 00:26:50,800 --> 00:26:52,800 And it gets a lot of bad flack. 557 00:26:52,940 --> 00:26:55,020 I mean, GNU Citizen was nominated for a Pony Award, 558 00:26:55,280 --> 00:26:56,220 even though I thought that 559 00:26:56,860 --> 00:26:58,800 their attack against the BT hub was cool. 560 00:27:00,260 --> 00:27:02,060 But in all reality, 561 00:27:02,200 --> 00:27:03,600 that's not the problems 562 00:27:03,600 --> 00:27:04,900 that we face on the Internet today. 563 00:27:05,940 --> 00:27:07,380 The problems are botnets. 564 00:27:07,380 --> 00:27:11,060 Large, controlled systems of computers 565 00:27:11,060 --> 00:27:13,720 that are even waging wars. 566 00:27:15,120 --> 00:27:16,700 Wars of spam. 567 00:27:17,260 --> 00:27:20,480 And that is actually my Oday. 568 00:27:20,680 --> 00:27:21,740 My Oday... 569 00:27:21,740 --> 00:27:24,080 This is DEFCON. 570 00:27:24,280 --> 00:27:27,440 And it is a unique place 571 00:27:27,440 --> 00:27:32,260 where you have people on both sides of the war. 572 00:27:32,440 --> 00:27:34,600 You have the blackest of the black hat 573 00:27:34,600 --> 00:27:36,700 sitting next to systems administrators, 574 00:27:37,020 --> 00:27:37,360 and you have people on both sides of the war. 575 00:27:37,360 --> 00:27:38,740 And software quality control. 576 00:27:39,080 --> 00:27:40,840 You're literally sitting next to your enemy 577 00:27:40,840 --> 00:27:41,700 in a brutal war. 578 00:27:42,440 --> 00:27:43,000 And... 579 00:27:46,800 --> 00:27:50,080 I'm very proud to drop this. 580 00:27:50,220 --> 00:27:51,760 This is a very good exploit. 581 00:27:52,780 --> 00:27:53,900 As an example, 582 00:27:55,800 --> 00:27:58,320 it affects none other than 583 00:27:58,320 --> 00:28:00,020 the Coppermine photo gallery, 584 00:28:00,220 --> 00:28:01,060 which if you don't know, 585 00:28:01,180 --> 00:28:02,740 there should be around... 586 00:28:02,740 --> 00:28:03,400 Oh. 587 00:28:04,040 --> 00:28:04,600 There. 588 00:28:04,600 --> 00:28:05,260 Hmm. 589 00:28:08,040 --> 00:28:09,040 Powered by... 590 00:28:09,600 --> 00:28:11,060 Don't have the Google hack on hand, 591 00:28:11,200 --> 00:28:12,400 but it's around five million sites 592 00:28:12,400 --> 00:28:13,840 that are running this. 593 00:28:14,040 --> 00:28:16,960 And the exploit is the ability 594 00:28:16,960 --> 00:28:20,860 to copy any remote file 595 00:28:20,860 --> 00:28:24,180 to the system and execute it. 596 00:28:24,280 --> 00:28:25,540 You could copy PHP files. 597 00:28:25,820 --> 00:28:27,520 This is Prime from Worms. 598 00:28:29,840 --> 00:28:30,400 Okay. 599 00:28:30,720 --> 00:28:31,620 I'm not done. 600 00:28:31,800 --> 00:28:32,640 I'm not done. 601 00:28:33,160 --> 00:28:33,720 Okay. 602 00:28:33,720 --> 00:28:34,460 Even worse. 603 00:28:35,100 --> 00:28:37,320 Over the past few years, 604 00:28:37,400 --> 00:28:38,760 I've been collecting worm code. 605 00:28:39,460 --> 00:28:42,000 I'm very happy with my worm code collection. 606 00:28:42,600 --> 00:28:44,800 And if you go to rooksecurity.com... 607 00:28:47,320 --> 00:28:47,940 Slash... 608 00:28:52,200 --> 00:28:53,440 Goodiebag.zip. 609 00:28:54,340 --> 00:28:54,960 Okay. 610 00:28:55,100 --> 00:28:56,720 In goodiebag.zip, 611 00:28:56,980 --> 00:28:59,480 there are source code for over 50 viruses 612 00:28:59,480 --> 00:29:00,280 and worms 613 00:29:00,280 --> 00:29:02,780 with Visual Studio build files. 614 00:29:02,780 --> 00:29:05,240 We have malware such as Mpac. 615 00:29:05,520 --> 00:29:07,000 Two versions of Mpac. 616 00:29:08,280 --> 00:29:10,620 Mydoom that builds and spreads. 617 00:29:12,140 --> 00:29:13,480 You name it. 618 00:29:13,560 --> 00:29:14,920 This is everything you need 619 00:29:14,920 --> 00:29:16,820 to build a botnet of your own. 620 00:29:17,140 --> 00:29:18,760 You're talking great outbreaks 621 00:29:18,760 --> 00:29:20,600 such as Blaster, Mytob. 622 00:29:20,920 --> 00:29:21,440 They're there. 623 00:29:22,080 --> 00:29:25,680 Custom modules for your GoBot and FatBot, 624 00:29:25,740 --> 00:29:27,220 they're also on this file. 625 00:29:27,500 --> 00:29:28,720 Goodiebag.zip. 626 00:29:29,440 --> 00:29:31,500 Honestly, I hope someone downloads it. 627 00:29:31,920 --> 00:29:32,560 Also, 628 00:29:32,560 --> 00:29:35,660 this is a particularly devastating combination. 629 00:29:38,160 --> 00:29:47,780 It is www.rooksecurity.com 630 00:29:48,360 --> 00:29:53,580 slash g-o-o-d-i-e-b-a-g.com. 631 00:29:53,780 --> 00:29:55,380 Please share it with your friends. 632 00:29:55,640 --> 00:29:56,580 Oh, that's it. 633 00:29:56,640 --> 00:29:56,900 That's it. 634 00:29:57,040 --> 00:29:57,580 That's it. 635 00:29:59,100 --> 00:30:00,600 Please share it with your friends. 636 00:30:00,600 --> 00:30:03,900 This is years of copulation. 637 00:30:05,220 --> 00:30:05,720 Now... 638 00:30:06,880 --> 00:30:07,380 Okay. 639 00:30:10,420 --> 00:30:11,940 Actually, I have a... 640 00:30:16,460 --> 00:30:18,720 I'm going to do a bit of a return to CSRF 641 00:30:18,720 --> 00:30:20,520 because this actually relates to this flaw. 642 00:30:21,880 --> 00:30:22,740 Turns out, 643 00:30:22,800 --> 00:30:25,840 this flaw is also exploitable by CSRF, 644 00:30:25,920 --> 00:30:26,940 although it doesn't have to be. 645 00:30:27,320 --> 00:30:28,920 It is simply sending... 646 00:30:28,920 --> 00:30:30,580 By sending a single git, 647 00:30:30,600 --> 00:30:31,260 and post request, 648 00:30:31,600 --> 00:30:32,440 you're able to... 649 00:30:34,560 --> 00:30:37,040 You're able to incur the flaw, 650 00:30:37,200 --> 00:30:37,960 incur the vulnerability. 651 00:30:40,080 --> 00:30:40,780 Okay. 652 00:30:41,020 --> 00:30:42,760 It's actually rather advanced. 653 00:30:43,040 --> 00:30:44,120 I'm using something called 654 00:30:44,120 --> 00:30:46,060 global variable manipulation, 655 00:30:46,400 --> 00:30:49,560 which is advanced PHP hacking. 656 00:30:50,480 --> 00:30:51,180 It's... 657 00:30:51,180 --> 00:30:51,900 They are... 658 00:30:51,900 --> 00:30:52,920 They're containing... 659 00:30:52,920 --> 00:30:53,280 Here. 660 00:30:53,420 --> 00:30:54,280 Pull it up. 661 00:30:56,240 --> 00:30:57,100 All right. 662 00:30:57,460 --> 00:30:58,760 I don't know... 663 00:30:59,880 --> 00:31:00,360 What? 664 00:31:01,600 --> 00:31:02,680 The URL again? 665 00:31:02,920 --> 00:31:05,660 It is rooksecurity.com 666 00:31:06,840 --> 00:31:07,320 slash... 667 00:31:09,120 --> 00:31:10,200 Make sure I get it right. 668 00:31:10,340 --> 00:31:11,800 Goodiebag.zip. 669 00:31:13,180 --> 00:31:14,320 I'll be posting it... 670 00:31:14,320 --> 00:31:15,720 I'll be posting it to my main page, 671 00:31:15,820 --> 00:31:16,740 rooksecurity.com, 672 00:31:16,800 --> 00:31:17,500 if you visit it. 673 00:31:17,580 --> 00:31:19,660 I'll be posting it after this talk. 674 00:31:20,460 --> 00:31:21,300 And again, 675 00:31:21,460 --> 00:31:23,160 I encourage you to visit my blog. 676 00:31:23,240 --> 00:31:24,660 I do post ODAs regularly. 677 00:31:26,240 --> 00:31:26,720 Very... 678 00:31:26,720 --> 00:31:27,920 I understand. 679 00:31:27,920 --> 00:31:29,640 This is not good disclosure. 680 00:31:30,100 --> 00:31:31,740 Not wise disclosure. 681 00:31:33,200 --> 00:31:33,920 Ethical? 682 00:31:34,080 --> 00:31:34,720 Ethics? 683 00:31:36,560 --> 00:31:37,500 All right. 684 00:31:38,680 --> 00:31:39,400 Okay. 685 00:31:39,580 --> 00:31:40,860 The ability... 686 00:31:40,860 --> 00:31:44,140 The ability for this flaw to work 687 00:31:45,100 --> 00:31:47,640 is actually a bit complex. 688 00:31:48,000 --> 00:31:51,400 And it's certainly more complex than CSRF. 689 00:31:51,760 --> 00:31:53,280 What I'm able to do, 690 00:31:53,420 --> 00:31:55,640 or what the code you are looking at here does, 691 00:31:55,640 --> 00:32:00,080 is it's attempting to clean up the global namespace 692 00:32:00,600 --> 00:32:02,160 of a PHP application. 693 00:32:03,540 --> 00:32:04,300 However, 694 00:32:04,540 --> 00:32:06,100 it contains a fundamental flaw. 695 00:32:06,800 --> 00:32:08,840 This array that is selected right here 696 00:32:08,840 --> 00:32:12,320 contains what variables 697 00:32:13,400 --> 00:32:17,940 that it does not want to unset or destroy. 698 00:32:18,760 --> 00:32:19,520 However, 699 00:32:20,460 --> 00:32:22,120 by unsetting this array, 700 00:32:22,360 --> 00:32:24,700 I'm then able to... 701 00:32:24,700 --> 00:32:25,040 actually... 702 00:32:26,200 --> 00:32:29,300 do something that sounds a bit counterintuitive. 703 00:32:29,600 --> 00:32:32,220 I'm unsetting the other request methods. 704 00:32:32,500 --> 00:32:33,220 I'm unsetting... 705 00:32:33,220 --> 00:32:33,880 In fact, 706 00:32:34,490 --> 00:32:37,860 any variable sent as a git or a cookie 707 00:32:37,860 --> 00:32:38,740 is being unset. 708 00:32:38,920 --> 00:32:40,740 I'm also unsetting the request superglobal. 709 00:32:41,100 --> 00:32:42,600 The reason why is because 710 00:32:42,600 --> 00:32:43,960 when they're unset, 711 00:32:44,000 --> 00:32:45,000 it's not checking them 712 00:32:45,000 --> 00:32:48,780 if a global variable has been sent 713 00:32:48,780 --> 00:32:51,860 via that superglobal. 714 00:32:52,450 --> 00:32:54,180 I know I missed a lot of you. 715 00:32:54,700 --> 00:32:56,460 But what this allows me to do 716 00:32:56,460 --> 00:32:59,820 is basically it turns the entire variable namespace 717 00:32:59,820 --> 00:33:00,540 into a taint. 718 00:33:00,760 --> 00:33:02,940 I'm able to have an amazing amount of control 719 00:33:02,940 --> 00:33:03,740 over the application 720 00:33:03,740 --> 00:33:05,760 and really make it vomit up on itself. 721 00:33:06,580 --> 00:33:07,460 In this case, 722 00:33:08,120 --> 00:33:10,400 the next step is literally to go through 723 00:33:10,400 --> 00:33:13,860 and look for syncs. 724 00:33:14,160 --> 00:33:14,860 In this case, 725 00:33:14,860 --> 00:33:18,420 the sync I'm hacking is a call to copy. 726 00:33:19,800 --> 00:33:24,680 Now, copy is much better than other syncs. 727 00:33:24,680 --> 00:33:25,340 There are other syncs that you've heard of, 728 00:33:25,400 --> 00:33:28,600 such as require once, require or include. 729 00:33:28,980 --> 00:33:30,380 The reason why is because 730 00:33:31,220 --> 00:33:34,760 it has to do with copy on a default PHP. 731 00:33:35,200 --> 00:33:37,660 You can pass it a parameter of a URL, 732 00:33:37,920 --> 00:33:42,020 and it'll download that URL to your local system. 733 00:33:42,260 --> 00:33:45,200 Whereas include can include remote code. 734 00:33:45,440 --> 00:33:47,940 However, by default, it does not allow this. 735 00:33:49,260 --> 00:33:51,300 In order for this vulnerability to work, 736 00:33:51,540 --> 00:33:54,140 you do have to have registered globals enabled. 737 00:33:55,060 --> 00:33:55,560 However, 738 00:33:57,200 --> 00:33:59,940 and this is not default on the latest version of PHP. 739 00:34:15,440 --> 00:34:16,440 In short, 740 00:34:17,820 --> 00:34:20,260 if any of you are curious about this exploit code, 741 00:34:20,520 --> 00:34:23,160 I encourage you to come to the question and answers afterwards. 742 00:34:24,680 --> 00:34:26,860 The code will be posted to my blog shortly 743 00:34:26,860 --> 00:34:29,280 if you wish to see it at that time 744 00:34:30,100 --> 00:34:31,520 or at a later date. 745 00:34:34,220 --> 00:34:38,320 One of the major points of this... 746 00:34:42,720 --> 00:34:44,000 The ability... 747 00:34:46,040 --> 00:34:49,840 The ability to use the resources around you 748 00:34:50,620 --> 00:34:53,580 that aren't necessarily a clear vulnerability, 749 00:34:53,580 --> 00:34:55,580 such as the spy dynamics flaw, 750 00:34:55,760 --> 00:34:59,060 has been known about for years, 751 00:34:59,280 --> 00:35:01,380 yet it's been unpatched. 752 00:35:01,700 --> 00:35:09,180 It allows you to identify local embedded systems. 753 00:35:10,460 --> 00:35:12,240 There are other issues, though. 754 00:35:12,540 --> 00:35:16,780 The ability to send get and post requests 755 00:35:16,780 --> 00:35:17,880 anywhere on the internet 756 00:35:17,880 --> 00:35:21,480 allows you to use web browsers 757 00:35:21,480 --> 00:35:22,940 as a means of 758 00:35:23,580 --> 00:35:24,600 as a proxy server, even, 759 00:35:24,640 --> 00:35:25,940 to break into other systems. 760 00:35:26,740 --> 00:35:27,580 In fact, 761 00:35:27,700 --> 00:35:29,760 because this particular flaw 762 00:35:29,760 --> 00:35:31,040 can be exploited 763 00:35:31,480 --> 00:35:36,080 by a cross site request, 764 00:35:36,860 --> 00:35:38,300 you can, in garrison, 765 00:35:39,940 --> 00:35:42,780 any web browser visiting your site, 766 00:35:42,980 --> 00:35:44,800 even if it's a fully patched web browser, 767 00:35:44,880 --> 00:35:46,760 can still be made of use. 768 00:35:47,040 --> 00:35:50,120 You can force them into hacking other servers. 769 00:35:51,200 --> 00:35:52,760 That's multiplying your bandwidth. 770 00:35:53,580 --> 00:35:54,180 In fact, 771 00:35:56,420 --> 00:35:58,880 in the URL that you choose to download, 772 00:35:59,080 --> 00:36:00,180 it could be anything online. 773 00:36:00,660 --> 00:36:00,960 For instance, 774 00:36:01,200 --> 00:36:04,080 a good example is SourceForge. 775 00:36:06,160 --> 00:36:08,920 SourceForge.net has a CVE, 776 00:36:09,960 --> 00:36:11,880 Common Versioning System, 777 00:36:12,180 --> 00:36:13,100 CVS. 778 00:36:13,840 --> 00:36:15,240 In this CVS, 779 00:36:15,280 --> 00:36:18,080 you can host raw text files. 780 00:36:18,680 --> 00:36:20,500 In essence, you could take, 781 00:36:20,600 --> 00:36:22,240 for instance, MPAC, 782 00:36:22,240 --> 00:36:25,120 or a backdoor, 783 00:36:25,300 --> 00:36:27,600 and host it as a SourceForge project, 784 00:36:27,960 --> 00:36:29,500 and then being able to use that 785 00:36:29,500 --> 00:36:34,540 to exploit other systems. 786 00:36:34,680 --> 00:36:36,000 You're using SourceForge's bandwidth 787 00:36:37,700 --> 00:36:39,820 to transfer your backdoor, 788 00:36:40,000 --> 00:36:42,540 and you're using common clients 789 00:36:42,540 --> 00:36:43,360 to visit your site 790 00:36:43,360 --> 00:36:44,340 to attack them. 791 00:36:45,560 --> 00:36:47,040 All your server is doing, 792 00:36:47,200 --> 00:36:49,180 the server that you actually own, 793 00:36:49,360 --> 00:36:51,700 all it is doing is having a list 794 00:36:51,700 --> 00:36:54,120 of other sites to attack. 795 00:36:54,540 --> 00:36:55,660 You're giving it a list, 796 00:36:55,780 --> 00:36:57,560 hey, start attacking this site, 797 00:36:57,700 --> 00:37:00,740 and it'll continue about its normal business. 798 00:37:01,140 --> 00:37:03,540 It's key that the site that you own, 799 00:37:03,560 --> 00:37:05,480 that you have remote code execution on, 800 00:37:05,660 --> 00:37:07,260 you don't want this to be detected. 801 00:37:07,440 --> 00:37:08,400 You want this under your control 802 00:37:08,400 --> 00:37:09,280 as long as possible. 803 00:37:12,340 --> 00:37:14,840 It would not be wise to use this system 804 00:37:14,840 --> 00:37:17,500 in a denial of service attack or others. 805 00:37:22,200 --> 00:37:22,760 Anyway. 806 00:37:26,460 --> 00:37:28,520 I suppose that concludes my talk. 807 00:37:29,080 --> 00:37:30,360 I hope you enjoyed it. 808 00:37:30,520 --> 00:37:33,900 I hope you download my worm code 809 00:37:33,900 --> 00:37:35,780 and use my exploit code. 810 00:37:36,440 --> 00:37:37,980 It makes me happy.