web applications that use Oracle databases there are of course prerequisites things you're gonna have to know a little bit about to be able to get through this presentation and that's going to be hopefully a little bit of our knowledge about how sequel works I'll show you briefly but if you know about that that'll probably help you a lot figure out what's going on also if any of you guys have done you know developed in PHP or JSP or ASP you know a little bit about how web apps work and how they develop data and how they access databases that'll probably help you guys a lot for everyone else hopefully I'll do a good job and you'll be able to understand so we're gonna start out here we're gonna start out here looking at just what a normal web application looks like I'm also going to note to everyone here that this was all put together and literally the last like 10 hours I'd like to thank Phil brass over there help me out a lot and other people so you know this isn't pretty and this isn't what you're likely to see on major corporation incorporated website or anything but it will do for our demonstration purposes so everyone's used to seeing stuff like this here can you guys hear me back there cool all right let's say we know some guys email address and they have a web application set up that I can get their phone number from the website for instance again this is all using the sample Oracle presentation data and everything so it's pretty simple I enter that and I get back their first name the last name and their phone number what sequel injection is going to allow you to do is instead of getting back their first name last name and phone number you're going to be able to actually control what information comes back from the database so the first thing we're going to look at here is the ASP source code of what we're going to be seeing because that's going to help us understand it normally of course you're not going to have access to their source code but here is what we're looking at here is the ASP source code of what we're looking at here is the line we're interested in select first name last name phone number from employees or email equals and you see this is the value that gets passed up here in the URI part of the request we control what that part is and because we control what the value of email is we can change the sequel statement and make it return different information back from the database other than first name last name now you're going to run into a lot of sites that are going to stop you from doing this in a couple ways they're not going to allow you to send characters like spaces or single quotes and those are the pages that other than a couple tricks that in certain circumstances can let you get through which I may show you later if we have time those are the pages that are not going to be vulnerable but I don't know if anyone's who use this technique before probably it's been around a couple years now but the amount of sites that are vulnerable to this is just enormous I've seen major you know communications corporations credit card companies investment banks all kinds of stuff so the first thing I'm going to do to show you how we're going to change what's getting back to the server is we're going to throw in a single quote here assuming this thing will work great okay um what's me all right forget that part want to try again guys help from the audience there we go thank you very much what we have here is this is an error message that is come back from the database server and it says quoted string not properly term at determine a Let's look at when we sent the value for email, a single quote, what the database server saw. This is Oracle SQL Plus Terminal. It's allowing me, normally, again, you wouldn't have access to this. But for demonstration purposes, to show everyone, it's very helpful for my presentation. So instead of all the stuff here for email, where it's modifying the source code, we're going to put in that single quote. So now we're going to see what happens here. It got sent this line. Of course, having the three quotes in a row, anyone who's done any programming can tell you that that's not a valid literal value. So it gave you back this error message. Now, our goal is to change that. Instead of using a single quote, put that little injection part to something very useful to be able to manipulate what comes back from the database. So let's go back and let's look at the web applications we have available. Here's another simple one. This is login. Enter username. Enter username and password. Let's change, instead of using an invalid username and password, of course, you get invalid login. Let's try quote for 1 equals single quote 1. And we're going to use that for both of these. I see people laughing about there. Maybe you've seen how many places this actually works on. And, of course, as we all know, behind... Behind each login form, as we all know, exists very sensitive corporate information. This actually happens to be a WorldCom SEC filing. So we're going to go back and we're going to look. We're going to open up. I'm going to show you the source of the login. We're going to see exactly what happened that allowed me to just jump right through the login and get to sensitive financial information. Let's look what goes on here. This is basic form. Form stuff. You send the username. You send the password. And let's see what it does with it. This is basic, you know, ASP, ODBC driver stuff. We're connecting to the database. Get the values from the URI. Now, here's what goes on. Here's how it authenticates. Select username from users where username equals username and password equals password. Now, let's see. If that statement fails, for instance, there is no row in the database where username and password... If it's matched like that, what's going to happen, rs.eof, if there are no records in the returned record set, then your login is invalid. If not, and again, this is very simple sample stuff that I put together, you know, in the last couple hours. It's been unbelievable. You get your access granted and you get sensitive financial information. So let's see what happens when we take the SQL statement here. And we plug in the VAT. We plug in the values that the quote, quote thing, where username equals quote, and here's where we start changing things, username equals no, or username can equal one equals one. Here's the part where we manipulate it. I want everyone to look real hard at that statement. Where username equals no, there is no username. Or where one is equal. I don't know if anyone here has ever done any programming, but that statement will always, 100% of the time, be true. You will get records back from the database and they do the same exact thing with password. And we're going to remove the double quotes there that came from the ASP. Simple note for people who have SQL injected against SQL Server, you can do quote, quote equals quote. Oracle, for your information, does not see that. No equals no will return a no. It will not return true. So you do have to actually use one. Or you can use a or anything as long as they'll match up. It's going to slap that single quote onto the end for you. Is everyone following me here? Does anyone have any questions so far? Okay then, we're good. Let's see what comes back there. As you see, we can get the full list of usernames. It returns multiple records. So our statement evaluated true. Now that we've got our basic stuff together, we're going to start looking at, and I've shown you the most simple things. And I've shown you the most simple things. The authentication bypass is the easiest thing you can do. We're going to go back to this script where it returns three columns of specific information from the database and displays them in the web application. Now, I'm going to show you real simple here how select union query would work using what I have here. Select, let's say, username that's, you know, let's change that to just sample information. Change, you know, A. In A, it'll return two rows. Of course, these are literals, not real records. These are in the database. Select AA from valid table name where username equals condition. And here's where we start what it's doing called a union. A union is used to put basically two select queries together. It's just a programming device to help programmers return information from two different places in one SQL query. Union, select. And let's try different information. B, comma, B. Let's say different tables. A table. I happen to know in all Oracle databases, there's a table called dual. The table dual does not contain information. It is a special kind of table. It exists again. It's a programming device that it will always return what's selected from it, one record set of it. So on every Oracle server you ever see, you can guarantee that there is a table called dual. And make, you know, universally true condition. Yeah. . . . As you can see, where username equals quote, quote, return false, it returned no records. But the union select part returned both. Now let's say if I were to modify that to where one equals one, we would get both back. Does everyone understand how the union works? It just puts two queries together. It's returning both. Select B, B from dual and select AA from users at the same time. . . . In SQL plus worksheet, no, because Larry Ellison hates everyone and does everything in Java, which really hates everything. We're going to go back here. Could everyone see that, though? This is the important stuff, what you're doing from a web browser, what you're going to be actually doing when you're running this against a site. So we're going to look here. Union select. And here's where you have to start paying attention. Let's try this. Union select table name from all tables. . . . All tables is another table that occurs in all Oracle databases. It simply contains a list of all the tables that are on the database. It's got the list of everything in there. And you can always depend that it's going to be there. Where, of course, we're going to put our magical little string here that will make it return records. And I'm going to copy that so I can show you back in PL-SQL terminal for those of you who are sitting close enough that you can actually see. I'm sorry. And we're going to see what we get back. Query block has incorrect number of result columns. I'll show you why that happens. What we've got here, and I'm really sorry about the font size, but there's nothing you can do. Oracle did not have the foresight to put font size information in the SQL plus worksheet application. Is that when you run a union select query, you have to have the same amount of selected columns in select. And you have to have the same amount of columns in the second select, in the union part. See if I were to delete the second column, it's going to complain. Well, that's complaining because I still have the comma there, but there you go. So what you have to do is you have to look at the legitimate output. We also, this returns three columns, first name, last name, and phone number. So we need three columns here. One, two, and of course I'm just using the literals here as dummy strings. And this time, instead of getting back first name, last name, and phone number, we have a list of every table in the Oracle database here. Now what we're going to go through is we're going to look, and of course you go through and you find the table names that look interesting. But before we do that, I'm going to show you a couple things that can occur in the SQL syntax that can make this a little confusing. Not all SQL statements are going to look exactly like this. You're going to have some programmers who are going to do little different things. One thing you're going to see, is, let's get down to the SQL statement, in addition to the single quote, they're putting what you control, email, also around parentheses. So let's go real simple, I'll show you how to get around that. It's very simple, it's the same concept, most of you have probably caught on by now. You end that right there, union select, all tables, sorry, table name, a, a, got to do our column matching, from all tables, where, and you put the parentheses right there so it matches up what it's got at the beginning and the end, just like we showed it to, and you get your table back. If you don't have the parentheses in there, Oracle actually, I don't know if any of you, again, SQL Server is the most common thing out there, SQL Server just tells you you have a syntax error, Oracle will actually tell you, you're missing a parentheses. Now I know, just one thing I'm going to point out here, SQL injection is not a problem in the database. The problem is, it's occurring here in the ASP programmer's code, that they're not stripping out things like single quotes, and they're not limiting the amount of information that can be passed. For instance, this application that I've been showing you, it searches for an email address. Does anyone know of anyone who has an email address that is that long? Your common sense for your programmer should be, have maximum for your email address something like 10 characters, do not let commas through, do not let single quotes through, do not let spaces through. So the problem isn't the database server, the problem is the web application programmer. He's not doing what is called input sanitization. Yeah? . . . Yes? . Uh, there will, and I will get to that later. Another thing you'll have to do is you'll have to match the data types of the columns. I'll show you that to you in a minute though. Uh, see we're going to have here, yeah, you have to do that. So while Oracle will return you, for instance, Oracle will say, you're missing a right parentheses, and of course this error message is for the benefit of, The application developer and not the end user, the customer, they're telling it to you anyway because the person who's running the web server and the ODBC server hasn't taken the time to disable error messages. Some web user out there looking at their site on the internet should never be able to see debugging error messages that are coming from your site. And while Oracle tells you missing right parentheses, one thing that it will not do is if you've ever seen a SQL server error message, it gives you parts of the SQL query that will run in the error message. Oracle will never do that. And while in SQL server it's really easy to pick some things like syntax or table name and stuff out of there because you get them in the error messages, on Oracle you are on your own. Another thing you're going to run into is a like query. Like queries are used in SQL for searching for things. They use wildcards. For instance, this one you'll notice, enter as much as you know of a Genericorp employee's last name to obtain their phone number, because I'm sure everyone saw the last time I used S King. Let's say I forgot their first name, but I know that their email address ends in King. And I got, look, two employees happen to have the last name King here. Here's what it looks like in code. First part's the same, but at the end, where email, like, and these percent signs here, they're the same as asterisks. They're basically wildcards. Now the way you get around this, and remember, you want to make sure that their SQL query select last, first name, last name, phone number from employees, you want to make sure that doesn't return records. You don't want to see them. So what we're going to do here is going to go something that's obviously not going to turn up in their email address database. Return no records, for instance. Union select all tables. Ah, did it again. Table name, that's right. All tables. Where, and you have to match what they have, so we're going to use a like here. Where table name, got to use a valid table name, like, or you actually don't have to match the like. We're going to do it anyway here. I just thought of something. Or like, and remember, at the end of what you put, they are going to throw in percent, quote. Like, does not occur in DB. That should look good. One sec. No, you want, I'm sorry, everyone. This one you want to return wildcard, because this is your union select. You want this one to return as many as possible, so you're actually going to leave that blank. And again, you get that back. I'll show you this one. And what happens here is you get, because you used the table name, you're going to have to match all the tables. If you used a single quote there, you get like, percent, and I said, the like is wildcard. You will get full matches will return back. The third thing you're going to see, where's my IE, there it is, nope. That's all we're doing for, we have time constraints. I wish I could show everyone everything with inserts, but we're going to move along here. So now we're going to use the most simple one, because it's going to be the easiest for me to get through the presentation, and I think you've all got the concept here. Just to check, does anyone have any questions thus far? Yeah. Yeah, you can. I'm going to go through all the different stuff you can do. So the first name, now that we've got our list of tables. Oh, typo. Oh, typo. Now that we've got this list, we're going to look through and see what tables look interesting. Since I happen to design this database myself, I will tell you that there is a very interesting table called users here. We're going to look, and the next thing we need to do, now we've got a table name, right? We need to know, before we can do a query on this table, we need to know what the column names are, or else what kind of information are we going to get back? Just like there is in all tables, there is a table called all tab columns. It's got the argument names, column name, and you'll see up here the two C's and stuff, Internet Explorer, when you send it through HTTP, it will encode certain things. I'll show that to you. Union select, column name, again, garbage, garbage. From. All. What is it? User columns? I guess I should know this when I'm asking you guys. One second. All tab columns, which is, of course, all table columns, where, and we specify, and again, all tab columns is another one of those standard Oracle tables. You can look it up in the Oracle reference documentation if you want what the rest of the column names are and stuff. Where table name equal, and here's what we want. We want user. And remember that Oracle is most of the time with the nvarchar data type that most database administrators are going to use. It will be case sensitive. Capital user will not be the same table as lowercase user. And, of course, we know that our ASP scripts lands an extra single quote onto the end and one onto the beginning, so we've got our syntax matched. And, amazingly enough, one sec. . . . . . . . . . . . . . . . . . . . . . . . . password. Now that we know that, we're going to run back here. We're going to plug in username password and it's coming from the table users where, and of course we don't need this part anymore. Check that out for a second. We're selecting username, password, and A from users where 1 equals 1. And as you can see, they have a very strict password policy on this site and for anyone who thinks things like this are unlikely, I recently did like a pen test on a large communications company and their admin password really was the administrator's username followed by 2002. So now we're going to use that and we're going to go back to another login page. Now this login page because it's designed a slightly different way and I'll show you, you can't do the quote equals 1 equals 1 thing on. What happens in this one is it does the same thing select username from users where username is password but in ASP code, which we can't tamper with it actually looks on this part to check is the record that it returned back the same as the variable I have for username? So in this one, we're not going to be able to SQL inject our way through our authorization bypass. Excuse me, authentication bypass. I was waiting for someone to call me on that. So, now since we SQL injected and we got Kidman's username, and his secret password, we can go through and we can still recover sensitive financial information. Now that's the basics about how your select SQL injection is going to work. And now I'm going to go into some Oracle-specific things I've figured out, going through reference manuals and things. Oracle databases are huge, and they contain almost all of their configuration information within system tables. There are system tables for all kinds of things. One of the things that they have a table for is, for instance, the password policy. If you can't get out, if in the improbable event, and I say improbable because I've done this on many, many sites, and it seems like no one really understands that it's a pretty good idea to hash your passwords instead of keeping them in clear text, you can get the password policy. In this case, and this, by the way, is the default configuration. I just want to point out that Oracle, by default, will let you try to log on as many times as you like, and it will not bother you. You can get failed login attempts. Password grace time. And this only will work, again, this is for the Oracle logon. This is not for the web application. It may be completely different. If you can get the Oracle server by your network, this information is unbelievably useful. If they do have a policy in place, and you have maximum amount of attempts, this stuff can really help you design tools that will cut down your brute force time dramatically. Another interesting thing about modern database servers is, they basically got their own enormous programming languages built in. They want developers to use nothing but Oracle tools, they want them to buy the devkits, they want them to do all kinds of stuff. And as a result, they contain some very, very interesting procedures and built-in commands as part of their database. One of the interesting things I found in the Oracle is there is a package called UTLHTDP, the HTTP utility, and it has a method called request. This will allow you, in a SQL statement, to make an HTTP request to another server, and return your result as part of the record set. If anyone can see up here, and it's probably not large enough, what this basically, what has happened here, is as part of my SQL statement, and I'll show you again on the founder page in a minute, it has pulled back an HTTP request and put it in the record set. And I'm also going to point out that there are like tens of thousands of these methods and procedures in Oracle, and there's not a database administrator. It's in the face of the earth that, you know, remembers to lock all this stuff down. It's simply unbelievable. So we're going to look at this and see how to do that. Union, select, UTL, http.request. And in this case, I'm not connecting this box to internet, so I'm just going to do localhost, which I know is, you know, really impressive. Scripts, what's another one? Phone, or let's use login like I showed you in the bookmark. Login.asp. Match your columns from union, select, localhost, jmp. Dual, I told you about the dual table. It doesn't really have anything in it, but it'll make sure you get your result back. Where, and we're going to match the end so that it works nicely with what's in the ASP code. Invalid relation, I'll hop around in a second. Union, select, UTL, http.request. From union, where, when, which one? One sec, sorry guys. Was it? Is that my relational operator problem? Yeah, thank you for solving all of my relational operator problems, man in the back. And we get that. Now I want everyone to think about the implication from this, of the implications of this. This request is being made from where your Oracle database server is, which is probably, although in some places people really do put the Oracle server on the exact same box as the web server, this is probably behind a firewall, and there's a very good chance you have no other way of getting at this Oracle box. You can make the Oracle box from inside the firewall, you can make requests to internal IP addresses, and you can scan for internet web servers using this thing that you normally would not be able to get through from the internet, which is really great. Another interesting thing about Oracle, in order to show everyone how it integrates great with web services and web applications, Oracle has taken the liberty of when you install the Oracle database, it installs an HTTP server, it's built on top of Apache, it's Oracle application server, on the same box as the Oracle server. I just set an Oracle server up on this test box a couple hours ago, and I can tell you that it is impossible to disable it in the installation, it will not let you uncheck the box, and by default it runs automatically as a service, and it will start it. So be sure you check localhost 80 when you get this, because there's a good chance that you're going to have a web server running on the Oracle database server and the administrator doesn't even know it. Other interesting stuff, you can get, union select, the column name is SQL text, and then you have, SQL text, there's the second one, yeah, SQL text, from, there's a table called SQL text, these are all the previous SQL queries that have been run against the database. They contain all kinds of interesting information. I didn't even run any of these, I never did this, this is something the system does by itself, and you can go through it all at your leisure, through SQL injection. See that, you guys remember all this stuff? All stored in the database, Oracle forgets nothing. Other interesting stuff, yeah, I apologize, like I said, I just set this up, this is not on your DEF CON CD ROMs, this presentation, but we will have it posted, I'll get Tangent, he'll put it on the DEF CON dot org site, and our company's website, www.spidynamics.com, we'll have all this information, we'll have a pretty document, white paper, whatever thing that we can give to suits, and it won't frighten them, and you guys can read, and pick out all kinds of interesting table names that I'm using here, you'll be able to have this information, so if you're not writing everything down at the speed of light here, don't worry about it. But, since you asked, table name, SQL text, and remember this is all in your standard Oracle documentation, this is completely in there for anyone who bothers to read it, column name is SQL text. Other great stuff, your privileges, username, granted role, from, user role privs. Now, this will give you a couple of interesting things, the first thing it tells you, is what your username is. In this case, I have it set up, it uses the username web user, and I see that I have rights to connect, which is an obvious one, also, interestingly enough, I have DBA privileges. And for anyone who thinks it is unlikely that the Oracle administrators will set up the web application user as DBA, I can tell you for a fact that, people do it all the time, because then they don't have to bother setting up like, it's privileges and rights and things like that. It will automatically have access to what it needs, you see. And so will we. So we've automatically got, we've got our privileges. Other interesting stuff, Oracle version info. This table name, is called, the dollar sign version, and the column name is banner, and it gives you all the information about what it's running, other great stuff, and this one will take a minute, because it's a very long query, and I'll tell you why it's long. Oracle stores, stored procedure information, in tables. You can get the source, to the Oracle stored procedures, by accessing tables, you see it's loading real slow, because it pulls back, you can go through the source code, for all the stored procedures on the database. This one's going to take a minute, so we're going to head to another browser while that one loads. Other great stuff, God, the Oracle server's going to be swamped. This is running on like a VMware box, and Win 2K Pro, so this isn't happening none too quickly. We may just have to wait for this one. I tell you what, I'll do this one right, oh, there we go. I have here, we're selecting name, line number, and like I said, if you're trying to write this all down, you don't have to worry about it, we'll get this stuff on the net, so that everyone can now see it. Select name, line, and text, from, table name is all underscore source, and another good nice thing about Oracle, is that it has an identifier called Ronum. Ronum is a universal column name, and you can use it to limit the amount of rows that are returned. In fact, I will show you this query, and I'll actually inject it myself, so that you can make sure you're getting all this, but just go through this stuff. It's all kinds of unbelievable stuff, you can see in the stored procedure source, about how the database is set up, what kind of other stuff is. On a really large database, you can have so many user defined table names, if you look through the stored procedure source code, you can usually figure out which ones are interesting, and which ones aren't. I'll go back, and that is name, two-tar line number, all source. Union, select, fuck, I forgot, I'm sorry. Yeah, two-tar and text. Select name, which is going to be your procedure name, two-tar line, and I will show you why we do that, two-tar in just a minute, just what I told that guy over there, is that you have to do certain type of data type matching on Union queries, I probably should have started with that at the beginning, we'll have to go back. Two-tar line, and of course text, from all source, where one equals one. And you'll notice that none of this stuff, is using like exploits, none of this stuff is underground information, we're using the SQL injection, this is just stuff that is stored in the Oracle database, and yours for the taking if you want it, and you know where it is. And of course, as we can see, it would take another half an hour to load, but we're not going to wait, that is how it works. Here is the part about type matching. I don't know why I skipped over it, but it's going to take a minute. I'll open it up over the ASP, and I'll show you what's happening. One part of the Union query, select, and I'll do this with literals and numbers, to make it real simple, from dual, now remember I just told you guys again, the dual table, it's not a real table, it will just return back what you give it, in this case it will return A and 1, where 1 equals 1. Union select, now watch this, let's say we have A and A, from dual, where 1 equals 1. Oracle does not like this. I'll show you what's happening. Expression must have some data type as corresponding expression. Not only do you have to have one two columns here, and one two columns here, the types have to match. If they don't match, you're in trouble. So what you have to do, is once you know how many columns there are, what you're going to want to do, is if you start getting errors, you're going to have to start playing with things. Generally, people are going to have, three different kinds of general data types, of course, nvarchar is different from nvarchar2, but they convert implicitly. But what you're going to have, you're going to try a letter, you're going to try a number, and you're going to try a date. And I'll tell you the easiest way to do dates, is not to try to do stuff like this, there is a function, called sysdate, and it will hand you back, the current date in that record set. In this case, let's say I try sysdate first, front key would not have been expected, sysdate, sysdate may not be a function, it just may be a normal term, one sec. There you go. It doesn't like sysdate, which by the way, case sensitive, like that. But let's say we make it one, and it gets happy. Gets happy. Real technical here. So I don't have any questions at this point. I've been moving kind of quickly and haphazardly. Anyone want to know anything? Yeah, and that's what we do here, in this one, which is still trying to load for some silly reason. Top ten, what? The loading, this is on like a VMware box with no RAM, so if it's taking a long time, we can't do much about it. You see here, line is a number, and in order to get it to return it, in the column, yeah, this one just takes a long time. Let's limit this with where, ronum, it's less than one, ronum, very useful. It still may actually go through and seek all of them, and only return what ronum is less than one. Anyway, I don't, we don't have probably time for this. I don't want to cut into the next speaker's time. We have two char here, and we're using this to convert line, which is a number, so we can do our character type matching to that. Other good stuff you can find, this whole thing may be waiting on the queries that may run, whether or not I've canceled this thing. You can get the name of the operating system, the operating system user you are running under using this query, syscontext. Oh, that's right, I should go through that. There is a function in Oracle. Most functions are stuff like to char. Most functions, you know, are things like they're going to help you add, divide, multiply, subtract, or plug in, put data types together, things like that. There's a very interesting one called, union, it's called syscontext. It returns information about the current session you're in. You give it a table space, which the one you want to use is userN, if it's probably the only ones you have permissions to, and you can get interesting stuff. And the second argument in the syscontext function, for instance, IP address. It will tell you the IP address of the box you're running under. Hang on. You select syscontext there. Of course, we have three columns. We're going to use dual. Don't have to bother with going to a real table. We'll just return back what we want, syscontext. Missing select keyword. I'm a real genius. You've all figured it out by now. There we go. And we get back an IP address. Now, you're noticing, of course, this is 192.168, which is, of course, disappointing. I'll tell you two reasons that's happening. One reason is, of course, I'm not connected to a LAN. That's really this box's only IP address. The second reason it's happening is because there's certain ways of configuring Oracle that it's the only Ethernet adapter that it will recognize as your local one. However, this information is still very, very useful because we can, using our HTTP proxy, we now know what to start scanning for when we, like, for instance, we've already determined that we can use utlhttp.request to pull information back. And what you can do is you can set up a script that'll try 192.168. This is stuff on the internal network. Obviously, you can't get it from the net, but if you can SQL inject to an org, to an Oracle host, you can get your information back. You can start at, you know, .1, .0. You can make that request. See if there's a web server there. If you don't, if you get a null response, there's nothing there. Try two and try three, and you can work that way, and you can basically turn the Oracle box into an HTTP port scanner. And if there are Internet web servers running, they're going to have interesting stuff on them. Yes, sir? . Yeah, absolutely. This works pretty standard sequence. One thing I tried, I was disappointed, does not work. I know you can, not do, like, file colon slash slash, and that pissed me off, because I was hoping for that. You could pull files from the local host. Yeah? What? Your question requires a pretty lengthy answer. I'll get to it in a minute. Yours, yeah, you can do HTTPS. It'll do all the negotiated stuff for you. Yeah? . Can you do, like, any other characters besides the single quote to break out of the, you know, the, the, the block? Um, generally not. Uh, if you can use parentheses. I haven't actually tested on this one, but let's see. I, he wants to know, let's say that you can't get, um, single quotes through the, the web server is your question, right? The web application's filtering out single quotes. You want enough so you can use double quotes and stuff like that? Uh, double quotes, I'll tell you, will not work. What you want to look for, and I don't have the information in front of me, I'm sorry, when I post the information, I'll get it to you, is, uh, like, if there's a char function, for instance, that's gonna be a good, bad one. Let's see if we get, uh, a character in the first column. Just an exploration. No, I don't have sequel, syntax information for this in front of me. Uh, I'll find out about that, though. Yes, sir, back there? What if you use the hex code? The hex code in here, and the char function? No, just, like, you know, a percentage hex code, but... Your web server, when it, when it gets to the web server, the web server will understand that, but what it will do is it will convert that to the real character before the ASP script gets a hold of it. So the ASP script will see, not the hex escape code, it'll see the real character, and if it's told to block single quotes, even if you have some coded, it'll still block it. Yes, sir? Uh, do you know why single quotes do not work? It does not until 4.0. It does not until 4.0, this man right here says. Um, the other question about, is there, do you have XP command shell, do you have arbitrary command execution? Uh, the answer to that is, I haven't found a way yet. I'm still working on it. The problem with this is I'm not an Oracle DBA. I'm a web application security guy. So there are all kinds of stuff in Oracle that I've been looking through. One thing I will tell you, and that anyone who's done this with SQL Server loves, is you can use semicolon to do multiple command statements. The Oracle ODBC driver will not let you pass a semicolon. The semicolons will never see the web server, and you'll, the, and you'll get an error message back. As far as arbitrage, is there a stored procedure to execute OS level commands? I don't think there is. Sir, over here. Yeah, I've run the metric to, to run the site on .NET of secure.net. Mm-hmm. It's really funny. It's a, it's a good forcer for Oracle, and it also uploads the TV doc and, and executes it. Yeah. And it's also, it works also for, for . Okay, what he's saying is that, what is the URL there again? What? Your friend's site. What is the, where can you get the tool? Hmm? . I don't have a net access on this right now. Can you just tell us again? . Yeah. . . Okay. While he's running up here, I'm, I'm gonna tell you that my presentation is covering clean things you can do with SQL injections. . Just type it up there. People see it. Is that, of course there are, you've got buffer overflow exports for Oracle. You've got privilege escalation techniques. My presentation isn't all in that stuff. That's database layer security. I'm doing web application stuff just showing you, you what you can do without getting to Oracle specific exploits. If you guys, you know, follow bug track, there's a ton of ways that once you are really putting information in there, you can, you can use buffer overflows. You can probably get OS commands executed. But, for instance, in SQL Server, in MS SQL Server, they have a procedure called XP command shell that very cleanly and with the server's permission will execute your commands for you. Oracle doesn't have that nice, easy functionality to get that done. Yes, sir. If you are using stored procedures, I don't have a demo web application for that. Yes, you can, you know, you can inject into stored procedures. Let's say, right, just a second. Sorry about that. Let's say that they've got, you know, stored procedure, my stored procedure, and they've got, what you need to do, you need to match when you're breaking through stored procedures, is you need to match the number of arguments. So, and you have to match it at the end. So, let's say they've got a stored procedure and the correct syntax, the stored procedure, and I'm just typing it up here. This isn't, you know, this is obviously, this is ASP. This isn't how you would do it. This isn't how it would appear on the web application. This is on the web server. Great, I'm losing people. Bye, guys. Let's say that your correct syntax looked like this, right? Three arguments. And your injection, and let's say you got to control the value of the first argument, right? Your injection string looked like that, union select, and then blah, blah, blah. And, and that was in there. Yeah. This stuff here is no good because this is what it would look like. Yeah. That's obviously not valid syntax. So, what you would have to do is your injection string, you would have to, and it'll do the same way it'll give you an error message as it'll tell you when you've got the wrong number of columns. You'd have to go A, A, close the parenthesis, send it, see if you get an error message. If not, you keep adding them and eventually you'd have to go like that, and you'd put that in there and the database server would end up seeing something that would look like that and of course at the end you would have to clean it up and have something with three arguments, too. But you can do it. Any other questions? Yes here. So, you've been looking to a lot of websites and going to assessments and so forth and see a lot of select statements. Do you see a lot Yeah, insert is vulnerable in the same kind of way. The insert syntax was different, and we have time constraints here. How much time do I have left here? All right, yeah, like I said, if I tried to do insert, too, it requires its own unique set of things to look for. I just didn't have the time to present it here. You can do it with insert. Occasionally, you run across the sites that are running really weird-looking SQL queries. If you're changing your password, it may have, like, an alter command or something like that. Nearly anything is injectable as long as your web application is not protecting against single quotes and stuff like that. Any other questions? Can you do a quick round, or what we need to do is tighten it up? Just tighten it up. Yeah, I guess some people here want to know that. Here is a real simple... I'm about to release... Check www.spydynamics.com. SPI is S-P-I. There's about to be... I have a whole paper written on secure web application and database server interaction, which covers what you need to do to tighten up in terms of web application and how to lock down your database server with correct roles and permissions in case, if someone can inject, the amount of damage they can do is greatly minimized. So let's look at... Let's take fonder.asp, and let's say... See, email request. That's where it pulls it. That's where it pulls it off. That's where it pulls your user argument from your UI out. Let's say we did two things here. Replace... What's that? I'm not an ASP programmer, and I don't intend to be, but this is what I had in front of me when I had to build this. Replace single quote with... Let's say this is what PHP does. Backslash single quote, or you can do it with null. It'll kick all of the single quotes out of there. What else you might want to do? Replace commas. What does an email address need commas in it for? Replace it with a bad character, or for instance, nothing. Yeah? Yeah, the best way to do it is to regex everything else out, but I don't even know how to run regex on ASP. It probably doesn't support it. It does? Thank you, Phil. Like I said, I'll have all this in a paper, proper. Default and eye filtering is always the best way to do things. This is basic stuff you can do real quick. Other stuff you want to do is simply limit the length. You would do that real easy. Email equals left. No, not quote email. Email, and I think that's the correct syntax on the ASP programmer. You would limit it to 10 characters. You're not going to be able to do a whole lot in SQL with only 10 characters to clean everything up and get what you want back. So those are your quick steps. Default and eye filtering, like this guy said, he was completely right. I wasn't thinking up here. And limiting length, and also data type. If your argument, in this case, it's a string, but if your argument is a numeric type, and someone is trying, and you're trying to pass letters into it, it goes with the deny filtering, don't let them do that. Other things you want to do is on the database server. It's a really bad idea to let the web application access your database server with DBA privileges and stuff. What you want to do is you want to take all the functionality of your web application, break it down into roles, logically break that down into users, and default, deny, and only grant those users the right to execute certain stored procedures. It's another thing. Try to stay away from building SQL statements. It's not a great idea. You're much better off using prepared statements and stored procedures. That gets into the database programming, which this isn't a presentation on. Like I said, there'll be a separate paper on this. This is really a demonstration of attack techniques. Yes, sir? This also works pretty easily for a service. If you just put in really complex query statements. There is all kinds of stuff, particularly if you're in DBA, you can go to those system tables, like all tables or all columns. You can start messing with stuff. And their database will probably stop working. Have any other questions? Okay, I think I am done up here then. I apologize again for having this put on together so quickly. Thank you very much. If you want more in-