-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathmodule_template.py
More file actions
59 lines (51 loc) · 2.76 KB
/
Copy pathmodule_template.py
File metadata and controls
59 lines (51 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import argparse
from typing import Dict, Any
from pinecone.core.main import Pinecone
from pinecone.core.module import BaseModule
class Module(BaseModule):
"""
This module serves as an template from which a real module can be built. The name of the class should be 'Module',
and the class should extend from any of the base abstract classes provided in the pinecone.core.module or
pinecone.core.script Python's modules. For a working example look any real module, like the 'attack/deauth' one.
"""
# Module's meta-information.
META = {
# ID of the module as it would appear in the directories tree.
"id": "example/template",
# Module's short name.
"name": "Pinecone module template",
# Module's author.
"author": "Valentín Blanco (https://github.com/valenbg1)",
# Module's version.
"version": "1.0.0",
# Module's long description.
"description": "This module serves as an template from which a real module can be built.",
# Module's options. It can be an argparse.ArgumentParser or a cmd2.argparse_completer.ACArgumentParser for
# leveraging cmd2's auto-completion.
"options": argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter),
# Set of module's dependencies. They can be either Python packages and, in the case of developing a Pinecone
# extension script, also other modules IDs.
"depends": {}
} # type: Dict[str, Any]
# Example options added to the argument parser.
META["options"].add_argument("-s", "--str", help="string option example", default="example")
META["options"].add_argument("-n", "--number", help="number option example", type=int, default=0)
def run(self, args: argparse.Namespace, cmd: Pinecone) -> Any:
"""
Implements the module's main functionality.
:param args: this method receives the options parsed in this parameter, as an argparse.Namespace instance.
:param cmd: an instance of Pinecone's main cmd2 object, which can be primarily used for providing feedback to
the user.
:return: this method can return anything.
"""
cmd.pfeedback("[i] This prints non-essential feedback.")
cmd.poutput("This prints module's output.")
cmd.perror("This prints an error.")
def stop(self, cmd: Pinecone) -> Any:
"""
Implements the module's stop functionality (for example, in case the module stays running in the background).
:param cmd: an instance of Pinecone's main cmd2 object, which can be primarily used for providing feedback to
the user.
:return: this method can return anything.
"""
cmd.poutput("The module correctly stopped!")