forked from rsmusllp/king-phisher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
KingPhisher
executable file
·134 lines (116 loc) · 5.09 KB
/
KingPhisher
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/usr/bin/python -B
# -*- coding: utf-8 -*-
#
# KingPhisher
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of the project nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
import argparse
import logging
import os
import sys
import threading
import time
if getattr(sys, 'frozen', False):
# set the basemap data directory for frozen builds
os.environ['BASEMAPDATA'] = os.path.join(os.path.dirname(sys.executable), 'mpl-basemap-data')
from king_phisher import color
from king_phisher import find
from king_phisher import its
from king_phisher import utilities
from king_phisher import version
from king_phisher.client import application
from king_phisher.client import gui_utilities
from gi.repository import GObject
from gi.repository import Gtk
from smoke_zephyr.requirements import check_requirements
__requirements__ = [
'boltons>=0.6.4',
"dns{0}>=1.12.0".format('python' if its.py_v2 else 'python3'),
'geojson>=1.2',
'Jinja2>=2.7.3',
'paramiko>=1.15.2',
'requests>=2.7.0'
]
if its.py_v2:
__requirements__.append('py2-ipaddress>=3.4')
def main():
parser = argparse.ArgumentParser(description='King Phisher Client GUI', conflict_handler='resolve')
utilities.argp_add_args(parser, default_root='KingPhisher')
parser.add_argument('-c', '--config', dest='config_file', required=False, help='specify a configuration file to use')
arguments = parser.parse_args()
utilities.configure_stream_logger(arguments.loglvl, arguments.logger)
config_file = arguments.config_file
del arguments, parser
logger = logging.getLogger('KingPhisher.Client.CLI')
if sys.platform.startswith('linux') and not os.environ.get('DISPLAY'):
color.print_error('no display was detected, this must be run with an interactive X session')
return 0
if Gtk.check_version(3, 4, 0):
color.print_error('the GTK+ version is too old (minimum required is 3.4)')
return 0
# check and configure the environment
if its.frozen:
data_path = os.path.dirname(sys.executable)
else:
missing_requirements = check_requirements(__requirements__)
if missing_requirements:
color.print_error('the following package requirements are missing or incompatible:')
for missing_req in missing_requirements:
color.print_error(' - ' + missing_req)
color.print_error('please install the missing requirements with pip')
return 0
data_path = os.path.dirname(__file__)
data_path = os.path.join(data_path, 'data', 'client')
if sys.platform.startswith('linux') and not os.getuid():
logger.warning('it is not necessary to run the king phisher client as root')
data_path = os.path.abspath(data_path)
if os.path.isdir(data_path):
find.data_path_append(data_path)
data_path = os.getcwd()
data_path = os.path.join(data_path, 'data', 'client')
data_path = os.path.abspath(data_path)
if os.path.isdir(data_path):
find.data_path_append(data_path)
if not gui_utilities.which_glade():
color.print_error('unable to locate the glade ui data file')
return 0
logger.debug("king phisher version: {0} python version: {1}.{2}.{3}".format(version.version, sys.version_info[0], sys.version_info[1], sys.version_info[2]))
logger.debug("client running in process: {0} main tid: 0x{1:x}".format(os.getpid(), threading.current_thread().ident))
start_time = time.time()
logger.debug('using ui data from glade file: ' + gui_utilities.which_glade())
try:
app = application.KingPhisherClientApplication(config_file=config_file)
except Exception as error:
logger.critical("ititialization error: {0} ({1})".format(error.__class__.__name__, getattr(error, 'message', 'n/a')))
color.print_error('failed to initialize the King Phisher client')
return 0
logger.debug("client loaded in {0:.2f} seconds".format(time.time() - start_time))
GObject.threads_init()
return app.run([])
if __name__ == '__main__':
sys.exit(main())