1 00:00:00,000 --> 00:00:05,080 Okay, I'm presenting a speech on SQL injection and out-of-band channeling. 2 00:00:08,020 --> 00:00:10,040 My name is Patrick Carlson. 3 00:00:11,120 --> 00:00:15,900 I work for a small firm called InspectIt, where I'm one of the owners. 4 00:00:17,120 --> 00:00:24,820 I also founded a website called secure.net back in the year 2000, where I published some of my tools. 5 00:00:30,000 --> 00:00:38,920 I currently work with penetration testing and application security reviews, source code reviews, general information security audits, basically. 6 00:00:43,200 --> 00:00:48,600 I'm going to present a speech on SQL injection with a focus on out-of-band channeling. 7 00:00:49,100 --> 00:00:56,700 And I'm going to show a number of examples using this technique, and I'm going to finish off the talk with a demonstration of how this can be performed. 8 00:00:58,200 --> 00:00:59,700 And the reason why is... 9 00:00:59,700 --> 00:01:03,020 Because when we perform our tests, we still see a lot of vulnerable applications. 10 00:01:03,220 --> 00:01:12,920 However, because applications are more hardened today maybe than before, it's a bit troublesome to get the data out of them sometimes. 11 00:01:14,240 --> 00:01:16,400 And, of course, tunneling data is fun. 12 00:01:19,900 --> 00:01:26,720 I'm not going to go through the basics of SQL injection that much, because it's quite a tight schedule. 13 00:01:27,860 --> 00:01:28,900 And I hope... 14 00:01:29,700 --> 00:01:34,680 And I hope that you're comfortable with SQL injection in order to understand everything here. 15 00:01:35,960 --> 00:01:42,880 I'm not presenting any arsenal of tools in order to automatically exploit this kind of vulnerabilities. 16 00:01:43,520 --> 00:01:47,540 And obviously not presenting a silver bullet solution to all SQL injection problems. 17 00:01:53,220 --> 00:01:55,640 Doing a very brief recap of SQL injection. 18 00:01:57,000 --> 00:01:58,780 It's a high-risk security vulnerability. 19 00:02:00,300 --> 00:02:04,660 We usually find it in web applications, but it's not limited to web application. 20 00:02:07,020 --> 00:02:14,240 And it's when you have the ability to inject arbitrary SQL code through poorly validated application parameters. 21 00:02:15,920 --> 00:02:22,380 And one might argue that this is due to inadequate design or due to improper validation controls. 22 00:02:24,460 --> 00:02:29,680 Having proper validation controls obviously rules out other problems such as cross-site scripting. 23 00:02:29,700 --> 00:02:31,600 So, it's always a good idea to have it. 24 00:02:32,080 --> 00:02:37,240 However, it's also even better to separate the data from the actual SQL code, 25 00:02:37,420 --> 00:02:42,020 not like building by concatenating strings, because then you usually run into these problems. 26 00:02:43,900 --> 00:02:47,960 And depending on the privileges and patch levels of the database server, 27 00:02:48,160 --> 00:02:50,820 the consequences may obviously range from troublesome to devastating. 28 00:02:53,080 --> 00:02:59,540 And a common misconception might be that usually just forms and URL parameters are vulnerable to this kind of problem. 29 00:03:00,460 --> 00:03:08,640 However, we find problems in cookies and referrer fields, and user agent fields in the HTTP headers. 30 00:03:09,200 --> 00:03:17,000 Like for example, when you implement a logging mechanism in order to log improper or failed login attempts, for example. 31 00:03:17,060 --> 00:03:25,020 You write a row into a database, and you use the insert statement, and you append a lot of data, like which web browser is the user using. 32 00:03:26,180 --> 00:03:29,660 Putting a couple of quotes in that user agent field, you can get a lot of data, but you can't get all the data you want. 33 00:03:29,680 --> 00:03:34,520 You can actually get control of the data. 34 00:03:36,620 --> 00:03:41,340 So looking at a classic example, we have the authentication function 35 00:03:41,340 --> 00:03:43,680 where you log in using your username and password. 36 00:03:45,720 --> 00:03:49,480 So basically the user supplies a username and password, 37 00:03:49,620 --> 00:03:52,500 and the database retrieves a user ID for this user, 38 00:03:52,600 --> 00:03:54,460 which is used throughout the application. 39 00:03:55,820 --> 00:03:58,860 In this case, we have no parameter validation, 40 00:03:58,860 --> 00:04:02,160 so we can enter any data we wish for. 41 00:04:03,320 --> 00:04:05,300 And by entering, for example, a quote, 42 00:04:05,440 --> 00:04:07,320 and or 1 equals 1 dash dash, 43 00:04:07,500 --> 00:04:09,960 we circumvent the whole login function 44 00:04:09,960 --> 00:04:11,600 and get access to the application. 45 00:04:11,960 --> 00:04:17,460 So basically that's SQL injection in a very brief recap. 46 00:04:21,100 --> 00:04:22,940 So our band channeling. 47 00:04:24,900 --> 00:04:27,920 Well, it relies on traditional SQL injection weaknesses 48 00:04:27,920 --> 00:04:28,740 for exploitation. 49 00:04:29,460 --> 00:04:33,260 However, contrary to normal SQL injection or in-band injection, 50 00:04:33,600 --> 00:04:36,600 it uses an alternative channel to return data. 51 00:04:38,300 --> 00:04:44,720 So, for example, you could be using timing, like, for example, 52 00:04:44,780 --> 00:04:48,460 does the first user begin with an A, then you wait five seconds. 53 00:04:48,560 --> 00:04:51,040 You would know that, okay, there's a user starting with A. 54 00:04:52,120 --> 00:04:56,980 You could use HTTP, which I'll show later in a couple of slides, 55 00:04:57,800 --> 00:04:58,360 where you. 56 00:04:59,040 --> 00:05:01,280 You could send the data in a HTTP request. 57 00:05:02,080 --> 00:05:06,940 And you could use DNS, which is the focus on the speech later on. 58 00:05:10,220 --> 00:05:12,200 And several different approaches exist, 59 00:05:12,440 --> 00:05:14,840 which depend on the back-end database. 60 00:05:15,040 --> 00:05:17,540 If you're running Microsoft SQL Server or Oracle, 61 00:05:17,700 --> 00:05:19,340 you might have to choose a different approach 62 00:05:19,340 --> 00:05:21,820 in order to exploit this vulnerability. 63 00:05:27,320 --> 00:05:28,560 So when is. 64 00:05:29,580 --> 00:05:32,140 Exploiting using out-of-band channels interesting. 65 00:05:34,180 --> 00:05:37,480 Well, when you don't have any detail error messages which 66 00:05:37,480 --> 00:05:41,140 you can rely on to extract data, it could be useful. 67 00:05:41,880 --> 00:05:46,280 When you gain access to, or when you're able to control 68 00:05:46,800 --> 00:05:49,220 a sql query very late in the query, 69 00:05:49,360 --> 00:05:52,360 like in the order by clause, which I will show also later on. 70 00:05:53,740 --> 00:05:56,660 When you're able to inject a second query through batching, 71 00:05:56,680 --> 00:05:58,180 when you do semicolon. 72 00:05:58,220 --> 00:05:58,440 And then. 73 00:05:58,500 --> 00:05:58,580 You. 74 00:05:58,640 --> 00:05:58,660 Have. 75 00:05:58,720 --> 00:05:58,840 Pascal. 76 00:05:58,860 --> 00:06:01,160 and a lot of SQL code after. 77 00:06:03,100 --> 00:06:05,840 And when results in some way are being limited or filtered, 78 00:06:06,060 --> 00:06:10,180 for example, you just get the first row of a table. 79 00:06:12,140 --> 00:06:15,180 And when firewall rules are lax, 80 00:06:15,260 --> 00:06:19,980 when you can open a channel back to one of your DNS servers 81 00:06:19,980 --> 00:06:22,200 or one of your HTTP servers or whatever. 82 00:06:25,340 --> 00:06:27,400 Contrary to blind SQL injection, 83 00:06:27,400 --> 00:06:28,620 when you do a lot of queries 84 00:06:28,620 --> 00:06:29,940 in order to extract little data, 85 00:06:30,840 --> 00:06:34,380 out-of-band channeling turns this around. 86 00:06:34,580 --> 00:06:37,100 You do a lot of injection or one single query 87 00:06:37,100 --> 00:06:39,900 and you retrieve all the data with one single query. 88 00:06:41,000 --> 00:06:42,980 And obviously, when blind SQL injection 89 00:06:42,980 --> 00:06:44,100 looks like the only option, 90 00:06:44,240 --> 00:06:46,400 this might come in handy in many cases. 91 00:06:46,780 --> 00:06:49,240 And I believe it's a much more efficient way 92 00:06:49,240 --> 00:06:50,020 of extracting data. 93 00:06:55,880 --> 00:06:57,100 So we have three 94 00:06:57,400 --> 00:07:02,120 examples here where we get control of the data, 95 00:07:02,220 --> 00:07:06,380 where all of the SQL statements in the first case 96 00:07:06,380 --> 00:07:07,680 very late in the order-by clause. 97 00:07:08,400 --> 00:07:13,100 We have a store procedure which actually log-ons the user. 98 00:07:13,200 --> 00:07:14,640 It returns true or false. 99 00:07:14,900 --> 00:07:16,720 So basically, we'll have a hard time here 100 00:07:16,720 --> 00:07:20,740 retrieving any data, but using out-of-band channeling, 101 00:07:20,760 --> 00:07:23,000 we could retrieve anything from the database. 102 00:07:24,320 --> 00:07:27,200 We have also the last query here, 103 00:07:27,200 --> 00:07:28,980 which simply returns a single row. 104 00:07:35,240 --> 00:07:37,440 And depending on a number of different factors, 105 00:07:37,560 --> 00:07:38,500 which we'll discuss, 106 00:07:41,000 --> 00:07:44,180 the channel chosen can be more or less suitable. 107 00:07:46,080 --> 00:07:48,000 I'll show you three different channels 108 00:07:48,520 --> 00:07:51,380 and I'll finish up by demonstrating the DNS channel. 109 00:07:54,340 --> 00:07:56,560 What I'm gonna talk about first is open row sets. 110 00:07:57,320 --> 00:08:00,040 It's a SQL server function. 111 00:08:01,580 --> 00:08:03,540 And I'm also gonna talk briefly about 112 00:08:03,540 --> 00:08:06,300 the UTL HTTP package in Oracle. 113 00:08:06,540 --> 00:08:09,780 And then finishing with a couple of slides of DNS. 114 00:08:17,840 --> 00:08:20,100 So open row set, I decided to include this 115 00:08:20,100 --> 00:08:22,360 in my demonstration even though that it's not very likely 116 00:08:22,360 --> 00:08:25,280 to be able to exploit it nowadays because it's restricted 117 00:08:25,280 --> 00:08:26,960 in most SQL server environments. 118 00:08:29,440 --> 00:08:32,100 But it illustrates the problem and it shows 119 00:08:32,100 --> 00:08:33,440 a good picture of how everything works. 120 00:08:35,480 --> 00:08:37,800 Open row set allows you to retrieve information 121 00:08:37,800 --> 00:08:39,300 from an alternative data provider. 122 00:08:40,690 --> 00:08:42,580 And usually it can be used together with union 123 00:08:42,990 --> 00:08:46,380 in order to extract data from another database 124 00:08:46,380 --> 00:08:47,080 for a neighbor database. 125 00:08:47,420 --> 00:08:50,200 And it's disabled by default in SQL Server 2005. 126 00:08:50,900 --> 00:08:54,840 And in SQL Server 2000 post service pack three, it's also 127 00:08:54,840 --> 00:08:57,240 disabled and available only to sysadmin users. 128 00:09:01,920 --> 00:09:04,180 The syntax, not very. 129 00:09:06,560 --> 00:09:08,780 Here's a classic example of enumerating data 130 00:09:08,780 --> 00:09:09,640 from a neighbor database. 131 00:09:09,960 --> 00:09:13,120 So basically we do a union of our first select statement 132 00:09:13,120 --> 00:09:15,800 and we do the open row set part. 133 00:09:16,880 --> 00:09:20,200 Followed by, we need to guess a correct user ID here. 134 00:09:20,360 --> 00:09:24,640 So we're like guessing system administrator blank password. 135 00:09:24,840 --> 00:09:28,160 And we try to extract data from the users table 136 00:09:28,980 --> 00:09:30,980 on the server 10, 10, 10, 10. 137 00:09:32,380 --> 00:09:37,480 And we try to join this result in the original SQL query 138 00:09:37,480 --> 00:09:40,140 in order to get the results back in one web page. 139 00:09:44,200 --> 00:09:47,840 So basically we're on the top talking to the web server. 140 00:09:48,120 --> 00:09:50,520 The web server communicates to the database server. 141 00:09:50,680 --> 00:09:54,780 The database server executes a query to our very secret data. 142 00:09:54,780 --> 00:09:57,420 The database fetches the data and joins it all together 143 00:09:57,420 --> 00:10:02,640 in the first SQL server and returns it back to our web server. 144 00:10:06,260 --> 00:10:09,880 So how is this relevant in regards to out of band channeling? 145 00:10:11,060 --> 00:10:12,960 Well, open rows can be reversed. 146 00:10:13,580 --> 00:10:15,600 So instead of using it to query data, 147 00:10:15,780 --> 00:10:16,940 we can use it to insert data. 148 00:10:18,880 --> 00:10:22,360 So we can actually, we can fetch the data from one source 149 00:10:22,360 --> 00:10:23,680 and insert it to another. 150 00:10:25,980 --> 00:10:28,360 And the destination database could be any host 151 00:10:28,360 --> 00:10:29,320 reachable from the source. 152 00:10:31,400 --> 00:10:35,140 And in this way, we can insert data into one of our own 153 00:10:35,140 --> 00:10:37,660 database servers through batching statements. 154 00:10:38,700 --> 00:10:40,860 So we try to terminate the first query 155 00:10:40,860 --> 00:10:43,440 and then we do a semicolon and then we add an insert 156 00:10:43,440 --> 00:10:44,720 into open rows set. 157 00:10:45,400 --> 00:10:46,880 Which would look something like this. 158 00:10:47,020 --> 00:10:48,300 So we have the first query here, 159 00:10:48,820 --> 00:10:52,020 where we fetch user ID, the login function, 160 00:10:52,080 --> 00:10:53,180 remember from the first slides. 161 00:10:54,780 --> 00:10:56,200 We do a semicolon after our password 162 00:10:56,200 --> 00:10:58,000 and we do an insert into open rows set. 163 00:10:58,440 --> 00:11:02,220 We point out our database server for which we already know 164 00:11:02,220 --> 00:11:03,180 the username and password. 165 00:11:04,060 --> 00:11:07,520 And then using the first select statement 166 00:11:07,520 --> 00:11:11,060 actually points out which table we want to insert data into 167 00:11:11,060 --> 00:11:11,900 in our database. 168 00:11:12,440 --> 00:11:16,580 And the second query says which table we want to 169 00:11:16,580 --> 00:11:17,660 fetch the data from. 170 00:11:18,360 --> 00:11:21,280 So basically, you don't need to know any username or password 171 00:11:21,280 --> 00:11:22,320 since it's our own database. 172 00:11:24,780 --> 00:11:27,960 After the others, we have comma 443. 173 00:11:28,000 --> 00:11:30,920 This is which port we want to use in order to insert our data. 174 00:11:31,060 --> 00:11:32,060 So you can choose any port here. 175 00:11:32,220 --> 00:11:35,920 You can use HTTPS, HTTP, FTP, Telnet, whatever 176 00:11:36,400 --> 00:11:39,640 becomes suitable in the environment 177 00:11:39,640 --> 00:11:40,420 you're actually attacking. 178 00:11:43,360 --> 00:11:44,980 You can also use it for port scanning. 179 00:11:45,220 --> 00:11:47,020 So you can use a higher timeout. 180 00:11:47,320 --> 00:11:48,700 Use like a timeout of five. 181 00:11:48,860 --> 00:11:51,360 Then you can easily check which ports are allowed outbound. 182 00:11:51,560 --> 00:11:52,900 And once you find a suitable port, 183 00:11:52,960 --> 00:11:54,060 you can just execute everything. 184 00:11:58,140 --> 00:11:59,840 In order to illustrate it with a picture, 185 00:11:59,900 --> 00:12:01,460 it looks something like this. 186 00:12:01,680 --> 00:12:04,740 We still talk to the web application server, 187 00:12:05,220 --> 00:12:06,700 which talks to the database server, 188 00:12:06,840 --> 00:12:09,660 which opens up a connection through our firewall back to us. 189 00:12:14,880 --> 00:12:16,640 So the obstacles in this solution 190 00:12:16,640 --> 00:12:19,840 is that you need to have the database server where 191 00:12:19,840 --> 00:12:20,960 you want to insert your data needs 192 00:12:20,960 --> 00:12:22,720 to be reachable from the source database. 193 00:12:23,380 --> 00:12:23,820 So. 194 00:12:24,280 --> 00:12:24,720 Yeah. 195 00:12:24,720 --> 00:12:26,520 In a tight network, you might have problems 196 00:12:27,640 --> 00:12:28,960 reaching the correct ports. 197 00:12:30,720 --> 00:12:33,320 Also, we need to have the source and destination tables. 198 00:12:33,480 --> 00:12:34,340 They need to be identical. 199 00:12:34,720 --> 00:12:38,320 We need to know what columns we have in our user table 200 00:12:38,320 --> 00:12:41,720 in order to insert them in our own user tables. 201 00:12:41,780 --> 00:12:44,720 We have to know the column names, the data types, 202 00:12:44,900 --> 00:12:46,200 the size of the data types. 203 00:12:48,320 --> 00:12:49,880 Usually when we do this kind of attack, 204 00:12:50,060 --> 00:12:53,940 we're successful in using HTTPS or HTTP or any of the common. 205 00:12:55,460 --> 00:12:55,900 protocols. 206 00:12:57,660 --> 00:13:00,140 And as we have in SQL Server, we have something 207 00:13:00,140 --> 00:13:01,840 called sysobjects and syscolumns, 208 00:13:01,920 --> 00:13:04,660 which are metatables containing information 209 00:13:04,660 --> 00:13:06,580 about all objects in the database, 210 00:13:07,240 --> 00:13:10,500 like all tables, all columns for all tables, 211 00:13:10,880 --> 00:13:12,460 and all data types for all columns. 212 00:13:13,200 --> 00:13:15,640 So by knowing the layout of these tables, 213 00:13:15,740 --> 00:13:17,860 we can create our own similar tables in our database, 214 00:13:18,000 --> 00:13:19,400 and we can extract all the data we need. 215 00:13:19,560 --> 00:13:22,280 So first, we start off by extracting, OK, 216 00:13:22,400 --> 00:13:24,220 so which tables do you actually have? 217 00:13:24,220 --> 00:13:26,360 Oh, well, I have the user table and the payments table. 218 00:13:26,780 --> 00:13:27,480 That's interesting. 219 00:13:27,740 --> 00:13:29,580 So we do an identical payments table, 220 00:13:29,720 --> 00:13:32,700 and then we just extract everything through this batching 221 00:13:32,700 --> 00:13:32,940 technique. 222 00:13:37,800 --> 00:13:39,980 Looking at the summary of the open ROSA then, 223 00:13:40,600 --> 00:13:41,960 like I mentioned in the beginning, 224 00:13:42,380 --> 00:13:48,320 only sysadmin members post sqlserver service pack 3 225 00:13:48,320 --> 00:13:51,540 are allowed to actually access these functions. 226 00:13:54,240 --> 00:13:57,540 For some reason, we've been able to do it quite a lot this year. 227 00:13:57,660 --> 00:14:00,860 So actually, it's still possible in many installations. 228 00:14:04,160 --> 00:14:07,620 Most hardening guys suggest disabling open ROSA altogether. 229 00:14:08,880 --> 00:14:11,120 You need to have a direct connection back 230 00:14:11,120 --> 00:14:12,340 to your database server. 231 00:14:12,500 --> 00:14:14,520 So in high security environments, 232 00:14:14,880 --> 00:14:17,480 this is most probably not possible of doing. 233 00:14:20,220 --> 00:14:22,620 And it's limited to SQL Server, obviously. 234 00:14:26,560 --> 00:14:30,160 Just to illustrate that I'm not just picking on SQL Server, 235 00:14:30,260 --> 00:14:32,940 I've decided to include the utlhttp package as well 236 00:14:33,560 --> 00:14:34,080 from Oracle. 237 00:14:36,760 --> 00:14:40,080 Basically, what the utlhttp package allows you to do 238 00:14:40,080 --> 00:14:43,700 is to perform a get request on a web page. 239 00:14:44,800 --> 00:14:47,680 The result from the web page with the first 2,000 bytes 240 00:14:47,680 --> 00:14:50,520 are returned in the answer like in a normal query. 241 00:14:50,680 --> 00:14:51,300 So you do select. 242 00:14:51,560 --> 00:14:52,940 In this case, we do utlhttprequest. 243 00:14:54,220 --> 00:14:57,000 and we try to download Oracle's web page. 244 00:14:57,160 --> 00:14:59,540 We'll get the 2,000 first bytes of this web page. 245 00:15:02,660 --> 00:15:09,660 And this can also be exploited in order to tunnel data through this type of function. 246 00:15:11,800 --> 00:15:16,600 What we actually do is that we're dynamically building the URL that we're retrieving. 247 00:15:16,740 --> 00:15:18,660 So we specify one of our own web servers, 248 00:15:19,140 --> 00:15:23,160 and then we dynamically fetch table data in order to build our URL. 249 00:15:23,160 --> 00:15:28,160 And then by looking at the web server log files on our web server, 250 00:15:28,280 --> 00:15:32,420 we can see what the data actually is in the database tables. 251 00:15:34,660 --> 00:15:36,860 So this is an example of late exploitation. 252 00:15:38,460 --> 00:15:43,260 Typically, when we've seen tables on different web pages, 253 00:15:43,440 --> 00:15:47,620 you have headers where you can sort the table data in a web page. 254 00:15:49,440 --> 00:15:52,320 Sometimes this is achieved through ascending. 255 00:15:53,160 --> 00:15:56,400 Or descending, as a parameter in the URL. 256 00:15:58,380 --> 00:16:02,320 This data is then used in order to sort the table data, 257 00:16:02,580 --> 00:16:07,120 and in order to match the actual topic that you clicked on in the header. 258 00:16:08,280 --> 00:16:13,020 In some cases, this is injected through concatenation of strings, 259 00:16:13,340 --> 00:16:15,880 and just concatenated at the end of a static SQL statement. 260 00:16:17,420 --> 00:16:21,460 In Oracle, if you return exactly one row of data, 261 00:16:23,160 --> 00:16:28,700 you could use this in order to order this first table that I've just described. 262 00:16:29,020 --> 00:16:34,640 So in this case, we're actually injecting a parenthesis instead of descending, for example. 263 00:16:34,840 --> 00:16:36,720 And then we do a UTL HTTP request. 264 00:16:37,220 --> 00:16:39,620 We try to access our web page, secure.net. 265 00:16:40,460 --> 00:16:43,240 The URL is slash ing for injection. 266 00:16:43,800 --> 00:16:48,160 And then we do a select username and user password from table logins, 267 00:16:48,260 --> 00:16:50,200 where row num is less than two. 268 00:16:50,820 --> 00:16:52,780 So this will return exactly one. 269 00:16:52,840 --> 00:16:53,140 And then we do a UTP request. 270 00:16:53,160 --> 00:16:53,480 And then we do a UTP request. 271 00:16:53,480 --> 00:16:54,380 And then we do a UTP request from our login table. 272 00:16:57,300 --> 00:17:03,060 So basically, we're asking the web server to start UTL HTTP, 273 00:17:03,680 --> 00:17:06,800 and perform a request to our server. 274 00:17:06,960 --> 00:17:09,260 This UTL HTTP package accepts proxies. 275 00:17:09,580 --> 00:17:11,580 So in an environment where we have a proxy server, 276 00:17:11,700 --> 00:17:12,820 you just tag along the proxy name, 277 00:17:12,920 --> 00:17:14,420 and you go through the proxy out on the internet. 278 00:17:16,640 --> 00:17:19,160 Looking at the log files, you would see something like this. 279 00:17:20,820 --> 00:17:23,140 With the usernames and passwords separated by the username. 280 00:17:23,140 --> 00:17:23,260 So you can see that the process is the same. 281 00:17:23,260 --> 00:17:23,660 You just have to add a new one by underscore. 282 00:17:29,520 --> 00:17:33,040 And looking at Oracle, you can see that many databases 283 00:17:33,040 --> 00:17:35,840 still have this package unrestricted. 284 00:17:35,880 --> 00:17:39,600 It's available to the public user, which is a user... 285 00:17:39,600 --> 00:17:42,180 a pseudo user, which everybody belongs to. 286 00:17:42,300 --> 00:17:43,440 Or a role, actually. 287 00:17:43,700 --> 00:17:45,980 So anyone can execute this function. 288 00:17:47,560 --> 00:17:51,120 So even if you have very limited access in Oracle database, 289 00:17:51,300 --> 00:17:53,060 you could use this, attacking text. 290 00:17:53,140 --> 00:17:54,020 technique in order to extract data. 291 00:17:57,080 --> 00:18:00,340 Commonly, firewalls tend to be less strict on outbound traffic, so 292 00:18:01,180 --> 00:18:04,380 accessing HTTP or HTTPS or going through a proxy 293 00:18:04,960 --> 00:18:08,940 usually solves this. The limitations, yes, well it's 294 00:18:08,940 --> 00:18:12,180 limited to Oracle database server. Hardening guides 295 00:18:12,180 --> 00:18:14,360 suggest disabling this, obviously. 296 00:18:16,440 --> 00:18:20,840 And one other limitation, it requires a direct outgoing connection to our attacking 297 00:18:20,840 --> 00:18:22,920 or to our web server, which we control. 298 00:18:26,220 --> 00:18:27,060 Slide 30. 299 00:18:29,480 --> 00:18:31,440 DNS and out-of-band channeling. 300 00:18:35,020 --> 00:18:36,180 So, DNS, 301 00:18:36,440 --> 00:18:40,740 it's a hierarchical protocol. Most of you 302 00:18:40,740 --> 00:18:44,020 use it daily. So, in order to illustrate 303 00:18:44,020 --> 00:18:48,780 the benefit of using DNS, let's assume we manage 304 00:18:48,780 --> 00:18:52,660 a DNS server for the zone secure.net. So, if 305 00:18:52,660 --> 00:18:55,780 somebody at the corporation X tries to look up a host in our domain, 306 00:18:56,920 --> 00:19:00,860 the query will find its way to us, as it's a hierarchical 307 00:19:00,860 --> 00:19:04,440 protocol. So, this would allow us to monitor 308 00:19:04,440 --> 00:19:08,100 queries for subdomains or hosts in our domain. 309 00:19:13,160 --> 00:19:16,620 So, even if you have a hardened database, it's our experience that usually 310 00:19:16,620 --> 00:19:17,400 you allow DNS. 311 00:19:21,120 --> 00:19:22,160 And most 312 00:19:22,540 --> 00:19:25,760 internal DNS servers are allowed to forward their queries. 313 00:19:28,580 --> 00:19:30,440 And most hardening guides, 314 00:19:30,580 --> 00:19:34,340 if you look at general hardening guides available from the vendors, they fail to 315 00:19:34,340 --> 00:19:38,540 actually mention a lot of these packages, which can be used in order to do DNS 316 00:19:38,540 --> 00:19:42,300 resolution. So, if we could 317 00:19:43,460 --> 00:19:46,160 some way trigger DNS resolution in a database, 318 00:19:46,160 --> 00:19:49,580 we would have an indirect channel to a DNS server of our choice, 319 00:19:49,720 --> 00:19:53,840 as we are controlling the domain name of the name resolution. 320 00:19:54,120 --> 00:19:58,080 We just point it to our domain, and the query will travel all the way back 321 00:19:58,080 --> 00:20:01,760 to our DNS server. So, if we 322 00:20:01,760 --> 00:20:05,060 could trigger DNS, we could ask for any host in our zone. 323 00:20:09,300 --> 00:20:10,280 So, in this case, 324 00:20:10,360 --> 00:20:14,220 we do a DNS resolution to our corporate DNS server, 325 00:20:14,220 --> 00:20:17,920 which forwards the query to the authoritative service 326 00:20:17,920 --> 00:20:22,000 for .NET, which in their turn forwards it to our 327 00:20:22,000 --> 00:20:24,500 DNS server for the secure .NET DNS zone. 328 00:20:28,800 --> 00:20:30,320 Both Microsoft and Oracle 329 00:20:30,320 --> 00:20:34,120 provide functions and store procedures and packages in order to do 330 00:20:34,120 --> 00:20:34,700 DNS resolution. 331 00:20:38,000 --> 00:20:42,340 Some of these functions are executable by the public user, so basically what I'm saying 332 00:20:42,340 --> 00:20:44,100 is that anyone can execute these 333 00:20:44,220 --> 00:20:45,720 packages or store procedures. 334 00:20:47,360 --> 00:20:51,400 Like I previously said, some of them are not mentioned in hardening guides, 335 00:20:52,220 --> 00:20:55,000 which makes them available in a lot of database servers. 336 00:20:58,940 --> 00:21:00,200 So, in SQL Server, 337 00:21:01,140 --> 00:21:03,880 a number of store procedures accept UNC 338 00:21:03,880 --> 00:21:06,880 path names. A UNC name is 339 00:21:06,880 --> 00:21:11,120 when you point out a share on a network 340 00:21:11,120 --> 00:21:11,580 server. 341 00:21:15,040 --> 00:21:18,100 And if you point a UNC path to a fully 342 00:21:18,100 --> 00:21:21,400 qualified domain name, it will result in a DNS resolution being performed. 343 00:21:22,900 --> 00:21:26,260 And this can be used in order to channel database information to an attacker. 344 00:21:27,120 --> 00:21:30,160 So, by looking, for example, at the extended store 345 00:21:30,160 --> 00:21:33,360 procedure Expedir tree, XP file exists, 346 00:21:33,740 --> 00:21:38,080 XP get file details, SP add job step, they all accept UNC 347 00:21:38,080 --> 00:21:40,160 paths in their file parameter. 348 00:21:42,280 --> 00:21:43,660 The backup database, 349 00:21:44,000 --> 00:21:48,180 when you choose to backup a database as the database owner of a database, 350 00:21:48,420 --> 00:21:52,140 you can point it to a file where it should be backed up. You can point this file to 351 00:21:52,140 --> 00:21:56,080 any network-based server. So basically you can do DNS resolution 352 00:21:56,080 --> 00:21:57,500 through the backup command as well. 353 00:22:01,520 --> 00:22:03,440 If you look at Oracle, you have the 354 00:22:04,000 --> 00:22:07,980 UTL in adder package, which basically does DNS resolution. 355 00:22:07,980 --> 00:22:11,840 That's what it's meant for. You have the UTL HTTP 356 00:22:11,840 --> 00:22:15,820 that I described, where you do a connection to a request 357 00:22:15,820 --> 00:22:19,780 to a web server. So even if you're not allowed to talk to the web server in 358 00:22:19,780 --> 00:22:23,540 outbound traffic, maybe the firewall blocks it, you can 359 00:22:23,540 --> 00:22:26,560 still use the package in order to do DNS resolution. 360 00:22:27,500 --> 00:22:31,740 So DNS traffic will most probably go through the firewall and out to our 361 00:22:32,340 --> 00:22:35,660 DNS server. There are packages like UTL TCP, 362 00:22:35,960 --> 00:22:36,380 ... 363 00:22:38,960 --> 00:22:41,460 and most probably there are a lot of more packages. 364 00:22:41,740 --> 00:22:46,040 I just had a brief look in both SQL Server and Oracle and I found this one so far. 365 00:22:46,340 --> 00:22:49,820 And what I was interested in was packages that have public 366 00:22:49,820 --> 00:22:53,900 execute privileges. So basically whoever can execute. 367 00:22:54,480 --> 00:22:57,900 So even if you just have read access in a database, you can still execute these 368 00:22:57,900 --> 00:22:58,200 packages. 369 00:23:04,840 --> 00:23:06,060 So how do we extract 370 00:23:06,060 --> 00:23:07,040 data using DNS? 371 00:23:07,980 --> 00:23:12,000 Well, basically we need to put the whole data or a payload, so to speak, 372 00:23:12,180 --> 00:23:15,400 in the DNS host name. As the zone name, 373 00:23:15,580 --> 00:23:18,700 secure.net, just directs it to our DNS server. 374 00:23:19,580 --> 00:23:23,400 The actual host name is the query that's being performed to our DNS server. 375 00:23:25,940 --> 00:23:27,660 This means that our host name 376 00:23:27,660 --> 00:23:30,140 has to be built dynamically using table data. 377 00:23:32,140 --> 00:23:35,980 So we stuff all the data into the host name and then we try to fire it away using a DNS 378 00:23:35,980 --> 00:23:39,940 resolution and it will end up in our database or in our DNS server. 379 00:23:41,300 --> 00:23:43,760 And by using cursors and variables 380 00:23:43,760 --> 00:23:48,060 in SQL, you could actually build these host names 381 00:23:48,060 --> 00:23:51,940 dynamically. Once you have built the host name, you just fire it away 382 00:23:51,940 --> 00:23:55,900 using expdir tree or exp get file details or file exists 383 00:23:55,900 --> 00:23:59,980 or whatever your stored procedure of choice is. 384 00:24:04,340 --> 00:24:06,240 So I'm providing a sample here. 385 00:24:06,580 --> 00:24:09,900 We have the variable s declared 386 00:24:11,280 --> 00:24:14,180 where we start off by saying that we want to use the expdir tree 387 00:24:14,840 --> 00:24:17,140 stored procedure in the master database. 388 00:24:18,260 --> 00:24:22,180 We add a double backslash in order to explain that we want to use 389 00:24:22,180 --> 00:24:26,000 the UNC pop. We tag along the user 390 00:24:26,000 --> 00:24:29,960 underscore name function, which will result to the current user name. Then we just 391 00:24:29,980 --> 00:24:33,980 tag along our suffix or our domain, .ini for injection 392 00:24:34,520 --> 00:24:38,140 .secure.net. Then another backslash and then the directory 393 00:24:38,140 --> 00:24:40,500 we want to perform a directory tree inside. 394 00:24:41,480 --> 00:24:45,920 The directory tree is never being performed. In our demonstration I'll always 395 00:24:45,920 --> 00:24:49,680 be returning the loopback address in the DNS resolution. 396 00:24:50,240 --> 00:24:53,940 So basically we're just interested in the name resolution. We're not interested in 397 00:24:53,940 --> 00:24:58,060 doing a directory tree or anything. We're just interested in performing the DNS resolution. 398 00:24:58,200 --> 00:24:58,600 That's it. 399 00:25:03,020 --> 00:25:03,880 We can do the 400 00:25:03,880 --> 00:25:07,860 same thing with basically any parameter or any function in SQL Server. 401 00:25:08,000 --> 00:25:11,820 In this case we're fetching the server name with the name of the 402 00:25:11,820 --> 00:25:15,700 instance as well. And we're tagging it along with our domain name in order to get the 403 00:25:15,700 --> 00:25:16,400 resolution to work. 404 00:25:22,280 --> 00:25:23,500 So looking at DNS, 405 00:25:24,420 --> 00:25:26,020 we have some challenges. 406 00:25:27,300 --> 00:25:29,220 DNS records are cached. 407 00:25:30,120 --> 00:25:34,020 This is true for both successful DNS requests 408 00:25:34,020 --> 00:25:37,640 and host names that are not found. 409 00:25:39,080 --> 00:25:41,800 We also have length restrictions on our 410 00:25:41,800 --> 00:25:44,340 fully qualified domain name, 255 characters. 411 00:25:45,810 --> 00:25:49,400 And on our labels. The labels is the data between the dots in a 412 00:25:49,400 --> 00:25:53,700 fully qualified domain name. We have problems with 413 00:25:53,700 --> 00:25:56,140 some characters which cannot be in a 414 00:25:57,220 --> 00:26:01,140 fully qualified domain name. And the obvious solutions are 415 00:26:02,020 --> 00:26:05,560 setting a low or zero time to live. If you have 416 00:26:05,560 --> 00:26:09,700 control of the DNS server, in our case I'll show you a small DNS 417 00:26:09,700 --> 00:26:13,040 server written in Perl which always returns a very low TTL. 418 00:26:13,800 --> 00:26:17,160 But if you're running TCP dump on a bind database for example, 419 00:26:17,920 --> 00:26:21,820 you might not have the opportunity to set a low TTL 420 00:26:21,820 --> 00:26:23,580 value. In these cases, 421 00:26:23,700 --> 00:26:26,920 you can always add a unique value 422 00:26:26,920 --> 00:26:31,320 to the data being queried. So you tag it along before the actual data 423 00:26:31,320 --> 00:26:35,480 you want to see. So performing the same 424 00:26:35,480 --> 00:26:38,960 requests ten times always sends a different seed, so to speak. 425 00:26:39,920 --> 00:26:43,400 Which will always result in unique DNS resolutions being made. 426 00:26:45,200 --> 00:26:47,120 And the obvious solution for length 427 00:26:47,700 --> 00:26:50,920 limitations are obviously to truncate or split values exceeding length. 428 00:26:52,900 --> 00:26:53,380 And 429 00:26:55,160 --> 00:26:57,420 for the nasty characters, we just convert them 430 00:26:57,420 --> 00:26:58,340 prior to our resolution. 431 00:27:05,260 --> 00:27:08,640 If you look at the caching part then, 432 00:27:09,340 --> 00:27:13,260 either you try to set a low TTL value, or in the demonstration 433 00:27:13,260 --> 00:27:17,600 I'll be using a checksum value or a seed. I'm using the checksum 434 00:27:17,600 --> 00:27:20,340 function in SQL Server, which takes one parameter 435 00:27:20,340 --> 00:27:23,380 and I'm feeding it the current timestamp. 436 00:27:25,080 --> 00:27:28,320 So if you do subsequent requests, it will always 437 00:27:28,320 --> 00:27:32,260 be a bit different. And the end result looks similar 438 00:27:32,260 --> 00:27:36,200 to the following. You have a large number in the beginning, you have a dash 439 00:27:36,200 --> 00:27:39,480 and then you have your table data, followed by the zone where you want to do the resolution in. 440 00:27:43,460 --> 00:27:44,320 So modifying 441 00:27:44,320 --> 00:27:48,620 our first example, we would actually add the checksum 442 00:27:48,620 --> 00:27:51,640 of the current timestamp. We need to convert it to a character stream 443 00:27:51,640 --> 00:27:56,300 using the convert var char function. And then it's basically 444 00:27:56,300 --> 00:27:57,200 exactly the same. 445 00:28:03,900 --> 00:28:04,420 So 446 00:28:04,420 --> 00:28:07,860 looking at RFC 1035, you see that the 447 00:28:08,440 --> 00:28:12,640 label restriction, or labels, they cannot exceed the length of 63 characters. 448 00:28:13,400 --> 00:28:16,620 The fully qualified domain name must be 255 characters 449 00:28:16,620 --> 00:28:20,200 or less. So the labels are actually the data between the dots. 450 00:28:22,340 --> 00:28:24,440 This means that we need to, in some ways, 451 00:28:24,480 --> 00:28:26,820 slice and dice our data in order to fit these restrictions. 452 00:28:28,380 --> 00:28:32,420 And our goal in this case is to split a large string and send it 453 00:28:32,420 --> 00:28:34,180 over several consecutive DNS requests. 454 00:28:39,340 --> 00:28:40,340 So my proposed 455 00:28:40,340 --> 00:28:43,560 layout for this is to actually do it this way. 456 00:28:43,560 --> 00:28:46,960 So you have first 457 00:28:46,960 --> 00:28:50,560 an indicator that the following 0x is a hex string. 458 00:28:51,680 --> 00:28:54,860 Where our data will be fitted with 459 00:28:56,660 --> 00:28:57,740 delimiting dots. 460 00:28:59,600 --> 00:29:02,980 You have an ID for the specific data being sent. 461 00:29:03,240 --> 00:29:07,260 Then you then have a part number, which specifies when we 462 00:29:07,260 --> 00:29:10,440 chopped up the data for suitable fully qualified domain names. 463 00:29:11,160 --> 00:29:13,420 It says, okay, this is part 1 of 7 464 00:29:13,560 --> 00:29:16,360 where the max part describes how many parts there are in total. 465 00:29:17,080 --> 00:29:21,580 So as DNS travels over UDP, you can have some loss 466 00:29:21,580 --> 00:29:24,260 or you can have the packets coming in the wrong sequence. 467 00:29:25,780 --> 00:29:29,160 This way you have control on how many packages 468 00:29:29,160 --> 00:29:31,780 you're actually supposed to receive and in what order. 469 00:29:33,360 --> 00:29:37,380 I'm not using the part and max part in the demonstration 470 00:29:37,380 --> 00:29:40,700 at all. However, if I would 471 00:29:40,700 --> 00:29:43,160 use it in the future over a more 472 00:29:43,160 --> 00:29:46,880 reliable network, I would use it. 473 00:29:50,980 --> 00:29:52,600 So by first converting our data 474 00:29:52,600 --> 00:29:56,000 to hex, we don't need to worry about any odd characters showing up. 475 00:29:56,220 --> 00:30:00,360 So what we're actually doing is taking any data type and using the 476 00:30:00,360 --> 00:30:04,440 convert or cost function in SQL Server and converting it to binary. 477 00:30:05,980 --> 00:30:08,260 When we have it in binary form, you can then use the 478 00:30:08,260 --> 00:30:10,680 function varbin to hex string 479 00:30:10,700 --> 00:30:15,280 which converts our binary data into a hex string starting with 0x 480 00:30:15,280 --> 00:30:18,880 and then letters from A to F and 0 to 9. 481 00:30:19,100 --> 00:30:22,300 So we no longer have a problem with characters which will 482 00:30:23,000 --> 00:30:24,360 break our DNS resolution. 483 00:30:27,020 --> 00:30:30,140 The hex string then needs to be divided into adequate pieces. 484 00:30:32,560 --> 00:30:33,660 And this is 485 00:30:34,480 --> 00:30:36,720 most easily done by using the substring function. 486 00:30:40,940 --> 00:30:42,680 So what we actually do is that 487 00:30:42,680 --> 00:30:46,660 we first split our data into suitable fully qualified domain name lengths. 488 00:30:47,800 --> 00:30:50,660 When we have these blocks, we split them into smaller 489 00:30:50,660 --> 00:30:54,220 blocks divided by dots so that they fit our label 490 00:30:54,220 --> 00:30:58,520 restrictions. We then tag along the ID and part information 491 00:30:59,380 --> 00:31:02,440 and when it's all built, we send it using the 492 00:31:02,440 --> 00:31:06,660 expedir3 command. And like I said earlier, the expedir3 doesn't do it 493 00:31:06,720 --> 00:31:10,480 in the directory tree in this case. The only purpose of the expedir3 494 00:31:10,480 --> 00:31:14,700 is to perform a DNS resolution in order to send our data to our DNS server. 495 00:31:19,100 --> 00:31:22,220 This means that our receiving part, the DNS server, 496 00:31:22,380 --> 00:31:26,240 reverses the process and prints the data out. So basically we're sending 497 00:31:26,240 --> 00:31:28,780 character by character but in larger chunks. 498 00:31:30,660 --> 00:31:34,140 And using this strategy, we need only to inject once. 499 00:31:34,140 --> 00:31:37,960 So we inject one large query and retrieve all 500 00:31:37,960 --> 00:31:42,140 table data instead of using ten requests in order 501 00:31:42,140 --> 00:31:43,120 to get three characters. 502 00:31:45,940 --> 00:31:49,740 Basically only the size of the variable receiving the data 503 00:31:50,780 --> 00:31:51,900 is our limitation. 504 00:31:55,200 --> 00:31:58,220 And obviously those database 505 00:31:58,220 --> 00:32:01,900 servers that don't do DNS will be sort of a limitation too. 506 00:32:06,640 --> 00:32:08,040 So this is time for the 507 00:32:08,040 --> 00:32:10,520 demonstration and hopefully it will work. 508 00:32:31,900 --> 00:32:34,000 So I just started our small 509 00:32:34,140 --> 00:32:36,180 DNS server here. We're talking to 510 00:32:36,180 --> 00:32:40,940 a VMware server here in another window. 511 00:32:41,900 --> 00:32:45,840 And it's running Windows with the SQL Server 512 00:32:45,840 --> 00:32:49,280 2005, Service Pack 2, all hotfixes, everything. 513 00:32:50,960 --> 00:32:53,980 And the DNS server is set to 514 00:32:53,980 --> 00:32:57,340 my host where this black window is running. 515 00:32:58,420 --> 00:32:59,180 Oh yeah. 516 00:33:01,020 --> 00:33:03,600 Let's see if we can... 517 00:33:04,840 --> 00:33:06,120 Yeah, like this. 518 00:33:12,720 --> 00:33:15,200 So I'll be cutting some, copy pasting some data 519 00:33:15,200 --> 00:33:16,360 here in the windows, let's see. 520 00:33:19,600 --> 00:33:22,780 This web application is just some 521 00:33:23,440 --> 00:33:27,120 application available on the internet where I just trashed all the back end and just 522 00:33:28,460 --> 00:33:30,560 replaced it with vulnerable code basically. 523 00:33:30,680 --> 00:33:33,680 So it has nothing to do with this actual website. 524 00:33:34,300 --> 00:33:35,960 And I'm running everything locally. 525 00:33:42,720 --> 00:33:46,700 So basically it's not giving us any detailed error messages, just saying that an error occurred. 526 00:33:46,900 --> 00:33:50,420 Please try again later. So we're going to try to inject some data into this. 527 00:33:51,880 --> 00:33:54,300 And we start off by 528 00:33:54,880 --> 00:33:56,880 injecting the first one that I showed you with the 529 00:33:57,120 --> 00:33:57,460 username. 530 00:34:06,660 --> 00:34:08,260 So we get our query, it says, 531 00:34:08,860 --> 00:34:11,320 webshop underscore reader dot ini dot secure dot net. 532 00:34:11,520 --> 00:34:13,080 The little Perl script 533 00:34:13,080 --> 00:34:15,080 I've written just chops 534 00:34:15,080 --> 00:34:17,300 off everything called ini dot secure dot net. 535 00:34:18,400 --> 00:34:19,460 So running it 536 00:34:19,460 --> 00:34:21,080 in a non-verbals mode won't show the 537 00:34:21,080 --> 00:34:22,900 queries and actually produce a more 538 00:34:22,900 --> 00:34:23,580 readable format. 539 00:34:24,620 --> 00:34:26,900 I'm going to put this small DNS 540 00:34:27,120 --> 00:34:28,900 server on the same web page as I'm putting the 541 00:34:28,900 --> 00:34:30,980 presentation later on. It's not yet 542 00:34:30,980 --> 00:34:31,260 there. 543 00:34:37,160 --> 00:34:38,260 Looking at the 544 00:34:39,580 --> 00:34:40,400 server name. 545 00:34:47,780 --> 00:34:48,820 In order to 546 00:34:48,820 --> 00:34:49,580 as the 547 00:34:51,300 --> 00:34:51,960 let's see 548 00:34:54,420 --> 00:34:55,700 as the server name 549 00:34:55,700 --> 00:34:57,160 is actually 550 00:34:58,060 --> 00:34:59,360 has a backslash in it 551 00:34:59,360 --> 00:35:01,560 as the instance is written as well. 552 00:35:01,680 --> 00:35:02,800 We need to tag along this 553 00:35:04,800 --> 00:35:05,880 small piece here 554 00:35:05,880 --> 00:35:07,900 with the replace where it converts 555 00:35:07,900 --> 00:35:09,660 the server property. It converts the 556 00:35:09,660 --> 00:35:10,560 backslash to underscore. 557 00:35:12,360 --> 00:35:13,800 This is before we start 558 00:35:13,800 --> 00:35:15,940 chopping up data. I'll show you when we chop up 559 00:35:15,940 --> 00:35:17,840 the data using the bigger SQL Server 560 00:35:17,840 --> 00:35:19,600 functions. We won't be needing this. 561 00:35:21,840 --> 00:35:23,620 In order to defeat our 562 00:35:23,620 --> 00:35:24,340 caching problem 563 00:35:25,640 --> 00:35:27,300 I'll show you the query 564 00:35:27,300 --> 00:35:28,860 using the current timestamp as well. 565 00:35:33,700 --> 00:35:35,240 It tags along the 566 00:35:35,240 --> 00:35:37,020 21, 55, blah blah blah. 567 00:35:37,760 --> 00:35:39,480 If we run it once more it should 568 00:35:39,480 --> 00:35:39,920 give us 569 00:35:41,240 --> 00:35:42,480 slightly higher value. 570 00:35:43,460 --> 00:35:45,560 We can do subsequent queries and always 571 00:35:46,140 --> 00:35:47,380 be sure to get a 572 00:35:47,380 --> 00:35:48,460 proper resolution. 573 00:35:52,160 --> 00:35:53,360 I'm going to switch into 574 00:35:53,360 --> 00:35:54,960 non-verbals mode now because 575 00:35:55,600 --> 00:35:56,960 it's not going to be as pretty 576 00:35:57,570 --> 00:35:58,260 if I don't. 577 00:36:01,800 --> 00:36:03,560 Like I mentioned, we're going to 578 00:36:03,560 --> 00:36:05,320 have a look inside the sys objects 579 00:36:05,320 --> 00:36:06,980 and sys columns tables 580 00:36:06,980 --> 00:36:08,420 which all describe the 581 00:36:09,760 --> 00:36:11,500 we have a small 582 00:36:15,560 --> 00:36:16,140 tiny 583 00:36:17,140 --> 00:36:18,400 injection code here. 584 00:36:20,800 --> 00:36:21,520 So basically 585 00:36:21,520 --> 00:36:22,180 we inject it here 586 00:36:23,480 --> 00:36:25,820 and it starts up 587 00:36:25,820 --> 00:36:27,440 a bit slow but hopefully we'll get 588 00:36:27,440 --> 00:36:28,440 the rest of the data as well. 589 00:36:31,340 --> 00:36:31,700 Hopefully. 590 00:36:35,000 --> 00:36:35,660 There it goes. 591 00:36:36,540 --> 00:36:37,560 So our little query 592 00:36:37,560 --> 00:36:39,320 is in the background. I need to scroll the screen 593 00:36:39,320 --> 00:36:40,540 in order for you to see the whole 594 00:36:41,280 --> 00:36:42,780 but it's in the slides. 595 00:36:52,440 --> 00:36:53,620 So what we see here 596 00:36:53,620 --> 00:36:55,200 is first our database name 597 00:36:55,200 --> 00:36:56,420 which is Webshop. 598 00:36:57,280 --> 00:36:59,260 Basically this script that I just injected 599 00:36:59,260 --> 00:37:00,680 goes through all databases 600 00:37:00,680 --> 00:37:02,220 in the database server. 601 00:37:02,660 --> 00:37:04,900 For all databases it looks for 602 00:37:04,900 --> 00:37:07,020 if it has permissions, it looks for all tables. 603 00:37:07,520 --> 00:37:09,280 For all tables it looks for the 604 00:37:09,280 --> 00:37:11,360 column names and for all column names 605 00:37:11,360 --> 00:37:13,260 it results the data type 606 00:37:13,260 --> 00:37:15,080 and for all data types it results 607 00:37:15,080 --> 00:37:16,360 the size of the data type. 608 00:37:16,980 --> 00:37:18,640 So what we have here is a complete 609 00:37:19,600 --> 00:37:21,300 database schema basically. 610 00:37:22,880 --> 00:37:24,940 And we see that we have the Webshop 611 00:37:24,940 --> 00:37:26,460 we have a table called Payments 612 00:37:26,460 --> 00:37:29,220 we see a purchase ID, card holder 613 00:37:29,220 --> 00:37:30,980 card type, card number, expiry 614 00:37:31,960 --> 00:37:32,520 everything. 615 00:37:33,300 --> 00:37:35,000 We have a products table 616 00:37:35,600 --> 00:37:36,660 where we have pricing information 617 00:37:36,660 --> 00:37:38,260 which might be handed to change. 618 00:37:40,980 --> 00:37:42,400 We have something called Users 619 00:37:42,400 --> 00:37:43,640 with usernames and passwords. 620 00:37:49,600 --> 00:37:52,580 So as we now know our data 621 00:37:52,580 --> 00:37:53,940 or our table definitions 622 00:37:53,940 --> 00:37:56,380 we can move to the next 623 00:37:56,380 --> 00:37:57,680 tiny SQL statement here. 624 00:38:05,500 --> 00:38:07,220 Which might work as well. 625 00:38:07,740 --> 00:38:09,500 Okay, so we get all the usernames 626 00:38:09,500 --> 00:38:09,880 and passwords. 627 00:38:10,940 --> 00:38:13,340 Obviously with Swedish passwords. 628 00:38:14,120 --> 00:38:15,180 I'm sorry for that. 629 00:38:19,600 --> 00:38:21,200 And then moving right along to the 630 00:38:21,200 --> 00:38:22,380 interesting stuff, we look at the 631 00:38:22,380 --> 00:38:23,140 credit card numbers. 632 00:38:30,080 --> 00:38:31,480 Yeah, I think so. 633 00:38:35,660 --> 00:38:36,460 Here they go. 634 00:38:37,900 --> 00:38:39,500 Please don't write them down. 635 00:38:44,520 --> 00:38:45,580 So we have the 636 00:38:45,580 --> 00:38:46,400 username 637 00:38:46,980 --> 00:38:49,460 or the full name as it's 638 00:38:49,600 --> 00:38:51,340 shown on the actual card. 639 00:38:51,640 --> 00:38:52,780 We have the card type, 640 00:38:53,040 --> 00:38:54,900 we have the number, we have the CDV. 641 00:39:01,080 --> 00:39:01,800 They want it? 642 00:39:03,900 --> 00:39:07,540 Yeah, well, basically that's it. 643 00:39:08,340 --> 00:39:09,340 That's the end of the 644 00:39:09,340 --> 00:39:10,960 demonstration and the end of the talk. 645 00:39:19,740 --> 00:39:21,180 Thank you.