Recent Posts

Programming
10 April 2012 6 Comments

Converting a Project from Ant to Maven

Introduction

I recently wanted to convert a number of Java projects from the Ant build system to the Maven build system. Unless you are very familiar with Ant and Maven this is not a trivial task. On this page I describe how I approached the problem, and how I dealt with the inevitable bumps in the road.

Note that the project conversions in this document are pretty much one-on-one. If you have a larger Ant project, you should consider a more modular approach for the resulting Maven projects.

Be sure to keep the Ant documentation and Maven documentation handy!

Analysing the Ant Project

As an example Ant project we look at a loader for the UniProt protein database [license].

We analyze the first two levels of the directory structure with the tree -L 2 command:

~/ant_projects$ tree -L 2
.
├── uniprot-loader
│   ├── build.xml
│   ├── docs
│   ├── etc
│   ├── lib
│   ├── src
│   └── test
└── utils
    ├── bin
    ├── src
    └── xsd
 
10 directories, 1 file

We have two directories, and the project we are after is called uniprot-loader. In the /uniprot-loader directory we see the Ant configuration file…

Linux
10 April 2012 1 Comment

About .bashrc, .profile, .bash_profile and .bash_login

How it works

There are various files that may be executed by the Bash shell when it is started. Usually they follow this logic:

  • When bash is invoked as an interactive login shell:
    1. Bash first reads and executes commands from the file /etc/profile, if that file exists.
    2. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. Usually there is a default ~/.profile file, and ~/.bash_profile and ~/.bash_login usually do not exist.
  • When bash is invoked as an interactive non-login shell:
    1. Bash reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if these files exist.
    2. The standard ~/.profile sources (runs) ~/.bashrc if it exists.

A login shell means a session where you directly log into a system, e.g. setting up a remote SSH session or logging in through a non-graphical text terminal. A non-login shell is then the type of shells you open after logging in: typically in a graphical session when you open a new terminal window.

The bottom line is that you should put customisations that should always be executed in ~/.bashrc!
Example

Example: After installing…

Tags: ,
Networking
25 November 2011 0 Comments

Wireshark: 802.11 Frame Display Filters

Introduction

When using a wireless network card in monitor mode (using airmon-ng), Wireshark will not just pick up Ethernet-level frames, but also the raw wireless 802.11 frames. This data is very interesting, but the volumes can be large: wireless Access Points send out a lot of “beacon frames” that you might want to filter.

In this post we provide a list of the most useful Wireshark display filters for 802.11 frames. Use them in Wireshark in the filter field displayed below.

802.11 Frame Format

The generic 802.11 frame structure is displayed below. Most of the interesting values are in the Frame Control section, because this section determines the type of the frame.

Display Filters

wlan.fc.type == 0           Management frames
wlan.fc.type == 1           Control frames
wlan.fc.type == 2           Data frames
wlan.fc.type_subtype == 0   Association request
wlan.fc.type_subtype == 1   Association response
wlan.fc.type_subtype == 2   Reassociation request
wlan.fc.type_subtype == 3   Reassociation response
wlan.fc.type_subtype == 4   Probe request
wlan.fc.type_subtype == 5   Probe response
wlan.fc.type_subtype == 8   Beacon
 
wlan.addr = 12:34:56:AB:CD:EF  Select frames where any of 

Tags: 802.11, 802.11 frame, , beacon, display filters, fc.type, frame control, pocket reference, subtype, , ,
Linux
22 October 2011 1 Comment

Expand Tabs to Spaces Recursively

If you have a bunch of files with tabs, and you want to replace these tabs with the appropriate amount of spaces then you can use the expand command.

$ expand --tabs=4 stuff.php > stuff.php

With the –tabs switch the tab width is denoted, in spaces. So in this example each tab is replaced with four spaces.

In order to run this command on all PHP files in a directory, including its subdirectories, use this script:

#!/bin/sh
#
# Iteratively replaces tabs in .php files with 4 spaces.
#
 
find . -name "*.php" | while read line
do
  expand --tabs=4 $line > $line.new
  mv $line.new $line
done

Save it to a file and execute it in the directory you want to run the expands:

// Create the file in the current directory
$ touch expand.sh
 
// Use a text-editor like 'nano' to put the script code in the file.
$ nano expand.sh
 
// Make the script executable
$ chmod +x expand.sh
 
// Run the script
$ ./expand.sh

Tags: , expand, , php, spaces, tabs
Security
12 October 2011 0 Comments

Using the RT3090 Chipset in Monitor Mode With Airodump-ng

If you want to monitor or inject wireless traffic with the Ralink 3090 chipset, this is possible by putting the chipset in monitor mode. The aircrack-ng website states that the rt2x00-family of modules works well (a module is a linux kernel driver). I have successfully used monitor mode with the the rt2860sta module.

First you should disable any running internet services (such as DHCP clients):

$ sudo /etc/init.d/networking stop

To unload the current module and load the rt2860sta module:

$ sudo modprobe -rf <name of module to remove>
$ sudo modprobe rt2860sta

Now you should have a wlan0 interface (or similar name), and you can start monitor mode. For monitor mode to work properly, and to be able to change channels, you must stop all processes that use the wlan0 interface. Loading the rt2860sta module may have triggered the start of the DHCP client dhclient or the ifup script, so we have to shut those down first.

$ sudo /etc/init.d/networking stop

Now create the monitor interface:

$ sudo airmon-ng start wlan0

This creates interface mon0 that is running monitor mode. You can now start analyzing all traffic in the air using this interface, i.e. with airodump-ng or Wireshark.…

Tags: airodump, airomon-ng, , modprobe, mon0, networking, stop, ,
Linux
7 October 2011 0 Comments

Linux Package Manager Tips

dpkg is the software at the base of the Debian package management system. dpkg is used to install, remove, and provide information about .deb packages.

dpkg itself is a low level tool; higher level tools, such as APT, are used to fetch packages from remote locations or deal with complex package relations. Tools like aptitude or synaptic are more commonly used than dpkg on its own, as they have a more sophisticated way of dealing with package relationships and a friendlier interface.

What package is that file in?

Source: http://www.ubuntugeek.com/what-package-is-that-file-in.html

One question I get all the time is “What package is that file in?” There’s a really easy way to find out yourself. It’s called apt-file and it can search for a file in any package (installed or not). It’s really easy to use:

[sourcecode language="bash"]
$ sudo apt-get install apt-file
$ sudo apt-file update
$ apt-file search autoexpect

expect-dev: usr/share/doc/expect-dev/examples/autoexpect.1.gz
expect-dev: usr/share/doc/expect-dev/examples/autoexpect.gz
expect-tcl8.3: usr/share/doc/expect-tcl8.3/examples/autoexpect
expect-tcl8.3: usr/share/doc/expect-tcl8.3/examples/autoexpect.1…

Tags: aptitude, , synaptics,
Linux
7 October 2011 0 Comments

Make the Ubuntu Network Manager Ignore an Interface

If you have several wired and/or wireless interfaces, the default Ubuntu network-manager program will manage them all. To make the network manager ignore an interface, you must edit the /etc/network/interfaces file.

The /etc/network/interfaces file contains network interface configuration information for the both Ubuntu and Debian Linux. This is where you configure how your system is connected to the network.

Look at your current interfaces:

$ ifconfig

To make network-manager ignore wlan0:

$ sudo nano /etc/network/interfaces

And add the line:

iface wlan0 inet manual

The manual keyword denotes that network-manager should ignore the interface. After a reboot, the network manager will show device not managed for wlan0.…

Linux
2 October 2011 5 Comments

Fixing Ralink 3090 Wireless Problems on Linux

Introduction

If you have a Ralink 3090 (RT3090) wireless network card, you can run into problems when running Linux. These problems manifest themselves as a connection that is unreliable and slow, or even completely broken.

The Linux kernel decides which modules (drivers) should be loaded for your hardware setup, but it can get it wrong. If you are having lots of wireless networking problems, you probably don’t have the correct modules loaded. The included-by-default kernel module that seems to give the best results with the RT3090 is called rt2860sta. If you are running Ubuntu, you can try the rt3090-dkms package, which might give better results than the rt2860sta module.

List Modules

To see your currently loaded kernel modules:

$ lsmod | less

Using the rt3090-dkms Module

If you are running Ubuntu, this module might give better results than rt2860. In my case Ubuntu would no longer shut down, but there are many positive stories about the module too.

First, install the package from the Markus Heberling’s personal package archive.

$ sudo add-apt-repository ppa:markus-tisoft/rt3090
$ sudo apt-get update
$ sudo apt-get install dkms rt3090-dkms

Now you should …

Linux
1 October 2011 0 Comments

Tips for Tweaking a New Ubuntu/Gnome2 Installation

Introduction

If you are a Windows poweruser, the switch to a Linux desktop environment can be quite a shock. Many of your favorite shortcuts and tricks become useless, and it can be quite challenging to get back up to speed. There are many tweaks that you do to make Ubuntu’s Gnome 2 desktop environment easier to use and more powerful. This article presents a list of things to do after a fresh install that may help both Ubuntu newbies and adept users.

Note that the 11.04 release of Ubuntu introduced a new desktop environment called Unity. It is a trainwreck of an UI at this point (2011), and power-users will most likely be much more productive in the ‘classic’ Gnome 2 UI. The tips in this article apply to Gnome 2 for Ubuntu, but some things might work for other distros and UIs.

Programs to Install

There are several invaluable programs that everyone should get after a fresh install.

Ubuntu Tweak

Ubuntu Tweak is a tool for Ubuntu that makes it easy to configure your system and desktop settings. If you are a Windows user you might know Windows Powertoys, which is very similar. You can configure login settings, package related jobs, default folder locations, which items to display…

Reversing
27 August 2011 2 Comments

x86 Registers and Operating Modes

Introduction

The x86 processor chips have gone through many changes in the last 20 years. The transitions between 16, 32 and 64 bits versions immediately come to mind–and they are very notable indeed–but x86 assembly programmers have had to deal with many other changes. Another big change was the introduction of a new operating mode in the 286 and 386 CPU models: protected mode. Protected mode replaced the older operating mode called real mode, and it allowed software to utilize features such as virtual memory and paging. These features are now used in virtually all modern operating systems which run on the x86 architecture, such as Microsoft Windows, Linux, and many others.

In this article we give an overview of the available registers and operating modes of the various x86 architectures, and we describe the basic register semantics in different operating modes.

x86 CPU Registers

Processors have small amounts of high-speed storage, called registers, located in the heart of the CPU. All data must be represented in a register before it can be processed, so they play a central role: the first step of learning a new platform is usually learning the register set. The advantage…

Tags: , , , , , ,