- All plugins must extend the class
MitmMode - The
__init__method of theMitmModeclass needs to be called in some way for the base functions of the class to be defined. - All plugins must be located in the folder
core/servers/mitm. - The plugins are automatically loaded by the application when read in the folder mentioned above, in addition, even if not linked to the config.ini file, they are listed by the application.
- Some methods defined by default of the
MitmModeclass, have an execution rule when starting the AP and all these methods can be overridden by the parent class.
MitmMode class, let’s implement a simple plugin based on the information above.
ProcessThread that runs a process in the background and redirects the command output to the _ProcessOutput object.
Tcpdump class has some important attributes such as Name, ID, ModType and LogFile, they are necessary for the plugin to work properly.
Method boot
The very important attribute that is only defined when the boot is calledself.reactor, with it we can simplify our process, all in the background, that is, you only need to define it in the boot method to guarantee a good operation. Note, whenever the stop command is used to disable the AP,self.reactor.stop()is called to end the background process.
LogFile Tcpdump
The LogFile attribute is responsible for informing the plugin where the output of the executed command will be saved, in this way, you need to add in the filecore / utility / constants.py which will be the name of the .log file.
Extra attributes and methods
The Name, ID and ModType attributes are defined as follows:- Name - name of plugin
- ID - ID do plugin (lower() format )
- ModType - server type
self.LogOutput method does not need to be overwritten if you use an external tool to run it, because the logs are usually already formed by the tool. but if you wanted to overwrite it, it doesn’t have a specific rule for them, just save at the end use self.logger.info(data) to save the data in the LOG_TCPDUMP file.
Developing Plugin Proxy
To develop one you need a little more than a plugin, because unlike a plugin, proxies have their own rules and will literally run between the communication between the client and the server, this type of proxy is called a transparent proxy. Detail, if your plugin is not necessarily a proxy (it is in the middle of the communication) but at some point it executes an iptables rule, we automatically call it a proxy, because it is handling traffic anyway. Okay, now that we know how the proxy plugin works, let’s understand its peculiarities.- All plugins must extend the class
ProxyMode - The
__init__method of theProxyModeclass needs to be called in some way for the base functions of the class to be defined. - All plugins must be located in the folder
core/servers/proxy. - The plugins are automatically loaded by the application when read in the folder mentioned above, in addition, even if not linked to the config.ini file, they are listed by the application.
- Some methods defined by default of the
ProxyModeclass, have an execution rule when starting the AP and all these methods can be overridden by the parent class.
ProxyMode class works, let’s implement a simple plugin based on the information above.
ProcessThread that runs a process in the background and redirects the output of the command for the _ProcessOutput object.
Mitmdump class has some important attributes like Name, ID, ModType and LogFile, they are necessary for the plugin to work properly. An important method here is add_default_rules, this method allows you to add an iptables rule that will be executed when Initialize is called.
Method Initialize
The Initialize method initiates some pre-defined configuration by the proxy, a simple example is therunDefaultRules method that iterates over a list of iptables rules.
Method boot
The very important attribute that is only defined when the boot is calledself.reactor, with it we can simplify our process, all in the background, that is, you only need to define it in the boot method to guarantee a good operation. Note, whenever the stop command is used to disable the AP,self.reactor.stop()is called to end the background process.
LogFile Mitmdump
The LogFile attribute is responsible for informing the plugin where the output of the executed command will be saved, in this way, you need to add in the filecore / utility / constants.py which will be the name of the .log file.
Extra attributes and methods
The Name, ID and ModType attributes are defined as follows:- Name - name of plugin
- ID - ID do plugin (lower() format )
- ModType - just type proxy
self.LogOutput method does not need to be overwritten if you use an external tool to run it, because the logs are usually already formed by the tool. but if you wanted to overwrite it, there is no specific rule for them, just save it at the end using self.logger.info(data) to save the data in the LOG_MITMDUMP file.