-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathhello_world.py
77 lines (73 loc) · 3.25 KB
/
hello_world.py
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import king_phisher.client.plugins as plugins
import king_phisher.client.gui_utilities as gui_utilities
try:
# imports that may not be available need to be an exception handler so
# the plugin module will still load
import advancedhttpserver
except ImportError:
# set a variable to whether this package is available or not for later use
has_ahs = False
else:
has_ahs = True
# this is the main plugin class, it is necessary to inherit from plugins.ClientPlugin
class Plugin(plugins.ClientPlugin):
authors = ['Spencer McIntyre'] # the plugins author
classifiers = ['Plugin :: Client'] # the list of classifiers for categorization
title = 'Hello World!' # the title of the plugin to be shown to users
description = """
A 'hello world' plugin to serve as a basic template and demonstration. This
plugin will display a message box when King Phisher exits.
""" # a description of the plugin to be shown to users
homepage = 'https://github.com/securestate/king-phisher-plugins' # an optional home page
options = [ # specify options which can be configured through the GUI
plugins.ClientOptionString(
'name', # the name of the option as it will appear in the configuration
'The name to which to say goodbye.', # the description of the option as shown to users
default='Alice Liddle', # a default value for the option
display_name='Your Name' # a name of the option as shown to users
),
plugins.ClientOptionBoolean(
'validiction',
'Whether or not this plugin say good bye.',
default=True,
display_name='Say Good Bye'
),
plugins.ClientOptionInteger(
'some_number',
'An example number option.',
default=1337,
display_name='A Number'
),
plugins.ClientOptionPort(
'tcp_port',
'The TCP port to connect to.',
default=80,
display_name='Connection Port'
)
]
req_min_py_version = '3.3.0' # (optional) specify the required minimum version of python
req_min_version = '1.4.0' # (optional) specify the required minimum version of king phisher
req_packages = { # (optional) specify a dictionary of required package names
'advancedhttpserver': has_ahs # set from within the exception handler when importing
}
req_platforms = ('Linux', 'Windows') # (optional) specify the supported platforms
version = '1.0' # (optional) specify this plugin's version
# this is the primary plugin entry point which is executed when the plugin is enabled
def initialize(self):
print('Hello World!')
self.signal_connect('exit', self.signal_exit)
# it is necessary to return True to indicate that the initialization was successful
# this allows the plugin to check its options and return false to indicate a failure
return True
# this is a cleanup method to allow the plugin to close any open resources
def finalize(self):
print('Good Bye World!')
# the plugin connects this handler to the applications 'exit' signal
def signal_exit(self, app):
# check the 'validiction' option in the configuration
if not self.config['validiction']:
return
gui_utilities.show_dialog_info(
"Good bye {0}!".format(self.config['name']),
app.get_active_window()
)