Scripting

A collection of useful pentesting scripts in bash, python, powershell and the like. Mainly collected here in a single library so I don't have to keep googling all over the place.

ALWAYS put a space between the square brackets [ and the contents! (etc if ["$1" == ""] will generate an error!)

Enumeration

ipsweep.sh

Pings ip address in the entire range to see who is up (etc ping 192.168.1.1 to 192.168.1.254) , greps 64 bytes line as its the linux default bytes for ping

#!/bin/bash

if [ "$1" == "" ]
then
echo "You forgot to input an IP address!"
echo "Syntax: ./ipsweep.sh <insert ip target>"

else
for ip in `seq 1 254`; do # seq a b will do a range(a,b+1)
ping -c 1 $1.$ip | grep "64 bytes" | cut -d " " -f 4 | tr -d ":" & # & allows the loop to be run all at once (254 sequences)       
done   # alternative is to put ; before done, which iterates 1 sequence at a time instead
fi
# $1 - takes user input "./ipsweep.sh <input the ip of ping target>

# INPUT should be excluding the last octet : etc 192.168.1 (last octet is looped)

Need trick is to use nmap loop on output text of IP results from this script

>>>in your kali terminal 
 for ip in $(cat iplist.txt); do nmap -p 80 -T4 $ip & done
 # -T4 is the scanning speed
 # & makes it run all at once, ; makes it run once at a time

The speed template nmap -T4 flag ranges from 0 for slow and stealthy to 5 for fast and obvious.25

Last updated