zmap在阿里云主机上的编译

时间:2021-06-04 11:53:34

环境:

cat /etc/issue
Ubuntu 14.04.2 LTS \n \l

cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 45
model name : Intel(R) Xeon(R) CPU E5-2430 0 @ 2.20GHz
stepping : 7
microcode : 0x70d
cpu MHz : 2200.044
cache size : 15360 KB
physical id : 0
siblings : 1
core id : 0
cpu cores : 1
apicid : 0
initial apicid : 0
fdiv_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clflush mmx fxsr sse sse2 ht nx rdtscp lm constant_tsc pni ssse3 cx16 sse4_1 sse4_2 popcnt aes hypervisor lahf_lm
bogomips : 4400.08
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:

# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.8/lto-wrapper
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.2-19ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-i386/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-i386 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-i386 --with-arch-directory=i386 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-targets=all --enable-multiarch --disable-werror --with-arch-32=i686 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1)

已经有一个编译过的源码包了,解压后

apt-get update(不然装不了cmake)

apt-get install cmake

# make
[ 2%] Generating parser.c
/bin/sh: 1: byacc: not found
make[2]: *** [src/parser.c] Error 127
make[1]: *** [src/CMakeFiles/zmap.dir/all] Error 2

apt-get install byacc

# make
[ 2%] Generating parser.c
[ 5%] Generating zopt.h
/bin/sh: 1: gengetopt: not found

apt-get install gengetopt

make
[ 2%] Generating zopt.h
[ 5%] Generating lexer.c
/bin/sh: 1: flex: not found

apt-get install flex

make
[ 2%] Generating lexer.c
Scanning dependencies of target zmap
[ 5%] Building C object src/CMakeFiles/zmap.dir/aesrand.c.o
[ 8%] Building C object src/CMakeFiles/zmap.dir/cyclic.c.o
/root/source/zmap-1.2.1/src/cyclic.c:47:17: fatal error: gmp.h: No such file or directory

apt-get install gmp-devel

make
[ 2%] Building C object src/CMakeFiles/zmap.dir/cyclic.c.o
[ 5%] Building C object src/CMakeFiles/zmap.dir/expression.c.o
[ 8%] Building C object src/CMakeFiles/zmap.dir/fieldset.c.o
[ 11%] Building C object src/CMakeFiles/zmap.dir/filter.c.o
[ 14%] Building C object src/CMakeFiles/zmap.dir/get_gateway.c.o
/root/source/zmap-1.2.1/src/get_gateway.c:17:23: fatal error: pcap/pcap.h: No such file or directory
#include <pcap/pcap.h>

apt-get install libpcap-dev

make
[ 2%] Building C object src/CMakeFiles/zmap.dir/get_gateway.c.o
[ 5%] Building C object src/CMakeFiles/zmap.dir/iterator.c.o
[ 8%] Building C object src/CMakeFiles/zmap.dir/monitor.c.o
[ 11%] Building C object src/CMakeFiles/zmap.dir/recv.c.o
[ 14%] Building C object src/CMakeFiles/zmap.dir/send.c.o
[ 17%] Building C object src/CMakeFiles/zmap.dir/shard.c.o
[ 20%] Building C object src/CMakeFiles/zmap.dir/state.c.o
[ 23%] Building C object src/CMakeFiles/zmap.dir/validate.c.o
[ 26%] Building C object src/CMakeFiles/zmap.dir/zmap.c.o
[ 29%] Building C object src/CMakeFiles/zmap.dir/zopt_compat.c.o
[ 32%] Building C object src/CMakeFiles/zmap.dir/lexer.c.o
[ 35%] Building C object src/CMakeFiles/zmap.dir/parser.c.o
[ 38%] Building C object src/CMakeFiles/zmap.dir/probe_modules/module_icmp_echo.c.o
[ 41%] Building C object src/CMakeFiles/zmap.dir/probe_modules/module_tcp_synscan.c.o
[ 44%] Building C object src/CMakeFiles/zmap.dir/probe_modules/module_udp.c.o
[ 47%] Building C object src/CMakeFiles/zmap.dir/probe_modules/packet.c.o
[ 50%] Building C object src/CMakeFiles/zmap.dir/probe_modules/probe_modules.c.o
[ 52%] Building C object src/CMakeFiles/zmap.dir/output_modules/module_csv.c.o
[ 55%] Building C object src/CMakeFiles/zmap.dir/output_modules/output_modules.c.o
[ 58%] Building C object src/CMakeFiles/zmap.dir/__/lib/blacklist.c.o
[ 61%] Building C object src/CMakeFiles/zmap.dir/__/lib/constraint.c.o
[ 64%] Building C object src/CMakeFiles/zmap.dir/__/lib/logger.c.o
[ 67%] Building C object src/CMakeFiles/zmap.dir/__/lib/pbm.c.o
[ 70%] Building C object src/CMakeFiles/zmap.dir/__/lib/random.c.o
[ 73%] Building C object src/CMakeFiles/zmap.dir/__/lib/rijndael-alg-fst.c.o
[ 76%] Building C object src/CMakeFiles/zmap.dir/__/lib/xalloc.c.o
Linking C executable zmap
[100%] Built target zmap

好了,这就编译好了zmap

再编译examples

~/source/zmap-1.2.1/examples/banner-grab# make
cc -I../../lib/ -Wall -g -O2 -fstack-protector-all --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -fPIC -c -o banner-grab-tcp.o banner-grab-tcp.c
banner-grab-tcp.c:14:26: fatal error: event2/event.h: No such file or directory
#include <event2/event.h>
^
compilation terminated.
make: *** [banner-grab-tcp.o] Error 1

apt-get install libevent-dev

再编译就好了

~/source/zmap-1.2.1/examples/banner-grab# make
cc -I../../lib/ -Wall -g -O2 -fstack-protector-all --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -fPIC -c -o banner-grab-tcp.o banner-grab-tcp.c
cc -I../../lib/ -Wall -g -O2 -fstack-protector-all --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -fPIC -c -o logger.o ../../lib/logger.c
cc -I../../lib/ -Wall -g -O2 -fstack-protector-all --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -fPIC -c -o xalloc.o ../../lib/xalloc.c
cc -I../../lib/ -Wall -g -O2 -fstack-protector-all --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -fPIC banner-grab-tcp.o logger.o xalloc.o -o banner-grab-tcp -lpcap -levent -levent_extra -lm -Wl,-Bsymbolic-functions -Wl,-z,relro,-z,now
root@iZ28jx1d1xfZ:~/source/zmap-1.2.1/examples/banner-grab#