forked from aipengjie/vulscans
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathELExpression.py
89 lines (80 loc) · 2.49 KB
/
ELExpression.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# -*- coding:utf-8 -*-
# !/usr/bin/env python
# http://www.wooyun.org/bugs/wooyun-2010-0196160
import traceback
import logging
import requests
import re
import json
import argparse
from gevent.threadpool import ThreadPool
class ELExpression():
def __init__(self):
self.result = []
self.pool = ThreadPool(10)
self.q = []
self.payload = '{1000-121}'
self.match = '879'
def putinqueue(self, info):
try:
url = info[0]
data = info[1]
current = data if data else url
for k in re.finditer(r'\=(?P<value>.*?)(?:$|&)', current):
value = k.group('value')
payload = current.replace(value, self.payload)
if data:
self.q.append((url, payload))
else:
self.q.append((payload, data))
except:
traceback.print_exc()
def Fuzz(self, info):
try:
url = info[0]
data = info[1]
if data:
try:
r = requests.post(url, data=data, timeout=10, verify=False)
content = r.content
except:
content = ''
else:
try:
print "Req ::" + url
r = requests.get(url, timeout=10, verify=False)
content = r.content
except:
content = ''
if self.match in content:
msg = 'find vulnerable url'
logging.info(msg)
self.result.append(info)
except:
traceback.print_exc()
def Scan(self, info):
try:
if isinstance(info, tuple):
self.putinqueue(info)
else:
with open(info) as f:
ud = json.loads(f.read())
for i in ud:
self.putinqueue(i)
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('-d', '--data', dest='data', default=None)
parse.add_argument('-f', '--file', dest='file')
args = parse.parse_args()
url = args.url
data = args.data
file = args.file
info = (url, data) if url else file
exa = ELExpression()
exa.Scan(info)
if exa.result:
print exa.result