Files
XSStrike/core/checker.py

43 lines
1.7 KiB
Python
Raw Normal View History

2018-10-27 18:58:52 +05:30
import re
import copy
from fuzzywuzzy import fuzz
from core.config import xsschecker
from core.requester import requester
from core.utils import replacer, fillHoles
from urllib.parse import unquote
2018-10-27 18:58:52 +05:30
def checker(url, params, headers, GET, delay, payload, positions, timeout, encoding):
2018-11-11 14:56:19 +05:30
checkString = 'st4r7s' + payload + '3nd'
if encoding:
checkString = encoding(unquote(checkString))
2018-10-27 18:58:52 +05:30
paramsCopy = copy.deepcopy(params)
2018-11-10 17:33:48 +05:30
response = requester(url, replacer(paramsCopy, xsschecker, checkString), headers, GET, delay, timeout).text.lower()
reflectedPositions = []
for match in re.finditer('st4r7s', response):
reflectedPositions.append(match.start())
filledPositions = fillHoles(positions, reflectedPositions)
2018-10-27 18:58:52 +05:30
# Itretating over the reflections
2018-11-11 14:56:19 +05:30
num = 0
2018-10-27 18:58:52 +05:30
efficiencies = []
2018-11-11 14:56:19 +05:30
for position in filledPositions:
allEfficiencies = []
try:
reflected = response[reflectedPositions[num]:reflectedPositions[num]+len(checkString)]
efficiency = fuzz.partial_ratio(reflected, checkString.lower())
allEfficiencies.append(efficiency)
except IndexError:
pass
if position:
reflected = response[position:position+len(checkString)]
if encoding:
checkString = encoding(checkString.lower())
efficiency = fuzz.partial_ratio(reflected, checkString)
2018-11-11 14:56:19 +05:30
if reflected[:-2] == ('\\%s' % checkString.replace('st4r7s', '').replace('3nd', '')):
efficiency = 90
allEfficiencies.append(efficiency)
efficiencies.append(max(allEfficiencies))
else:
efficiencies.append(0)
2018-11-11 14:56:19 +05:30
num += 1
return list(filter(None, efficiencies))