Hi all
I have been set with the task of creating an automated pen test box for work.
Now the device needs to obtain the IP address range automatically and I am struggling on how I can achieve this without user input.
The reason I need the IP range is so I can pump this to NMAP and Fping to check for live devices.
Now I have used the following command to obtain the IP address from ifconfig /sbin/ifconfig $adapter | grep 'inet addr:' | cut -d: -f2 | awk '{print $1}'"
Now when I run the above directly in a terminal I get the IP address only, however when I put this into a bash script , it shows be the following output : "192.168.0.39 Bcast"
Below is my bash script
#Varibles
adapter="enp0s3"
ipaddress="/sbin/ifconfig $adapter | grep 'inet addr:' | cut -d: -f2 | awk '{print $1}'"
ip=$(eval $ipaddress) #Runs the command above
echo $ip
I also need this script to pull the broadcast address, which I am also struggling with.
However when I obtain the IP address I need to change the last digit after the 3 dot to a 0.
Im also hoping I can use a IF statement to translate the broadcast address to /24 for example
Anyhelp would be appreciated!!