Go Back   Webmaster Malaysia Forum » Website Design & Development » Website Programming

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-10-2004, 03:49 PM
YajivMalhotra's Avatar
Novice Webmaster
 
Join Date: Oct 2004
Location: Johor Bahru, Malaysia
Posts: 41
Rep Power: 0
YajivMalhotra is on a distinguished road
Send a message via Yahoo to YajivMalhotra
Anti SQL Injection Code / Intro

Sql injection biasa berlaku kat login form. Katakan query anda seperti ini:

sql_send("insert into yajiv (name) value ('$name');");

Biasanya SQL Injection attack dilakukan pada Login form:

User akan memasukkan username'nya (dalam field username) sebagai contoh di bawah
Yajiv')"; delete * from names;

Oleh Itu, SQL akan query berikut:
insert into names (name) value ('Yajiv')"; delete * from names;');

Sekarang query default telah berubah kepada query baru. Sekiranya database tak secure, semua data dalam table names akan hilang

Untuk mengelakkan kejadian di atas berlaku function berikut boleh membantu:


<?PHP
function stripQuotes($strWords)
{
$strWords = str_replace("''", "'", $strWords)
return $strWords ;
}
function killChars($strWords)
{
$badChars = array("select", "drop", ";", "--", "insert", "delete", "xp_") ;
str_replace() ;
foreach($badChars as $current)
{
$strWords = str_replace($current, '', $strWords);
}
return $strWords ;
}
?>


Masukkan Code berikut dibahagian login process:
$login = stripQuotes( $_POST['user'], $_POST['pass']

Oleh itu, function ini akan menapis ayat-ayat berikut:

select
drop"
;
--
insert
delete
xp_

(Anda boleh edit sendiri)

Sekarang site dah selamat daripada SQL Injection. Untuk keterangan lanjut sila layari:

http://www.sqlsecurity.com/


Selamat Mencuba

Last edited by YajivMalhotra; 11-10-2004 at 01:01 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 10-10-2004, 04:03 PM
BreakSys's Avatar
Novice Webmaster
 
Join Date: Jan 2003
Location: JB
Posts: 59
Rep Power: 74
BreakSys is on a distinguished road
Send a message via Yahoo to BreakSys
correction!!!

Script Kiddy..
or Cracker...

bukan Hacker!~
__________________
<b><i>Only the paranoid survive</i> - Andy Groove</b>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-10-2004, 10:24 PM
YajivMalhotra's Avatar
Novice Webmaster
 
Join Date: Oct 2004
Location: Johor Bahru, Malaysia
Posts: 41
Rep Power: 0
YajivMalhotra is on a distinguished road
Send a message via Yahoo to YajivMalhotra
wuteva la... hehe.. yg penting.. msg tu penting.. :P hehe
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 10-10-2004, 11:17 PM
Ben-davis's Avatar
Senior Webmaster
 
Join Date: Jan 2002
Location: SoObHanG JhaYa
Posts: 501
Rep Power: 94
Ben-davis is on a distinguished road
Send a message via ICQ to Ben-davis Send a message via Yahoo to Ben-davis
Script kiddy, cracker and hacker.... is diffrent thing....
__________________
<form name="jump">
<select name="menu" onChange="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" style="border:1px #393F31 solid;color:#393F31;font:10px Verdana;font-weight:bold;" >
<option value="0" style="background: #9CC8FE" selected>*SELECT-LINKS</option>
<option value="http://www.gengturbo.org/" style="background: #FF0000">GENGTURBO</option>
<option value="http://www.phixelgrafix.com/" target="new" style="background: #C6D607">PHIXELGRAFIX</option>
<option value="http://dailydigital.phixelgrafix.com/" style="background: #FCBC45">OLD-BLOG</option>
<option value="http://www.mesrahosting.net/" style="background: #FF99CC">WEBHOSTING</option>
</select>
</form>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 11-10-2004, 01:02 AM
YajivMalhotra's Avatar
Novice Webmaster
 
Join Date: Oct 2004
Location: Johor Bahru, Malaysia
Posts: 41
Rep Power: 0
YajivMalhotra is on a distinguished road
Send a message via Yahoo to YajivMalhotra
oklah .. .aku dah edit balik... tutorial aku tu.. .... aku lemah lah dalam hal hacker/cracker ni semua..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 11-10-2004, 01:12 AM
Novice Webmaster
 
Join Date: Sep 2004
Location: Shah Alam
Posts: 68
Rep Power: 53
infeeneetee is on a distinguished road
hehehe,.. takpe... usaha anda sgt dihargai.. bagus sekali artikel tuh
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 11-10-2004, 09:24 AM
Ben-davis's Avatar
Senior Webmaster
 
Join Date: Jan 2002
Location: SoObHanG JhaYa
Posts: 501
Rep Power: 94
Ben-davis is on a distinguished road
Send a message via ICQ to Ben-davis Send a message via Yahoo to Ben-davis
oit YajivMalhotra, buh sekali la... XSS vuln ngan remote shell execution thru PHP code.... depa nak tau gak tue....
__________________
<form name="jump">
<select name="menu" onChange="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" style="border:1px #393F31 solid;color:#393F31;font:10px Verdana;font-weight:bold;" >
<option value="0" style="background: #9CC8FE" selected>*SELECT-LINKS</option>
<option value="http://www.gengturbo.org/" style="background: #FF0000">GENGTURBO</option>
<option value="http://www.phixelgrafix.com/" target="new" style="background: #C6D607">PHIXELGRAFIX</option>
<option value="http://dailydigital.phixelgrafix.com/" style="background: #FCBC45">OLD-BLOG</option>
<option value="http://www.mesrahosting.net/" style="background: #FF99CC">WEBHOSTING</option>
</select>
</form>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 11-10-2004, 01:12 PM
YajivMalhotra's Avatar
Novice Webmaster
 
Join Date: Oct 2004
Location: Johor Bahru, Malaysia
Posts: 41
Rep Power: 0
YajivMalhotra is on a distinguished road
Send a message via Yahoo to YajivMalhotra
pasal shell execute tu.. hehe... depa tak pasti...:P .... tapi cross site script attack .. tahulah sket sket....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 11-10-2004, 04:01 PM
Senior Webmaster
 
Join Date: Oct 2001
Location: Melbourne, AU
Posts: 456
Rep Power: 97
sufyan is on a distinguished road
Another good resource:

http://www.owasp.org/index.jsp

(Look under documentation)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Anti-Spam Software Terry Paid Hosting Discussion Forum 3 28-11-2006 11:50 AM
setup anti spam use oss linasham Mamak Stall 1 22-09-2006 01:55 PM
About XSS Injection YajivMalhotra Website Programming 3 11-10-2004 03:53 PM
sql injection MHR Website Programming 7 08-10-2004 03:03 PM
the best anti virus! fadlee Mamak Stall 30 08-10-2004 09:00 AM


All times are GMT +8. The time now is 12:02 PM. Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0 vBulletin skin by ForumMonkeys.com.


WebmasterMalaysia.com is Proudly Hosted by Exabytes Semi Dedicated Server.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61