Thanks xiam, I like the enhancements.
I did a slight hack to decrement the counter whenever an nmap process is complete.
Code:
#!/bin/bash
# Script origin written by ???
#
# Strongly enhanced by Flo M.
# Hacked further by jhowell
. nmap_linux.config
# Check if any nmap is running....
ps aux | grep -v grep | grep 'nmap -v -O -oN nmap.txt' > /dev/zero
if [ "$?" == "0" ]; then
echo
echo "Some other nmap processes of openaudit running..."
echo "Use 'ps aux | grep nmap' to find out!"
echo "Quitting now...!"
echo
exit 1
fi
function portscan {
# A directory of each ip is needed to prevent overlapping...
mkdir "$NMAP_NET.$a"
cd "$NMAP_NET.$a"
# Starting the portscan...
nmap_file="nmap.txt"
nmap_input=`nmap -v -O -oN $nmap_file $NMAP_NET.$a`
nmap_output=`cat $nmap_file`
echo "Now scanning " $NMAP_NET.$a " ..."
# Transfer to openaudit...
wget -q --post-data="submit=submit&add=$nmap_output" http://"$OASERVER"/openaudit/admin_nmap_input.php
# Cleaning up...
cd ..
rm -rf "$NMAP_NET.$a"
let i--
}
i=0
for ((a=$NMAP_START; a <= $NMAP_END ; a++)); do
portscan $a &
let i++
if [ $i -ge 10 ]; then
sleep 20
fi
done
Hope you like.
Jonathan