Advertisement
plast1k

list domain as seen in a web page

Nov 26th, 2012
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.81 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. ##variables
  3. domain_mirror=$domain.txt
  4. domain=$1
  5. ##functions go here
  6.  
  7. ##banner function
  8. banner()
  9. {
  10. echo -e "\033[34m\t\t#############################################
  11. \t\t##this script search for domains and subdomain ##
  12. \t\t##        as seen from a given website         ##
  13. \t\t##           inspiration:list-urls.py          ##
  14. \t\t##        author:plast1k                       ##
  15. \t\t##+++++++++++++++++++++++++++++++++++++++++++++##
  16. \033[0m"
  17.  
  18. }
  19.  
  20. ##usage function
  21. usage()
  22. {
  23. echo -e ""
  24. echo -e "USAGE: $./list_domains.sh domain"
  25. echo -e "example: user@box:~$./list_domain.sh mysite.com"
  26. echo -e ""
  27. }
  28.  
  29. ##download function
  30. download()
  31. {
  32. wget http://$domain -O $domain_mirror -o /dev/null
  33. }
  34.  
  35. ##matching_domain_purser function
  36. matching_domain_purser()
  37. {
  38. grep "href=" $domain_mirror  | cut -d "/" -f 3 | grep $domain | sort -u | cut -d " " -f 1 | sed s'/\"//g' | sort -u | sed s'/ //g'
  39. }
  40.  
  41. ##unmatching_domain_purser function
  42. unmatching_domain_purser()
  43. {
  44. grep "href=" $domain_mirror  | cut -d "/" -f 3 | cut -d " " -f 1 | grep "\." | sed s'/"//g' | sort -u | grep -v $domain | egrep -v  '[!,@,#,$,%,^,&,*,(,),{,},[,[,<,>,?,=]'
  45. }
  46.  
  47. ##results display function
  48. display()
  49. {
  50. echo -e "getting a local copy of $domain index page.........."
  51. download
  52. echo -e "Done!"
  53. echo -e ""
  54. echo -e "\033[31mrelated domains found on http://www.$domain\033[0m"
  55. echo -e ""
  56. matching_domain_purser
  57. echo -e ""
  58. echo -e "\033[31mother domains found on http://www.$domain \033[0m"
  59. echo -e ""
  60. unmatching_domain_purser
  61. echo -e ""
  62. }
  63.  
  64. ##clean up function
  65. clean_up()
  66. {
  67. rm  -rf $domain_mirror
  68. }
  69.  
  70. ##master function
  71. master()
  72. {
  73. banner
  74. display
  75. clean_up
  76. }
  77.  
  78. ###################################
  79. ########script entrance############
  80. if [ $# == 1 ]
  81. then
  82. #run call master
  83. master
  84. else
  85. banner
  86. usage
  87. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement