Giter Site home page Giter Site logo

xssfork's Introduction

 重要说明

kali下无法使用的话,请下载正确的phantomjs 到目录thirdparty/phantomjs/Linux

更多信息访问http://xssfork.secbug.net/

由于使用的是phantomjs,所以使用期间可能会造成内存,cpu消耗过大。对网络造成的破坏,本人不负任何法律责任。

免责申明

xssfork保证竭诚为网络用户提供最安全的上网服务,但因不可避免的问题导致出现的问题,我们尽力解决,期间引起的问题我们不承担以下责任。

第 一 条

xssfork使用者因为违反本声明的规定而触犯中华人民共和国法律的,一切后果自己负担,xssfork.secbug.net站点以及作者不承担任何责任。

第 二 条

凡以任何方式直接、间接使用xssfork资料者,视为自愿接受xssfork.secbug.net声明的约束。

第 三 条

本声明未涉及的问题参见国家有关法律法规,当本声明与国家法律法规冲突时,以国家法律法规为准。

第 四 条

对于因不可抗力或xssfork不能控制的原因造成的网络服务中断或其它缺陷,xssfork.secbug.net网站以及作者不承担任何责任。

第 五 条

xssfork之声明以及其修改权、更新权及最终解释权均属xssfork.secbug.net网所有。

更多信息访问http://xssfork.secbug.net/

更新xssforkapi,提供分布式部署方案。

概述

xssfork是新一代xss漏洞探测工具,其开发的目的是帮助安全从业者高效率的检测xss安全漏洞,关于xss的更多详情可以移步Cross-site Scripting (XSS)。不管什么语言,传统的xss探测工具,一般都是采用第三方库向服务器发送一个注入恶意代码的请求,其工作原理是采用payload in response的方式,即通过检测响应包中payload的完整性来判断,这种方式缺陷,很多。 例如 1.不能检测dom类xss(无法从源代码中检查) 2.不能模拟真正的浏览器 3.网页js无法交互,第三方库不认识网页中的js的代码。 与传统的工具相比,xssfork使用的是 webkit内核的浏览器phantomjs,其可以很好的模拟浏览器。工具分为两个部分,xssfork和xssforkapi,其中xssfork在对网站fuzz xss的时候会调用比较多的payload。

两者结合

可以使用xssforkapi来做批量xss检测工具,xssfork做深度fuzz工具。xssforkapi这种webservice方式十分适合分布式部署。

创建任务

关于key,为了保证外部不能非法调用服务,xssforkapi采用的是http协议验证key的方式。

key的获取方式

在每次启动xssforkapi的时候,会将key写入到根目录authentication.key中,你也可以在每次启动服务的时候看到key。 key默认是每次启动服务不更新的,你也可以在下一次启动服务的时候强制更新,只需要启动的时候指定--refresh True即可。值得注意的时候,refresh指定为true之后,原有的保存在data目录下xssfork.db将会清除,这意味着你将清除你之前所有的检测纪录。 ##新建扫描任务
需要向服务传递两个参数,1.key(主要用于验证身份);2.检测参数

get协议检测

###创建任务 1.get反射型类型

req = requests.post('http://127.0.0.1:2333/xssfork/create_task/7T2o22NcQSLGk75',data=json.dumps({'url':'http://10.211.55.13/xss/example1.php?name=hacker', ), headers={'Content-Type':'application/json'})
return req.content

2.post反射类型

req = requests.post('http://127.0.0.1:2333/xssfork/create_task/7T2o22NcQSLGk75',data=json.dumps({'url':'http://10.211.55.13/xss/post_xss.php', 'data':'name=233'), headers={'Content-Type':'application/json'})
return req.content

3.get反射型类型,需要验证cookie

req = requests.post('http://127.0.0.1:2333/xssfork/create_task/7T2o22NcQSLGk75',data=json.dumps({'url':'http://10.211.55.13/xss/example1.php?name=hacker', 'cookie':'usid=admin'), headers={'Content-Type':'application/json'})
return req.content

4.post反射型类型,需要验证cookie

req = requests.post('http://127.0.0.1:2333/xssfork/create_task/7T2o22NcQSLGk75',data=json.dumps({'url':'http://10.211.55.13/xss/post_xss.php', 'data':'name=2333', 'cookie': 'usid=admin'), headers={'Content-Type':'application/json'})
return req.content

5.get储存型,需要验证cookie

req = requests.post('http://127.0.0.1:2333/xssfork/create_task/7T2o22NcQSLGk75',data=json.dumps({'url':'http://10.211.55.13/xss/example1.php?name=hacker', 'cookie':'usid=admin', 'destination': 'http://10.211.55.13/output.php'), headers={'Content-Type':'application/json'})
return req.content

4.post储存型,需要验证cookie

req = requests.post('http://127.0.0.1:2333/xssfork/create_task/7T2o22NcQSLGk75',data=json.dumps({'url':'http://10.211.55.13/xss/example1.php?name=hacker', 'data':'name=2333', 'cookie':'usid=admin', 'destination': 'http://10.211.55.13/output.php'), headers={'Content-Type':'application/json'})
return req.content

返回码

{"status": "success", "task_id": "1"}

调用者可以获取到任务id,以便于启动检测。 #启动任务

import requests
req = requests.get('http://127.0.0.1:2333/xssfork/start_task/tM0Xnl0qD6nsHku/%s' % (task_id))
print req.content

返回码

{"status": "success", "msg": "task will start"}

#查看状态

import requests
req = requests.get('http://127.0.0.1:2333/xssfork/task_status/tM0Xnl0qD6nsHku/%s' % (task_id))
print req.content

返回码分为4种,分别如下:
1.任务不存在

{"status": -1, "msg": "task isn’t existed"}

2.任务创建了,但是未启动

{"status": 0, "msg": "task isn't started"}

3.任务正在作业中,未完成

{"status": 1, "msg": "task is working"}

4.任务作业完成

{"status":2, "msg": "task has been done"}

#获取结果

req = requests.get('http://127.0.0.1:2333/xssfork/task_result/7T2o22NcQSLGk75/%s' % (task_id))
	print req.content

返回分为两种
1.检测到漏洞,并且返回payload

{"payload": "{'url': "http://10.211.55.13/xss/example1.php?name=%22<xss></xss>//", 'data': null}"}

2.未检测到漏洞

{"payload": null}

#结束任务

req = requests.get('http://127.0.0.1:2333/xssfork/kill_task/7T2o22NcQSLGk75/%s' % (task_id))
	print req.content

返回结果可能有4种 1.结束任务失败,因为任务不存在

{"status": "false", "msg": "task isn’t existed"}

2.结束任务失败,因为任务根本没启动

{"status": "false", "msg": "task isn't started"}

3.结束任务失败,因为任务本已经结束,不需要强制杀死

{"status": "false", "msg": "task has been done"}

4.结束任务成功,任务原本是处于运行中的状态

{"status": "success", "msg": "task will be killed"}

#完整的例子 1.一次带有cookie验证的post xss 漏洞示例代码

<?php
if (isset($_COOKIE['usid']) && isset($_POST['id']))
{
	if ($_COOKIE['usid']=="admin")
		{
			echo $_POST['id'];
		}
}
?>

客户端代码

#! /usr/bin/env python
# coding=utf-8
import json
import time
import requests


def creat_task(url, data, cookie):
    json_data = json.dumps({'url': url, 'data': data, 'cookie': cookie})
    req = requests.post('http://127.0.0.1:2333/xssfork/create_task/7T2o22NcQSLGk75', data=json_data, headers={'Content-Type':'application/json'})
    return req.content


def start_task(task_id):
    req = requests.get('http://127.0.0.1:2333/xssfork/start_task/7T2o22NcQSLGk75/{}'.format(task_id))
    return req.content


def get_task_status(task_id):
    req = requests.get('http://127.0.0.1:2333/xssfork/task_status/7T2o22NcQSLGk75/{}'.format(task_id))
    return req.content


def get_task_result(task_id):
    req = requests.get('http://127.0.0.1:2333/xssfork/task_result/7T2o22NcQSLGk75/{}'.format(task_id))
    return req.content


def running(task_id):
    time.sleep(5)
    task_status = int(json.loads(get_task_status(task_id)).get('status'))
    return task_status in [0, 1]


if __name__ == "__main__":
    url = "http://10.211.55.3/xsstest/cookie_xss_post.php"
    data = "id=1"
    cookie = "usid=admin"
    task_id = json.loads(creat_task(url, data, cookie)).get('task_id')
    start_task(task_id)
    while running(task_id):
        print "the task is working"
    print get_task_result(task_id)

效果

xssfork简介

xssfork作为sicklescan的一个功能模块,其开发主要目的是用于检测xss漏洞。 传统的xss探测工具,一般都是采用 payload in response的方式,即在发送一次带有payload的http请求后,通过检测响应包中payload的完整性来判断,这种方式缺陷,很多。
第一:不能准确地检测dom类xss
第二:用类似于requests之类的库不能真正的模拟浏览器
第三:网页js无法交互
怎么解决?如果能够用浏览器代替这个模块,去自动hook是最好的。所幸,我了解到phantomjs,当然现在google浏览器也支持headless模式,类似的,你也可以采用google浏览器去做检测。

原理

对于这类fuzz过程,基本都是预先准备好一些payload,然后加载执行。对于这类io型密集的扫描模型,后端使用多线程就比较适用,但是由于phantomjs你可以理解为一个无界面的浏览器,在加载的时候,其缺陷也比较明显,比较吃内存,用它来发包自然不像requests库轻量。

编码脚本

由于基础的payload模块,我收集了71个。 基础payload会在现有的基础上,会添加上各种闭合的情况。 除了这些基础的payload,xssfork还提供了几个编码脚本,查看脚本,可以看help 现阶段提供了10进制,16进制,随机大小写,关键字叠加四个脚本。

10hex_encode

将html标签内部字符10进制化 <a href=&#x6a&#x61&#x76&#x61&#x73&#x63&#x72&#x69&#x70&#x74&#x3a&#x61&#x6c&#x65&#x72&#x74&#x28&#x36&#x35&#x35&#x33&#x34&#x29&#x3b>aaa</a> 其效果如下

16hex_encode

将html标签内部字符16进制化

uppercase

随机大小写 将 <script>alert(65534);</script> 转换成 <ScRIPt>alert(65534);</ScRIpT>

addkeywords

主要是应对过滤为replace('keyword>s','')的情况
<script>alert(65534);</script> 变成 <<script>script>alert(65534);</script> 当然默认开启的是轻量模式,即只返回一个payload,开启重量模式,可以生成更加丰富的pyaload,效果如下 <script>alert(65534);</script>
<script>alert(65534);</ScrIpt>
<ScrIpt>alert(65534);</sCrIpt>
<scRiPt>alert(65534);</script>
<ScrIpt>alert(65534);</script>

演示

场景1.反射型xss

场景2.大小写绕过

场景3.dom型xss
场景3.post类型 场景4.需要验证cookie

post类型
python xssfork.py -u "xx" -d "xx" 存储型
python xssfork.py -u "xx" -d "xxx" -D "输出位置" 带cookie python xssfork.py -u "xx" -c "xx"

支持伪静态的检测

说明

开源只为分享,请勿将本脚本做任何商业性质的集成。开发的时候,有可能很多情况没有考虑到,如果你有更好的建议或者发现bug, [email protected]
开源地址 https://github.com/bsmali4/xssfork 记得不要吝啬你的star

更新日志:2017-10-24 修复卡住进度bug

xssfork's People

Contributors

bsmali4 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xssfork's Issues

centos启动报错

[ERROR] 系统找不到适配器'gevent',你可以尝试执行'sudo apt-get install python-gevent'或'sudo pip install gevent'

似乎存储型xss检测效果不好

本地搭建dvwa,设置lever为low后尝试检测post存储型xss
http://192.168.43.190/dvwa/vulnerabilities/xss_s/
python2 xssfork.py -u "http://192.168.43.190/dvwa/vulnerabilities/xss_s/" --data="txtName=a&mtxMessage=b&btnSign=Sign+Guestbook" --cookie "PHPSESSID=ht4fjel6rpta7qbfibksr3ao80;security=low" -m heavy
使用上面的命令没有检测出来,后换成xssforkapi.py的添加任务方式也没检测出来,不知这里可有改进?

ImportError: No module named requests

I create an environment for python2 in kali. A problem has came up when I run python xssfork.py.

Traceback (most recent call last):
File "xssfork.py", line 12, in
from common import log
File "/root/pen_test/xssfork/common/init.py", line 11, in
from taskschedule.task_schedule import CompletePacket
File "/root/pen_test/xssfork/common/../taskschedule/task_schedule.py", line 10, in
import requests
ImportError: No module named requests

It should be written this way from thirdparty.requests import request in the file taskschedule/task_schedule.py.

关于请求方法和payload问题

RT,作者的项目简单看了下很棒,但鄙人这里有两个小问题:

1.只加-u参数,每次payload在890/1527就卡住了,换了好几个站都这样,不知道是否鄙人使用方法有错。
2.似乎您只采用了phantomjs,没采用selenium?想请教下您这里是如何支持post方法的,是否能检测referer之类的参数。

就个人所得,光依靠JS本身,似乎不能带上非w3g所规定的非安全因素【如referer】发送数据包,望指教如何解决。

cannot import name 'XSS_FORK_PATH'

when I use this on my mac ,
python3.5 xssfork.py -u=http://....
it report some errors,

Traceback (most recent call last):
  File "xssfork.py", line 12, in <module>

    from common import log

  File "/private/var/www/xssfork/common/__init__.py", line 11, in <module>

    from taskschedule.task_schedule import CompletePacket

  File "/private/var/www/xssfork/common/../taskschedule/__init__.py", line 13, in <module>

    from common import log

  File "/private/var/www/xssfork/common/log.py", line 9, in <module>

    from path import XSS_FORK_PATH

ImportError: cannot import name 'XSS_FORK_PATH'

mac下路径问题

mac下python3使用,报错
Traceback (most recent call last):
File "xssforkapi.py", line 11, in
import web_service
File "/Users/lateink/Documents/tools/xssfork/web_service.py", line 15, in
from common import log
File "/Users/lateink/Documents/tools/xssfork/common/init.py", line 11, in
from taskschedule.task_schedule import CompletePacket
File "/Users/lateink/Documents/tools/xssfork/common/../taskschedule/init.py", line 13, in
from common import log
File "/Users/lateink/Documents/tools/xssfork/common/log.py", line 9, in
from path import XSS_FORK_PATH
ModuleNotFoundError: No module named 'path'
python3兼容性没做好

TypeError: unhashable type: 'dict'

Traceback (most recent call last):
File "/root/github/xssfork/common/../taskschedule/task_thread.py", line 176, in run
self.check_xss(payload)
File "/root/github/xssfork/common/../taskschedule/task_thread.py", line 142, in check_xss
child_process, payload = self.sub_process_open(payload)
File "/root/github/xssfork/common/../taskschedule/task_thread.py", line 122, in sub_process_open
request_command, url_payload, destination_command = self.get_cmd(payload)
File "/root/github/xssfork/common/../taskschedule/task_thread.py", line 100, in get_cmd
url_payload = self.replace_url_to_payload(payload)
File "/root/github/xssfork/common/../taskschedule/task_thread.py", line 89, in replace_url_to_payload
url_payload = re.subn(r'bsmali4_(?:int|mix|other|str|float)', payload, url_payload)[0]
File "/usr/lib/python2.7/re.py", line 166, in subn
return _compile(pattern, flags).subn(repl, string, count)
File "/usr/lib/python2.7/re.py", line 286, in _subx
template = _compile_repl(template, pattern)
File "/usr/lib/python2.7/re.py", line 266, in _compile_repl
p = _cache_repl.get(key)
TypeError: unhashable type: 'dict'

当扫描的是卡在payload测试那儿,看data/exception.log出现的是这个错误。

只发送了一个请求

使用xssfork,injected payloads数一直在空跑,实际检测服务器上,只收到一个请求,也就是说除了check url的请求之外,根本没payloads发送出去,什么原因?

ImportError: No module named colorlog

环境:MacOs, python 2.7.14
输入:python2.7 xssfork.py -u http://xssfork.codersec.net/xssdemo.php?id=23
Traceback (most recent call last): File "xssfork.py", line 87, in <module> help() File "xssfork.py", line 63, in help task_schedule.main() File "/Users/lvxiaoqian/tools/xss/xssfork/common/../taskschedule/task_schedule.py", line 54, in main self.check_complete_packet_is_alive() File "/Users/lvxiaoqian/tools/xss/xssfork/common/../taskschedule/task_schedule.py", line 88, in check_complete_packet_is_alive self.check_complete_url_is_alive() File "/Users/lvxiaoqian/tools/xss/xssfork/common/../taskschedule/task_schedule.py", line 92, in check_complete_url_is_alive logger = log.get_logger() File "/Users/lvxiaoqian/tools/xss/xssfork/common/log.py", line 27, in get_logger init_config() File "/Users/lvxiaoqian/tools/xss/xssfork/common/log.py", line 55, in init_config stream_handler = get_stream_handler() File "/Users/lvxiaoqian/tools/xss/xssfork/common/log.py", line 44, in get_stream_handler from colorlog import ColoredFormatter ImportError: No module named colorlog
请问这个是怎么回事呢?

windows与linux环境下行分隔符不一致导致的错误

  • windows行分割符为“\r\n”
  • linux 行分隔符为“\n”
    由windows系统赋值到linux系统中的payload字典文件在解析后变成
    image
    究其原因是在读取payload并处理的时候在utils.py#read_file_to_array函数中使用了replace函数,建议修改为line.strip()
    image

Kali,python 2.7环境启动报错

刚才下的新版,报错信息如下,想问一下如何解决?
Traceback (most recent call last):
File "./xssfork.py", line 12, in
from common import log
File "/root/Desktop/xssfork-master/common/init.py", line 11, in
from taskschedule.task_schedule import CompletePacket
File "/root/Desktop/xssfork-master/common/../taskschedule/init.py", line 38, in
from thirdparty.requests import request
File "/root/Desktop/xssfork-master/taskschedule/../thirdparty/requests/init.py", line 53, in
from .packages.urllib3.contrib import pyopenssl
File "/root/Desktop/xssfork-master/taskschedule/../thirdparty/requests/packages/urllib3/contrib/pyopenssl.py", line 73, in
ssl.PROTOCOL_SSLv3: OpenSSL.SSL.SSLv3_METHOD,
AttributeError: 'module' object has no attribute 'PROTOCOL_SSLv3'

普通的xss扫不出来。。

您好 我这里写了个测试的页面
<!doctype html>

<title>Document</title>

不过使用xssfork没有检测出来,这个真没想到,也不知道咋回事,在kali下使用的

`root@kali:~/Desktop/myhack/xssfork-master# python2 ./xssfork.py -u "http://192.168.5.1/xss.php?a=1"

           __           _    
          / _|         | |       

__ _____ __| | ___ _ __| | __
\ / / __/ | _/ _ | '| |/ / version: 1.0.2#dev

<__ __ \ || () | | | < author: b5mali4
/
/__//| ___/|| ||_\ http://xssfork.secbug.net

[22:53:20] [DEBUG] checking if url is available
[22:53:20] [INFO] url connection success
[22:53:20] [DEBUG] checking if destination is available
[22:53:20] [INFO] destination connection success
[22:53:20] [DEBUG] checking if has_params
[22:53:20] [INFO] there is params, xssfork will work
[22:53:20] [INFO] loading default paloads
[22:53:20] [INFO] loading default paloads success
[22:53:20] [INFO] 1527 payloads loaded
[22:53:24] [WARNING] [!] xssfork can not find XSS Vulnerability
This task costs 4.33251285553 s
[*] shutting down at 2019-05-31 22:53:24
`

没有检测出XSS,反射型

之前碰到卡住的问题,今天看到修复了试了一下新版,卡住的问题没有了,但是测试中没有发现明显的XSS漏洞。不知道是环境的问题还是BUG。

页面代码如下:

<?php 
include_once 'header.php';

?>
<table width="99%" border="0" cellpadding="0" cellspacing="0" class="news">
  <?php foreach(getArticleList("cid=".$_GET['id']."|row=2") as $list){?>
  <tr>
    <td height="30" align="left"><a href="show.php?id=<?php echo $list['id']?>" target="_blank"><?php echo $list['title']?></a>&nbsp;</td>
    <td width="120" align="left"><?php echo $list['pubdate']?>&nbsp;</td>
  </tr>
  <?php }?>
  <tr>
    <td height="30" colspan="2" align="center" style="padding-right:20px"><?php echo getPagination("list.php?id=".$_GET['id']);?></td>
  </tr>
</table>
<?php 
include_once 'footer.php';
?>

`

又测了一下,用xssfork跑的时候,tcpdump和wireshark没有抓到数据包,这个应该是不正常的吧?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.