@@ -294,16 +294,63 @@ def checkStability():
294294 infoMsg = "testing if the url is stable, wait a few seconds"
295295 logger .info (infoMsg )
296296
297- firstResult = Request .queryPage ()
297+ firstPage , firstHeaders = Request .queryPage (content = True )
298298 time .sleep (0.5 )
299299
300- secondResult = Request .queryPage ()
300+ secondPage , secondHeaders = Request .queryPage (content = True )
301301 time .sleep (0.5 )
302302
303- thirdResult = Request .queryPage ()
303+ thirdPage , thirdHeaders = Request .queryPage (content = True )
304304
305- condition = firstResult == secondResult
306- condition &= secondResult == thirdResult
305+ condition = firstPage == secondPage
306+ condition &= secondPage == thirdPage
307+
308+ if condition == False :
309+ contentLengths = []
310+ requestsHeaders = ( firstHeaders , secondHeaders , thirdHeaders )
311+
312+ for requestHeaders in requestsHeaders :
313+ requestHeaders = str (requestHeaders ).lower ()
314+
315+ clHeader = re .search ("content-length:\s+([\d]+)" , requestHeaders , re .I | re .M )
316+
317+ if clHeader and clHeader .group (1 ).isdigit ():
318+ contentLengths .append (int (clHeader .group (1 )))
319+
320+ if contentLengths :
321+ clSum = 0
322+
323+ for cl in contentLengths :
324+ clSum += cl
325+
326+ clAverage = clSum / len (contentLengths )
327+
328+ # TODO: go ahead here with the technique to compare True/False
329+ # based upon clAverage discard (conf.contentLengths)
330+
331+ counter = 0
332+ firstLines = firstPage .split ("\n " )
333+ secondLines = secondPage .split ("\n " )
334+ thirdLines = thirdPage .split ("\n " )
335+
336+ for firstLine in firstLines :
337+ if counter > len (secondLines ) or counter > len (thirdLines ):
338+ break
339+
340+ if firstLine in secondLines and firstLine in thirdLines :
341+ conf .equalLines .append (firstLine )
342+
343+ counter += 1
344+
345+ if conf .equalLines :
346+ warnMsg = "url is not stable, sqlmap inspected the page "
347+ warnMsg += "content and identified a stable lines subset "
348+ warnMsg += "to be used in the comparison algorithm"
349+ logger .warn (warnMsg )
350+
351+ kb .defaultResult = True
352+
353+ return True
307354
308355 return condition
309356
@@ -325,7 +372,7 @@ def checkString():
325372 infoMsg += "target URL page content"
326373 logger .info (infoMsg )
327374
328- page = Request .queryPage (content = True )
375+ page , _ = Request .queryPage (content = True )
329376
330377 if conf .string in page :
331378 setString ()
@@ -356,7 +403,7 @@ def checkRegexp():
356403 infoMsg += "the target URL page content"
357404 logger .info (infoMsg )
358405
359- page = Request .queryPage (content = True )
406+ page , _ = Request .queryPage (content = True )
360407
361408 if re .search (conf .regexp , page , re .I | re .M ):
362409 setRegexp ()
0 commit comments