Dear Andres, I've written a brand new SESSION FIXATION audit plugin. the step is : the Plugin will Find freqs that contain SSID, change this SSID and send to server. If Server don't provide new SSID => VULN otherwise, NO VULN
I've created 2 very simple PHP scripts : one is vulnerable to Session fixaton, one is none I tested with these 2 script. The plugin runs fine. But, Please review and give me comments.. If it's wrong, I will fix it again.. :( Thank you very much -- Best Regards, Summer Nguyen .
'''
session_fixation.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
class session_fixation(baseAuditPlugin):
'''
Find SESSION FIXATION vulnerabilities.
@author: Summer Nguyen ([email protected])
'''
def __init__(self):
baseAuditPlugin.__init__(self)
self._fuzzableRequests = []
self._SSID=''
self._SSIDparam=''
self._fakeSSID=''
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() )
self._fuzzableRequests.append(freq)
if self._hasSSID(freq): # The plugin only test the URL that may respond SESSID
self._checkvuln(freq)
def _checkvuln(self,freq):
'''
Generate New SSID from original SSSID, send it and get response
I don't want to set fake_SSID=1234.. ^_^
'''
SSID=""
for i,A in enumerate(self._SSID):
if i%5==1:
SSID+="0"
else:
SSID+=A
self._fakeSSID=SSID
Cookie= str(freq.getCookie())
Cookie=Cookie.replace(self._SSID,SSID);
freq.setCookie(Cookie)
targs = (freq,)
self._tm.startFunction( target=self._sendMutant, args=targs, ownerObj=self )
def _hasSSID( self, freq ):
'''
Check if the server provided SSID
'''
Cookie= str(freq.getCookie())
if (self._SSIDparam==''):
params=self._getSSIDparam()
else:
params=[self._SSIDparam]
for param in params:
num=string.find(Cookie,param)
if num!=-1:
SSID=""
end=False
i=1
while not end:
char=Cookie[num+len(param)+i]
if char!=';':
SSID+=char
else:
end=True
i=i+1
self._SSIDparam=param
self._SSID=SSID
self._hasID=True
return True
return False
def _analyzeResult( self, mutant, response ):
'''
Do we have Session Fixation VULN??
@return: None, record all the results in the kb.
'''
vulne=False
res=response.getHeaders()
if 'Set-Cookie' in res:
num=string.find(res['Set-Cookie'],self._SSIDparam)
if num== -1:
vulne=True
else:
SSID=''
char=''
i=1
end=False
while not end: ## Get the SSID value
char=res['Set-Cookie'][num+len(self._SSIDparam)+i]
if char!=';':
SSID+=char
else:
end=True
i=i+1
if SSID==self._fakeSSID:
vulne=True
else:
vulne=True
if vulne: ## there is VULN
print mutant.getURL()
print "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')
param.append('PHPSESSID')
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 SESSION FIXATION vulnerabilities.
To find SESSION FIXATION Vulnerability, the Plugin will Find freqs that contain SSID, change this SSID and send to server.
If Server don't provide new SSID => VULN
otherwise, NO VULN
'''
<<attachment: ss.php>>
<<attachment: no-ss.php>>
------------------------------------------------------------------------------
_______________________________________________ W3af-develop mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/w3af-develop
