sqlmap/tamper/xforwardedfor.py

33 lines
722 B
Python
Raw Normal View History

2014-09-20 16:48:36 +04:00
#!/usr/bin/env python
"""
2019-01-05 23:38:52 +03:00
Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/)
2017-10-11 15:50:46 +03:00
See the file 'LICENSE' for copying permission
2014-09-20 16:48:36 +04:00
"""
from lib.core.enums import PRIORITY
from random import sample
__priority__ = PRIORITY.NORMAL
def dependencies():
pass
def randomIP():
numbers = []
2018-10-02 15:07:14 +03:00
2014-09-20 16:48:36 +04:00
while not numbers or numbers[0] in (10, 172, 192):
numbers = sample(xrange(1, 255), 4)
2018-10-02 15:07:14 +03:00
2014-09-20 16:48:36 +04:00
return '.'.join(str(_) for _ in numbers)
def tamper(payload, **kwargs):
"""
2018-07-31 03:18:33 +03:00
Append a fake HTTP header 'X-Forwarded-For'
2014-09-20 16:48:36 +04:00
"""
headers = kwargs.get("headers", {})
headers["X-Forwarded-For"] = randomIP()
2018-09-15 22:36:21 +03:00
headers["X-Client-Ip"] = randomIP()
2018-09-13 11:50:58 +03:00
headers["X-Real-Ip"] = randomIP()
2014-09-20 16:48:36 +04:00
return payload