Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Parasimpaticki/0b1f1f508b2ee2a146244ab53d0bb3b8 to your computer and use it in GitHub Desktop.
Save Parasimpaticki/0b1f1f508b2ee2a146244ab53d0bb3b8 to your computer and use it in GitHub Desktop.
#!/bin/bash
#Escape slash from name for folder name
folderName=$(echo $1| awk '{gsub("/","_")}1');
mkdir $folderName && cd $folderName
fqdn=$1;
ipList=$(dig +short $fqdn|grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'); #Get all A names
if [ -z "$ipList" ]
then
ipArgument=$fqdn
else
ipArgument=$(echo $ipList| awk '{gsub(/ /,",")}1');
fi
masscan -p1-65535 $ipArgument --max-rate 1000 --open -oG "masscan_$folderName";
hostList=$(cat masscan_$folderName| grep open|cut -d" " -f2|sort -u);
for host in $hostList; do
portList=$(cat masscan_$folderName| grep $host|grep -Po 'Ports: \K.*'|cut -d"/" -f1);
portArgument=$(echo $portList| awk '{gsub(/ /,",")}1');
nmap -p $portArgument -sV -sC -oG "nmap_${host}_grepable" -oN "nmap_${host}_normal" $host;
done
@Xeek3y
Copy link

Xeek3y commented Jan 6, 2021

Hey how to use this script with bunch of resolved ips inside a txt file?

@Parasimpaticki
Copy link
Author

Hey how to use this script with bunch of resolved ips inside a txt file?

Just remove lines 7-13 and then do while read -r ip; do ./script $ip; done < resolved_ips.txt

@Xeek3y
Copy link

Xeek3y commented Jan 6, 2021

do while read -r ip; do ./script $ip; done < resolved_ips.txt

still can't figure out, how this script runs exactly? i mean the command arguments what command do you pass?
I haven't learned bash scripting yet so paradon me...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment