Guest User

Untitled

a guest
Apr 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # CPU config
  4. loadPerCore="1.33"
  5. overheadJobs=2
  6.  
  7. # CPU Detect
  8. threads="$(LC_ALL=C lscpu | egrep "^Thread\(s\) per core:" | sed -r "s/^.*: +//")"
  9. cpus="$(LC_ALL=C lscpu | egrep "^CPU\(s\):" | sed -r "s/^.*: +//")"
  10. jobsMax="$(qalc -t "round((${cpus}/${threads})*${loadPerCore})+${overheadJobs}")"
  11.  
  12. echo "Detected $cpus total cpus, with $threads threads per physical core"
  13. echo "Ideal jobs number is $jobsMax"
  14.  
  15. dt="$(date +%FT%T)"
  16.  
  17. function log() {
  18. echo -ne "${@}" >&2
  19. }
  20.  
  21.  
  22. (
  23. 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];'
  24. 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
  25. while [ $(jobs -p|wc -l) -gt ${jobsMax} ]; do
  26. sleep 1
  27. done
  28. (
  29. log "\rTracing IP ${j} \033[0K"
  30. last="localhost";
  31. for i in $(nmap -sP --traceroute $j | egrep '^[0-9]+ +' | egrep -o '[0-9.]+\)?$' | tr -d ')' ); do
  32. [ "$i" == "..." ] && i="(...) $RANDOM" || {
  33. j="$(dig +short -x "$i"|tr "\n" " "|sed -r "s/ $//;s/ +/ /g;s/ /\\\\\\\n/g")"
  34. [ "$j" != "" ] && i="$j\\\n$i"
  35. }
  36. echo -e '\t"'"$last"'"--"'"$i"'"';
  37. log "ยท"
  38. last="$i";
  39. done;
  40. ) &
  41. done |\
  42. sort -Vu
  43. echo "}"
  44. ) | tee "${dt}.dot" | fdp -Tjpg | tee "${dt}.jpg" | feh - >/dev/null 2>&1
Add Comment
Please, Sign In to add comment