Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # CPU config
- loadPerCore="1.33"
- overheadJobs=2
- # CPU Detect
- threads="$(LC_ALL=C lscpu | egrep "^Thread\(s\) per core:" | sed -r "s/^.*: +//")"
- cpus="$(LC_ALL=C lscpu | egrep "^CPU\(s\):" | sed -r "s/^.*: +//")"
- jobsMax="$(qalc -t "round((${cpus}/${threads})*${loadPerCore})+${overheadJobs}")"
- echo "Detected $cpus total cpus, with $threads threads per physical core"
- echo "Ideal jobs number is $jobsMax"
- dt="$(date +%FT%T)"
- function log() {
- echo -ne "${@}" >&2
- }
- (
- echo -e 'graph G {\n\tgraph [pad=1]\n\tnode [style=filled color="#BFDFFF" fontsize=8 shape=circle width=.1 fixedsize=shape fontname="sans-serif"];\n\tedge [color="#4080FF"];\n\tlocalhost [color="#FFDFBF" shape=box fixedsize=false];'
- for j in $( nmap -sP "${@}" | egrep -B1 'Host is up' | egrep 'scan report for ' | egrep -o '(\([0-9\.]+\)|[0-9\.]+)$' | tr -d '()' | sort -Vu ); do
- while [ $(jobs -p|wc -l) -gt ${jobsMax} ]; do
- sleep 1
- done
- (
- log "\rTracing IP ${j} \033[0K"
- last="localhost";
- for i in $(nmap -sP --traceroute $j | egrep '^[0-9]+ +' | egrep -o '[0-9.]+\)?$' | tr -d ')' ); do
- [ "$i" == "..." ] && i="(...) $RANDOM" || {
- j="$(dig +short -x "$i"|tr "\n" " "|sed -r "s/ $//;s/ +/ /g;s/ /\\\\\\\n/g")"
- [ "$j" != "" ] && i="$j\\\n$i"
- }
- echo -e '\t"'"$last"'"--"'"$i"'"';
- log "ยท"
- last="$i";
- done;
- ) &
- done |\
- sort -Vu
- echo "}"
- ) | tee "${dt}.dot" | fdp -Tjpg | tee "${dt}.jpg" | feh - >/dev/null 2>&1
Add Comment
Please, Sign In to add comment