1、安装脚本
#!/usr/bin/env bash
# Upgrade nmap
# Check if user is root
if [ $(id -u) != "0" ]; then
echo "Error: You must be root to run this script"
exit 1
fi
cur_dir=$(pwd)
Nmap_Install()
{
wget -c https://nmap.org/dist/nmap-7.60.tar.bz2
if [ -f "./nmap-7.40.tar.bz2" ]; then
bzip2 -cd nmap-7.40.tar.bz2 | tar xvf -
cd nmap-7.40
./configure
make && make install
fi
}
nmap --version
if [ $? == 0 ]; then
version = `nmap --version` | awk '{print $3}'
if [ $version == "7.60" ]; then
echo "Current nmap version is 7.40"
exit 1
else
yum -y remove nmap
if [ $? == 0 ]; then
Nmap_Install
fi
fi
else
Nmap_Install
fi
2、安装nmap 过程中可能会出错 g++: command not found
原因:G++没有装或却没有更新
运行如下命令:
centos:
yum -y update gcc
yum -y install gcc+ gcc-c++
ubuntu:
apt-get update gcc
apt-get install g++
3、运行nmap 出现如下错误
nmap: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory
这是由于openssl库的位置不正确造成的。
解决方法:
在root用户下执行:
ln -s /usr/local/lib64/libssl.so.1.1 /usr/lib64/libssl.so.1.1
ln -s /usr/local/lib64/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1