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

 

12 Replies to “snmpenum.pl Not Working on Kali Linux”

    1. Yes, if it’s the same error then you can use dos2unix on the windows.txt file. You can verify the windows.txt file is in Windows format by running the “file” command on it:

      $ file test.txt
      test.txt: ASCII text, with CRLF line terminators

      The “CRLF” line terminators is the indicator it is in “Windows” format.

      1. i leeave a replay but is dissipier. first thanks for above reply.
        i have one question similar to this. when i compile exploit in kali with gcc output file is full of strange characters so can i remove them all ath once is there any way to repair that. when i type locale in terminal locat is utf-8 us en. so maybe you can help

        1. What do you mean by strange characters? And how are you trying to read the file? When you compile a program, whether it is an exploit or any other program, it turns it into machine code so that the computer will understand what to do with it once it is run. The binary will not look like the source code file, it won’t be easily human readable.

  1. Hi,
    I just installed Kali and I’m missing the snmpenum.pl
    Well I downloaded the script who commes with some .txt files
    Where should I copy snmpenum.pl and the txt files ? in which path should I “paste” them? together ?

    1. You could technically put them anywhere, and call it by running “perl /path/to/where/it/is/snmpenum.pl”. If you want to move them to locations on the system so that it is similar to how many of the other programs are setup then follow the directions below. But before doing that, I suggest you run “dos2unix” on snmpenum.pl and all of the files that come with it.

      dos2unix cisco.txt
      dos2unix linux.txt
      dos2unix windows.txt
      dos2unix README.txt
      dos2unix snmpenum.pl

      Change the first line in snmpenum.pl to look like this:
      #! /usr/bin/perl -w

      Then do:
      chmod +x snmpenum.pl
      mv snmpenum.pl /usr/bin/

      Next:
      mkdir /usr/share/snmpenum/
      mv cisco.txt /usr/share/snmpenum/
      mv linux.txt /usr/share/snmpenum/
      mv windows.txt /usr/share/snmpenum/
      mv README.txt /usr/share/snmpenum/

      At this point you should be able to simply call it by running:
      snmpenum.pl

      Or a full command example:
      snmpenum.pl 192.168.1.1 testcommunity /usr/share/snmpenum/linux.txt

  2. Thank you, works fine !
    One last question (little long):
    I red that (in backtrack r3) I have to, eventually compile the code .. and proceed this way.

    # prepare-kernel-sources
    # cd /usr/src/linux
    # cp -rf include/generated/* inclide/linux

    But:
    # prepare-kernel-sources doesn’t work in Kali (is it needed ?) , but I found the files into
    include/linux.version.h
    usr/src/inux-headers-4.4.0-kali1-amd64/included/generated/utsrelease.h
    scripts/checksyscalls.sh can’t “locate” this file

    what are those files ?

    What I done to get them is:

    apt-get install linux-headers-$(uname -r)
    apt-get install linux-source-4.5

    what gives me:

    linux-headers-4.4.0-kali1-amd64
    linux-headers-4.4.0-kali1-common
    linux-config-4.5
    linux-kbuild-4.4 -> ../lib/linux-kbuild-4.4

    How should I manage to get this properly ? In the right path ?
    I only want to have a proper start-installation before getting deeply into Kali.

    Thank in advance

    1. Hi Tome,

      Would you mind adding some more details for me, please?

      1) What program are you trying to compile?
      2) If you are following a specific guide, could you paste it here.
      2) What command did you run to get the output?

      These will help me give a better answer, thanks!

  3. I’m not compiling any program (the guide says that I should do this in case …), I follow the backtrack 5 cookbook that I borrowed (I didn’t knew that meanwhile backtrack has became Kali). But obviously not the same steps are needed.

    how do I get this output ?

    To replace “prepare kernel sources” I’ve done:
    apt-get install linux-headers-$(uname -r)
    apt-get install linux-source-4.5

    what gives me those directory’s.

    linux-headers-4.4.0-kali1-amd64
    linux-headers-4.4.0-kali1-common
    linux-config-4.5
    linux-kbuild-4.4 -> ../lib/linux-kbuild-4.4

    This step is before (2) the installing ATI Video card and (3) configure the network card to get “all traffic” that also didn’t manage do finish correctly but maybe the guide backtrack is not the same for Kali.

    If you can share a link to manage this points I can try to finish the install without annoying 🙂 otherwise I can “clean this out” and follow your advices.

    Thanks

  4. Well maybe I’m asking too much.
    I’ll try to figure it out by my own & google, but not easy shot for a beginner.

    I abandon the idea of “prepare-kernel-sources” I ll concentrate to ATI Vcard & WNIC

    Thank you for snmpenum, clears out some doubts

    1. Hi Tome,

      I’m not sure I understand exactly what you are trying to accomplish with the idea of “prepare-kernel-sources” – is this to install Backtrack/Kali from source, versus installing it directly via the install tool on the live cd?

      I would run ‘apt-get install linux-source’ instead of ‘apt-get install linux-source-4.5’, to make sure you get the version of linux-source that matches the version of the kernel you have installed.

      Any luck with this btw? Sorry I haven’t responded in a while, I must’ve missed the notification email of your reply.

Leave a Reply

Your email address will not be published. Required fields are marked *