Dear Experts, I've finish my job writting Session Fixation Audit plugin. Can you test the plugin and give me comments about it.. I'll fix it immidiately. The plugin is attached. Thank you very much.. I hope I can contribute much to W3af Community..
-- Best Regards, Summer Nguyen .
''' xss.py Copyright 2006 Andres Riancho This file is part of w3af, w3af.sourceforge.net . w3af is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation version 2 of the License. w3af is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with w3af; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ''' import core.controllers.outputManager as om from core.data.dc.form import form as form # options from core.data.options.option import option from core.data.options.optionList import optionList from core.controllers.basePlugin.baseAuditPlugin import baseAuditPlugin from core.data.fuzzer.fuzzer import createMutants, createRandAlNum from core.controllers.w3afException import w3afException import core.data.kb.knowledgeBase as kb import core.data.kb.vuln as vuln import core.data.constants.severity as severity import string import re class sessionfixation(baseAuditPlugin): ''' Find cross site scripting vulnerabilities. @author: Summer Nguyen (summer0ngu...@gmail.com) Steps: 1. Attacker get SSID 2. Victim login use valid username and password , .. and attacker' SSID If server provide new SSID => NO VULN otherwise => VULN ''' def __init__(self): baseAuditPlugin.__init__(self) self._fuzzableRequests = [] self._hasID = False self._username = 'username' ## Webmaster provide valid username and password to test the website self._password = 'password' self._SSID='' self._SSIDparam='' def audit(self, freq ): ''' Tests an URL for Session Fixation vulnerabilities. @param freq: A fuzzableRequest ''' om.out.debug( 'Session Fixation plugin is testing: ' + freq.getURL() ) # Save it here, so I can check this URL after geting the SSID self._fuzzableRequests.append(freq) if self._hasID: ## I have SSID of anomunous user ( Attacker) if self._isLoginForm(freq): ## Find Login form to login self._victimlogin(freq) ## Victim Login else: ## I am an attacker, I am trying to get SSID of anonymous user if self._hasSSID(freq): self._hasID=True if self._isLoginForm(freq): ## Check if this URL is a login form self._victimlogin(freq) for freq in self._fuzzableRequests: ## Check the URL that are saved above if self._isLoginForm(freq): self._victimlogin(freq) def _victimlogin(self,freq): ''' Victim login useing valid username,password .. and use attacker's SSID ''' data_container = freq.getDc() user_field, passwd_field = self._getLoginFieldNames( freq ) data_container[ user_field ] = self._username ## Valid Username, Password data_container[ passwd_field ] = self._password freq.setDc( data_container ) Cookie=self._getJSESSION() mutants = createMutants( freq , Cookie ) for mutant in mutants: targs = (mutant,) self._tm.startFunction( target=self._sendMutant, args=targs, ownerObj=self ) def _hasSSID( self, freq ): ''' Check if the server provide a new SSID ''' response = self._sendMutant( freq , analyze=False, grepResult=False ) params=self._getSSIDparam() res2string=str(response.getHeaders()) ## convert to String if 'Set-Cookie' in res2string: ## There is Cookie param print "KAKAKAKAKAK" SSID='' for param in params: num=string.find(res2string,param) if num!= -1: self._SSIDparam=param char ='' i=1 end=False while not end: ## Get the SSID value char=res2string[num+len(param)+i] if char!=';': SSID+=char else: end=True i=i+1 return True return False def _getJSESSION(self): ''' Use the attacker's SESSION ID when victim logging in ''' js=[] js.append("Cookie: "+self._SSIDparam+"="+self._SSID) return js def _isLoginForm( self, freq ): ''' @return: True if this fuzzableRequest is a loginForm. ''' passwd = 0 text = 0 other = 0 data_container = freq.getDc() if isinstance(data_container ,form ): for key in data_container.keys(): if data_container.getType( key ).lower() == 'password': passwd += 1 elif data_container.getType( key ).lower() == 'text': text += 1 else: other += 1 if text == 1 and passwd == 1: return True return False def _getLoginFieldNames( self, freq ): ''' @return: The names of the form fields where to input the user and the password. ''' data_container = freq.getDc() user = passwd = '' if isinstance(data_container ,form ): for key in data_container.keys(): if data_container.getType( key ).lower() == 'password': passwd = key elif data_container.getType( key ).lower() == 'text': user = key return user, passwd def _analyzeResult( self, mutant, response ): ''' Do we have a reflected XSS? @return: None, record all the results in the kb. ''' vuln=False param=self._SSIDparam res2string=str(response.getHeaders()) if 'Set-Cookie' in res2string: SSID='' num=string.find(res2string,param) if num== -1: ## THERE IS NO SSID => VULN vuln=True else: ## THERE IS SSID, GET SSID NOW param=self._SSIDparam res2string=str(response.getHeaders()) SSID='' char='' i=1 end=False while not end: ## Get the SSID value char=res2string[num+len(param)+i] if char!=';': SSID+=char else: end=True i=i+1 if SSID==self._SSID: vuln=True else: vuln=True if vuln: ## there is VULN v = vuln.vuln( mutant ) v.setId( response.id ) v.setName( 'Session Fixation vulnerability' ) v.setSeverity(severity.MEDIUM) kb.kb.append( self, 'sessionfixation', v ) def _getSSIDparam(self ): ''' SSID parameters, Please add more parameters ''' param=[] param.append('JSESSIONID') param.append('wordpress_test_cookie') param.append('PHPSESSIONID') param.append('SID') return param def getOptions( self ): ''' @return: A list of option objects for this plugin. ''' ol = optionList() return ol def setOptions( self, optionsMap ): ''' This method sets all the options that are configured using the user interface generated by the framework using the result of getOptions(). @parameter OptionList: A dictionary with the options for the plugin. @return: No value is returned. ''' pass def getPluginDeps( self ): ''' @return: A list with the names of the plugins that should be runned before the current one. ''' return [] def getLongDesc( self ): ''' @return: A DETAILED description of the plugin functions and features. ''' return ''' This plugin finds Cross Site Scripting (XSS) vulnerabilities. Two configurable parameters exist: - checkStored - numberOfChecks To find XSS bugs the plugin will send a set of javascript strings to every parameter, and search for that input in the response. The parameter "checkStored" configures the plugin to store all data sent to the web application and at the end, request all pages again searching for that input; the numberOfChecks determines how many javascript strings are sent to every injection point. '''
------------------------------------------------------------------------------
_______________________________________________ W3af-develop mailing list W3af-develop@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/w3af-develop