Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0e89cc6

Browse files
committed
Adding a hidden switch --dummy used for dummy runs (getPage() returns random data) - usefull for testing purposes for skipping connections
1 parent bf05709 commit 0e89cc6

5 files changed

Lines changed: 17 additions & 1 deletion

File tree

lib/controller/checks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,7 @@ def checkNullConnection():
11311131
return kb.nullConnection is not None
11321132

11331133
def checkConnection(suppressOutput=False):
1134-
if not any([conf.proxy, conf.tor]):
1134+
if not any((conf.proxy, conf.tor, conf.dummy)):
11351135
try:
11361136
socket.getaddrinfo(conf.hostname, None)
11371137
except socket.gaierror:

lib/core/optiondict.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@
210210
"verbose": "integer",
211211
},
212212
"Hidden": {
213+
"dummy": "boolean",
213214
"binaryFields": "boolean",
214215
"profile": "boolean",
215216
"cpuThrottle": "integer",

lib/core/settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@
131131
# Reference: http://en.wikipedia.org/wiki/ISO/IEC_8859-1
132132
DEFAULT_PAGE_ENCODING = "iso-8859-1"
133133

134+
# URL used in dummy runs
135+
DUMMY_URL = "http://foo/bar?id=1"
136+
134137
# System variables
135138
IS_WIN = subprocess.mswindows
136139

lib/parse/cmdline.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from lib.core.data import logger
1919
from lib.core.defaults import defaults
2020
from lib.core.settings import BASIC_HELP_ITEMS
21+
from lib.core.settings import DUMMY_URL
2122
from lib.core.settings import IS_WIN
2223
from lib.core.settings import MAX_HELP_OPTION_LENGTH
2324

@@ -664,6 +665,9 @@ def cmdLineParser():
664665
help="Simple wizard interface for beginner users")
665666

666667
# Hidden and/or experimental options
668+
parser.add_option("--dummy", dest="dummy", action="store_true",
669+
help=SUPPRESS_HELP)
670+
667671
parser.add_option("--pickled-options", dest="pickledOptions", help=SUPPRESS_HELP)
668672

669673
parser.add_option("--profile", dest="profile", action="store_true",
@@ -760,6 +764,9 @@ def _(self, *args):
760764
if sys.argv[i] == '-z':
761765
expandMnemonics(sys.argv[i + 1], parser, args)
762766

767+
if args.dummy:
768+
args.url = args.url or DUMMY_URL
769+
763770
if not any((args.direct, args.url, args.logFile, args.bulkFile, args.googleDork, args.configFile, \
764771
args.requestFile, args.updateAll, args.smokeTest, args.liveTest, args.wizard, args.dependencies, \
765772
args.purgeOutput, args.pickledOptions)):

lib/request/connect.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
from lib.core.common import getUnicode
3232
from lib.core.common import logHTTPTraffic
3333
from lib.core.common import randomizeParameterValue
34+
from lib.core.common import randomInt
35+
from lib.core.common import randomStr
3436
from lib.core.common import readInput
3537
from lib.core.common import removeReflectiveValues
3638
from lib.core.common import singleTimeLogMessage
@@ -181,6 +183,9 @@ def getPage(**kwargs):
181183
elif conf.cpuThrottle:
182184
cpuThrottle(conf.cpuThrottle)
183185

186+
if conf.dummy:
187+
return randomStr(int(randomInt())), {}, int(randomInt())
188+
184189
threadData = getCurrentThreadData()
185190
with kb.locks.request:
186191
kb.requestCounter += 1

0 commit comments

Comments
 (0)