Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Web Development
You last visited: Today at 11:59

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Website] PHP Ideas: Javascript and Security (XSS Attacks)

Discussion on [Website] PHP Ideas: Javascript and Security (XSS Attacks) within the Web Development forum part of the Coders Den category.

View Poll Results: Rate the helpfulness of this post: 5 being the most help
1 1 100.00%
2 0 0%
3 0 0%
4 0 0%
5 0 0%
Voters: 1. You may not vote on this poll

Reply
 
Old   #1
 
xBlackPlagu3x's Avatar
 
elite*gold: 0
Join Date: Jan 2011
Posts: 286
Received Thanks: 71
[Website] PHP Ideas: Javascript and Security (XSS Attacks)

Hello again, E*PVP! Here's my second PHP (hopefully helpful) post.

This one is around the concept of an XSS attack. Let me define it first:

An XSS attack is when a user is capable of entering html code and then whatever webpage it is on will then process the code.

Example of a normal user:

Example of an XSS attack:

The script that the attacker inputted would mean that every page your user tried to browse, since his name was now registered as that script, when your page loads the newest account which is now him, it redirects the page to Google!

Obviously the registration form might not be the easiest place to use it, but if you created your own message board on your website by hand, it would definitely work when it posted the message because you have that script in there.

How to defend from it:
Well, as for the registration page, you should have a check that makes sure the username/password has no invalid characters in it. Mainly the only characters that should be allowed are Aa-Zz and 0-9.

As for your handmade message board or forums that don't yet have this protection implemented, you will need to write code that when the user submits his forum post, it turns the html tags (such as < and >) into what is called a character reference.

EDIT:
PHP Code:
mysql_real_escape_string();
//and
htmlspecialchars(); 
A big thank you to for getting these to hopefully start some of you in the right direction of what to use! (I know it even helped me, as my fix is a lot more code. >_<)

Here's an example:
You could write code that would turn something like this "&" into this: "&" which would display the same thing either way. But yeah, your code would turn the html tag like
Code:
<script>
into something like "&lessthan;script&morethan;"

Note: That isn't the real character reference for < and >

I hope this helps in some sort of way, and I apologize if I made it harder to understand. Like my other posts tagged with [Website], I'll continue to work on this post and make it easier to understand!

-xSherufanir/xBlackPlagu3x; Please rate the helpfulness of this thread! ^^

Great Resource on XXS (Cross-site) attacks: Wikipedia Cross-site scripting
xBlackPlagu3x is offline  
Thanks
1 User
Old 07/04/2012, 07:51   #2
 
Zeroxelli's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 1,769
Received Thanks: 1,143
PHP Code:
mysql_real_escape_string();
//and
htmlspecialchars(); 
Ftw
Zeroxelli is offline  
Old 07/04/2012, 08:00   #3
 
xBlackPlagu3x's Avatar
 
elite*gold: 0
Join Date: Jan 2011
Posts: 286
Received Thanks: 71
Quote:
Originally Posted by Zeroxelli View Post
PHP Code:
mysql_real_escape_string();
//and
htmlspecialchars(); 
Ftw
Dang, saved by the Zeroxelli again *****. Thanks. ^^
xBlackPlagu3x is offline  
Old 07/04/2012, 08:06   #4
 
Zeroxelli's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 1,769
Received Thanks: 1,143
Quote:
Originally Posted by xBlackPlagu3x View Post
Dang, saved by the Zeroxelli again *****. Thanks. ^^
I guess I need to shut up. xD

Edit: Btw, you might wanna post these in CO2 Programming instead of PServer guides/releases.
Zeroxelli is offline  
Old 07/04/2012, 08:07   #5
 
xBlackPlagu3x's Avatar
 
elite*gold: 0
Join Date: Jan 2011
Posts: 286
Received Thanks: 71
Quote:
Originally Posted by Zeroxelli View Post
I guess I need to shut up. xD
Nah, it's totally fine. Anything you can contribute is definitely worth opening your mouth for.
xBlackPlagu3x is offline  
Old 07/04/2012, 08:08   #6
 
Zeroxelli's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 1,769
Received Thanks: 1,143
Quote:
Originally Posted by xBlackPlagu3x View Post
Nah, it's totally fine. Anything you can contribute is definitely worth opening your mouth for.
You're right on that. Check my post in your other thread, btw.
Zeroxelli is offline  
Reply


Similar Threads Similar Threads
[Website] PHP Ideas: Cookies and Security Checks
07/04/2012 - Web Development - 3 Replies
Hello, E*PVP community! I hopefully have a relatively useful PHP guide/release for you here today. After all the PHP I've done with websites over the last couple of years, I've never really learned more than I have on the last project I had begun working on, which was a PHP, tick-based MMORPG (a tick-based MMORPG is a MMORPG that allows the user do do RPGish actions, but the server part of it is refreshed every time the user either loads the page, or every set time or so. For instance, the...
MMO Gamers target of worm attacks according to Microsoft Security Report
11/05/2009 - Gaming News - EN - 1 Replies
Make sure that Internet security is up to date. MMO gamers seem to be the target of Worm and malicious software attacks according to a recent Microsoft Security Intelligence Report called Sirv7. According to Microsoft, Taterf, a worm that spreads via mapped drives in order to steal login and account details for popular online games saw a 156% increase since the second half of 2008 and mainly targets MMOG gamers. Microsoft Report Reveals Resurgence of Worms; Rogue Security Software Still Top...
CABAL RIDER 1.0.6 PH WEBSITE JAVASCRIPT INITIATED VIRUS
07/17/2008 - Cabal Online - 6 Replies
last night my antivirus started to detect this javascript/vbscript automatically downloaded from cabalrider ph launcher. (instead of the proper cabalrider guide that pops up on the window of cabalrider....a blank page is displayed.) This script instantly creates a KPY folder and attaches to your windows processes (worm/rootkit) once it has downloaded its main .exe file. So far updating my antivirus and rescanning it does not contain it. Im trying to remove my other Harddrive now and rescan...
Good website ideas...
06/08/2007 - Main - 2 Replies
Hi everyone. I wanna make a website, made a couple so far. But i need a good idea for a website. A good subject... I have Photoshop CS2 so i can make templates myself, i only need a good idea... So, anyone knows a good idea?



All times are GMT +1. The time now is 12:00.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.