Re: Re: domainhack

From NAT, 6 Years ago, written in Bash, viewed 795 times. This paste is a reply to Re: domainhack from NAT - view diff
URL https://code.nat.moe/view/d24aab0b Embed
Download Paste or View Raw
  1. #!/bin/bash
  2. #
  3. # domainhack: Find the registered domains with no handle on nameservers.
  4. # Currently, the script is configured to capture dnspod's domains.
  5. #
  6.  
  7. DAILYCHALES_DOMAINLIST_CSV="./domain.csv"
  8. DOMAIN_LIST="./domain.lst"
  9. DOMAIN_SAVE="./save.lst"
  10. CHECKED_SAVE="./save-checked.lst"
  11. DEFAULT_NS="f1g1ns1.dnspod.net"
  12. DOWNLOAD_NS="dnspod.net"
  13.  
  14. WARN="\033[1;33m"
  15. ERR="\033[0;31m"
  16. SUCCESS="\033[1;32m"
  17. RST="\033[0m"
  18.  
  19. DATE=$1
  20. [[ -z $DATE || $DATE == "NOW" || $DATE == "now" ]] && DATE="$(date +%Y-%m-%d)"
  21. WHOIS_CHECKMODE=$(echo $* | grep whois-mode)
  22. VERIFY_NS=$(echo $* | grep verifyns)
  23.  
  24. function getarg {
  25.         cat /dev/stdin | awk -F"--$1 " '{print $2}' | awk -F" " '{print $1}'
  26. }
  27.  
  28. function checkDomainNS {
  29.         echo -n "checkDomainNS: checking $1..."
  30.         NS=$(whois $1 2> /dev/null | grep "Name Server")
  31.         [[ -z $NS ]] && echo -e "$WARN whois error$RST" && return 1
  32.         [[ ! -z $(echo $NS | grep $DEFAULT_NS) ]] && echo -e "$SUCCESS using target nameserver$RST" && echo $1 >> $CHECKED_SAVE || echo -e "$ERR not using target nameserver$RST"
  33. }
  34.  
  35. function checkDomainCofniguredByNS {
  36.         echo -n "checkDomainCofniguredByNS: checking $1 in $2..."
  37.         [[ ! -z $(nslookup $1 $DEFAULT_NS | grep -E "NXDOMAIN|SERVFAIL|could|timed") ]] && echo -e "$SUCCESS unconfiged$RST" && echo "$1" >> $DOMAIN_SAVE || echo -e "$ERR configed$RST"
  38.         [[ ! -z $VERIFY_NS ]] && checkDomainNS $1
  39. }
  40.  
  41. function checkDomainList {
  42.         for domain in $(cat $DOMAIN_LIST)
  43.         do
  44.                 checkDomainCofniguredByNS $domain $DEFAULT_NS
  45.         done
  46. }
  47.  
  48. function processDomainList {
  49.         echo -n "processDomainList: processing $DAILYCHALES_DOMAINLIST_CSV..."
  50.         cat $DAILYCHALES_DOMAINLIST_CSV | grep ,new, | sed -e "s/,new,//g" > $DOMAIN_LIST
  51.         dos2unix $DOMAIN_LIST > /dev/null 2> /dev/null
  52.         echo -e "$SUCCESS done$RST"
  53. }
  54.  
  55. function downloadDomainList {
  56.         echo -n "downloadDomainList: downloading domains list for $DATE from dailychanges..."
  57.         curl -s -A "Mozilla Firefox" -e "http://www.dailychanges.com/$DOWNLOAD_NS/$DATE/" "http://www.dailychanges.com/export/$DOWNLOAD_NS/$DATE/export.csv" > $DAILYCHALES_DOMAINLIST_CSV 2> /dev/null
  58.         [[ -z $(cat $DAILYCHALES_DOMAINLIST_CSV | grep ,new,) ]] && echo -e "$ERR failed$RST" && exit 1 || echo -e "$SUCCESS done$RST"
  59. }
  60.  
  61. function main {
  62.         downloadDomainList
  63.         processDomainList
  64.         checkDomainList
  65. }
  66.  
  67. main

Reply to "Re: Re: domainhack"

Here you can reply to the paste above

captcha