Waraxe IT Security Portal
Login or Register
November 6, 2024
Menu
Home
Logout
Discussions
Forums
Members List
IRC chat
Tools
Base64 coder
MD5 hash
CRC32 checksum
ROT13 coder
SHA-1 hash
URL-decoder
Sql Char Encoder
Affiliates
y3dips ITsec
Md5 Cracker
User Manuals
AlbumNow
Content
Content
Sections
FAQ
Top
Info
Feedback
Recommend Us
Search
Journal
Your Account
User Info
Welcome, Anonymous
Nickname
Password
(Register)

Membership:
Latest: MichaelSnaRe
New Today: 0
New Yesterday: 0
Overall: 9144

People Online:
Visitors: 67
Members: 0
Total: 67
Full disclosure
4 vulnerabilities in ibmsecurity
32 vulnerabilities in IBM Security Verify Access
xlibre Xnest security advisory & bugfix releases
APPLE-SA-10-29-2024-1 Safari 18.1
SEC Consult SA-20241030-0 :: Query Filter Injection in Ping Identity PingIDM (formerly known as ForgeRock Identity Management) (CVE-2024-23600)
SEC Consult SA-20241023-0 :: Authenticated Remote Code Execution in Multiple Xerox printers (CVE-2024-6333)
APPLE-SA-10-28-2024-8 visionOS 2.1
APPLE-SA-10-28-2024-7 tvOS 18.1
APPLE-SA-10-28-2024-6 watchOS 11.1
APPLE-SA-10-28-2024-5 macOS Ventura 13.7.1
APPLE-SA-10-28-2024-4 macOS Sonoma 14.7.1
APPLE-SA-10-28-2024-3 macOS Sequoia 15.1
APPLE-SA-10-28-2024-2 iOS 17.7.1 and iPadOS 17.7.1
APPLE-SA-10-28-2024-1 iOS 18.1 and iPadOS 18.1
Open Redirect / Reflected XSS - booked-schedulerv2.8.5
Log in Register Forum FAQ Memberlist Search
IT Security and Insecurity Portal

www.waraxe.us Forum Index -> Sql injection -> Basic SQL Injection
Post new topicReply to topic View previous topic :: View next topic
Basic SQL Injection
PostPosted: Wed Feb 25, 2009 11:08 pm Reply with quote
Cool_Man
Beginner
Beginner
Joined: Feb 26, 2009
Posts: 3




Hi

I'm trying to learn SQL injection (spent 4-5 hours). I have setup a basic

PHP+APACHE+MYSQL development area; with a user table and a basic front end using PHP.

I'm trying to do the basic SQL injection, where I'm inserting
Code:
'' or '' = ''";


inside one of the inputs. The result I'm getting is

Code:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\xampp\login.php on line 20
--- Incorrect Username or Password ---


However, I dont quite get how this is a exploit... (i know it sounds stupid)
View user's profile Send private message
PostPosted: Wed Feb 25, 2009 11:16 pm Reply with quote
slsl
Advanced user
Advanced user
Joined: Oct 14, 2008
Posts: 66




try different things what it is saying with that error is that your syntax is wrong try:

Code:

' OR 1=1--+
" OR 1=1--+

it has to do with how your statment in the code is set up if your code was


Code:

SELECT * FROM USERS WHERE password = ' . $pass .' ORDER BY DESC


you would use something like ' OR 1=1 --+

SQL injection is a common security flaw in sites where the don't sanitize user input that goes into SQL queries. This allows users to manipulate that database and the returned input in many ways, that is why I would call it an exploit.

i recommend you visit a tutorial like http://www.securiteam.com/securityreviews/5DP0N1P76E.html
View user's profile Send private message
PostPosted: Thu Feb 26, 2009 12:10 am Reply with quote
Cool_Man
Beginner
Beginner
Joined: Feb 26, 2009
Posts: 3




slsl wrote:

Code:

' OR 1=1--+



Now i got three senarios



    If i use the above for both input boxes, I login as normal

    If I use it on only one inpux box, I dont login in however get error message

    If i use normal invalid username and password, i dont login with no error message
View user's profile Send private message
PostPosted: Thu Feb 26, 2009 1:06 am Reply with quote
slsl
Advanced user
Advanced user
Joined: Oct 14, 2008
Posts: 66




that would be because how the SQL query is formed.

say the query is


Code:
SELECT * FROM users WHERE username = ' . $user . ' AND password = ' . $pass . '


when you use ' OR 1=1 --+ you are saying Grab the user from users table where username is NULL or if 1=1 grab a user. since 1=1 is always true it will grab all users in the database. if you use invalid info it is saying grab the user with that username AND that password but since it does not exist it returns NULL. Also you should know that the -- is the comment symbol in SQL so it disregards anything after the "--"

If you don't really know how SQL works and how to form statements use http://www.w3schools.com/sql/ I Would recommend that site for almost any web programming language
View user's profile Send private message
PostPosted: Fri Feb 27, 2009 11:39 pm Reply with quote
Cool_Man
Beginner
Beginner
Joined: Feb 26, 2009
Posts: 3




Thanks for the help

I have done few experiments on UNION ALL SELECT and blind injection (brute...)

Don't want to sound stupid but, is it possible to INSERT and DELETE data from the URL? because I have not managed to do it.

What I have tried

Code:
www.example.com/users.php?id=2'; DELETE FROM users WHERE 1 or username = '";


Thanks
View user's profile Send private message
PostPosted: Sat Feb 28, 2009 2:27 am Reply with quote
waraxe
Site admin
Site admin
Joined: May 11, 2004
Posts: 2407
Location: Estonia, Tartu




In case of Mysql/Php you can't use stacked sql queries (separated by ; ). So you can manipulate with UPDATE only if there is sql injection in UPDATE query and same for INSERT and DELETE.
View user's profile Send private message Send e-mail Visit poster's website
Basic SQL Injection
www.waraxe.us Forum Index -> Sql injection
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT
Page 1 of 1

Post new topicReply to topic


Powered by phpBB © 2001-2008 phpBB Group



Space Raider game for Android, free download - Space Raider gameplay video - Zone Raider mobile games
All logos and trademarks in this site are property of their respective owner. The comments and posts are property of their posters, all the rest (c) 2004-2024 Janek Vind "waraxe"
Page Generation: 0.036 Seconds