Created
May 6, 2020 23:22
-
-
Save Parasimpaticki/0b1f1f508b2ee2a146244ab53d0bb3b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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...