From 4f440513eb74f77ffd486fe60d9b4aeeabe2e6dc Mon Sep 17 00:00:00 2001 From: "Sylvain \"Cloud\" MARET" <sylvain.maret@ensiie.fr> Date: Sat, 28 Sep 2019 17:19:05 +0200 Subject: [PATCH] update shell script --- scan_country.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 scan_country.sh diff --git a/scan_country.sh b/scan_country.sh new file mode 100755 index 0000000..716566a --- /dev/null +++ b/scan_country.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +# test if there is a country as 1st argument + +if [ $# -ne 1 ] +then + echo "incorrect number of argument" + echo "example : ./get_country_csv.sh France" + exit +fi + + +# download and extract database if missing + +if [ ! -f "IP2LOCATION-LITE-DB1.CSV" ] +then + wget https://download.ip2location.com/lite/IP2LOCATION-LITE-DB1.CSV.ZIP + unzip IP2LOCATION-LITE-DB1.CSV.ZIP + rm IP2LOCATION-LITE-DB1.CSV.ZIP +fi + + +# generate csv +if [ ! -f $1.csv ] +then + echo "[INFO] generate csv" + grep $1 IP2LOCATION-LITE-DB1.CSV > $1.csv +fi + +if [ ! -f $1.ips ] +then + echo "[INFO] generate IPs" + python conversion.py $1 +fi + +if [ ! -f $1.445.scan ] +then + echo "[INFO] scanning port 445 for exposed windows machines" + sudo masscan -p445 -iL $1.ips -oG $1.445.scan && cat $1.445.scan | wc -l +fi + +if [ -f $1.53.scan ] +then + echo "[INFO] scanning port 53 udp to find exposed DNS" + sudo masscan -pU:53 -iL $1.ips -oG $1.53.scan && cat $1.53.scan | wc -l +fi + +if [ ! -f $2 ] +then + mkdir $2 +fi + +mv $1.* $2 + +echo "Scan finished, result can be found in the " $2 " folder" -- GitLab