Jump to content

SQL Injection Test


Muncey

Recommended Posts

Basically im making a input in which i need someone to input an sql injection. I thought of just doing a simple  if statement and say if their input is ' or 1=1 -- then it's right but they could also put ' or 2=2 -- and it's still right, or x' or 2=2 -- or hello' or 100000=100000 -- and they would be right yet i dont know how to test to see if the user input a successful sql injection line.

 

I really need help with this, thanks.

Link to comment
Share on other sites

Sorry i didn't explain it very well. Im fully aware of what sql injection is, how to do it and how to prevent it.

 

Im making a workshop type thing with like levels and one of the questions is give an example of a sql injection... when they input a correct sql injection i need to show one thing and show another if it's wrong.

Link to comment
Share on other sites

Ah, check for the single quote and the OR statement and maybe even the equals sign.

 

If it has those chances are it is pretty close. Or use www.php.net/preg_match regular expressions to do the check for you.

Link to comment
Share on other sites

Here is an example:

<?php

$input = "' R 1=1 --";

$ptn = "/('|\") OR ([0-9]+)=([0-9]+) (\-){2}/i";

preg_match($ptn, $input, $matches);

if($matches[0] == $input)
{
    echo '<tt>' . $input . '</tt><br />Successfull SQL Injection command';
}
else
{
    echo '<tt>' . $input . '</tt><br />Is not an SQL Injection command';
}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.