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

 

How To: Configure Synergy Server as a systemd Service in Linux (Fedora 20)

After I got my desktop up and running full time, I decided that I wanted to use it as my Synergy server instead of as a Synergy client (see here for how to setup as a client).  If you would like to learn more about what Synergy is then you can visit my previous post here or you can visit the Synergy website.

TABLE OF CONTENTS:

  1. DIRECTIONS
    1. Install and Configure Synergy Server
    2. Verify systemd User Instance is Running
    3. Create systemd user service for synergys
    4. Create synergys.desktop Autostart File
  2. Wrapping Up
  3. References

DIRECTIONS

The following directions were verified to work on my Fedora 20 64-bit system.  Hopefully your experience will be the same, though your mileage may vary.  I cannot guarantee exactly what will happen with your system, and I take no responsibility for any issues this causes.  Follow these at your own risk.

If you do not understand what a certain command or component might be doing, then I suggest you research it to fully understand what changes you are making to your system.

Install and Configure Synergy Server

If you don’t have it already, you’re going to need to download and install Synergy.

  1. Download — Go to http://synergy-project.org/download/?list and grab the appropriate file for your version of Linux.  In my case with Fedora 20 64-bit, http://synergy-project.org/download/?file=synergy-1.5.0-r2278-Linux-x86_64.rpm.  Or via command line:
    $ wget http://synergy-project.org/download/?file=synergy-1.5.0-r2278-Linux-x86_64.rpm
  2. Install — Go to where you downloaded the file, and install it.
    $ cd ~/Downloads/
    $ sudo yum -y localinstall synergy-1.5.0-r2278-Linux-x86_64.rpm
  3. Get a working configuration — Open the Synergy GUI (in command line type: synergy) and edit your settings so Synergy clients can successfully connect to this system (your Synergy server).  Verify you can swipe your mouse over to one of the clients and use the mouse and keyboard on that system correctly.
  4. Copy the command used by synergys to run your server — Run the following command and look for the line that starts with /usr/bin/synergys:
    $ ps -eo command | grep -v grep | grep synergys

    Note: The line should look something like
    /usr/bin/synergys -f –no-tray –debug INFO –name YourHostName -c /tmp/<tmpFileName> –address :24800
    Note: If you use synergy’s built-in encryption then the option –crypto-pass <yourPasswordHash> will also be present. Example:
    /usr/bin/synergys -f –no-tray –debug INFO –name YourHostName –crypto-pass <passHashHere> -c /tmp/<tmpFileName> –address :24800

  5. Click ‘File’, then click ‘Save configuration as…’ and choose a location and name to save your file (ex: /home/yourUser/.synergy.conf)
  6. Now stop synergy and close it.

Verify systemd User Instance is Running

We just need to check that your systemd user instance is starting on boot.  This should be the default action of your system.

  1. Find your userid — At the command line type the following command, and look for “uid=####(username)”, where #### is any number, most likely 1000 (doesn’t have to be 1000, whatever is there is your userid).
    $ id
  2. Make sure a sytemd user instance has been created for your user
    $ sudo systemctl status user@####.service

Create systemd user service for synergys

Now we need to create the synergys.service file to use for our systemd user instance.  Creating this service will cause the synergys service to start once you log in to your system.

  1. Create appropriate directory
    $ mkdir -p ~/.config/systemd/user
  2. Using your favorite text editor, create the file ~/.config/systemd/user/synergys.serviceTo understand what any of the switches in the synergys commmand do, run ‘synergys –help’ from a command line.Copy and paste the following config into the file. In the ExecStart= line, put the entire command you found above.  If you would like to have synergys log to a specific file (instead of logging to the default journald log), add the -l option after the -d option (ex: -l /path/to/log-file/writeable/by/your/user). Also make sure to specify the Synergy configuration file you saved earlier with the -c option (place it after the –crypto-pass option).Note:  In the config below I replaced the long options with their respective short options.  For example, I replaced –name with -n.
    [Unit]
    Description=Synergy server service
    After=display-manager.service
    
    [Service]
    ExecStart=/usr/bin/synergys -f -d INFO -n pcName --crypto-pass passwordHashHere -c /home/yourUser/.synergy.conf -a :24800
    Restart=on-failure
    
    [Install]
    WantedBy=graphical.target
  3. Save your file.
  4. Make your user instance aware of the service, and verify you can start, restart, and stop it:
    $ systemctl --user daemon-reload
    $ systemctl --user start synergys.service
    $ systemctl --user restart synergys.service
    $ systemctl --user stop synergys.service

Create synergys.desktop Autostart File

Now we need to create our synergys.desktop file, which will run once we log in to our system.

  1. Create the file ~/.config/autostart/synergys.desktop
  2. Copy and paste the config below into the file, then save your file.
    [Desktop Entry]
    Name=Synergys
    GenericName=Software KVM
    Comment=Share your keyboard and mouse over a network
    Exec=systemctl --user start synergys.service
    Terminal=false
    Type=Application
    Icon=/usr/share/icons/synergy.ico
    Categories=Utility
    StartupNotify=true
    X-GNOME-Autostart-enabled=true

Wrapping Up

You should now be able to reboot your system, log in, and then use your mouse and keyboard to control your Synergy clients.  Please see the references below which helped me to create this guide.  If you have any questions or comments, leave them below!

References