> For the complete documentation index, see [llms.txt](https://davin-hong3.gitbook.io/d/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://davin-hong3.gitbook.io/d/walkthroughs/cybersecurity-concepts/scripting.md).

# 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.

{% embed url="<https://tldp.org/LDP/abs/html/special-chars.html>" %}

{% hint style="info" %}
ALWAYS put a space between the square brackets \[ and the contents! (etc if \["$1" == ""] will generate an error!)
{% endhint %}

## 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

```bash
#!/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)
```

<div align="left"><img src="https://2068334946-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fow1iM27u7disHeJiSlBC%2Fuploads%2Fgdw6ATUosFgBwBuKjhe5%2Fimage.png?alt=media&amp;token=0220dea2-0420-455c-8307-dab8cedb734d" alt=""></div>

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

![Sample results ](https://2068334946-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fow1iM27u7disHeJiSlBC%2Fuploads%2FaqOhmrYe3UYlAy12AQOs%2Fimage.png?alt=media\&token=6cc30f69-d497-4a4b-a5cb-0021e8c9f331)
