28 Oct 2010

Compiling Jpcap on 64-bit Ubuntu 10.10

Why?

While learning more about clojure, I wanted to do some network sniffing. Following a guide to raw traffic in clojure I needed to install jpcap in order to use libpcap from java.

Jpcap doesn’t provide a 64-bit version so I had to compile my own. Here’s the documentation of how I did it. A patch is provided at the end of the post.

Compiling jpcap 0.7 on 64-bit Ubuntu 10.10

  1. First install sun java on ubuntu 10.10

  2. Download jpcap or use the following command:

    wget http://netresearch.ics.uci.edu/kfujii/Jpcap/jpcap-0.7.tar.gz
    

  3. Untar jpcap

    tar -xvf jpcap-0.7.tar.gz
    

  4. Move into src directory

    cd jpcap-0.7/src/c/
    

  5. Open up Makefile in your favorite editor (mine’s emacs)

    emacs Makefile
    

  6. Change this line:

    JAVA_DIR = $(JAVA_HOME)
    

To This:

JAVA_DIR = /usr/lib/jvm/java-6-sun/

  1. Change the compile options from this:
    COMPILE_OPTION = -shared -L.
    

To this:

COMPILE_OPTION = -shared -L. -fPIC

  1. Save your file and close your editor.

  2. Run make:

    make
    

  3. Follow the jpcap installation instructions

Patch for more advanced users

Patch to do this automatically

How to patch

Let me know if you have any problems!

27 Oct 2010

Redirecting a Folder to HTTPS with Apache's Config on Ubuntu

I found some information about how to do this on the web, but everything I saw talked about using an .htaccess file. I didn’t want to use an .htaccess file.

Here’s what I had to do in Ubuntu (this was on an old 8.10 server).

  1. Enabled mod_rewrite:

      sudo a2enmod rewrite
      

  2. Add the following in the VirtualHost section of my regular http setup to my config at /etc/apache2/sites-enabled/ :

      RewriteEngine On
      RewriteCond %{SERVER_PORT} 80
      RewriteCond %{REQUEST_URI} ^/foldername/.*
      RewriteRule ^(.*)$ https://host.name.com$1 [R,L]
      

  3. Restart Apache:

      sudo service apache2 restart
      

Make sure if you use this to change foldername to the name of the folder where you want to enforce HTTPS and host.name.com to the name of your host.

22 Oct 2010

Configuring Linux Bridge to Act as a Hub

So after struggling for a while with this, the answer is surprisingly simple.

For a bridge that you've created with brctl, you can use this simple command:

brctl setageing <bridgename> 0

This command tells Linux to forget every MAC address that it sees on
the bridge, making it act as a hub.

Here's the source.

Adam Doupé's Space

Computer Security PhD Student at UCSB, specializing in Web Application Security.

Academic homepage
Twitter account
LinkedIn Profile

Previously worked at Microsoft for a year.

Feel free to email me adamdoupe@gmail.com