|
1 |
| -import logging |
2 | 1 | import sys
|
3 |
| -import os |
4 |
| - |
5 |
| -from paramiko import Transport |
6 |
| - |
7 |
| -from ssh_proxy_server.server import SSHProxyServer |
8 |
| - |
9 |
| -from ssh_proxy_server.authentication import ( |
10 |
| - AuthenticatorPassThrough, |
11 |
| - validate_remote_host, |
12 |
| - validate_honeypot |
13 |
| -) |
14 |
| -from ssh_proxy_server.interfaces import ServerInterface |
15 |
| -from ssh_proxy_server.plugins.scp.store_file import SCPStorageForwarder |
16 |
| -from ssh_proxy_server.plugins.sftp.store_file import SFTPHandlerStoragePlugin |
17 |
| - |
18 |
| -from ssh_proxy_server.interfaces.sftp import SFTPProxyServerInterface |
19 |
| - |
20 |
| -from ssh_proxy_server.forwarders.tunnel import ( |
21 |
| - ClientTunnelForwarder, |
22 |
| - ServerTunnelForwarder, |
23 |
| -) |
24 |
| - |
25 |
| -from ssh_proxy_server.workarounds import dropbear |
26 |
| -from ssh_proxy_server.plugins.ssh.mirrorshell import SSHMirrorForwarder |
27 |
| -from ssh_proxy_server.__version__ import version as ssh_mitm_version |
28 |
| - |
29 |
| -try: |
30 |
| - from gooey import Gooey, GooeyParser |
31 |
| -except ImportError: |
32 |
| - def Gooey(*args, **kwargs): |
33 |
| - def wrapper(func): |
34 |
| - if os.environ.get('APPIMAGE', None): |
35 |
| - print("SSH-MITM GUI not available from an AppImage!") |
36 |
| - print("Please install SSH-MITM with pip:\n pip install ssh-mitm[gui]") |
37 |
| - print("You can also install SSH-MITM as Snap:\n snap install ssh-mitm") |
38 |
| - else: |
39 |
| - logging.error("Gooey not installed! Please install it with: pip install Gooey") |
40 |
| - sys.exit(1) |
41 |
| - return wrapper |
42 |
| - |
43 |
| - |
44 |
| -@Gooey( |
45 |
| - program_name=f'SSH-MITM {ssh_mitm_version}', |
46 |
| - program_description='ssh audits made simple', |
47 |
| - tabbed_groups=True, |
48 |
| - optional_cols=1, |
49 |
| - default_size=(550, 670), |
50 |
| - richtext_controls=True, |
51 |
| - clear_before_run=True, |
52 |
| - menu=[{ |
53 |
| - 'name': 'Help', |
54 |
| - 'items': [ |
55 |
| - { |
56 |
| - 'type': 'Link', |
57 |
| - 'menuTitle': 'Documentation', |
58 |
| - 'url': 'https://docs.ssh-mitm.at' |
59 |
| - },{ |
60 |
| - 'type': 'Link', |
61 |
| - 'menuTitle': 'Report an issue', |
62 |
| - 'url': 'https://github.com/ssh-mitm/ssh-mitm/issues' |
63 |
| - },{ |
64 |
| - 'type': 'AboutDialog', |
65 |
| - 'menuTitle': 'About', |
66 |
| - 'name': 'SSH-MITM', |
67 |
| - 'description': 'ssh audits made simple', |
68 |
| - 'version': ssh_mitm_version, |
69 |
| - 'website': 'https://www.ssh-mitm.at', |
70 |
| - 'developer': 'https://github.com/ssh-mitm/ssh-mitm', |
71 |
| - 'license': 'LGPL-3.0 License ' |
72 |
| - } |
73 |
| - ] |
74 |
| - }] |
75 |
| -) |
76 | 2 | def main():
|
77 |
| - logging.basicConfig(format='%(message)s', level=logging.INFO) |
78 |
| - logging.getLogger("paramiko").setLevel(logging.WARNING) |
79 |
| - |
80 |
| - |
81 |
| - parser = GooeyParser(description='SSH Proxy Server') |
82 |
| - |
83 |
| - remotehostsettings = parser.add_argument_group("Connection settings") |
84 |
| - remotehostsettings.add_argument( |
85 |
| - '--listen-port', |
86 |
| - metavar='listen port', |
87 |
| - dest='listen_port', |
88 |
| - default=10022, |
89 |
| - type=int, |
90 |
| - help='listen port (default 10022)' |
91 |
| - ) |
92 |
| - remotehostsettings.add_argument( |
93 |
| - '--remote-host', |
94 |
| - dest='remote_host', |
95 |
| - default='127.0.0.1:22', |
96 |
| - type=validate_remote_host, |
97 |
| - metavar='remote host and port', |
98 |
| - help='remote host to connect to (default 127.0.0.1:22)' |
99 |
| - ) |
100 |
| - remotehostsettings.add_argument( |
101 |
| - '--host-key', |
102 |
| - metavar='host key file (optional)', |
103 |
| - dest='host_key', |
104 |
| - help='host key file, if not provided a temorary key will be generated', |
105 |
| - widget="FileChooser" |
106 |
| - ) |
107 |
| - remotehostsettings.add_argument( |
108 |
| - '--hide-credentials', |
109 |
| - dest='auth_hide_credentials', |
110 |
| - metavar='hide credentials', |
111 |
| - action='store_true', |
112 |
| - help='do not log credentials (usefull for presentations)' |
113 |
| - ) |
114 |
| - |
115 |
| - logsettings = parser.add_argument_group("Logging") |
116 |
| - logsettings.add_argument( |
117 |
| - '--session-log-dir', |
118 |
| - metavar='terminal session logdir (optional)', |
119 |
| - dest='ssh_log_dir', |
120 |
| - help='directory to store ssh session logs', |
121 |
| - widget="DirChooser" |
122 |
| - ) |
123 |
| - logsettings.add_argument( |
124 |
| - '--store-ssh-session', |
125 |
| - metavar='save terminal session log', |
126 |
| - dest='store_ssh_session', |
127 |
| - action='store_true', |
128 |
| - help='this options stores terminal sessions in a scriptreplay compatible format' |
129 |
| - ) |
130 |
| - logsettings.add_argument( |
131 |
| - '--store-scp-files', |
132 |
| - metavar='store SCP file transfers', |
133 |
| - dest='store_scp_files', |
134 |
| - action='store_true', |
135 |
| - help='store files from scp' |
136 |
| - ) |
137 |
| - logsettings.add_argument( |
138 |
| - '--store-sftp-files', |
139 |
| - dest='store SFTP file transfers', |
140 |
| - action='store_true', |
141 |
| - help='store files from sftp' |
142 |
| - ) |
143 |
| - |
144 |
| - honeypotsettings = parser.add_argument_group( |
145 |
| - "Honeypot", |
146 |
| - description="\n".join([ |
147 |
| - 'SSH-MITM is able to check if a user is allowed to login with public key', |
148 |
| - 'authentication to a remote host, but due to a missing forwarded agent,', |
149 |
| - 'authentication to the remote host is not possible.', |
150 |
| - 'Those connections can be redirected to a honeypot.' |
151 |
| - ]) |
152 |
| - ) |
153 |
| - honeypotsettings.add_argument( |
154 |
| - '--fallback-host', |
155 |
| - dest='fallback_host', |
156 |
| - type=validate_honeypot, |
157 |
| - metavar='Honeypot-Host (optional)', |
158 |
| - help='format: username:password@hostname:port' |
159 |
| - ) |
160 |
| - |
161 |
| - args = parser.parse_args() |
162 |
| - |
163 |
| - Transport.run = dropbear.transport_run |
164 |
| - |
165 |
| - SSHProxyServer( |
166 |
| - args.listen_port, |
167 |
| - key_file=args.host_key, |
168 |
| - ssh_interface=SSHMirrorForwarder, |
169 |
| - scp_interface=SCPStorageForwarder, |
170 |
| - sftp_interface=SFTPProxyServerInterface, |
171 |
| - sftp_handler=SFTPHandlerStoragePlugin, |
172 |
| - server_tunnel_interface=ServerTunnelForwarder, |
173 |
| - client_tunnel_interface=ClientTunnelForwarder, |
174 |
| - authentication_interface=ServerInterface, |
175 |
| - authenticator=AuthenticatorPassThrough, |
176 |
| - transparent=False, |
177 |
| - args=args |
178 |
| - ).start() |
| 3 | + print("GUI not implemented!") |
| 4 | + sys.exit(1) |
179 | 5 |
|
180 | 6 |
|
181 | 7 | if __name__ == '__main__':
|
|
0 commit comments