Skip to content

Instantly share code, notes, and snippets.

@mzpqnxow
Created October 2, 2021 16:51
Show Gist options
  • Save mzpqnxow/ddb5c36c351a7fc4f542e9c01a1b1d37 to your computer and use it in GitHub Desktop.
Save mzpqnxow/ddb5c36c351a7fc4f542e9c01a1b1d37 to your computer and use it in GitHub Desktop.
Build nmap on Debian/Ubuntu without zenmap, ncat (+ install dependencies)
#!/bin/bash
#
# How many times I've had to do this... this saves the trouble, especially of one-by-one
# recalling what the dependencies are by reading the output of ./configure ...
#
# - AG
#
set -eu
declare -r BUILD_DIR=~/nmap-build
declare -r NMAP_VERSION="7.92"
declare -r NMAP_STRING="nmap-$NMAP_VERSION"
declare -r NMAP_TGZ="$NMAP_STRING.tgz"
echo "Building nmap $NMAP_VERSION ..."
echo "You can manually remove $BUILD_DIR if it exists and an error is thrown here..."
mkdir "$BUILD_DIR"
cd "$BUILD_DIR"
wget -c "https://nmap.org/dist/$NMAP_TGZ"
tar -xvf "$NMAP_TGZ"
pwd
sudo apt-get install -y \
liblua5.3-dev \
libbpfcc-dev \
libpcap-dev \
libcfg-dev \
libssl-dev \
libssh2-1-dev \
libpcre3-dev \
zlib1g-dev \
build-essential
cd "$NMAP_STRING"
./configure \
--prefix="/opt/$NMAP_STRING" \
--disable-zenmap \
--disable-nping \
--disable-ndiff \
--disable-ncat
make -j && \
sudo make install && \
sudo ln -sf "/opt/$NMAP_STRING" /opt/nmap
echo "Please see ~/nmap-build if you want to..."
echo "Add the following to your ~/.zshrc or ~/.bashrc ..."
echo 'export PATH=/opt/nmap/bin:$PATH'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment