There are multiple ways of building or compiling Android tcpdump. The one outlined below is the method we use to build the Android tcpdump binary that you will find in our downloads section. You can also try using the NDK from Google. The NDK uses a different set of libraries, tool-chains, and compile tools.
The tcpdump we offer in our downloads section was compiled with a method called Cross-Compiling. Cross-Compiling is a method of compiling one operating system binary on another operating system. In our instance we are cross-compiling the Android binary on an Ubuntu Linux system targeting the ARM architecture. Once the binary or program is created, it can only run on the targeted operating system. So the binary can only run on Android devices running on the ARM architecture.
Aside Note: The Architecture could be ARM, i386 or MIPS. The ARM architecture is used in 95% of the Androids in the market, so the binary you will find in our downloads is for the ARM architecture. Also, we only have access to devices with the ARM architecture, so we cannot confirm whether binaries compiled for other architectures will work. If you would like us to compile a binary for i386 or MIPS please let us know in our contact page so we can make appropriate arrangements.
To install the compile tools and tool chains we used, execute the following on your Ubuntu Linux Server:
To compile the 32 Bit version, you need the following gcc compiler:
sudo apt-get install gcc-arm-linux-gnueabi
To compile the 64 Bit version, you need the following gcc compiler:
apt-get install gcc-aarch64-linux-gnu
You may need the following dependencies as well:
sudo apt-get install byacc
sudo apt-get install flex
Note: You only need to install the above mentioned compile tools once on your system.
wget https://www.tcpdump.org/release/tcpdump-4.99.5.tar.gz
wget https://www.tcpdump.org/release/libpcap-1.10.5.tar.gz
tar zxvf tcpdump-4.99.5.tar.gz
tar zxvf libpcap-1.10.5.tar.gz
export CC=arm-linux-gnueabi-gcc
export CC=aarch64-linux-gnu-gcc
cd libpcap-1.10.5
./configure --host=arm-linux --with-pcap=linux
make
cd tcpdump-4.99.5
uname -a
The above command produced the following output:
Linux androidtcpdump 2.6.32-042stab094.8 #1 SMP Tue Dec 16 20:36:56 MSK 2014 i686 i686 i686 GNU/Linux
export ac_cs_linux_vers=2
export CFLAGS=-static
export CPPFLAGS=-static
export LDFLAGS=-static
./configure --host=arm-linux --disable-ipv6
make
arm-linux-gnueabi-strip tcpdump
aarch64-linux-gnu-strip tcpdump
Below are all the steps listed above in an easy script. You only need to change the versioning information and perhaps your linux Kernel version in the "ac_cv_linux_vers" variable
export TCPDUMP=4.99.5
export LIBPCAP=1.10.5
wget https://www.tcpdump.org/release/tcpdump-$TCPDUMP.tar.gz
wget https://www.tcpdump.org/release/libpcap-$LIBPCAP.tar.gz
tar zxvf tcpdump-$TCPDUMP.tar.gz
tar zxvf libpcap-$LIBPCAP.tar.gz
export CC=arm-linux-gnueabi-gcc
cd libpcap-$LIBPCAP
./configure --host=arm-linux --with-pcap=linux
make
cd ..
cd tcpdump-$TCPDUMP
export ac_cv_linux_vers=2
export CFLAGS=-static
export CPPFLAGS=-static
export LDFLAGS=-static
./configure --host=arm-linux --disable-ipv6
make
arm-linux-gnueabi-strip tcpdump
Below are all the steps listed above in an easy script. You only need to change the versioning information and perhaps your linux Kernel version in the "ac_cv_linux_vers" variable
export TCPDUMP=4.99.5
export LIBPCAP=1.10.5
wget https://www.tcpdump.org/release/tcpdump-$TCPDUMP.tar.gz
wget https://www.tcpdump.org/release/libpcap-$LIBPCAP.tar.gz
tar zxvf tcpdump-$TCPDUMP.tar.gz
tar zxvf libpcap-$LIBPCAP.tar.gz
eport CC=aarch64-linux-gnu-gcc
cd libpcap-$LIBPCAP
./configure --host=arm-linux --with-pcap=linux
make
cd ..
cd tcpdump-$TCPDUMP
export ac_cv_linux_vers=2
export CFLAGS=-static
export CPPFLAGS=-static
export LDFLAGS=-static
./configure --host=arm-linux --disable-ipv6
make
aarch64-linux-gnu-strip tcpdump
Now you have the instructions we use to build android tcpdump. But there are alternatives to compiling/building. If you do not have access to a Linux system, or ran into difficulties compiling, you can always just download the latest version from our Downloads area. It is just that easy.