Last active
August 23, 2020 16:03
-
-
Save Cgboal/b2dd417867429c834f9c38172fce526f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env bash | |
# Set magic variables for current file & dir | |
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | |
__file="${__dir}/$(basename "${BASH_SOURCE[0]}")" | |
__base="$(basename ${__file} .sh)" | |
__root="$(cd "$(dirname "${__dir}")" && pwd)" # <-- change this as it depends on your app | |
__TIMESTAMP=`date +%Y-%m-%d_%H-%M-%S` | |
arg1="${1:-}" | |
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT | |
add_vlan() { | |
sudo ip link add link enp0s20f0u2 name enp0s20f0u2.$1 type vlan id $1 | |
sudo ip addr add 10.184.$1.241 brd 10.184.$1.255 dev enp0s20f0u2.$1 | |
sudo ip link set dev enp0s20f0u2.$1 up | |
sudo ip route add 0.0.0.0/0 dev enp0s20f0u2.$1 | |
} | |
remove_vlan() { | |
sudo ip link delete enp0s20f0u2.$1 | |
} | |
main() { | |
ip addr | awk '{print $2}' | grep enp | cut -d@ -f 1 | for iface in $(cat); do sudo ip link delete $iface; done | |
for tag in $(cat $1); do | |
add_vlan $tag | |
#sudo nmap -T4 -iL $2 --top-ports 100 -oA nmap/vlans/all_from_$tag.txt --min-hostgroup 40 --max-retries 0 --host-timeout 2m -sS -n | |
sudo masscan --router-ip 10.184.$tag.1 --interface enp0s20f0u2.$tag -p 7,9,13,21-23,25-26,37,53,79-81,88,106,110-111,113,119,135,139,143-144,179,199,389,427,443-445,465,513-515,543-544,548,554,587,631,646,873,990,993,995,1025-1029,1110,1433,1720,1723,1755,1900,2000-2001,2049,2121,2717,3000,3128,3306,3389,3986,4899,5000,5009,5051,5060,5101,5190,5357,5432,5631,5666,5800,5900,6000-6001,6646,7070,8000,8008-8009,8080-8081,8443,8888,9100,9999-10000,32768,49152-49157 -iL $2 -oX nmap/vlans/all_from_$tag.xml -oG nmap/vlans/all_from_$tag.grep --rate 1000 | |
remove_vlan $tag | |
done; | |
} | |
main $1 $2 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment