Create a Custom Attack Module
AppSpider has over fifty in-built attack modules. In some cases, users may want to create a custom attack specific to their environment. Hence, AppSpider provides unique functionality which allows users to create a custom attack module to explore a new attack module based on their application environment.
To create a custom attack module we have create a Library project in Visual Studio Express. It is a freeware tool from Microsoft. It can be downloaded from the following link.: https://www.visualstudio.com/en-us/products/visual-studio-express-vs.aspx
Create the Custom Attack Module
New Library Project
After installation, open VS Express and create a new Class Library project.
Add a reference dll (AttackerCOMLib.dll) from the installation file. Use following steps to add a new reference ddl in the project:
- Right click on the project
- Navigate to “Add” >> “Reference”
- Click on the “Browse” button
- Navigate to “AttackerCom.dll” into the AppSpider installation directory and select it.
- Click on the “Add” button
Create New Classes
Now, create two new classes ICSModule.cs and ICSModuleFactory.cs. Use following steps to create a new class in VS Express:
- Right click on the project
- Navigate to “Add” >> “New Item”
- Select a C# class item and name it to “ICSModule.cs”
- Likewise we can create multiple class files
- Add following code for
ICSModule.cs
:
1using System;23namespace CustomModule4{5public interface ICSModule6{7void Load(uint moduleRunnerId);89uint CalculateNumberOfAttacks();10bool RunAttack(uint attackIndex);11}12}
- Add following code for
CSModuleFactory.cs
:
1using System;23namespace CustomModule4{5public interface ICSModuleFactory6{7bool CreateModule(Guid moduleGuid, out ICSModule module);8}9}
- Add a new class file ModuleFactory.cs. In this class we need to add a unique GUID, which will be used to attach in the Attack module in future.
1using System;2using AttackerCOMLib;3using System.Text.RegularExpressions;45namespace CustomModule6{7public class CSModuleFactory : ICSModuleFactory8{9public bool CreateModule(Guid moduleGuid, out ICSModule module)10{11Guid correctGuid = new Guid("7DEE1967-063D-4BE0-8061-028D3E707FCE");12if (correctGuid == moduleGuid)13module = new Internal();14else15module = null;16return module != null;17}1819}20}
- Now, add an
Internal.cs
with following code:
1using AttackerCOMLib;2using System;3using System.Text.RegularExpressions;45namespace CustomModule6{7/// <summary>8/// Internal module name as per location indicated in module.cfg9/// </summary>10public class Internal : ICSModule11{1213IModuleRunner _moduleRunner;1415public bool AttackPointIsRelevant()16{17throw new NotImplementedException();18}1920public uint CalculateNumberOfAttacks()21{22IAttackPoint attackPoint = _moduleRunner.GetAttackPoint();23if (attackPoint.Type == AttackPointType.ATTACKPOINT_PARAMETER)24{2526return 1;27}28else29{3031// Other attack points are:32// CrawlResult33// File34// Directory35// Host36return 0;37}38}39404142public void Load(uint moduleRunnerId)43{44_moduleRunner = new ModuleRunner();45_moduleRunner.SetModuleInstanceID(moduleRunnerId);46}
- Place a “attack.cfg” and “module.cfg” by creating a new folder “Internal” at “C:\Program Files (x86)\Rapid 7\AppSpider 6\ScanEngine\Modules”
- Compile and run the project and it will generate a “internal.dll” file. Copy and paste to the “C:\Program Files (x86)\Rapid 7\AppSpider 6\ScanEngine\Modules\internal” path.
- Edit “ApplicationPolicies.xml” file from “C:\Program Files (x86)\Rapid 7\AppSpider 6\ScanEngine\Config\” path. Add following code into the xml.
1<AttackModulePolicy>2<Enabled>1</Enabled>3<ModuleId>7DEE1967063D4BE08061028D3E707FCE</ModuleId>4<ModulePriority>Medium</ModulePriority>5<Severity>Informational</Severity>6<MaxVulnLimit>100</MaxVulnLimit>7<MaxVarianceLimit>1</MaxVarianceLimit>8<PassiveAnalysisOnAttacks>0</PassiveAnalysisOnAttacks>9<EnforceEncoding>0</EnforceEncoding>10<AttackPoints>Response Analysis</AttackPoints>11<ParameterLocations>Directory|File|Path|Query|Fragment|Post|Http Header|Cookie|Referer</ParameterLocations>12<RequestOriginations>HTML|Form|AJAX|Flash|Silverlight|WSDL</RequestOriginations>13</AttackModulePolicy>
- Create a new scan from AppSpider GUI. Navigate to configuration file in %Documents%/AppSpider/scans/Configname/config.scfg.
- Edit the configuration file and add following code.
1<AttackModulePolicy>2<Enabled>1</Enabled>3<ModuleId>7DEE1967063D4BE08061028D3E707FCE</ModuleId>4<ModulePriority>Medium</ModulePriority>5<Severity>Low</Severity>6<MaxVulnLimit>100</MaxVulnLimit>7<MaxVarianceLimit>1</MaxVarianceLimit>8<PassiveAnalysisOnAttacks>0</PassiveAnalysisOnAttacks>9<EnforceEncoding>0</EnforceEncoding>10<AttackPoints>Parameter</AttackPoints>11<ParameterLocations>Directory|File|Path|Query|Fragment|Post|Cookie|Referer|Http Header</ParameterLocations>12<RequestOriginations>HTML|Form|AJAX|Flash|Silverlight|WSDL</RequestOriginations>13</AttackModulePolicy>
You can see a new attack module in attack policy.
- Select the custom attack module and run a scan.