1919from lib .core .common import extractRegexResult
2020from lib .core .common import getDirs
2121from lib .core .common import getDocRoot
22+ from lib .core .common import getPublicTypeMembers
2223from lib .core .common import getSQLSnippet
2324from lib .core .common import ntToPosixSlashes
2425from lib .core .common import isTechniqueAvailable
3738from lib .core .enums import DBMS
3839from lib .core .enums import OS
3940from lib .core .enums import PAYLOAD
41+ from lib .core .enums import WEB_API
42+ from lib .core .settings import EVENTVALIDATION_REGEX
43+ from lib .core .settings import VIEWSTATE_REGEX
4044from lib .request .connect import Connect as Request
4145
4246
@@ -85,14 +89,14 @@ def webFileUpload(self, fileToUpload, destFileName, directory):
8589 def __webFileStreamUpload (self , stream , destFileName , directory ):
8690 stream .seek (0 ) # Rewind
8791
88- if self .webApi in ( "php" , "asp" , "aspx" , "jsp" ):
92+ if self .webApi in getPublicTypeMembers ( WEB_API , True ):
8993 multipartParams = {
9094 "upload" : "1" ,
9195 "file" : stream ,
9296 "uploadDir" : directory ,
9397 }
9498
95- if self .webApi == "aspx" :
99+ if self .webApi == WEB_API . ASPX :
96100 multipartParams ['__EVENTVALIDATION' ] = kb .data .__EVENTVALIDATION
97101 multipartParams ['__VIEWSTATE' ] = kb .data .__VIEWSTATE
98102
@@ -141,7 +145,7 @@ def webInit(self):
141145 logger .info (infoMsg )
142146
143147 default = None
144- choices = ( 'asp' , 'aspx' , 'php' , 'jsp' )
148+ choices = list ( getPublicTypeMembers ( WEB_API , True ) )
145149
146150 for ext in choices :
147151 if conf .url .endswith (ext ):
@@ -150,9 +154,9 @@ def webInit(self):
150154
151155 if not default :
152156 if Backend .isOs (OS .WINDOWS ):
153- default = "asp"
157+ default = WEB_API . ASP
154158 else :
155- default = "php"
159+ default = WEB_API . PHP
156160
157161 message = "which web application language does the web server "
158162 message += "support?\n "
@@ -268,9 +272,9 @@ def webInit(self):
268272 logger .warn (warnMsg )
269273 continue
270274
271- elif self .webApi == "aspx" :
272- kb .data .__EVENTVALIDATION = extractRegexResult (r"__EVENTVALIDATION[^>]+value=\"(?P<result>[^\"]+)\"" , uplPage , re . I )
273- kb .data .__VIEWSTATE = extractRegexResult (r"__VIEWSTATE[^>]+value=\"(?P<result>[^\"]+)\"" , uplPage , re . I )
275+ elif self .webApi == WEB_API . ASPX :
276+ kb .data .__EVENTVALIDATION = extractRegexResult (EVENTVALIDATION_REGEX , uplPage )
277+ kb .data .__VIEWSTATE = extractRegexResult (VIEWSTATE_REGEX , uplPage )
274278
275279 infoMsg = "the file stager has been successfully uploaded "
276280 infoMsg += "on '%s' - %s" % (localPath , self .webStagerUrl )
0 commit comments