Skip to main content

Black hat bash

Из одноименной книги "BLACK HAT BASH Creative Scripting for Hackers and Pentesters by Dolev Farhi and Nick Aleks"

Запуск тестовых контейнеров

cd ~/Black-Hat-Bash/lab/ 
sudo make deploy

Usage: make deploy | teardown | cleanup | rebuild | status | init | help
deploy   | build images and start containers
teardown | stop containers (shut down lab)
rebuild  | rebuild the lab from scratch (clean up and deploy)
cleanup  | stop and delete containers and images
status   | check the status of the lab
init     | build everything (containers and hacking tools)
help     | show this help message

Список адресов.

#!/bin/bash

for ip in $(seq 1 254); do
  echo "172.16.10.${ip}" >> 172-16-10-hosts.txt
done
echo 10.1.0.{1..254} | sed 's/ /\n/g'

Список доменов.

Есть списки часто используемых поддоменов. Называются gists. В Kali они есть по /usr/share/wordlists/amass/bitquark_subdomains_top100K.txt Или можно в google "subdomain wordlist site:gist.github.com".

#!/bin/bash

DOMAIN=$1
FILE=$2

while read -r subdomain; do
  echo "${subdomain}.${DOMAIN}"
done < "${FILE}" > ${DOMAIN}.txt

Поиск хостов.

Доступность IP хостов по ping 

#!/bin/bash

FILE=$1
while read -r host; do
  if ping -c 1 -W 1 -w 1 "${host}" &> /dev/null; then
    echo "${host} is up."
  fi
done < "${FILE}"

Через nmap, работает гораздо быстрее.

nmap -sn 172.16.10.0/24 | grep "Nmap scan" | awk -F'report for ' '{print $2}'

 ARP сканирование 

sudo arp-scan -f 172-16-10-hosts.txt -I br_public | grep '^[0-9]\+\.[0-9]*' | awk '{print $1}'