TestInviteFloodingAuth.py

Go to the documentation of this file.
00001 ##
00002 # 
00003 # Test case: security.dos.voip.TesInviteFloodingAuth
00004 # 
00005 from testenv.core.TestCase import TestCase
00006 
00007 import socket
00008 
00009 ##
00010 # 
00011 #       Scenario: INVITE flooding with authentication
00012 #       
00013 #       This test does an INVITE flood with authentication.
00014 #       
00015 #       - Flooding scenario:
00016 #       
00017 #       @code
00018 #       Mallory                      Bob
00019 #         |         INVITE            |
00020 #         |-------------------------->|
00021 #         |          401              |
00022 #         |<--------------------------|
00023 #         |          ACK              |
00024 #         |-------------------------->|
00025 #         |         INVITE            |
00026 #         |-------------------------->|
00027 #         |          200              |
00028 #         |<--------------------------|
00029 #       @endcode
00030 #       
00031 #       @ingroup test_case_all
00032 #       
00033 class TestInviteFloodingAuth(TestCase):
00034         
00035         ##
00036         # 
00037         #               This function is called by the __init__ function from the parent.
00038         #               Don't define your own __init__ here!
00039         #               
00040         def initTestCase(self):
00041 
00042                 #set description to identify test case in output
00043                 self.setDescription("INVITE flooding with authentication")
00044                 
00045                 #files to be updated with test users data
00046                 self.addFile("userinfo.csv")
00047 
00048 
00049         ##
00050         # 
00051         #               implementation of an INVITE flood
00052         #               
00053         def test(self):
00054                 
00055                 #get scenario path
00056                 scenarioPath = self.getResourcesPath() + "/"
00057                 #get target IP address from config
00058                 targetIp = self.getParameter("configuration.local.target.ip")
00059                 #get network interface to use from config
00060                 localDevice = self.getParameter("configuration.local.interface")
00061                 #get IP address of network interface
00062                 localIp = self.getIpAddress(localDevice)
00063                 
00064                 #nmap parameter list
00065                 nmapArgs = ["-p5060", targetIp]
00066                 
00067                 #define port scan
00068                 nmapTest = self.newTest("nmap", "portscan", {'arguments' : nmapArgs})
00069                 
00070                 #run port scan
00071                 nmapTest.start()
00072                 nmapTest.join()
00073                 
00074                 #get results from port scan
00075                 nmapTestResult = self.getResult("portscan")
00076                 hosts = nmapTestResult.getValue("hosts")
00077                 #run test only if 5060 is open
00078                 for host in hosts:
00079                         if host.getPorts() > 0:
00080                                 address = host.getAddress()
00081                                 #sipp parameter lists
00082                                 argsMallory = []
00083                                 argsMallory.extend(["-sf", scenarioPath + "inviteflood_auth_mallory.xml"])
00084                                 argsMallory.extend([address])
00085                                 argsMallory.extend(["-i", localIp])
00086                                 argsMallory.extend(["-p", "5066"])
00087                                 argsMallory.extend(["-inf", scenarioPath + "userinfo.csv"])
00088                                 argsMallory.extend(["-mp", "6001"])
00089                                 argsMallory.extend(["-m", "150000"])
00090                                 argsMallory.extend(["-r", "5000"])
00091                                                 
00092                                 argsBob = []
00093                                 argsBob.extend(["-sf", scenarioPath + "inviteflood_bob.xml"])
00094                                 argsBob.extend([address])
00095                                 argsBob.extend(["-i", localIp])
00096                                 argsBob.extend(["-p", "5060"])
00097                                 argsBob.extend(["-inf", scenarioPath + "userinfo.csv"])
00098                                 argsBob.extend(["-mp", "6002"])
00099                                 argsBob.extend(["-m", "150000"])
00100                                 
00101                                 argsBobRegister = []
00102                                 argsBobRegister.extend(["-sf", scenarioPath + "register.xml"])
00103                                 argsBobRegister.extend([address])
00104                                 argsBobRegister.extend(["-i", localIp])
00105                                 argsBobRegister.extend(["-p", "5060"])
00106                                 argsBobRegister.extend(["-inf", scenarioPath + "userinfo.csv"])
00107                                 argsBobRegister.extend(["-m", "1"])
00108                                 
00109                                 argsBobUnregister = []
00110                                 argsBobUnregister.extend(["-sf", scenarioPath + "unregister.xml"])
00111                                 argsBobUnregister.extend([address])
00112                                 argsBobUnregister.extend(["-i", localIp])
00113                                 argsBobUnregister.extend(["-p", "5060"])
00114                                 argsBobUnregister.extend(["-inf", scenarioPath + "userinfo.csv"])
00115                                 argsBobUnregister.extend(["-m", "1"])
00116                         
00117                                 #define flood
00118                                 testMallory = self.newTest("sipp", "mallory (on proxy " + address + ")", {'arguments' : argsMallory}, 60)
00119                                 testBob = self.newTest("sipp", "bob (on proxy " + address + ")", {'arguments' : argsBob}, 60)
00120                                 testBobRegister = self.newTest("sipp", "register bob (on registrar " + address + ")", {'arguments' : argsBobRegister}, 20)
00121                                 testBobUnregister = self.newTest("sipp", "unregister bob (on registrar " + address + ")", {'arguments' : argsBobUnregister}, 20)
00122                         
00123                                 #set scenario path (needed to receive log files)
00124                                 testMallory.set("scenarioPath", self.getResourcesPath())
00125                                 testBob.set("scenarioPath", self.getResourcesPath())
00126                                 testBobRegister.set("scenarioPath", self.getResourcesPath())
00127                                 testBobUnregister.set("scenarioPath", self.getResourcesPath())
00128 
00129                                 #run flood
00130                                 testBobRegister.start()
00131                                 testBobRegister.join()
00132                                 testBob.start()
00133                                 testMallory.start()
00134                                 testMallory.join()
00135                                 testBob.join()
00136                                 testBobUnregister.start()
00137                                 testBobUnregister.join()
00138 
00139 

Generated on Mon Aug 11 17:28:24 2008 for TestEnv by  doxygen 1.5.5