| General Hacking Discussions Got a question about hacking? Post it here. |
|
#1
| |||
| |||
| How to Login to Any Account on an Insecure Site
I sat down with a friend today and spent a good 5 hours attempting to breach the security of an unnamed website. The website in question is a rather popular website with an Alexa ranking of just over 3,000. I've always been of the opinion that esoteric knowledge is only esoteric because the individuals wish to make it that way. Governmental procedures, for instance, are very esoteric. Unless you're actually there, the procedures are well over many individuals' head. If you can decipher the language used most people can understand it. This is where I'd like to sit down with everyone at TalkPHP and explain in simple terms how I did it, the reasons why and what you can do to prevent this from happening to you. Note: Although we successfully hacked the target site, no core information was gathered and no harmful information was injected. The administrators of the site were notified and advised on how to patch the vulnerability. This breach of security involved the common security method, SQL injection. Now, I've used the unnamed site on numerous occasions for various reasons that I'm not going to mention. All perfectly innocuous. However, from using the website off and on I noticed many security issues that were arising from normal use. Today was the day I decided to put theory into practice. I already had an account and so I attempted to login to my account using the following: Username: Wildhoney Password: ' OR 1=1 What that essentially says is take the user name, Wildhoney, and then attempt to issue my own SQL. If you think that the normal query would be like so: Code: SELECT
myUsername,
myPassword
FROM
myTable
WHERE
myUsername = 'Wildhoney'
AND
myPassword = 'myPassword'
Code: SELECT
myUsername,
myPassword
FROM
myTable
WHERE
myUsername = 'Wildhoney'
AND
myPassword = '' OR 1=1
However, on this website there is more code at the end of the SQL making our MySQL statement now make absolutely no sense. The solution for this is MySQL comments! A comment will comment out any code we do not want. In this case, the code after our OR 1=1. First up was the -- comment block. However, -- only comments single lines and after that didn't work we deduced the site must have been using multiple SQL lines. Step in /*. Once that had been issued MySQL ignored everything after our OR 1=1 and the login was successful. Note: Although we logged into our own user name, absolutely any user name on the site could have been accessed. I presume that many individuals are asking "why?". This wasn't a case of boosting our ego or bragging rights. Rather, education. Although we did a lot more after the login attempt, nothing harmless in the least, the login attempt is perhaps 1 of the most vulnerable part to any website and I felt was worth mentioning to everyone on TalkPHP to stop them making the same mistakes in their code. For the login attempt, the code was not complex nor was it tricky to construct. We successfully logged into our account without specifying the correct password after about the 5th attempt. A little research was required before logging in but after that, the world is yours (Or, ours). The way to protect yourself against something like that is just so simple. You should escape all single quotes, as well as check the data using a type specifier. See our article on sprintf.
__________________ Just focus... |
|
#2
| ||||
| ||||
| Re: How to Login to Any Account on an Insecure Site
Nice article about Blind SQL Injection, nothing new but I haven't seen this way of discussing it. However, this is not true in all cases since it might be different depending on the affected application. In some cases One might have to use " instead of ' to escape the quotation and do an "OR" condition and in some other cases there might be no quotation where a simple space will be sufficient. The easiest way to protect against this is to use prepared statements, the right way. An alternative to prepared statements could be mysql_real_escape_string() which has to be implemented correct as well. Note about the SQL query: Code: SELECT
myUsername,
myPassword
FROM
myTable
WHERE
myUsername = 'Wildhoney'
AND
myPassword = '' OR 1=1
Code: SELECT
myUsername,
myPassword
FROM
myTable
WHERE
myUsername = 'Wildhoney'
AND
myPassword = '' OR 1=1'
__________________ Code: ____/____\_________________
\|/ | OMG IT'S TEH LEET STORY!! |
/*\ /\ -*- |______ ________/\_________|
// \\ / \ /|\ / \/ \ / \
/// \\\ / \ / \/ \
// \\ / \ / \o/ \ \
| | / \ / | \ \
___| |____/ \______/________/ \_______\_____\_________
/ o \
#"=-
/\
__________________________________________________________
On a mission, to find the lost member of Teh Unkwon.. Last edited by MaXe; 1st February 2010 at 15:52. |
|
#4
| ||||
| ||||
| Re: How to Login to Any Account on an Insecure Site
You're right, I've moved the thread.
__________________ Code: ____/____\_________________
\|/ | OMG IT'S TEH LEET STORY!! |
/*\ /\ -*- |______ ________/\_________|
// \\ / \ /|\ / \/ \ / \
/// \\\ / \ / \/ \
// \\ / \ / \o/ \ \
| | / \ / | \ \
___| |____/ \______/________/ \_______\_____\_________
/ o \
#"=-
/\
__________________________________________________________
On a mission, to find the lost member of Teh Unkwon.. |
|
#5
| ||||
| ||||
| Re: How to Login to Any Account on an Insecure Site
SiG thank you very much for your honest ambition regarding on Hacking.... Hope every Hacker should be thinking like you.
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [Win32] PayPal Account verifier BETA | Lolhax | Hacking Tools & Utilities | 4 | 3rd February 2010 02:26 |
| [Article] Kingston Admits Secure USB Drive really Insecure | agriloan | Security News and Feeds | 2 | 11th January 2010 19:56 |