@@ -123,31 +123,32 @@ def runThreads(numThreads, threadFunction, cleanupFunction=None, forwardExceptio
123123 kb .threadContinue = True
124124 kb .threadException = False
125125 kb .technique = ThreadData .technique
126-
127- 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 )):
128- while True :
129- message = "please enter number of threads? [Enter for %d (current)] " % numThreads
130- choice = readInput (message , default = str (numThreads ))
131- if choice :
132- skipThreadCheck = False
133-
134- if choice .endswith ('!' ):
135- choice = choice [:- 1 ]
136- skipThreadCheck = True
137-
138- if isDigit (choice ):
139- if int (choice ) > MAX_NUMBER_OF_THREADS and not skipThreadCheck :
140- errMsg = "maximum number of used threads is %d avoiding potential connection issues" % MAX_NUMBER_OF_THREADS
141- logger .critical (errMsg )
142- else :
143- conf .threads = numThreads = int (choice )
144- break
145-
146- if numThreads == 1 :
147- warnMsg = "running in a single-thread mode. This could take a while"
148- logger .warn (warnMsg )
126+ kb .multiThreadMode = False
149127
150128 try :
129+ 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 )):
130+ while True :
131+ message = "please enter number of threads? [Enter for %d (current)] " % numThreads
132+ choice = readInput (message , default = str (numThreads ))
133+ if choice :
134+ skipThreadCheck = False
135+
136+ if choice .endswith ('!' ):
137+ choice = choice [:- 1 ]
138+ skipThreadCheck = True
139+
140+ if isDigit (choice ):
141+ if int (choice ) > MAX_NUMBER_OF_THREADS and not skipThreadCheck :
142+ errMsg = "maximum number of used threads is %d avoiding potential connection issues" % MAX_NUMBER_OF_THREADS
143+ logger .critical (errMsg )
144+ else :
145+ conf .threads = numThreads = int (choice )
146+ break
147+
148+ if numThreads == 1 :
149+ warnMsg = "running in a single-thread mode. This could take a while"
150+ logger .warn (warnMsg )
151+
151152 if numThreads > 1 :
152153 if startThreadMsg :
153154 infoMsg = "starting %d threads" % numThreads
@@ -156,6 +157,8 @@ def runThreads(numThreads, threadFunction, cleanupFunction=None, forwardExceptio
156157 threadFunction ()
157158 return
158159
160+ kb .multiThreadMode = True
161+
159162 # Start the threads
160163 for numThread in xrange (numThreads ):
161164 thread = threading .Thread (target = exceptionHandledFunction , name = str (numThread ), args = [threadFunction ])
@@ -225,6 +228,7 @@ def runThreads(numThreads, threadFunction, cleanupFunction=None, forwardExceptio
225228 traceback .print_exc ()
226229
227230 finally :
231+ kb .multiThreadMode = False
228232 kb .threadContinue = True
229233 kb .threadException = False
230234 kb .technique = None
0 commit comments