Plugins are intended to extend the basic HatSploit command list. After deciding what your plugin should do, take this template and edit it for your needs.
"""
This plugin requires HatSploit: https://hatsploit.com
Current source: https://github.com/EntySec/HatSploit
"""
from hatsploit.lib.plugin import Plugin
class HatSploitPlugin(Plugin):
def __init__(self):
super().__init__()
self.details.update({
'Name': "full name",
'Plugin': "name",
'Authors': [
'Your name (your nickname) - plugin developer',
],
'Description': "description.",
})
self.commands = {
'category': {
'command': {
'Description': "description",
'Usage': "command",
'MinArgs': 0,
}
}
}
def command(self, argc, argv):
pass
def load(self):
pass
def unload(self):
pass
NOTE: All plugins should inherit from Plugin
(hatsploit.lib.plugin
), otherwise plugin won’t be loaded.
Let’s go through all the necessary methods:
self.details
- Is a dictionary containing all necessary information (Full name
,name
,description
,authors
, etc.)self.commands
- Is a dictionary that contains all categories and commands implemented by the plugin.self.load()
- Method, which is called when plugin is being loaded.self.unload()
- Method, which is called when plugin is being unloaded.self.command()
- Method, which contains code ofcommand
specified in theself.commands
.
Acknowledge that self.commands
contains category and then the list of commands that belong to this category. For example:
self.commands = {
'My Category': {
'command1': {
'Description': "description",
'Usage': "command1",
'MinArgs': 0,
},
'command2': {
'Description': "description",
'Usage': "command2",
'MinArgs': 0,
},
}
}
Description
- Command description.Usage
- Usage which is displayed ifMinArgs
condition is not achieved.MinArgs
- Minimum necessary arguments. (e.g. if your command requires one mandatory argument, thenMinArgs
should be1
)
NOTE: If your command has specific list of arguments that should be displayed if MinArgs
condition is not achieved, add Options
like this:
'Options': {
'-e': ['<arg>', 'Example'],
}
Moreover, commands are implemented within methods which have the same names as their commands from self.commands
. For example (for previous dictionary):
def command1(self, argc, argv):
... snip ...
def command2(self, argc, argv):
... snip ...
argc
- Number or arguments. (including command name)argv
- List of arguments. (including command name, which isargv[0]
)
Examples
You can always refer to the main repository which contains some plugins and rely on them. We will be glad if you first explore already existing plugins before writing new ones.