博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Preventing XSS with JSOUP
阅读量:7144 次
发布时间:2019-06-29

本文共 2438 字,大约阅读时间需要 8 分钟。

hot3.png

JSOUP is XSS prevention tool. Jsoup can detect xss script in html and url also. Now i am giving example with url. Jsoup can validate the url with the help of "isValidate()" method. "isValidate()" method return type is boolean. If return type is true that means url having xss script so we need to clean the url with the help of "clean()" method. "clean()" method will return clean url as string.

  • JSOUP can handle all cheat sheet scenarios. url of cheat sheet is: "https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet"

  • JSOUP has clear api. "http://jsoup.org/apidocs/"

Antisamy also one of the tool to prevent xss script but, its customized one so we need to configure everything. Its not better than JSOUP
Steps to use JSOUP:

1. Download jsoup jar file

2. Write the code like the following

import java.io.UnsupportedEncodingException;import org.jsoup.Jsoup;import org.jsoup.safety.Whitelist;public class JsoupSolution {	public static void main(String[] args) throws UnsupportedEncodingException {		/*		 * Sequrity issue scenario		 */		String input = "GET /selfservice/forgotpwd.jsp?ssError=2&returnUrl=https://stg-wealthinteractive.skandiainternational.com/SecurityAndRoles/SignIn/SignIn?authn_try_count=06f080\"style%3d\"behavior%3aurl(%23default%23time2)\"onbegin%3d\"alert('xss')\"f6bc57307de&contextType=external&username=string&contextValue=%2Foam&password=sercure_string&challenge_url=https%3A%2F%2Fstg-wealthinteractive.skandiainternational.com%2FSecurityAndRoles%2FSignIn%2FSignIn&request_id=6990594052748823869&OAM_REQ=&locale=en_GB&resource_url=http%253A%252F%252Fstg-wealthinteractive.skandiainternational.com%252Fauth%252Flevel2.jsp%253FreturnURL%25253Dhttp%2525253A%2525252F%2525252Fstg-wealthinteractive.skandiainternational.com%2525252Fselfservice%2525252Flevel3.jsp%2525253FreturnURL%252525253Dhttp%25252525253A%25252525252F%25252525252Fstg-wealthinteractive.skandiainternational.com%25252525252FSkandia%25252525252Flogout HTTP/1.1";		String unsafe = "';alert(String.fromCharCode(88,83,83))//';alert(String.fromCharCode(88,83,83))//\";alert(String.fromCharCode(88,83,83))//\";alert(String.fromCharCode(88,83,83))//-->\">'>";		String unsafe1 = "
 "; // String input = // "\"behavior%3aurl(%23default%23time2)\"onbegin%3d\"alert('xss')\""; // String input = "
\">"; // String input = "
"; // String input = "

转载于:https://my.oschina.net/ydsakyclguozi/blog/490169

你可能感兴趣的文章
centos 6.3搭建个人私有云存储owncloud
查看>>
PHP中的浅拷贝和深拷贝
查看>>
利用redis-sentinel+keepalived实现redis高可用
查看>>
CloudStack4.2登录报用户名或密码错误问题解析
查看>>
逻辑备库之ORA-01403解决方法
查看>>
MySQL Replication(复制)基本原理
查看>>
分享Silverlight/WPF/Windows Phone/HTML5一周学习导读(12月5日-12月11日)
查看>>
十年老站吐血迁移实录
查看>>
配置Exchange2010的边缘传输服务器
查看>>
我的家庭私有云计划-7
查看>>
Word中使用正则表达式进行查找和替换
查看>>
Cocos2d-x Eclipse下程序运行产生错误Effect initCheck() returned -1
查看>>
微软MVP社区巡讲
查看>>
Silverlight3游戏开发之空当接龙基础篇
查看>>
.NET深入解析LINQ框架(二:LINQ优雅的前奏)
查看>>
虚弱的原则
查看>>
我的友情链接
查看>>
为什么网络棋牌的分成那么高?
查看>>
答案永远在现场
查看>>
博客九周年:稳中求胜 持续发展
查看>>