Created
November 7, 2023 23:43
-
-
Save richin13/a8ec164ef75496f3a31bb55c0bfb331e to your computer and use it in GitHub Desktop.
Useful bash scripts compiled during my ethical hacking learning journey
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 | |
# Change the MAC address of a given interface. | |
# Usage: sudo ./change-mac.bash <interface name> [<new mac address>] | |
# Example: sudo ./change-mac.bash wlan0 11:99:22:88:33:77 | |
# Author: @richin13 | |
if [ "$#" -lt 1 ]; then | |
echo "Usage: $0 <interface name> [mac address]" | |
exit 1 | |
fi | |
int="$1" | |
cur_mac="$(ifconfig "$int" | grep ether | xargs | cut -d' ' -f2)" | |
mac="${2:-00:11:22:33:44:55}" | |
echo "Changing MAC address for inteface $int from $cur_mac to $mac" | |
sudo ifconfig "$int" down | |
sudo macchanger -m "$mac" "$int" | |
sudo ifconfig "$int" up | |
echo "[+] Done! Verifying..." | |
ifconfig "$int" | grep ether | xargs | cut -d' ' -f2 |
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
#!/bin/env bash | |
# Read information from crt.sh | |
# Usage: ./crtsh.bash <domain name> | |
# Example: ./crtsh.bash example.com | |
# Author: @richin13 | |
set -e | |
PREREQUISITES=(curl jq sed sort grep) | |
for prereq in ${PREREQUISITES[@]}; do | |
if [ ! -x "$(command -v "$prereq")" ]; then | |
echo "$prereq is not installed" | |
exit 1 | |
fi | |
done | |
if [ "$#" != 1 ]; then | |
echo "Invalid number of args" | |
echo "Usage: $(basename $0) <domain>" | |
exit 1 | |
fi | |
URL="https://crt.sh/?output=json&q=$1" | |
echo -e "Checking \033[0;36m$URL\033[0m" >&2 | |
curl -s "$URL" | jq -r '.[] | [.name_value] | @csv' | sed 's/"//g' | sort -u | grep -v "*" |
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
#!/bin/env bash | |
# Given a list of domains, retrieve the different IPs associated with those domains | |
# Usage: ./find-domain-ips.bash <domain name> | |
# Example: ./find-domain-ips.bash example.com | |
# Author: @richin13 | |
set -e | |
PREREQUISITES=(cat dig) | |
for prereq in ${PREREQUISITES[@]}; do | |
if [ ! -x "$(command -v "$prereq")" ]; then | |
echo "$prereq is not installed" | |
exit 1 | |
fi | |
done | |
if [ "$#" != 1 ]; then | |
while read -r domain; do | |
dig +short "$domain" | |
done | sort -u | grep -Eo '\b([0-9]{1,3}\.){3}[0-9]{1,3}\b' | |
else | |
while read -r domain; do | |
dig +short "$domain" | |
done < "$1" | sort -u | grep -Eo '\b([0-9]{1,3}\.){3}[0-9]{1,3}\b' | |
fi |
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 | |
# Check an interface's MAC address | |
# Usage: ./interface-mac.bash <interface name> | |
# Example: ./interface-mac.bash wlan0 | |
# Author: @richin13 | |
function interface-mac() { | |
if [ "$#" -lt 1 ]; then | |
echo "Usage: $0 <interface name>" | |
return 1 | |
fi | |
int="$1" | |
ifconfig "$int" | grep ether | xargs | cut -d' ' -f2 | |
} |
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 | |
# Enable monitor mode in a wireless interface. | |
# Usage: sudo ./mon-mode.bash <interface name> | |
# Example: sudo ./mon-mode.bash wlan0 | |
# Author: @richin13 | |
if [ "$#" -lt 1 ]; then | |
echo "Usage: $0 <interface name>" | |
exit 1 | |
fi | |
int="$1" | |
cur_mode="$(iwconfig "$int" | grep Mode | xargs | cut -d' ' -f1 | cut -d':' -f2)" | |
echo "Enabling monitor mode on $int [Current: $cur_mode]" | |
sudo ifconfig "$int" down | |
sudo iwconfig "$int" mode monitor | |
sudo ifconfig "$int" up | |
echo "[+] Done! Verifying..." | |
iwconfig "$int" | grep Mode | xargs | cut -d' ' -f1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment