Learn sql injection

Started on the old forum in June 2009 · view the original in the archive · old links redirect here

18 replies · 5,067 views · started 17 years ago · 1 min read

13 participants
mr_lash Junior · 21 posts #2

hmmmmmm

wy bring this up in the 1st place? 😳

something else Fellow · 2,296 posts #4

if someone is hacking on your site via sql injection dont you think they would cover there own site against it?

..... kinda pointless ?

opticalpigion Lead · 593 posts #5

makvanpor2000 wrote: the reason why i bring up this topic cos some one is hacking into my database, and i want to hack back into his

RewriteCond %{QUERY_STRING} [^a-z](declare|char|set|cast|convert|delete|drop|exec|insert|meta|script|select|truncate|update)[^a-z] [NC] 
RewriteRule (.*) - [F]

add this into ur .htaccess

paramound Junior · 18 posts #6

don't hack back since you are a new coder, just chillout. Hacking is bad just learn preventive measures

GiLL Senior · 356 posts #7

Prevention from Sql Injection Attack in PHP

To avoid the sql injection attack, please follow the following simple mechanisms in PHP

  1. Always restrict the length of the fields of form such as don’t allow more than 20 characters in the fields like username and password with the “maxlength” property available in the html form.

  2. Always validate for the proper input like weather the value is valid email or not, is numeric or not , valid date or not etc.

  3. Finally, Always use mysql_real_escape_string() function before sending the variable to the SQL query, it ad. For example note you must be connected to the database for using this function

$username=mysql_real_escape_string($_POST['username']);
$password=mysql_real_escape_string($_POST['password']);

if a intruder inject ‘ OR 1 in the user name and password field then the value of the $username and $password will become \’ OR 1 which is not going to harm us anymore.

this might also help some one .htaccess

# Block out any script trying to set a mosConfig value through the URL

RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]

# Block out any script trying to base64_encode crap to send via URL

RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]

# Block out any script that includes a <script> tag in URL

RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]

# Block out any script trying to set a PHP GLOBALS variable via URL

RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]

# Block out any script trying to modify a _REQUEST variable via URL

RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})

# Send all blocked request to homepage with 403 Forbidden error!

RewriteRule ^(.*)$ index.php [F,L]

left wap stuff

kei_ki7 Senior · 431 posts #8

GiLL wrote: Prevention from Sql Injection Attack in PHP

$username=mysql_real_escape_string($_POST['username']);
$password=mysql_real_escape_string($_POST['password']);
# Block out any script trying to set a mosConfig value through the URL

RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]

# Block out any script trying to base64_encode crap to send via URL

RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]

# Block out any script that includes a <script> tag in URL

RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]

# Block out any script trying to set a PHP GLOBALS variable via URL

RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]

# Block out any script trying to modify a _REQUEST variable via URL

RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})

# Send all blocked request to homepage with 403 Forbidden error!

RewriteRule ^(.*)$ index.php [F,L]

where do i need to put that htaccess? i mean the .htaccess file

Did I help you? You can help me too Your donations will help me finance my studies.

ranzit2 Developer · 187 posts #9

kei_ki7 wrote: where do i need to put that htaccess? i mean the .htaccess file

in the folder where ur script is.

she is beautifull than php.and i love her more than php.

youngbobby Developer · 55 posts #10

Hi thanks for the help. It was really helpful. But if u have time, u can also tutor on how to validate email field apart from using mysql_real_escape_string(); function

Naijatop.net = Mobile Traffic Booster 👑

📖 YoungBobby.com = Bobby's BLoG 😁

You're Welcome !!

metulj Super moderator Principal · 1,726 posts #11

GiLL wrote: Prevention from Sql Injection Attack in PHP

To avoid the sql injection attack, please follow the following simple mechanisms in PHP

  1. Always restrict the length of the fields of form such as don’t allow more than 20 characters in the fields like username and password with the “maxlength” property available in the html form.

  2. Always validate for the proper input like weather the value is valid email or not, is numeric or not , valid date or not etc.

  3. Finally, Always use mysql_real_escape_string() function before sending the variable to the SQL query, it ad. For example note you must be connected to the database for using this function

$username=mysql_real_escape_string($_POST['username']);
$password=mysql_real_escape_string($_POST['password']);
@$username = mysql_real_escape_string(strip_tags(htmlspecialchars($_POST['username'])));
@$password = mysql_real_escape_string(strip_tags(htmlspecialchars($_POST['password'])));

this should be pretty much better😊

It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt. ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ ! ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.

キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

manavworld Developer · 118 posts #13

Whts sql_injection, its a reason 4 hack our site? Wot we can do for security of our site, last day sm1 hack mah site, and may be he used mah pasword also, hw is it posible even i was change my pasworld last evening? Am very confused about it, can any one tell me how to that hacker enter mah site nd how he get mah pasword?

manavworld Developer · 118 posts #15

Than hw we can protact our site from hacking? ..and whr i can put this code...mysql_real_escape_string(strip_tags....i wana to protact my site only to sql injection...hw i can do it...plz help me...plz

paramound Junior · 18 posts #16

makvanpor this is the best option for your site, just remrove your broadcast, and direct uploading of pic intoa profile let it come through the file share.

paramound Junior · 18 posts #18

i am working on securing lavaliar, blocking the holes in the script

amylee Principal · 1,092 posts #19

paramound wrote: i am working on securing lavaliar, blocking the holes in the script

lol ****ing good luck, i know how many holes there are in the script and believe me its a ****ing **** load i am talking 25 plus ways to **** with the script

thats one of the reasons why i dont update my script or even use it anymore

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close