• Home
  • Become a Hacker
    • Get Started
    • Hacker Mindset
    • Roadmap
    • Simple Setup – Hacker 101
    • Types of Hackers
    • Recommended Courses
  • Boot People Offline
  • Courses
    • All Hacking Courses
    • Cyber Security School
  • CTF
    • Beginners to Advanced Guide
    • Create your own CTF box
    • Field and Resources Guide
    • Platforms & Wargames
    • Tools Used for Solving CTF
    • Writeups
  • Dark Web
    • Beginners Guide
    • Darknet Markets
    • Darkweb 101 (Anonymity Guide)
    • Dark Web OSINT Tools
    • Hacking Forums
    • Latest News
    • Onion Links
  • Hacker Gadgets
  • Hacking Books
  • Tools Directory
Menu
  • Home
  • Become a Hacker
    • Get Started
    • Hacker Mindset
    • Roadmap
    • Simple Setup – Hacker 101
    • Types of Hackers
    • Recommended Courses
  • Boot People Offline
  • Courses
    • All Hacking Courses
    • Cyber Security School
  • CTF
    • Beginners to Advanced Guide
    • Create your own CTF box
    • Field and Resources Guide
    • Platforms & Wargames
    • Tools Used for Solving CTF
    • Writeups
  • Dark Web
    • Beginners Guide
    • Darknet Markets
    • Darkweb 101 (Anonymity Guide)
    • Dark Web OSINT Tools
    • Hacking Forums
    • Latest News
    • Onion Links
  • Hacker Gadgets
  • Hacking Books
  • Tools Directory
Search
Close
  • Home
  • 2021
  • January
  • 16
  • Ssh-Mitm – Ssh Mitm Server For Security Audits Supporting Public Key Authentication, Session Hijacking And File Manipulation

Ssh-Mitm – Ssh Mitm Server For Security Audits Supporting Public Key Authentication, Session Hijacking And File Manipulation

January 16, 2021 Comments Off on Ssh-Mitm – Ssh Mitm Server For Security Audits Supporting Public Key Authentication, Session Hijacking And File Manipulation
Ssh-Mitm - Ssh Mitm Server For Security Audits Supporting Public Key Authentication, Session Hijacking And File Manipulation cybersecurity ethical hacking hack android hack app hack wordpress hacker news hacking hacking tools for windows keylogger kit kitploit password brute force penetration testing pentest pentest android pentest linux pentest toolkit pentest tools spy tool kit spyware tools

ssh-mitm is an intercepting (mitm) proxy server for security audits.

  • Redirect/mirror Shell to another ssh client supported in 0.2.8
  • Replace File in SCP supported in 0.2.6
  • Replace File in SFTP supported in 0.2.3
  • Transparent proxy support in 0.2.2! – intercepting traffic to other hosts is now possible when using arp spoofing or proxy is used as gateway.
  • Since release 0.2.0, SSH Proxy Server has full support for tty (shell), scp and sftp!
do not use this library in production environments! This tool is only for security audits!

Installation

pip install ssh-mitm

Start Proxy Server

Password authentication

Start the server:

ssh-mitm --remote-host 127.0.0.1

Connect to server:

ssh -p 10022 [email protected]

Public key authentication

When public key authentication is used, the agent is forwarded to the remote server.

Start the server:

ssh-mitm --forward-agent --remote-host 127.0.0.1

Connect to server:

ssh -A -p 10022 [email protected]

SSH MITM Attacks

SSH uses trust on first use. This means, that you have to accept the fingerprint if it is not known.

$ ssh -p 10022 [email protected]
The authenticity of host '[localhost]:10022 ([127.0.0.1]:10022)' can't be established.
RSA key fingerprint is SHA256:GIAALZgy8Z86Sezld13ZM74HGbE9HbWjG6T9nzja/D8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[localhost]:10022' (RSA) to the list of known hosts.

If a server fingerprint is known, ssh warns the user, that the host identification has changed.

$ ssh -p 10022 [email protected]
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
SHA256:GIAALZgy8Z86Sezld13ZM74HGbE9HbWjG6T9nzja/D8.
Please contact your system administrator.
Add correct host key in /home/user/.ssh/known_hosts to get rid of this message.
Offending RSA key in /home/user/.ssh/known_hosts:22
remove with:
ssh-keygen -f "/home/user/.ssh/known_hosts" -R "[localhost]:10022"
RSA host key for [localhost]:10022 has changed and you have requested strict checking.
Host key verification failed.

If the victim accepts the (new) fingerprint, then the session can be intercepted.

Use-Case: Honey Pot

When ssh proxy server is used as a honey pot, attackers will accept the fingerprint, because he wants to attack this machine. An attacker also does not know if the fingerprint is correct and if the key has changed, perhaps it the server was reinstalled and a new keypair was generated.

User-Case: Security Audit

When trying to figure out the communication schematics of an application, intercepting ssh can be an invaluable tool.

For example, if you have an application, which connects to you local router via ssh, to configure the device, you can intercept those connections, if the application does not know the fingerprint and accepts it on first use.

If the application knows the fingerprint, then the same host key is used on every device. In this case, you have a good chance to extract the host key from a firmware updated and use it to trick the application.

Use-Case: Transparent Proxy

When the ssh proxy server needs to monitor general ssh communication in a network the transparent feature can be used.

To setup this feature correctly and intercept ssh traffic to multiple different hosts traffic needs to be routed through the ssh proxy server.

SSH packets that need to be audited can now be transparently processed and forwarded by the ssh proxy server making use of the TPROXY feature of the linux kernel.

For example, when traffic is routed through a CentOS 7 machine following configuration can be used:

With iptables

iptables -t mangle -A PREROUTING -p tcp --dport 22 -j TPROXY --tproxy-mark 0x1/0x1 --on-port=10022 --on-ip=127.0.0.1

# Saving the configuration permanently
yum install -y iptables-services
systemctl enable iptables
iptables-save > /etc/sysconfig/iptables
systemctl start iptables

With firewalld

# Making use of directly and permanently adding a rule to the iptables table
firewall-cmd --direct --permanent --add-rule ipv4 mangle PREROUTING 1 -p tcp --dport 22 --j TPROXY --tproxy-mark 0x1/0x1 --on-port=10022 --on-ip=127.0.0.1

:information: additional firewall rules may be necessary to maintain device management capabilities over ssh

To process the packets locally further routing needs to take place:

echo 100 tproxy >> /etc/iproute2/rt_tables
ip rule add fwmark 1 lookup tproxy
ip route add local 0.0.0.0/0 dev lo table tproxy

# Setting routes and policies persistent
echo 'from all fwmark 0x1 lookup tproxy' >> /etc/sysconfig/network-scripts/rule-lo
echo 'local default dev lo scope host table tproxy' >> /etc/sysconfig/network-scripts/route-lo

Now only the ssh proxy server needs to be started in transparent mode to be able to handle sockets that do not have local addresses:

ssh-mitm --transparent

https://powerdns.org/tproxydoc/tproxy.md.html

Available modules

The proxy can be configured and extended using command line arguments.

Some arguments accept Python-class names as string.

Loading a class from a package:

ssh-mitm --ssh-interface ssh_proxy_server.forwarders.ssh.SSHForwarder

⚠️

creating a pip package for custom classes is recommended, because loading from files has some bugs at the moment

Loading a class from a file (experimental):

ssh-mitm --ssh-interface /path/to/my/file.py:ExtendedSSHForwarder

SSH interface

  • cmd argument: --ssh-interface
  • base class: ssh_proxy_server.forwarders.ssh.SSHBaseForwarder
  • default: ssh_proxy_server.forwarders.ssh.SSHForwarder

Available forwarders:

  • ssh_proxy_server.forwarders.ssh.SSHForwarder – forwards traffic from client to remote server
  • ssh_proxy_server.plugins.ssh.sessionlogger.SSHLogForwarder – write the session to a file, which can be replayed with script
  • ssh_proxy_server.plugins.ssh.noshell.NoShellForwarder – keeps the session open, when used as master channel, but tty should not be possible to the remote server
  • ssh_proxy_server.plugins.ssh.mirrorshell.SSHMirrorForwarder – Mirror ssh session to another ssh client
  • ssh_proxy_server.plugins.ssh.injectorshell.SSHInjectableForwarder – Creates injection shells for listening on and writing to a ssh session

SCP interface

  • cmd argument: --scp-interface
  • base class: ssh_proxy_server.forwarders.scp.SCPBaseForwarder
  • default: ssh_proxy_server.forwarders.scp.SCPForwarder

Available forwarders:

  • ssh_proxy_server.forwarders.scp.SCPForwarder – transfer file between client and server
  • ssh_proxy_server.plugins.scp.store_file.SCPStorageForwarder – save file to file system
  • ssh_proxy_server.plugins.scp.replace_file.SCPReplaceFile – replace transfered file with another file

SFTP Handler

  • cmd argument: --sftp-handler
  • base class: ssh_proxy_server.forwarders.sftp.SFTPHandlerBasePlugin
  • default: ssh_proxy_server.forwarders.sftp.SFTPHandlerPlugin

Available forwarders:

  • ssh_proxy_server.forwarders.sftp.SFTPHandlerPlugin – transfer file between client and server
  • ssh_proxy_server.plugins.sftp.store_file.SFTPHandlerStoragePlugin – save file to file system
  • ssh_proxy_server.plugins.sftp_replace.SFTPProxyReplaceHandler – replace transfered file with another file

Authentication:

  • cmd argument: --authenticator
  • base class: ssh_proxy_server.authentication.Authenticator
  • default: ssh_proxy_server.authentication.AuthenticatorPassThrough

Available Authenticators:

  • ssh_proxy_server.authentication.AuthenticatorPassThrough – default authenticator, which can reuse credentials

Currently, only one authenticator (AuthenticatorPassThrough) exists, but it supports arguments to specify remote host, username and password, which shlould fit most scenarios. (public keys are on the roadmap)

Authors

  • Manfred Kaiser
  • Simon Böhm
Download Ssh-Mitm

Post navigation

Windows 10 NTFS file system has a vulnerability
safety v1.10.3 releases: checks your installed dependencies for known security vulnerabilities

Related Articles

Fake-Sms - A Simple Command Line Tool Using Which You Can Skip Phone Number Based SMS Verification By Using A Temporary Phone Number That Acts Like A Proxy

Fake-Sms – A Simple Command Line Tool Using Which You Can Skip Phone Number Based SMS Verification By Using A Temporary Phone Number That Acts Like A Proxy

- Hack Tools
March 2, 2021
OWASP ASST (Automated Software Security Toolkit) - A Novel Open Source Web Security Scanner

OWASP ASST (Automated Software Security Toolkit) – A Novel Open Source Web Security Scanner

- Hack Tools
March 2, 2021
URLs Deduplication Tool

uddup: URLs Deduplication Tool

- Hack Tools
March 2, 2021
hacker gadgets
hacker phone covers

Recent Posts

Fake-Sms - A Simple Command Line Tool Using Which You Can Skip Phone Number Based SMS Verification By Using A Temporary Phone Number That Acts Like A Proxy

Fake-Sms – A Simple Command Line Tool Using Which You Can Skip Phone Number Based SMS Verification By Using A Temporary Phone Number That Acts Like A Proxy

March 2, 2021
OWASP ASST (Automated Software Security Toolkit) - A Novel Open Source Web Security Scanner

OWASP ASST (Automated Software Security Toolkit) – A Novel Open Source Web Security Scanner

March 2, 2021
CVE-2020-1938: Apache Tomcat AJP Connector Remote Code Execution Vulnerability Alert

CVE-2021-25329: Apache Tomcat session code execution vulnerability alert

March 2, 2021
URLs Deduplication Tool

uddup: URLs Deduplication Tool

March 2, 2021
SnitchDNS

SnitchDNS: Database Driven DNS Server

March 2, 2021
Halogen - Automatically Create YARA Rules From Malicious Documents

Halogen – Automatically Create YARA Rules From Malicious Documents

March 1, 2021

Social Media Hacking

SocialPath – Track users across Social Media Platforms

SocialPath – Track users across Social Media Platforms

- Social Media Hacking
October 16, 2019October 16, 2019

SocialPath is a django application for gathering social media intelligence on specific username. It checks for Twitter, Instagram, Facebook, Reddit...

SocialScan – Check Email Address and Username Availability on Online Platforms

SocialScan – Check Email Address and Username Availability on Online Platforms

June 17, 2019
Shellphish – Phishing Tool For 18 Social Media Apps

Shellphish – Phishing Tool For 18 Social Media Apps

June 10, 2019July 27, 2019
WhatsApp Hacking using QRLJacking

WhatsApp Hacking using QRLJacking

May 2, 2019May 19, 2019
How to Hack any Facebook Account with Z-Shadow

How to Hack any Facebook Account with Z-Shadow

April 26, 2019June 29, 2020
hacker buffs
ABOUT US

Haxf4rall is a collective, a good starting point and provides a variety of quality material for cyber security professionals.

Our primary focus revolves around the latest tools released in the Infosec community and provide a platform for developers to showcase their skillset and current projects.

COMPANY
  • Contact Us
  • Disclaimer
  • Hacker Gadgets
  • LANC Remastered
  • PCPS IP Puller
  • Privacy Policy
  • Sitemap
  • Submit your Tool
Menu
  • Contact Us
  • Disclaimer
  • Hacker Gadgets
  • LANC Remastered
  • PCPS IP Puller
  • Privacy Policy
  • Sitemap
  • Submit your Tool
Live Chat
RESOURCES
  • Attack Process
  • Become a Hacker
  • Career Pathways
  • Dark Web
  • Hacking Books
  • Practice Your Skills
  • Recommended Courses
  • Simple Setup – Hacker 101
Menu
  • Attack Process
  • Become a Hacker
  • Career Pathways
  • Dark Web
  • Hacking Books
  • Practice Your Skills
  • Recommended Courses
  • Simple Setup – Hacker 101
Get Started
TOOLBOX
  • Anonymity
  • Bruteforce
  • DoS – Denial of Service
  • Information Gathering
  • Phishing
  • SQL Injection
  • Vulnerability Scanners
  • Wifi Hacking
Menu
  • Anonymity
  • Bruteforce
  • DoS – Denial of Service
  • Information Gathering
  • Phishing
  • SQL Injection
  • Vulnerability Scanners
  • Wifi Hacking
Tools Directory

2014 – 2020 | Haxf4rall.com               Stay Connected:

Facebook
Twitter
Google-plus
Wordpress
Please wait...

Join Our Community

Subscribe now and get your free HACKERS HANDBOOK

Don't Worry ! You will not be spammed
SIGN UP FOR NEWSLETTER NOW