xss problems sloved over lol

Started on the old forum in August 2010 · view the original in the archive · old links redirect here

8 replies · 901 views · started 16 years ago · 1 min read

7 participants
subzero Super moderator Fellow · 3,954 posts #1

type 1

if(preg_match("(<|>|%|;|<a|<img|<script|<script>|")", $text)) 
{  
$text = "Illegal tags used!";  
} 

type 2

function xss($text,$subject,$action)
{
// Bad Message board 
                                                  $text = str_replace("%","%",$text);
                                                  $text = str_replace(">",">",$text);
                                                  $text = str_replace("<","<",$text);
                                                  $text = str_replace("@","@",$text);
                                                  $text = str_replace("£","£",$text);
                                                  $text = str_replace("$","$",$text);
                                                  $text = str_replace("#","#",$text);
                                                  $text = str_replace("'","'",$text);
                                                  $text = str_replace(",",",",$text);
                                                  $text = str_replace("-","-",$text);
                                                  $text = str_replace("^","^",$text);
                                                  $text = str_replace("`","`",$text);
                                                  $text = str_replace("{","{",$text);
                                                  $text = str_replace("}","}",$text);
                                                  $text = str_replace("®","®",$text);
                                                  $text = str_replace("©","©",$text);
                                                  $text = str_replace("§","§",$text);
                                                  $text = str_replace("¨","¨",$text);
return html_entity_decode($text);
// Bad SubJect
                                                  $subject = str_replace("%","%",$subject);
                                                  $subject = str_replace(">",">",$subject);
                                                  $subject = str_replace("<","<",$subject);
                                                  $subject = str_replace("@","@",$subject);
                                                  $subject = str_replace("£","£",$subject);
                                                  $subject = str_replace("$","$",$subject);
                                                  $subject = str_replace("#","#",$subject);
                                                  $subject = str_replace("'","'",$subject);
                                                  $subject = str_replace(",",",",$subject);
                                                  $subject = str_replace("-","-",$subject);
                                                  $subject = str_replace("^","^",$subject);
                                                  $subject = str_replace("`","`",$subject);
                                                  $subject = str_replace("{","{",$subject);
                                                  $subject = str_replace("}","}",$subject);
                                                  $subject = str_replace("®","®",$subject);
                                                  $subject = str_replace("©","©",$subject);
                                                  $subject = str_replace("§","§",$subject);
                                                  $subject = str_replace("¨","¨",$subject);
return html_entity_decode($subject);
// Bad Action 
                                                  $action = str_replace("%","%",$action);
                                                  $action = str_replace(">",">",$action);
                                                  $action = str_replace("<","<",$action);
                                                  $action = str_replace("@","@",$action);
                                                  $action = str_replace("£","£",$action);
                                                  $action = str_replace("$","$",$action);
                                                  $action = str_replace("#","#",$action);
                                                  $action = str_replace("'","'",$action);
                                                  $action = str_replace(",",",",$action);
                                                  $action = str_replace("-","-",$action);
                                                  $action = str_replace("^","^",$action);
                                                  $action = str_replace("`","`",$action);
                                                  $action = str_replace("{","{",$action);
                                                  $action = str_replace("}","}",$action);
                                                  $action = str_replace("®","®",$action);
                                                  $action = str_replace("©","©",$action);
                                                  $action = str_replace("§","§",$action);
                                                  $action = str_replace("¨","¨",$action);
return html_entity_decode($action);
}

Usage !

echo xss('$_POST[text]','$_POST[subject]','$_GET[action]');

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

CreativityKills Lead · 833 posts #2

U know using preg match is misguided coding. Could help u temporarily bt if the ha.ckers.org cheatsheet is anyfin to go by, u nid a stronger library. Theres htmlpurifier bt thats 2 slow, theres htmlawed, ur best bet. Theres also wibble, 2nd best bet.

subzero Super moderator Fellow · 3,954 posts #3

Well it helps out others

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

khan Lead · 681 posts #4

It may Helps. Use It on .htaccess

RewriteCond %{REQUEST_URI}?%{QUERY_STRING} (.*)chmod(.*) [OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} (.*)chown(.*) [OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} (.*)wget(.*) [OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} (.*)cmd(.*) [OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} (.*)cd%20(.*) [OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} (.*)scp(.*) [OR]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} (.*)curl(.*) [OR]

Before this You should add (If already not added)

RewriteEngine On
RewriteBase /
pagal Junior · 40 posts #5

strip_tags and htmlspecialchars is enough to block xss.

Jerson Developer · 70 posts #6

Mod rewrite are g0od

Added after 2 minutes:

I saw that c0de on dmpwap script haha. Its w0rking. strip_tags and htmlspecialchar is n0t enough

subzero Super moderator Fellow · 3,954 posts #9

This does not mean your site will be 100% safe if your using htmlspecialchars !!

Most of your coding can easy bypass your htmlspecialchars('input');

Doing this str_replace does let you use (!@($!@(!@&#(@!) with html friendly code so users can still use chapters if your forum ! Most htmlspecialchars don't do all chapters right way !!

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

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