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 184.108.40.206.220.127.116.11.2.1.2 Linux SYSTEM INFO 18.104.22.168.22.214.171.124 Linux HOSTNAME 126.96.36.199.188.8.131.52 Linux UPTIME 184.108.40.206.220.127.116.11 Linux MOUNTPOINTS 18.104.22.168.22.214.171.124.3.1.3 Linux RUNNING SOFTWARE PATHS 126.96.36.199.188.8.131.52.2.1.4 Linux LISTENING UDP PORTS 184.108.40.206.220.127.116.11.18.104.22.168.0.0 Linux LISTENING TCP PORTS 22.214.171.124.126.96.36.199.188.8.131.52.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..184.108.40.206.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