Friday, January 22, 2010

Embedded Linux From Scratch in 90 minutes

Goals
- Linux kernel configuring and compiling;
- Root file system creation;
- Busybox compiling and installation;
- Device file creation;
- System initialization scripts: virtual file system, networking;
- Setup of a simple HTTP interface to the system.

1. Download fast processor emulator using a portable dynamic translator.

wget http://download.savannah.gnu.org/releases/qemu/qemu-0.12.2.tar.gz
tar zxvf qemu-0.12.2.tar.gz
cd qemu-0.12.2.tar.gz


Then you configure QEMU and build it (usually no options are needed):

./configure


install zlib if you need (apt-get install zlib1g-dev)

make


Then type as root user:

make install




2. Getting the Kernel sources:
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.25.4.tar.gz

Start with a minimalistic kernel configuration
make allnoconfig


Adding settings specific to the embedded system
install ncurses if you need (apt-get install libncurses5-dev)
make menuconfig


Compiling:
make


You will get
arch/x86/boot/bzImage


3. Getting Busybox source
wget http://www.busybox.net/downloads/busybox-1.15.3.tar.gz


Configuring BusyBox
make menuconfig


choosing to build a statically, natively compiled executable.

Compiling busybox
make


Pre-installing busybox (in the _install/ subdirectory):
make install


4. Creating a root filesystem
Creating an empty file with a 1000K size:
dd if=/dev/zero of=rootfs.img bs=1k count=1000

Formating this file for the ext2 filesystem:
mkfs.ext2 -i 1024 -F rootfs.img

5. Populating the root filesystem
logged as root:
Creating a mount point:
mkdir /mnt/tmproot

Mounting the root filesystem image:
mount -o loop rootfs.img /mnt/tmproot

Copying the busybox file structure into the mounted image:
rsync -a busybox/_install/ /mnt/tmproot/
(or cp -ax busybox/_install/ /mnt/tmproot/)
chown -R root:rooot /mnt/tmproot/

Flushing the changes into the mounted filesystem image:
sync

6. Booting the Virtual System
Using the QEMU emulator as a bootloader
qemu -m 32 -hda rootfs.img -kernel linux-2.6.25.4/arch/x86/boot/bzImage -append "root=/dev/hda" -redir tcp:5555::80

click "Applications -> Internet -> Terminal Server Client"then fill in the Computer with "127.0.0.1:5900",and select VNC in the protocol, if VNC grayed, install vncviewer
apt-get install vncviewer

Friday, January 1, 2010

Network Traffic Generation Tool for Linux

Mausezahn is a free fast traffic generator written in C which allows you to send nearly every possible and impossible packet. It is mainly used to test VoIP or multicast networks but also for security audits to check whether your systems are hardened enough for specific attacks.

http://www.perihel.at/sec/mz/index.html