MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / runThreads

Function runThreads

lib/core/threads.py:122–263  ·  view source on GitHub ↗
(numThreads, threadFunction, cleanupFunction=None, forwardException=True, threadChoice=False, startThreadMsg=True)

Source from the content-addressed store, hash-verified

120 thread.setDaemon(True)
121
122def runThreads(numThreads, threadFunction, cleanupFunction=None, forwardException=True, threadChoice=False, startThreadMsg=True):
123 threads = []
124
125 def _threadFunction():
126 try:
127 threadFunction()
128 finally:
129 if conf.hashDB:
130 conf.hashDB.close()
131
132 kb.multipleCtrlC = False
133 kb.threadContinue = True
134 kb.threadException = False
135 kb.technique = ThreadData.technique
136 kb.multiThreadMode = False
137
138 try:
139 if threadChoice and conf.threads == numThreads == 1 and not (kb.injection.data and not any(_ not in (PAYLOAD.TECHNIQUE.TIME, PAYLOAD.TECHNIQUE.STACKED) for _ in kb.injection.data)):
140 while True:
141 message = "please enter number of threads? [Enter for %d (current)] " % numThreads
142 choice = readInput(message, default=str(numThreads))
143 if choice:
144 skipThreadCheck = False
145
146 if choice.endswith('!'):
147 choice = choice[:-1]
148 skipThreadCheck = True
149
150 if isDigit(choice):
151 if int(choice) > MAX_NUMBER_OF_THREADS and not skipThreadCheck:
152 errMsg = "maximum number of used threads is %d avoiding potential connection issues" % MAX_NUMBER_OF_THREADS
153 logger.critical(errMsg)
154 else:
155 conf.threads = numThreads = int(choice)
156 break
157
158 if numThreads == 1:
159 warnMsg = "running in a single-thread mode. This could take a while"
160 logger.warning(warnMsg)
161
162 if numThreads > 1:
163 if startThreadMsg:
164 infoMsg = "starting %d threads" % numThreads
165 logger.info(infoMsg)
166 else:
167 try:
168 _threadFunction()
169 except (SqlmapUserQuitException, SqlmapSkipTargetException):
170 pass
171 return
172
173 kb.multiThreadMode = True
174
175 # Start the threads
176 for numThread in xrange(numThreads):
177 thread = threading.Thread(target=exceptionHandledFunction, name=str(numThread), args=[_threadFunction])
178
179 setDaemon(thread)

Callers 7

crawlFunction · 0.90
tableExistsFunction · 0.90
columnExistsFunction · 0.90
fileExistsFunction · 0.90
unionUseFunction · 0.90
bisectionFunction · 0.90
errorUseFunction · 0.90

Calls 15

_threadFunctionFunction · 0.85
xrangeClass · 0.85
setDaemonFunction · 0.85
infoMethod · 0.80
startMethod · 0.80
valuesMethod · 0.80
readInputFunction · 0.70
isDigitFunction · 0.70
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…