Advertisement
metalx1000

Termux Netscan with NMAP and HTML output

Jan 9th, 2019
903
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.08 KB | None | 0 0
  1. #!/bin/bash
  2. #created by Kris Occhipinti
  3. #http://filmsbykris.com
  4. #Copyright Jan 2019
  5. #GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
  6. #For use in Termux on Android
  7. #quickly scans network based you current device's ip
  8.  
  9. log=$HOME/downloads/scan_$(date +%s).log
  10. ip="$(ip addr|grep wlan -A3|grep inet|head -n1 |awk '{print $2}'|cut -d\/ -f1)"
  11.  
  12. ipr="$(echo "$ip"|cut -d\. -f1,2,3)"
  13.  
  14. echo "-------$ip--------"
  15. #scan for http and printer servers
  16. nmap -v $ipr.0/24 -p 80 |tee -a "$log"
  17. nmap -v $ipr.0/24 -p 9100 |tee -a "$log"
  18.  
  19. #create HTML output
  20. echo "<h1>HTTP Servers</h1>" > $log.html
  21. grep 'Discovered open port 80' "$log"|\
  22.   awk '{print $6}'|while read ipaddress
  23.   do
  24.     echo "<a href='http://$ipaddress'>$ipaddress</a><br>"
  25.   done >> $log.html
  26.  
  27. echo "<br>" >> $log.html
  28. echo "<h1>Printer Servers</h1>" >> $log.html
  29. grep 'Discovered open port 9100' "$log"|\
  30.   awk '{print $6}'|while read ipaddress
  31.   do
  32.     echo "<a href='http://$ipaddress'>$ipaddress</a><br>"
  33.   done >> $log.html
  34.  
  35. termux-open $log.html
  36.  
  37. nmap -v $ipr.0/24  |tee -a "$log"
  38.  
  39. grep "Discovered open port" $log
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement