1 00:00:00,000 --> 00:00:05,080 I didn't know this was going to be at 4.30, so I apologize if I interrupted your 4.20 break. 2 00:00:06,080 --> 00:00:10,320 Anyway, hey, thanks for coming out. I know it's been a long day, especially a long week if you've been a black hat. 3 00:00:11,520 --> 00:00:15,380 I'm going to talk about some new techniques in SQLI obfuscation, 4 00:00:16,020 --> 00:00:19,020 meaning new ways of sort of hiding your SQL injection attacks, 5 00:00:20,060 --> 00:00:23,200 or ways of avoiding web application firewalls. 6 00:00:24,280 --> 00:00:30,620 And if you dare use your Wi-Fi or wireless, these slides are online right now, 7 00:00:30,700 --> 00:00:35,240 a slightly older version, but I'll repost the latest later tonight. 8 00:00:36,380 --> 00:00:38,660 So let that bake for people to type in stuff. 9 00:00:45,000 --> 00:00:47,000 All right. It's not that many characters. 10 00:00:47,940 --> 00:00:50,620 Cool. Who am I? My name is Nick Galbraith. 11 00:00:50,960 --> 00:00:53,180 I work at Etsy. How many people know who Etsy is? 12 00:00:53,200 --> 00:00:56,460 Oh, yeah. Right on. Okay. 13 00:00:57,320 --> 00:01:03,640 For those who don't, we're an online marketplace for artisans, handmade stuff. 14 00:01:04,140 --> 00:01:07,580 It pretty much owns the cyber steampunk category, if you're into that, 15 00:01:07,740 --> 00:01:10,460 which seems to be a popular meme here at DEF CON. 16 00:01:11,380 --> 00:01:13,860 Top 50 American website. 17 00:01:14,240 --> 00:01:19,160 Did about $500 million in transaction volume, so we see a lot of crazy stuff at our site. 18 00:01:19,400 --> 00:01:21,660 And this is some of the research that came out from it. 19 00:01:22,480 --> 00:01:23,180 My site is a web site. 20 00:01:23,180 --> 00:01:28,980 My specialty is managing some of the groups that handle security, fraud, and a bunch of sort of enterprise features. 21 00:01:30,120 --> 00:01:32,960 Previously, I've worked a lot in cryptography. 22 00:01:33,120 --> 00:01:35,460 Wiley published a book of mine about 10 years ago. 23 00:01:37,440 --> 00:01:43,960 And I've been fixing, like, broken auth systems and password storage systems and applications for the last, like, 15 or 20 years. 24 00:01:47,580 --> 00:01:51,880 So, this sort of came out of some stuff that my colleague, Zane Lackey, who's here, 25 00:01:51,880 --> 00:01:53,360 right here in the front row. 26 00:01:57,500 --> 00:02:02,000 How can we determine if our website is under attack? 27 00:02:02,280 --> 00:02:08,280 How do we know when people are probing us and, you know, poking at our systems and stuff like that? 28 00:02:08,500 --> 00:02:13,380 We're a little larger than, the problem is we're sort of this mid-tier. 29 00:02:13,520 --> 00:02:18,400 It's very difficult for us to put, like, a true web application firewall in front of all our stuff. 30 00:02:18,680 --> 00:02:21,860 So, we do a lot of monitoring in the application on the back end. 31 00:02:21,880 --> 00:02:23,420 And we try and detect SQL injection. 32 00:02:25,180 --> 00:02:29,740 And so, one of the things we were doing is, like, well, how can you actually tell if something is a SQL injection or not? 33 00:02:29,980 --> 00:02:32,060 And I sort of started going down this path. 34 00:02:32,240 --> 00:02:34,200 And it turns out SQL is gargantuan. 35 00:02:35,400 --> 00:02:41,120 You know, the 92 spec is 625. 36 00:02:41,700 --> 00:02:42,100 Hello? 37 00:02:42,480 --> 00:02:42,880 Test. 38 00:02:43,520 --> 00:02:44,060 We back? 39 00:02:44,720 --> 00:02:45,440 Everyone hear me? 40 00:02:46,240 --> 00:02:46,640 Test. 41 00:02:46,840 --> 00:02:47,700 Yeah, okay, we're back. 42 00:02:49,360 --> 00:02:51,240 625 pages of this pure text. 43 00:02:51,880 --> 00:02:56,640 The latest BNF specification, what does it say, 120 pages of pure text? 44 00:02:56,820 --> 00:02:57,900 It's gargantuan. 45 00:02:57,940 --> 00:03:00,420 And no one implements it to spec. 46 00:03:00,640 --> 00:03:03,640 And everyone's got special rules that they do. 47 00:03:04,120 --> 00:03:05,140 Everyone's got exceptions. 48 00:03:05,520 --> 00:03:06,820 Everyone's got special cases. 49 00:03:07,340 --> 00:03:15,660 So, what happens is, when I was investigating how people look at, how do they determine if something is a SQL injection or not, 50 00:03:15,840 --> 00:03:17,860 we kind of end up with something like this. 51 00:03:18,500 --> 00:03:21,760 And it's, this is a big mess. 52 00:03:21,880 --> 00:03:27,800 And part of the reason I just sort of threw up when I saw it is, just by inspection, I see bugs. 53 00:03:28,220 --> 00:03:29,600 I just see bugs all over it. 54 00:03:29,660 --> 00:03:34,340 It's like, oh, well, you just add an extra space to your thing, and you're going to get by this application firewall. 55 00:03:34,680 --> 00:03:39,400 Not to pick on PHP IDS, nice guys, mod security, same problems. 56 00:03:39,840 --> 00:03:45,060 Hard-wired limits, things missing, white space at the end, all sorts of ways of getting around it. 57 00:03:45,180 --> 00:03:48,220 And so it's like, we've got to be able to do it a different way. 58 00:03:49,340 --> 00:03:51,860 And, uh, has anyone seen my talk at BuzzFeed? 59 00:03:51,880 --> 00:03:52,800 Black Hat a couple days ago? 60 00:03:53,920 --> 00:03:55,580 Hey, a couple people. 61 00:03:56,020 --> 00:03:56,580 Awesome. 62 00:03:56,860 --> 00:03:57,240 Okay. 63 00:03:57,900 --> 00:04:01,480 The 30-second version of it is, maybe a minute, 64 00:04:02,980 --> 00:04:04,780 Live Injection's a new C library. 65 00:04:05,260 --> 00:04:07,000 It's easy to port to other languages. 66 00:04:07,120 --> 00:04:08,520 It's open source right now. 67 00:04:08,740 --> 00:04:15,860 And it handles parsing and tokenizing user input in a totally different way than regular expressions. 68 00:04:16,320 --> 00:04:18,320 It creates a series of tokens. 69 00:04:18,480 --> 00:04:19,500 It does some reductions. 70 00:04:19,520 --> 00:04:21,860 And then matches it against known expressions. 71 00:04:21,880 --> 00:04:23,040 It's called SQL Injection Attacks. 72 00:04:24,320 --> 00:04:26,140 It was released a couple days ago. 73 00:04:26,560 --> 00:04:27,920 Some URLs for it. 74 00:04:31,200 --> 00:04:32,520 Let that bake for a minute. 75 00:04:34,680 --> 00:04:38,900 And so what I was doing with this is, this detects SQL Injection Attacks pretty well. 76 00:04:38,960 --> 00:04:40,720 It has a really low false positive rate. 77 00:04:41,380 --> 00:04:44,720 And I was writing this, and I've been studying the spec and all these rules. 78 00:04:45,200 --> 00:04:46,580 Writing a whole bunch of stuff. 79 00:04:46,680 --> 00:04:47,960 And a bunch of stuff I didn't care about. 80 00:04:48,120 --> 00:04:49,740 Like, I'm not going to worry about that right now. 81 00:04:50,560 --> 00:04:51,860 And, you know, I'm not going to worry about that right now. 82 00:04:51,880 --> 00:04:57,520 What I did is I pumped tens of thousands of real SQL Injection Attacks into it. 83 00:04:58,940 --> 00:05:00,940 And it came from everywhere. 84 00:05:01,060 --> 00:05:01,800 Published attacks. 85 00:05:02,220 --> 00:05:03,560 How-to guides. 86 00:05:04,020 --> 00:05:05,800 Random stuff we see at Etsy. 87 00:05:06,120 --> 00:05:09,720 And the output of things like SQL Map and things like that. 88 00:05:09,840 --> 00:05:12,720 So just tens of thousands of real SQL Injection Attacks. 89 00:05:13,720 --> 00:05:16,300 And what I did is pumped it all through. 90 00:05:17,630 --> 00:05:20,700 I used code coverage analysis at the end of this. 91 00:05:20,700 --> 00:05:25,780 And lo and behold, like, large parts of my parser weren't invoked. 92 00:05:25,860 --> 00:05:29,760 Which means that code has never been used in SQL Injection. 93 00:05:30,420 --> 00:05:32,780 Then there's a bunch of features I didn't implement. 94 00:05:33,240 --> 00:05:34,840 And it didn't seem to stop anything. 95 00:05:35,560 --> 00:05:39,680 So that means, like, those things I didn't implement also weren't being used in SQL Injection. 96 00:05:39,720 --> 00:05:41,040 Because that's kind of weird. 97 00:05:41,300 --> 00:05:43,720 So basically what I discovered is there's a bunch... 98 00:05:44,560 --> 00:05:45,500 That's a good talk. 99 00:05:47,480 --> 00:05:50,240 There's a bunch of SQL that's laying around. 100 00:05:50,300 --> 00:05:50,680 It's not... 101 00:05:50,700 --> 00:05:53,200 And it's never been used in SQL Injection. 102 00:05:53,560 --> 00:05:58,880 Which also means probably web application firewalls aren't detecting it either. 103 00:05:59,320 --> 00:06:02,800 If attackers don't know about it, it's unlikely defenders do too. 104 00:06:04,460 --> 00:06:09,800 So what I'm going to do is just sort of walk down the list of a lot of dark corners in SQL. 105 00:06:12,080 --> 00:06:13,520 Some you may know about. 106 00:06:13,680 --> 00:06:14,820 Some you may not know about. 107 00:06:15,260 --> 00:06:17,740 And this is going to be great for building new fuzzers. 108 00:06:18,320 --> 00:06:19,920 You know, vulnerability scanners. 109 00:06:19,920 --> 00:06:22,300 And certainly on defense, people detecting stuff. 110 00:06:22,600 --> 00:06:25,020 Some things they need to know about when they're doing it. 111 00:06:26,600 --> 00:06:28,240 So let's get started. 112 00:06:29,420 --> 00:06:29,900 Null. 113 00:06:30,020 --> 00:06:31,000 Our friend Null. 114 00:06:31,680 --> 00:06:32,980 Popular token in SQL. 115 00:06:34,260 --> 00:06:35,200 Let's take a look. 116 00:06:36,560 --> 00:06:37,960 So it turns out... 117 00:06:37,960 --> 00:06:38,820 This is the easiest one. 118 00:06:38,900 --> 00:06:40,480 I start with this one because it's so trivial. 119 00:06:40,860 --> 00:06:41,960 But it's a good example. 120 00:06:42,660 --> 00:06:44,340 MySQL Null, which actually... 121 00:06:44,340 --> 00:06:48,060 If we pop back a few slides, we'd see Null peppered through the regular expression. 122 00:06:48,060 --> 00:06:52,580 It can actually be written as backslash capital N. 123 00:06:54,060 --> 00:06:56,040 Backslash lowercase N is not Null. 124 00:06:56,120 --> 00:06:56,760 It's a new line. 125 00:06:57,400 --> 00:07:01,820 So that means if anyone does normalization, they do it too lower on the input. 126 00:07:01,960 --> 00:07:03,520 They just lowercase the whole string. 127 00:07:04,660 --> 00:07:10,340 And you used a capital slash N, your patterns wouldn't match it. 128 00:07:10,400 --> 00:07:11,480 It'd just slip right through. 129 00:07:11,600 --> 00:07:13,340 It wouldn't match those basic regular exceptions. 130 00:07:13,840 --> 00:07:15,220 People sort of know what I'm talking about? 131 00:07:15,360 --> 00:07:15,980 Does this sort of make sense? 132 00:07:16,540 --> 00:07:17,060 Yes. 133 00:07:17,300 --> 00:07:17,540 Yes. 134 00:07:17,720 --> 00:07:17,960 Yes. 135 00:07:17,960 --> 00:07:18,260 Yes. 136 00:07:18,540 --> 00:07:19,060 Cool. 137 00:07:19,260 --> 00:07:19,560 All right. 138 00:07:19,760 --> 00:07:21,580 So that's a great case. 139 00:07:21,700 --> 00:07:22,860 So just using that. 140 00:07:22,980 --> 00:07:24,240 I didn't see it in SQL map. 141 00:07:24,560 --> 00:07:27,000 Like in their sort of algorithms to fuzz things. 142 00:07:27,260 --> 00:07:31,400 Like that's a great example of something you can just bypass firewalls just by using 143 00:07:31,400 --> 00:07:31,900 slash N. 144 00:07:32,940 --> 00:07:34,920 So let's do some more exotic stuff. 145 00:07:36,160 --> 00:07:41,500 Lots of sort of unusual functions in Postgres that are not used elsewhere. 146 00:07:42,120 --> 00:07:44,440 Some of these things are functions in Microsoft. 147 00:07:44,440 --> 00:07:47,640 But they're not in Postgres. 148 00:07:47,820 --> 00:07:48,900 So there's a little different signature. 149 00:07:49,040 --> 00:07:51,340 Sometimes they're expected in a parenthesis at the end. 150 00:07:51,620 --> 00:07:52,680 Sometimes not. 151 00:07:53,040 --> 00:07:57,760 And then you have these sort of peculiar functions that are only unique to Postgres. 152 00:07:58,000 --> 00:08:03,800 So if you're building out some of these probing things like, you know, the classic like and or or one equals one. 153 00:08:04,000 --> 00:08:06,900 These are some other things that might slip through. 154 00:08:07,980 --> 00:08:09,040 They're very unusual. 155 00:08:09,160 --> 00:08:10,160 Just Postgres does them. 156 00:08:11,420 --> 00:08:14,420 So let's try some things. 157 00:08:14,420 --> 00:08:15,120 Let's try some things in Numbers. 158 00:08:15,540 --> 00:08:22,400 Numbers, when I was writing the parser in lib injection, it turns out parsing numbers is surprisingly difficult in SQL. 159 00:08:22,620 --> 00:08:24,300 And there's an amazing amount of diversity. 160 00:08:25,000 --> 00:08:27,640 And here's just an example of floating point numbers. 161 00:08:29,420 --> 00:08:32,300 I didn't actually write in true regular expression format. 162 00:08:32,800 --> 00:08:37,220 But it turns out you actually can't write this in a single regular expression. 163 00:08:37,900 --> 00:08:40,340 If you do, you're going to get a ton of false positives. 164 00:08:40,920 --> 00:08:42,740 That's sort of one of the tradeoffs I found. 165 00:08:42,740 --> 00:08:45,300 Is that, yeah, you can use regular expressions to do this. 166 00:08:45,640 --> 00:08:48,160 Except you're going to have this ton of false positives. 167 00:08:48,280 --> 00:08:49,140 And you just can't detect. 168 00:08:49,340 --> 00:08:50,300 You have to detect accurately. 169 00:08:51,020 --> 00:08:54,940 So if you just go down this list, there's, let's see, one, two, three, four, five, six, seven, eight, nine, ten. 170 00:08:55,060 --> 00:08:55,440 Okay. 171 00:08:56,360 --> 00:08:56,740 Fifteen. 172 00:08:57,140 --> 00:09:00,300 Fifteen different variations with possible unary operators. 173 00:09:01,000 --> 00:09:04,420 And Oracle has its own thing where you can throw some other stuff at the end. 174 00:09:05,140 --> 00:09:07,860 It's a complicated thing to do in a regular expression. 175 00:09:08,640 --> 00:09:11,020 So what I'm thinking is, you know, 176 00:09:11,020 --> 00:09:13,840 if you're writing something to fuzz SQL or fuzz a website, 177 00:09:14,260 --> 00:09:17,700 and you just sort of do like, yeah, one, and maybe just do a floating point, 178 00:09:17,880 --> 00:09:19,900 there's a lot more diversity. 179 00:09:20,160 --> 00:09:22,120 Especially things that just start with a dot. 180 00:09:23,580 --> 00:09:24,480 Exponential numbers. 181 00:09:24,860 --> 00:09:26,940 I've never seen that in any SQL injection. 182 00:09:27,360 --> 00:09:29,780 That's probably going to trip up a bunch of regular expressions. 183 00:09:31,680 --> 00:09:36,200 And then I've noticed parsers themselves handle things differently. 184 00:09:36,920 --> 00:09:40,840 So just the spacing and when it sort of figures out when a number ends, 185 00:09:41,020 --> 00:09:42,360 and when the next token starts. 186 00:09:43,180 --> 00:09:44,400 Very different behavior. 187 00:09:44,660 --> 00:09:47,460 Sometimes they're syntax errors, sometimes they're not. 188 00:09:47,660 --> 00:09:51,140 Which means it's going to be really tough writing a regular expression 189 00:09:51,140 --> 00:09:57,420 in order to handle these special database-specific parsing rules. 190 00:09:58,740 --> 00:10:00,380 And you see there's a few examples there. 191 00:10:00,460 --> 00:10:05,580 Exponential, floating point, you know, all sorts of deliminations there. 192 00:10:07,080 --> 00:10:08,700 And this one I like a lot. 193 00:10:08,700 --> 00:10:13,780 Because basically you're able to throw in a number that's not a number. 194 00:10:14,680 --> 00:10:17,860 So you want to do your and or equals one equals one type checks. 195 00:10:18,220 --> 00:10:19,840 These are great. They're not actually numbers. 196 00:10:20,020 --> 00:10:21,540 They actually look like just regular words. 197 00:10:21,820 --> 00:10:26,460 I haven't seen any, you know, WAF sort of like handle these sort of unusual cases. 198 00:10:26,920 --> 00:10:29,920 So you're building out like expressions, arithmetic expressions. 199 00:10:30,260 --> 00:10:33,800 These are great things to try out to sort of bypass firewalls. 200 00:10:34,820 --> 00:10:35,800 Making sense so far? 201 00:10:36,560 --> 00:10:36,980 Cool. 202 00:10:37,620 --> 00:10:38,220 All right. 203 00:10:38,700 --> 00:10:40,940 Let's get some more interest in in just a few minutes. 204 00:10:42,460 --> 00:10:43,220 Some more stuff. 205 00:10:43,520 --> 00:10:44,480 Hexadecimal literals. 206 00:10:44,620 --> 00:10:47,920 I've seen this a few times, you know, when you're building out strings 207 00:10:47,920 --> 00:10:50,420 and you do the CHR function or a D function. 208 00:10:50,700 --> 00:10:54,580 But again, it turns out special case exceptions for everything. 209 00:10:55,480 --> 00:10:56,660 Postgres got stuff. 210 00:10:56,940 --> 00:11:00,780 MySQL actually, sorry, Microsoft actually just lets 0x be a number. 211 00:11:01,980 --> 00:11:06,200 Quoting, non-quoting, complicated stuff and more. 212 00:11:06,740 --> 00:11:07,960 Binary literals. 213 00:11:07,960 --> 00:11:09,120 Didn't know about this. 214 00:11:09,360 --> 00:11:11,740 Why the hell you'd need this in SQL, I have no idea. 215 00:11:12,020 --> 00:11:12,900 But it's there. 216 00:11:13,600 --> 00:11:14,900 Oh, binary numbers. 217 00:11:15,220 --> 00:11:15,980 And they're different. 218 00:11:16,160 --> 00:11:17,060 And it's case sensitive. 219 00:11:17,640 --> 00:11:20,640 So if you did an upcase version, wouldn't work. 220 00:11:22,420 --> 00:11:22,900 Interesting. 221 00:11:25,540 --> 00:11:26,260 More stuff. 222 00:11:27,040 --> 00:11:27,520 Money. 223 00:11:28,020 --> 00:11:32,240 I am not a Microsoft expert, so I'd love some feedback on it. 224 00:11:33,440 --> 00:11:37,340 We already said like floating point already had 12 different variations, maybe more. 225 00:11:37,340 --> 00:11:38,600 Now we got more. 226 00:11:39,100 --> 00:11:39,980 Commas, okay. 227 00:11:40,660 --> 00:11:41,880 Dollar signs, okay. 228 00:11:42,740 --> 00:11:43,780 How does it cast? 229 00:11:43,980 --> 00:11:44,300 I don't know. 230 00:11:44,360 --> 00:11:46,720 I'd love some feedback on it or some help here. 231 00:11:47,580 --> 00:11:53,620 Again, if you're parsing things or if you're doing that 1 equals 1 trick or 1 not equals 0 trick, 232 00:11:53,960 --> 00:11:58,180 you can try a money dollar sign, you know, money value instead of a regular integer. 233 00:11:58,420 --> 00:12:00,600 That's probably going to snap some regular expressions. 234 00:12:01,100 --> 00:12:03,340 It's a really good test case. 235 00:12:05,560 --> 00:12:06,540 The fun part. 236 00:12:07,340 --> 00:12:11,940 So MySQL's been known to have some unusual commenting rules. 237 00:12:12,100 --> 00:12:16,080 If you're familiar with MySQL, it has a whole bunch of version commenting. 238 00:12:16,220 --> 00:12:18,260 It has all sorts of different ways of doing it. 239 00:12:18,400 --> 00:12:22,660 And in particular, the sort of, hey, my pointer's here, awesome. 240 00:12:23,620 --> 00:12:24,800 Pound sign comment. 241 00:12:25,040 --> 00:12:27,740 And this has been well used in SQL I attacks. 242 00:12:29,020 --> 00:12:34,320 However, if you're attacking Postgres, pound is actually an operator. 243 00:12:34,500 --> 00:12:35,740 It's not a comment. 244 00:12:35,960 --> 00:12:37,240 So if you're, wow. 245 00:12:37,240 --> 00:12:39,720 Is this like, hey, if there's a comment, just nuke it. 246 00:12:40,100 --> 00:12:43,500 In Postgres, you'd be actually eliminating real code. 247 00:12:44,020 --> 00:12:45,700 And that's really interesting. 248 00:12:46,120 --> 00:12:51,760 If there's a firewall or WAF that's actually like changing the input, this is a great way of like, hey, 249 00:12:51,780 --> 00:12:56,140 if you know the target's Postgres, throw in these like fake operators that don't do anything, 250 00:12:56,380 --> 00:13:02,060 it's very likely you're able to inject something courtesy of the WAF itself, rewriting stuff. 251 00:13:02,460 --> 00:13:07,220 And there's just a ton of interesting oddities in MySQL comments. 252 00:13:07,220 --> 00:13:13,040 They're pretty well known, but I just wanted to call it out that it's very complicated to sort of like tease these out. 253 00:13:14,000 --> 00:13:15,040 But there's more. 254 00:13:16,900 --> 00:13:21,780 Postgres, I don't know who did this, but they're actually recursive or nested C-style comments. 255 00:13:23,700 --> 00:13:25,360 So I've never seen this before. 256 00:13:25,480 --> 00:13:26,400 It doesn't work in C. 257 00:13:26,980 --> 00:13:30,240 And that last example, what happens when you remove all the comments? 258 00:13:30,360 --> 00:13:31,060 There's a lot of WAFs. 259 00:13:31,140 --> 00:13:33,480 Like, hey, I'm just going to nuke comments in the thing. 260 00:13:33,940 --> 00:13:34,920 Let's go over here. 261 00:13:35,200 --> 00:13:36,000 Chop it out. 262 00:13:36,000 --> 00:13:38,520 What happens if you remove the comments in a regular expression? 263 00:13:39,720 --> 00:13:42,300 They both go away and all you're left with is union all. 264 00:13:42,680 --> 00:13:43,560 That's pretty cool. 265 00:13:44,260 --> 00:13:46,520 And you can do more than one level. 266 00:13:46,580 --> 00:13:47,360 It just goes on forever. 267 00:13:47,620 --> 00:13:49,020 It's like a completely bizarre feature. 268 00:13:49,140 --> 00:13:50,000 I don't know what it's doing there. 269 00:13:51,080 --> 00:13:52,240 It gets worse. 270 00:13:54,000 --> 00:13:54,440 Strings. 271 00:13:54,440 --> 00:13:55,240 How am I doing on time? 272 00:13:55,340 --> 00:13:55,720 Pretty good. 273 00:13:57,940 --> 00:13:59,780 This is sort of one borrowed from C. 274 00:14:02,160 --> 00:14:05,980 Two strings next to each other actually merge into each other. 275 00:14:06,000 --> 00:14:09,080 So select foo bar is actually select foo bar. 276 00:14:09,280 --> 00:14:10,540 It just merges into one. 277 00:14:11,220 --> 00:14:16,260 So you can see you can chop up a query into little tiny string bits with all these parentheses, 278 00:14:16,680 --> 00:14:21,680 I mean quotation marks, and make a real mess for regular expression to parse. 279 00:14:22,900 --> 00:14:27,240 And again, Postgres and other ones require a new line. 280 00:14:29,360 --> 00:14:31,680 I'm going to whip through Unicode because it's just such a mess. 281 00:14:31,840 --> 00:14:33,860 It's something I really think needs a little more investigation. 282 00:14:35,580 --> 00:14:41,240 Sometimes you can specify strings being Unicode either with capital N, lowercase n, 283 00:14:41,380 --> 00:14:44,160 sometimes it's case sensitive, not sure on escaping rules. 284 00:14:44,380 --> 00:14:46,220 Another great way of sort of bypassing stuff. 285 00:14:47,580 --> 00:14:50,840 MySQL ad hoc character sets make up all sorts of crazy stuff. 286 00:14:51,740 --> 00:14:52,240 Fantastic. 287 00:14:53,680 --> 00:14:56,540 This is, you're screwed. 288 00:14:57,240 --> 00:14:58,020 You're screwed. 289 00:14:58,160 --> 00:15:01,060 I mean there's no, it's like I didn't even know about this. 290 00:15:01,220 --> 00:15:03,840 You're probably never going to use this as an application device. 291 00:15:03,840 --> 00:15:04,020 You're probably never going to use this as an developer. 292 00:15:04,220 --> 00:15:07,720 But as an attacker, oh, why bother using quotes? 293 00:15:07,880 --> 00:15:08,820 I'll just use dollar signs. 294 00:15:09,620 --> 00:15:11,920 You know, like, and guess what? 295 00:15:12,060 --> 00:15:12,680 They're nested. 296 00:15:12,760 --> 00:15:15,760 So go figure out the parsing rule of that. 297 00:15:15,920 --> 00:15:19,840 You really have to go character by character by character to figure out what's going on. 298 00:15:22,240 --> 00:15:28,800 This one, unfortunately, maybe the best is just to go down to the bottom here. 299 00:15:29,040 --> 00:15:31,580 I'm sorry for people on my right. 300 00:15:32,400 --> 00:15:33,960 Okay, it's a whole bunch of stuff. 301 00:15:34,660 --> 00:15:41,160 The main thing is here, the escape character is specified after the string. 302 00:15:42,220 --> 00:15:43,460 It's a post fix operator. 303 00:15:43,940 --> 00:15:48,380 So it means you don't even know what you're parsing until after you're done with it. 304 00:15:48,460 --> 00:15:48,840 Got it. 305 00:15:48,860 --> 00:15:49,220 Ten minutes. 306 00:15:49,260 --> 00:15:49,560 Thank you. 307 00:15:51,040 --> 00:15:54,900 I mean, when you get the slides, you can go click the link and try and decipher this stuff. 308 00:15:55,060 --> 00:15:57,880 But it's like, it's almost impossible to decipher. 309 00:15:58,140 --> 00:16:01,200 And this one, I think, is really good for busting. 310 00:16:01,200 --> 00:16:01,420 Wow. 311 00:16:03,580 --> 00:16:04,940 Same thing with Oracle. 312 00:16:06,260 --> 00:16:08,380 You can use Q as a delimiter. 313 00:16:08,800 --> 00:16:13,620 And this function call thing is really interesting because it's basically like a deferred evaluation. 314 00:16:14,620 --> 00:16:17,960 You can just pass in, you know, straight SQL into another function. 315 00:16:21,120 --> 00:16:22,980 And there's something with delimiters. 316 00:16:23,060 --> 00:16:28,460 If someone's an Oracle expert, I'd love to talk to you about exactly what is going on here with the other delimiters. 317 00:16:28,540 --> 00:16:29,820 It's complicated stuff. 318 00:16:29,820 --> 00:16:33,160 Bad for defense, good for offense. 319 00:16:34,880 --> 00:16:35,620 All right. 320 00:16:36,040 --> 00:16:38,500 Just a few more minutes here on expressions and operators. 321 00:16:38,780 --> 00:16:43,600 And here's some various sort of tips that might be useful if you're attacking things. 322 00:16:44,460 --> 00:16:45,420 Random operators. 323 00:16:45,800 --> 00:16:46,840 They're really strange. 324 00:16:47,420 --> 00:16:48,640 Cube root and Postgres. 325 00:16:48,720 --> 00:16:50,980 How many people have ever used a cube root? 326 00:16:52,000 --> 00:16:52,560 Silence. 327 00:16:53,960 --> 00:16:54,760 No one. 328 00:16:55,320 --> 00:16:56,420 Why are they there? 329 00:16:56,640 --> 00:16:57,200 Factorial. 330 00:16:57,420 --> 00:16:58,040 Like, why? 331 00:16:59,080 --> 00:16:59,560 More. 332 00:17:00,520 --> 00:17:01,580 Lots of things. 333 00:17:01,740 --> 00:17:03,180 Bit Y, X, or Oracle only. 334 00:17:05,200 --> 00:17:07,880 Not less than, not greater than. 335 00:17:07,940 --> 00:17:09,300 I've never seen that operator before. 336 00:17:09,860 --> 00:17:15,660 You know, like, you make the jokes write themselves. 337 00:17:15,860 --> 00:17:16,100 Right. 338 00:17:18,740 --> 00:17:21,100 So let's go up just one level more. 339 00:17:21,740 --> 00:17:26,340 So you see a lot of the sort of classic or one equals one, which is really easy to detect. 340 00:17:26,820 --> 00:17:31,000 This is me just sort of testing my own we screwed up. 341 00:17:31,040 --> 00:17:32,100 That's the talk to go to. 342 00:17:35,260 --> 00:17:36,220 One equals one. 343 00:17:36,480 --> 00:17:40,980 What I haven't seen, I did this only in my own testing, I've never seen it, is why do that? 344 00:17:41,080 --> 00:17:43,220 Why not use actual functions? 345 00:17:44,260 --> 00:17:47,120 Anything that evaluates true or false is what you need here. 346 00:17:47,420 --> 00:17:49,080 So, hey, you can go back to high school math. 347 00:17:49,360 --> 00:17:50,500 I probably made a mistake here. 348 00:17:51,640 --> 00:17:52,700 I'm almost positive. 349 00:17:52,980 --> 00:17:55,900 It's embarrassing because I have a degree in mathematics, but so be it. 350 00:17:56,860 --> 00:18:03,860 You can get a lot more creative in these test cases that are going to be really tough to figure out how to solve for. 351 00:18:06,420 --> 00:18:08,320 We all know about union, union all. 352 00:18:09,160 --> 00:18:13,560 There's also an intersect statement, which I was not familiar with. 353 00:18:13,680 --> 00:18:16,220 I think someone clever could do something with it. 354 00:18:16,300 --> 00:18:17,220 I don't know what. 355 00:18:17,400 --> 00:18:23,600 But I can absolutely guarantee that every web application firewall is not black banning that one. 356 00:18:23,860 --> 00:18:25,880 So that's something else to sort of poke around with. 357 00:18:27,440 --> 00:18:30,200 This one is sort of a side note. 358 00:18:30,300 --> 00:18:31,240 This one has come up. 359 00:18:32,680 --> 00:18:33,880 It's used all the time. 360 00:18:34,000 --> 00:18:35,160 There's things that poke through it. 361 00:18:35,240 --> 00:18:43,180 What's interesting about in lists, where you do this sort of select star where, you know, ID equals one, two, three, you know, it's a pretty common thing. 362 00:18:43,280 --> 00:18:53,400 To my knowledge, there is no platform, no system, no framework, no prepared statement that actually lets you pass in an array of values. 363 00:18:54,060 --> 00:18:55,880 Which means everything. 364 00:18:55,900 --> 00:19:00,020 Everyone who's using in list is writing custom code, not using parameter binding. 365 00:19:00,500 --> 00:19:04,140 Which means, knowing developers, they're not going to do it. 366 00:19:04,200 --> 00:19:05,140 They're not going to validate input. 367 00:19:05,580 --> 00:19:16,360 So if you're poking things and you have some form input that has a range or plurality of inputs that sort of you pass in the query string, prime target. 368 00:19:16,720 --> 00:19:19,380 Because if they're good developers, there's no parameter binding. 369 00:19:19,860 --> 00:19:21,800 It's custom code to build this query. 370 00:19:22,180 --> 00:19:23,760 So that's sort of neither here nor there. 371 00:19:23,880 --> 00:19:25,880 But it's a real weak point. 372 00:19:25,900 --> 00:19:27,400 It's sort of the application side. 373 00:19:30,180 --> 00:19:31,560 So I'm so smart. 374 00:19:31,720 --> 00:19:33,720 How come we don't see these all the time? 375 00:19:34,200 --> 00:19:36,320 I think it's because dumb attacks work. 376 00:19:37,200 --> 00:19:40,560 We haven't seen a lot of diversity in it because the dumb attacks work. 377 00:19:42,040 --> 00:19:45,360 Or there's not published reports on more interesting attacks. 378 00:19:46,400 --> 00:19:50,120 The good news is, I mean, this is a rich area for research. 379 00:19:50,880 --> 00:19:52,480 So it's something I look forward to working on. 380 00:19:53,900 --> 00:19:55,360 So what am I going to work on next? 381 00:19:55,900 --> 00:19:58,060 So loop injection, which I'll give you a link in just a minute. 382 00:19:58,460 --> 00:20:01,540 I really need to add more rules and more parsing types. 383 00:20:01,720 --> 00:20:04,320 And I really need to publish the stats of the output of it. 384 00:20:04,700 --> 00:20:06,880 I really need more testing on it. 385 00:20:07,620 --> 00:20:08,840 There's a whole bunch of things. 386 00:20:08,940 --> 00:20:09,720 There's big int types. 387 00:20:09,980 --> 00:20:12,760 Postgres has arrays and hashes and all sorts of stuff. 388 00:20:13,160 --> 00:20:16,100 Oh, and a regular expression engine just to make things more interesting. 389 00:20:16,900 --> 00:20:18,700 Those things can go on infinite loops. 390 00:20:18,860 --> 00:20:19,920 There's all sorts of stuff. 391 00:20:20,020 --> 00:20:21,180 You can bus stack on that. 392 00:20:21,420 --> 00:20:22,940 That's a real ripe area. 393 00:20:22,940 --> 00:20:24,760 And character encodings. 394 00:20:27,680 --> 00:20:28,920 It's just so complicated. 395 00:20:29,160 --> 00:20:30,180 It's the user. 396 00:20:30,620 --> 00:20:31,580 It's the application. 397 00:20:31,920 --> 00:20:32,640 It's the OS. 398 00:20:32,980 --> 00:20:34,220 It's the client library. 399 00:20:35,200 --> 00:20:36,620 Talking to the database. 400 00:20:37,240 --> 00:20:39,540 I mean, there's just a whole area of opportunity for mistakes. 401 00:20:41,200 --> 00:20:43,840 And some references you can go read on the website on your own. 402 00:20:44,500 --> 00:20:46,000 And thank you very much. 403 00:20:46,220 --> 00:20:47,100 Here are the URLs. 404 00:20:47,520 --> 00:20:48,560 And I'll leave that up. 405 00:20:48,640 --> 00:20:50,100 And I'm happy to take questions afterwards. 406 00:20:50,220 --> 00:20:51,060 Thanks a lot for coming. 407 00:20:52,940 --> 00:20:53,940 Thank you.