mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2026-01-08 07:39:04 +00:00
Dealing with Github issue creation (default UA blacklisted)
This commit is contained in:
@@ -3497,6 +3497,28 @@ def getLatestRevision():
|
||||
|
||||
return retVal
|
||||
|
||||
def fetchRandomAgent():
|
||||
"""
|
||||
Returns random HTTP User-Agent header value
|
||||
|
||||
>>> '(' in fetchRandomAgent()
|
||||
True
|
||||
"""
|
||||
|
||||
if not kb.userAgents:
|
||||
debugMsg = "loading random HTTP User-Agent header(s) from "
|
||||
debugMsg += "file '%s'" % paths.USER_AGENTS
|
||||
logger.debug(debugMsg)
|
||||
|
||||
try:
|
||||
kb.userAgents = getFileItems(paths.USER_AGENTS)
|
||||
except IOError:
|
||||
errMsg = "unable to read HTTP User-Agent header "
|
||||
errMsg += "file '%s'" % paths.USER_AGENTS
|
||||
raise SqlmapSystemException(errMsg)
|
||||
|
||||
return random.sample(kb.userAgents, 1)[0]
|
||||
|
||||
def createGithubIssue(errMsg, excMsg):
|
||||
"""
|
||||
Automatically create a Github issue with unhandled exception information
|
||||
@@ -3550,9 +3572,9 @@ def createGithubIssue(errMsg, excMsg):
|
||||
except:
|
||||
pass
|
||||
|
||||
userAgent = "curl/7.{curl_minor}.{curl_revision} (x86_64-pc-linux-gnu) libcurl/7.{curl_minor}.{curl_revision} OpenSSL/0.9.8{openssl_revision} zlib/1.2.{zlib_revision}".format(curl_minor=random.randint(8, 22), curl_revision=random.randint(1, 9), openssl_revision=random.choice(string.ascii_lowercase), zlib_revision=random.randint(2, 6))
|
||||
|
||||
data = {"title": "Unhandled exception (#%s)" % key, "body": "```%s\n```\n```\n%s```" % (errMsg, excMsg)}
|
||||
req = _urllib.request.Request(url="https://api.github.com/repos/sqlmapproject/sqlmap/issues", data=getBytes(json.dumps(data)), headers={HTTP_HEADER.AUTHORIZATION: "token %s" % decodeBase64(GITHUB_REPORT_OAUTH_TOKEN, binary=False), HTTP_HEADER.USER_AGENT: userAgent})
|
||||
req = _urllib.request.Request(url="https://api.github.com/repos/sqlmapproject/sqlmap/issues", data=getBytes(json.dumps(data)), headers={HTTP_HEADER.AUTHORIZATION: "token %s" % decodeBase64(GITHUB_REPORT_OAUTH_TOKEN, binary=False), HTTP_HEADER.USER_AGENT: fetchRandomAgent()})
|
||||
|
||||
try:
|
||||
content = _urllib.request.urlopen(req).read()
|
||||
|
||||
@@ -25,6 +25,7 @@ from lib.core.common import dataToStdout
|
||||
from lib.core.common import decodeStringEscape
|
||||
from lib.core.common import getPublicTypeMembers
|
||||
from lib.core.common import getSafeExString
|
||||
from lib.core.common import fetchRandomAgent
|
||||
from lib.core.common import filterNone
|
||||
from lib.core.common import findLocalPort
|
||||
from lib.core.common import findPageForms
|
||||
@@ -137,7 +138,6 @@ from lib.request.httpshandler import HTTPSHandler
|
||||
from lib.request.pkihandler import HTTPSPKIAuthHandler
|
||||
from lib.request.rangehandler import HTTPRangeHandler
|
||||
from lib.request.redirecthandler import SmartRedirectHandler
|
||||
from lib.request.templates import getPageTemplate
|
||||
from lib.utils.har import HTTPCollectorFactory
|
||||
from lib.utils.crawler import crawl
|
||||
from lib.utils.deps import checkDependencies
|
||||
@@ -1400,22 +1400,7 @@ def _setHTTPUserAgent():
|
||||
conf.httpHeaders.append((HTTP_HEADER.USER_AGENT, DEFAULT_USER_AGENT))
|
||||
|
||||
else:
|
||||
if not kb.userAgents:
|
||||
debugMsg = "loading random HTTP User-Agent header(s) from "
|
||||
debugMsg += "file '%s'" % paths.USER_AGENTS
|
||||
logger.debug(debugMsg)
|
||||
|
||||
try:
|
||||
kb.userAgents = getFileItems(paths.USER_AGENTS)
|
||||
except IOError:
|
||||
warnMsg = "unable to read HTTP User-Agent header "
|
||||
warnMsg += "file '%s'" % paths.USER_AGENTS
|
||||
logger.warn(warnMsg)
|
||||
|
||||
conf.httpHeaders.append((HTTP_HEADER.USER_AGENT, DEFAULT_USER_AGENT))
|
||||
return
|
||||
|
||||
userAgent = random.sample(kb.userAgents or [DEFAULT_USER_AGENT], 1)[0]
|
||||
userAgent = fetchRandomAgent()
|
||||
|
||||
infoMsg = "fetched random HTTP User-Agent header value '%s' from " % userAgent
|
||||
infoMsg += "file '%s'" % paths.USER_AGENTS
|
||||
|
||||
@@ -18,7 +18,7 @@ from lib.core.enums import OS
|
||||
from thirdparty import six
|
||||
|
||||
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
|
||||
VERSION = "1.3.5.24"
|
||||
VERSION = "1.3.5.25"
|
||||
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
|
||||
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
|
||||
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
|
||||
|
||||
Reference in New Issue
Block a user