Adding a hidden switch --dummy used for dummy runs (getPage() returns random data) - usefull for testing purposes for skipping connections

This commit is contained in:
Miroslav Stampar 2013-02-28 20:20:08 +01:00
parent bf05709841
commit 0e89cc62a2
5 changed files with 17 additions and 1 deletions

View File

@ -1131,7 +1131,7 @@ def checkNullConnection():
return kb.nullConnection is not None return kb.nullConnection is not None
def checkConnection(suppressOutput=False): def checkConnection(suppressOutput=False):
if not any([conf.proxy, conf.tor]): if not any((conf.proxy, conf.tor, conf.dummy)):
try: try:
socket.getaddrinfo(conf.hostname, None) socket.getaddrinfo(conf.hostname, None)
except socket.gaierror: except socket.gaierror:

View File

@ -210,6 +210,7 @@ optDict = {
"verbose": "integer", "verbose": "integer",
}, },
"Hidden": { "Hidden": {
"dummy": "boolean",
"binaryFields": "boolean", "binaryFields": "boolean",
"profile": "boolean", "profile": "boolean",
"cpuThrottle": "integer", "cpuThrottle": "integer",

View File

@ -131,6 +131,9 @@ DUMMY_USER_PREFIX = "__dummy__"
# Reference: http://en.wikipedia.org/wiki/ISO/IEC_8859-1 # Reference: http://en.wikipedia.org/wiki/ISO/IEC_8859-1
DEFAULT_PAGE_ENCODING = "iso-8859-1" DEFAULT_PAGE_ENCODING = "iso-8859-1"
# URL used in dummy runs
DUMMY_URL = "http://foo/bar?id=1"
# System variables # System variables
IS_WIN = subprocess.mswindows IS_WIN = subprocess.mswindows

View File

@ -18,6 +18,7 @@ from lib.core.common import getUnicode
from lib.core.data import logger from lib.core.data import logger
from lib.core.defaults import defaults from lib.core.defaults import defaults
from lib.core.settings import BASIC_HELP_ITEMS from lib.core.settings import BASIC_HELP_ITEMS
from lib.core.settings import DUMMY_URL
from lib.core.settings import IS_WIN from lib.core.settings import IS_WIN
from lib.core.settings import MAX_HELP_OPTION_LENGTH from lib.core.settings import MAX_HELP_OPTION_LENGTH
@ -664,6 +665,9 @@ def cmdLineParser():
help="Simple wizard interface for beginner users") help="Simple wizard interface for beginner users")
# Hidden and/or experimental options # Hidden and/or experimental options
parser.add_option("--dummy", dest="dummy", action="store_true",
help=SUPPRESS_HELP)
parser.add_option("--pickled-options", dest="pickledOptions", help=SUPPRESS_HELP) parser.add_option("--pickled-options", dest="pickledOptions", help=SUPPRESS_HELP)
parser.add_option("--profile", dest="profile", action="store_true", parser.add_option("--profile", dest="profile", action="store_true",
@ -760,6 +764,9 @@ def cmdLineParser():
if sys.argv[i] == '-z': if sys.argv[i] == '-z':
expandMnemonics(sys.argv[i + 1], parser, args) expandMnemonics(sys.argv[i + 1], parser, args)
if args.dummy:
args.url = args.url or DUMMY_URL
if not any((args.direct, args.url, args.logFile, args.bulkFile, args.googleDork, args.configFile, \ if not any((args.direct, args.url, args.logFile, args.bulkFile, args.googleDork, args.configFile, \
args.requestFile, args.updateAll, args.smokeTest, args.liveTest, args.wizard, args.dependencies, \ args.requestFile, args.updateAll, args.smokeTest, args.liveTest, args.wizard, args.dependencies, \
args.purgeOutput, args.pickledOptions)): args.purgeOutput, args.pickledOptions)):

View File

@ -31,6 +31,8 @@ from lib.core.common import getRequestHeader
from lib.core.common import getUnicode from lib.core.common import getUnicode
from lib.core.common import logHTTPTraffic from lib.core.common import logHTTPTraffic
from lib.core.common import randomizeParameterValue from lib.core.common import randomizeParameterValue
from lib.core.common import randomInt
from lib.core.common import randomStr
from lib.core.common import readInput from lib.core.common import readInput
from lib.core.common import removeReflectiveValues from lib.core.common import removeReflectiveValues
from lib.core.common import singleTimeLogMessage from lib.core.common import singleTimeLogMessage
@ -181,6 +183,9 @@ class Connect(object):
elif conf.cpuThrottle: elif conf.cpuThrottle:
cpuThrottle(conf.cpuThrottle) cpuThrottle(conf.cpuThrottle)
if conf.dummy:
return randomStr(int(randomInt())), {}, int(randomInt())
threadData = getCurrentThreadData() threadData = getCurrentThreadData()
with kb.locks.request: with kb.locks.request:
kb.requestCounter += 1 kb.requestCounter += 1