Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
all:
@echo type "make install" or "./install.sh"

install:
./install.sh
25 changes: 25 additions & 0 deletions autonmap.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## Begin Config

# The directory for autonmap data/scans
RUN_DIRECTORY="/usr/local/autonmap/"

# The directory you want the web report to live in
WEB_DIRECTORY="/var/www/autonmap/"

# The hosts and subnets you want to scan daily, space seperated.
SCAN_SUBNETS="10.101.0.0/24"

# The full path (http) to where the report will be hosted by your webserver. This is included in the email report.
# I suggest setting up auth using htpasswd etc, in which case you can include the auth in the URL for simplicity if you want.
WEB_URL="http://mywebserver.com/autonmap/scan-$DATE.xml"

# The full path to your chosen nmap binary
NMAP="/usr/bin/nmap"

# The path to the ndiff tool provided with nmap
NDIFF="/usr/bin/ndiff"

# The email address(es), space seperated that you wish to send the email report to.
EMAIL_RECIPIENTS="you@yourdomain.com youteam@yourdomain.com"

## End config
42 changes: 19 additions & 23 deletions autonmap.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
#!/bin/bash

DATE=`date +%F`
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

## Begin Config
test -e /etc/autonmap.conf && . /etc/autonmap.conf || {
test -e /usr/local/etc/autonmap.conf && . /usr/local/etc/autonmap.conf || {
test -e "$DIR/"autonmap.conf && . "$DIR/"autonmap.conf || {
test -e ./autonmap.conf && . ./autonmap.conf || {
echo Error: can not find config file autonmap.conf, place it in /etc/
exit 1
}
}
}
}

# The directory for autonmap data/scans
RUN_DIRECTORY="/usr/local/autonmap/"
test -n "$RUN_DIRECTORY" -a -n "$WEB_DIRECTORY" || {
echo Error: no configuration data loaded
exit 1
}

# The directory you want the web report to live in
WEB_DIRECTORY="/var/www/autonmap/"

# The subnets you want to scan daily, space seperated.
SCAN_SUBNETS="10.101.0.0/24"

# The full path (http) to where the report will be hosted by your webserver. This is included in the email report.
# I suggest setting up auth using htpasswd etc, in which case you can include the auth in the URL for simplicity if you want.
WEB_URL="http://mywebserver.com/autonmap/scan-$DATE.xml"

# The full path to your chosen nmap binary
NMAP="/usr/bin/nmap"

# The path to the ndiff tool provided with nmap
NDIFF="/usr/bin/ndiff"

# The email address(es), space seperated that you wish to send the email report to.
EMAIL_RECIPIENTS="you@yourdomain.com youteam@yourdomain.com"

## End config
# be sure the paths are there
mkdir -p /usr/local/autonmap/
mkdir -p /var/www/autonmap/

echo "`date` - Welcome to AutoNmap2. "

Expand All @@ -50,7 +46,7 @@ then
echo "`date` - Differences Detected. Sending mail."
echo -e "AutoNmap2 found differences in a scan for '${SCAN_SUBNETS}' since yesterday. \n\n$DIFF\n\nFull report available at $WEB_URL" | mail -s "AutoNmap2" $EMAIL_RECIPIENTS
else
echo "`date`- No differences, skipping mail. "
echo "`date` - No differences, skipping mail. "
fi

else
Expand Down
17 changes: 17 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh
echo Checking environment ...
NMAP=`which nmap 2> /dev/null`
MAIL=`which mail 2> /dev/null`
test -n "$NMAP" && echo "nmap: ok" || echo "nmap: not found - fix this!"
test -n "$MAIL" && echo "mail: ok" || echo "mail: not found - fix this!"
echo Installing autonmap
echo Copying autonmap.sh to /usr/local/bin
cp -v autonmap.sh /usr/local/bin || exit 1
echo Copying autonmap.conf to /etc
cp -v autonmap.conf /etc || exit 1
echo Creating daily run job in /etc/cron.daily/autonmap.sh
echo '#!/bin/sh' > /etc/cron.daily/autonmap.sh || exit 1
echo '/usr/local/bin/autonmap.sh >> /var/log/autonmap.log || exit 1' >> /etc/cron.daily/autonmap.sh || exit 1
chmod 755 /etc/cron.daily/autonmap.sh
echo Done.
echo NOTE: Do not forget to config autonmap in /etc/autonmap.conf