snmpenum.pl Not Working on Kali Linux

Recently I was asked by someone to help figure out why snmpenum.pl was not working on Kali Linux.  Though the solution was simple, it took more time than it should have to get there.

Note: snmpenum.pl can be downloaded directly using the following link – http://dl.packetstormsecurity.net/UNIX/scanners/snmpenum.zip

snmpenum.pl is a tool to enumerate SNMP information on any host with an open SNMP port (usually UDP 161).  For it to work, you need to specify, in order, the IP of the host you want to enumerate, the community string to use, and the name or full path to a tab delimited file containing the following information:

<Type of host, ex: Cisco>   <Name of Enumeration Item>   <MIB.in.dotted.decimal.notation>

Here are the contents of the example file for Linux hosts that comes with snmpenum.pl:

Linux   RUNNING PROCESSES       1.3.6.1.2.1.25.4.2.1.2
Linux   SYSTEM INFO             1.3.6.1.2.1.1.1
Linux   HOSTNAME                1.3.6.1.2.1.1.5
Linux   UPTIME                  1.3.6.1.2.1.1.3
Linux   MOUNTPOINTS             1.3.6.1.2.1.25.2.3.1.3
Linux   RUNNING SOFTWARE PATHS  1.3.6.1.2.1.25.4.2.1.4
Linux   LISTENING UDP PORTS     1.3.6.1.2.1.7.5.1.2.0.0.0.0
Linux   LISTENING TCP PORTS     1.3.6.1.2.1.6.13.1.3.0.0.0.0

Now the specific error we were getting was as follows:

root@kali:~/tmp# perl snmpenum.pl 192.168.1.1 public linux.txt 


----------------------------------------
    UPTIME
----------------------------------------

" is expected in dotted decimal notation..1.2.1.1.3

For some reason or another it was not liking the MIB, stating it was not in dotted decimal notation.  After (too much) troubleshooting and investigating both the snmpenum.pl code as well as the linux.txt file, I realized that the linux.txt file was in Windows/DOS format, containing CRLF (carriage return, line feed) line terminators.

root@kali:~/tmp# file linux.txt 
linux.txt: ASCII text, with CRLF line terminators

CRLF line termination characters cause issues when used on Linux (http://en.wikipedia.org/wiki/Newline).  Linux only uses LF to signify a new line, so it treats the CR character as an actual character in the file, and in this case, causes a character to be added to the end of the MIB, in turn making the MIB not in dotted decimal notation.

The quick fix was to use the dos2unix tool on the file to remove the Windows line termination characters and replace them with *nix line termination characters.  After this, we were able to run snmpenum.pl without any issues.

# If the tool is not already installed:
apt-get update && apt-get install dos2unix

# Then run
root@kali:~/tmp# dos2unix linux.txt 
dos2unix: converting file linux.txt to Unix format ...

root@kali:~/tmp# file linux.txt 
linux.txt: ASCII text