@@ -4417,59 +4417,52 @@ def geturl(self):
44174417 except :
44184418 pass
44194419
4420- if forms :
4421- for form in forms :
4422- try :
4423- for control in form .controls :
4424- if hasattr (control , "items" ) and not any ((control .disabled , control .readonly )):
4425- # if control has selectable items select first non-disabled
4426- for item in control .items :
4427- if not item .disabled :
4428- if not item .selected :
4429- item .selected = True
4430- break
4431-
4432- if conf .crawlExclude and re .search (conf .crawlExclude , form .action or "" ):
4433- dbgMsg = "skipping '%s'" % form .action
4434- logger .debug (dbgMsg )
4435- continue
4420+ for form in forms or []:
4421+ try :
4422+ for control in form .controls :
4423+ if hasattr (control , "items" ) and not any ((control .disabled , control .readonly )):
4424+ # if control has selectable items select first non-disabled
4425+ for item in control .items :
4426+ if not item .disabled :
4427+ if not item .selected :
4428+ item .selected = True
4429+ break
44364430
4437- request = form .click ()
4438- except (ValueError , TypeError ) as ex :
4439- errMsg = "there has been a problem while "
4440- errMsg += "processing page forms ('%s')" % getSafeExString (ex )
4441- if raise_ :
4442- raise SqlmapGenericException (errMsg )
4443- else :
4444- logger .debug (errMsg )
4431+ if conf .crawlExclude and re .search (conf .crawlExclude , form .action or "" ):
4432+ dbgMsg = "skipping '%s'" % form .action
4433+ logger .debug (dbgMsg )
4434+ continue
4435+
4436+ request = form .click ()
4437+ except (ValueError , TypeError ) as ex :
4438+ errMsg = "there has been a problem while "
4439+ errMsg += "processing page forms ('%s')" % getSafeExString (ex )
4440+ if raise_ :
4441+ raise SqlmapGenericException (errMsg )
44454442 else :
4446- url = urldecode (request .get_full_url (), kb .pageEncoding )
4447- method = request .get_method ()
4448- data = request .data
4449- data = urldecode (data , kb .pageEncoding , spaceplus = False )
4443+ logger .debug (errMsg )
4444+ else :
4445+ url = urldecode (request .get_full_url (), kb .pageEncoding )
4446+ method = request .get_method ()
4447+ data = request .data
4448+ data = urldecode (data , kb .pageEncoding , spaceplus = False )
44504449
4451- if not data and method and method .upper () == HTTPMETHOD .POST :
4452- debugMsg = "invalid POST form with blank data detected"
4453- logger .debug (debugMsg )
4454- continue
4450+ if not data and method and method .upper () == HTTPMETHOD .POST :
4451+ debugMsg = "invalid POST form with blank data detected"
4452+ logger .debug (debugMsg )
4453+ continue
44554454
4456- # flag to know if we are dealing with the same target host
4457- _ = checkSameHost (response .geturl (), url )
4455+ # flag to know if we are dealing with the same target host
4456+ _ = checkSameHost (response .geturl (), url )
44584457
4459- if conf .scope :
4460- if not re .search (conf .scope , url , re .I ):
4461- continue
4462- elif not _ :
4458+ if conf .scope :
4459+ if not re .search (conf .scope , url , re .I ):
44634460 continue
4464- else :
4465- target = (url , method , data , conf .cookie , None )
4466- retVal .add (target )
4467- else :
4468- errMsg = "there were no forms found at the given target URL"
4469- if raise_ :
4470- raise SqlmapGenericException (errMsg )
4471- else :
4472- logger .debug (errMsg )
4461+ elif not _ :
4462+ continue
4463+ else :
4464+ target = (url , method , data , conf .cookie , None )
4465+ retVal .add (target )
44734466
44744467 for match in re .finditer (r"\.post\(['\"]([^'\"]*)['\"],\s*\{([^}]*)\}" , content ):
44754468 url = _urllib .parse .urljoin (url , htmlUnescape (match .group (1 )))
@@ -4481,6 +4474,22 @@ def geturl(self):
44814474 data = data .rstrip (DEFAULT_GET_POST_DELIMITER )
44824475 retVal .add ((url , HTTPMETHOD .POST , data , conf .cookie , None ))
44834476
4477+ for match in re .finditer (r"(?s)(\w+)\.open\(['\"]POST['\"],\s*['\"]([^'\"]+)['\"]\).*?\1\.send\(([^)]+)\)" , content ):
4478+ url = _urllib .parse .urljoin (url , htmlUnescape (match .group (2 )))
4479+ data = match .group (3 )
4480+
4481+ data = re .sub (r"\s*\+\s*[^\s'\"]+|[^\s'\"]+\s*\+\s*" , "" , data )
4482+
4483+ data = data .strip ("['\" ]" )
4484+ retVal .add ((url , HTTPMETHOD .POST , data , conf .cookie , None ))
4485+
4486+ if not retVal :
4487+ errMsg = "there were no forms found at the given target URL"
4488+ if raise_ :
4489+ raise SqlmapGenericException (errMsg )
4490+ else :
4491+ logger .debug (errMsg )
4492+
44844493 if addToTargets and retVal :
44854494 for target in retVal :
44864495 kb .targets .add (target )
0 commit comments