├── README ├── README.md ├── blackhole ├── preparations.sh ├── run.sh ├── tmp.blacklist ├── tmp.whitelist └── whitelist_checker.sh └── unbound.conf /README: -------------------------------------------------------------------------------- 1 | DNSBlacklist project. 2 | 3 | Introduction. 4 | This project aims to be an assisting tool to setup your own DNS blacklisting in your enterprise environment. While the DNS provide 5 | blacklisting service, it will provide a good and fast caching for the enterprise DNS use. This tool will retrieve latest known 6 | malicious domains, and generate configuration file for BIND or UNBOUND DNS server. 7 | 8 | This include domain parser from various malicious domain provider 9 | - http://www.malwaredomains.com/ 10 | - https://spyeyetracker.abuse.ch/blocklist.php?download=domainblocklist 11 | - http://www.abuse.ch/zeustracker/blocklist.php?download=domainblocklist 12 | - https://palevotracker.abuse.ch/blocklists.php?download=domainblocklist 13 | - https://isc.sans.edu/suspicious_domains.html#lists 14 | - http://malc0de.com/bl/ZONES 15 | - http://labs.sucuri.net/?malware 16 | - www.malwareblacklist.com/mbl.xml 17 | - http://www.malwarepatrol.net/cgi/submit?action=list_bind 18 | - http://mtc.sri.com/live_data/malware_dns/ 19 | - http://exposure.iseclab.org/malware_domains.txt 20 | - http://support.clean-mx.de/clean-mx/xmlviruses?format=xml&fields=review,url&response=alive 21 | - http://www.nictasoft.com/ace/malware-urls/ 22 | - http://mirror1.malwaredomains.com/files/spywaredomains.zones 23 | 24 | Main features 25 | - Configurables of which domain sources to be used. 26 | - Choosable option for output format, Unbound or Bind DNS server 27 | 28 | The main script is preparation.sh, which generate a configuration 29 | file for unbound DNS server. You can choose BIND format output as well 30 | 31 | How to use 32 | - Pull to /etc/unbound/ 33 | - Edit /etc/unbound/unbound.conf according to your server environment. (Note the reference to "/etc/unbound/blackhole/blacklisted_domains.conf") 34 | - Run preparation.sh in /etc/unbound/blackhole/. Your "/etc/unbound/blackhole/blacklisted_domains.conf" will be created automatically. 35 | - run unbound-checkconf to verify the config file 36 | - Restart unbound for the config file to be effective. 37 | 38 | Farhan Faisal 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #DNSBlacklist project. 2 | 3 | ##Introduction. 4 | This project aims to be an assisting tool to setup your own DNS blacklisting in your 5 | enterprise environment. While the DNS provide blacklisting service, it will provide 6 | a good and fast caching for the enterprise DNS use. This tool will retrieve latest known 7 | malicious domains, and generate configuration file for BIND or UNBOUND DNS server. 8 | 9 | This script utilizing unbound as local recursive DNS server for your environment. 10 | 11 | ##How it works 12 | 13 | The script will pull malicious domains from various sources, to be configured in an 14 | unbound/bind DNS server. This server will be your internal DNS server in your environment. 15 | Any DNS request to malicious domain by any user in your environment will be handled by 16 | Unbound/BIND by returning a specified IP, usually 127.0.0.1, or any 'blackhole' IP. You 17 | can point to another server to monitor the malicious request 18 | 19 | This include domain parser from various malicious domain provider 20 | - http://www.malwaredomains.com/ 21 | - https://spyeyetracker.abuse.ch/blocklist.php?download=domainblocklist 22 | - http://www.abuse.ch/zeustracker/blocklist.php?download=domainblocklist 23 | - https://palevotracker.abuse.ch/blocklists.php?download=domainblocklist 24 | - https://isc.sans.edu/suspicious_domains.html#lists 25 | - http://malc0de.com/bl/ZONES 26 | - http://labs.sucuri.net/?malware 27 | - www.malwareblacklist.com/mbl.xml 28 | - http://www.malwarepatrol.net/cgi/submit?action=list_bind 29 | - http://mtc.sri.com/live_data/malware_dns/ 30 | - http://exposure.iseclab.org/malware_domains.txt 31 | - http://support.clean-mx.de/clean-mx/xmlviruses?format=xml&fields=review,url&response=alive 32 | - http://www.nictasoft.com/ace/malware-urls/ 33 | - http://mirror1.malwaredomains.com/files/spywaredomains.zones 34 | 35 | ##Main features 36 | - Configurables of which domain sources to be used. 37 | - Option for output format, Unbound or Bind DNS server (Unbound by default) 38 | - Domain permanent whitelisting and blacklisting 39 | 40 | The main script is preparation.sh, which generate a configuration 41 | file for unbound DNS server. You can choose BIND format output as well 42 | 43 | ##How to use 44 | - Pull to /etc/unbound/ 45 | - Edit /etc/unbound/unbound.conf according to your server environment. 46 | (Note the reference to "/etc/unbound/blackhole/blacklisted_domains.conf") 47 | - Run run.sh in /etc/unbound/blackhole/. 48 | Your "/etc/unbound/blackhole/blacklisted_domains.conf" will be created automatically. 49 | - run unbound-checkconf to verify the config file 50 | - Restart unbound for the config file to be effective. 51 | 52 | 53 | ####@2014 54 | -------------------------------------------------------------------------------- /blackhole/preparations.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | today=`date "+%Y-%m-%d-%H-%M-%S"` 3 | 4 | BASE="/etc/unbound" 5 | FOLDER_BL="blackhole" 6 | 7 | #### Notes 8 | ### http://www.digriz.org.uk/network-layer-protection/dns 9 | ### https://calomel.org/unbound_dns.html 10 | 11 | ########## Configurations 12 | # http://dns-bh.sagadc.org/domains.txt / http://www.malwaredomains.com/ 13 | SAGADC=0 14 | # https://spyeyetracker.abuse.ch/blocklist.php?download=domainblocklist 15 | SPYEYE=1 16 | # http://www.abuse.ch/zeustracker/blocklist.php?download=domainblocklist 17 | ZEUSTRACKER=1 18 | # https://palevotracker.abuse.ch/blocklists.php?download=domainblocklist 19 | PALEVOTRACKER=1 20 | # https://isc.sans.edu/suspicious_domains.html#lists 21 | ISCSANS=1 22 | # http://malc0de.com/bl/ZONES 23 | MALCODE=1 24 | # http://labs.sucuri.net/?malware 25 | SUCURI=1 26 | # www.malwareblacklist.com/mbl.xml 27 | MALWAREBLACKLIST=1 28 | # http://www.malwarepatrol.net/cgi/submit?action=list_bind 29 | MALWAREPATROL=1 30 | # http://mtc.sri.com/live_data/malware_dns/ 31 | MTC_SRI=1 32 | # http://exposure.iseclab.org/malware_domains.txt 33 | ISECLAB=1 34 | # http://support.clean-mx.de/clean-mx/xmlviruses?format=xml&fields=review,url&response=alive 35 | CLEANMX=0 36 | # http://www.nictasoft.com/ace/malware-urls/ 37 | NICTASOFT=1 38 | # http://mirror1.malwaredomains.com/files/spywaredomains.zones 39 | MALWAREDOMAINS_SPY=1 40 | # http://www.malwaredomainlist.com/hostslist/hosts.txt 41 | MALWAREDOMAINLIST=1 42 | 43 | ## Choose which DNS server are you using, BIND of UNBOUND 44 | DNSSERVER="unbound" # bind or unbound 45 | 46 | ## Delete all downloaded tmp files? 47 | DELETE=1 48 | DOWNLOAD_FILES=0 49 | 50 | ############################################################ 51 | ############ END OF CONFIGURABLE OPTIONS ################ 52 | ############################################################ 53 | 54 | if [ ! -d $BASE/$FOLDER_BL/backup ]; then 55 | mkdir -p $BASE/$FOLDER_BL/backup 56 | fi 57 | 58 | ## Backing up previous files. 59 | mv $BASE/$FOLDER_BL/master.list $BASE/$FOLDER_BL/backup/master.list.$today.txt 60 | if [ $DNSSERVER == 'bind' ]; then 61 | mv $BASE/$FOLDER_BL/master.list.zones $BASE/$FOLDER_BL/backup/master.list.zones.$today.txt 62 | elif [ $DNSSERVER == 'unbound' ]; then 63 | mv $BASE/$FOLDER_BL/blacklisted_domains.conf $BASE/$FOLDER_BL/backup/blacklisted_domains.conf.$today.txt 64 | fi 65 | 66 | 67 | 68 | ############################################## 69 | ######### malwaredomains.com ############## 70 | ############################################## 71 | if [ $SAGADC -ne 0 ]; then 72 | if [ $DOWNLOAD_FILES -ne 0 ]; then 73 | wget http://dns-bh.sagadc.org/domains.txt -O $BASE/$FOLDER_BL/dns-bh.sagadc.org.tmp 74 | fi 75 | more $BASE/$FOLDER_BL/dns-bh.sagadc.org.tmp | grep -v '#' | awk '$1 ~ /^20/ {print}' \ 76 | | awk '$6 ~ /^20/ {print $2}' | sort -u | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 77 | more $BASE/$FOLDER_BL/dns-bh.sagadc.org.tmp | grep -v '#' | awk '$1 !~ /^20/ {print}' \ 78 | | awk '{print $1}' | sort -u | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 79 | #more $BASE/$FOLDER_BL/dns-bh.sagadc.org.tmp | grep -v '#' | awk '{print $2}' \ 80 | # | cut -d'?' -f1 >> $BASE/$FOLDER_BL/master.list 81 | if [ $DELETE == 1 ]; then rm -rf $BASE/$FOLDER_BL/dns-bh.sagadc.org.tmp ; fi 82 | fi 83 | 84 | ################################################## 85 | ######### spyeyetracker.abuse.ch ############## 86 | ################################################## 87 | if [ $SPYEYE -ne 0 ]; then 88 | if [ $DOWNLOAD_FILES -ne 0 ]; then 89 | wget --no-check-certificate -t 3 https://spyeyetracker.abuse.ch/blocklist.php?download=domainblocklist -O $BASE/$FOLDER_BL/spyeyetracker.tmp 90 | fi 91 | cat $BASE/$FOLDER_BL/spyeyetracker.tmp | grep -v '#' | cut -d'?' -f1 | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 92 | if [ $DELETE == 1 ]; then rm -rf $BASE/$FOLDER_BL/spyeyetracker.tmp ; fi 93 | fi 94 | ############################################## 95 | ############## zeustracker ################ 96 | ############################################## 97 | if [ $ZEUSTRACKER -ne 0 ]; then 98 | if [ $DOWNLOAD_FILES -ne 0 ]; then 99 | wget -t 3 http://www.abuse.ch/zeustracker/blocklist.php?download=domainblocklist -O $BASE/$FOLDER_BL/zeustracker.tmp 100 | fi 101 | cat $BASE/$FOLDER_BL/zeustracker.tmp | grep -v '#' | cut -d'?' -f1 | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 102 | if [ $DELETE == 1 ]; then rm -rf $BASE/$FOLDER_BL/zeustracker.tmp ; fi 103 | fi 104 | 105 | ############################################## 106 | ############## palevotracker ################ 107 | ############################################## 108 | if [ $PALEVOTRACKER -ne 0 ]; then 109 | if [ $DOWNLOAD_FILES -ne 0 ]; then 110 | wget --no-check-certificate -t 3 https://palevotracker.abuse.ch/blocklists.php?download=domainblocklist -O palevotracker.tmp 111 | fi 112 | cat $BASE/$FOLDER_BL/palevotracker.tmp | grep -v '#' | cut -d'?' -f1 | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 113 | if [ $DELETE == 1 ]; then rm -rf $BASE/$FOLDER_BL/palevotracker.tmp ; fi 114 | fi 115 | 116 | ####################################################################### 117 | # Download from ISC High list Most Observed Malware-Related DNS Names # 118 | ####################################################################### 119 | if [ $ISCSANS -ne 0 ]; then 120 | if [ $DOWNLOAD_FILES -ne 0 ]; then 121 | #wget -t 3 http://isc.sans.edu/feeds/suspiciousdomains_Low.txt -O $BASE/$FOLDER_BL/suspiciousdomains_Low.txt 122 | wget -t 3 http://isc.sans.edu/feeds/suspiciousdomains_Medium.txt -O $BASE/$FOLDER_BL/suspiciousdomains_Medium.tmp 123 | wget -t 3 http://isc.sans.edu/feeds/suspiciousdomains_High.txt -O $BASE/$FOLDER_BL/suspiciousdomains_High.tmp 124 | fi 125 | 126 | #cat $BASE/$FOLDER_BL/suspiciousdomains_Low.txt | grep -v ^# | grep -v ^Site | sed '/^$/d' > $BASE/$FOLDER_BL/ISC.txt 127 | cat $BASE/$FOLDER_BL/suspiciousdomains_Medium.tmp | grep -v ^# | grep -v ^Site | sed '/^$/d' >> $BASE/$FOLDER_BL/ISC.tmp 128 | cat $BASE/$FOLDER_BL/suspiciousdomains_High.tmp | grep -v ^# | grep -v ^Site | sed '/^$/d' >> $BASE/$FOLDER_BL/ISC.tmp 129 | 130 | cat $BASE/$FOLDER_BL/ISC.tmp | grep -v "[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}" \ 131 | | sort | uniq | cut -d'?' -f1 | sed -e '/^M/d' >> $BASE/$FOLDER_BL/isc2.tmp 132 | cat $BASE/$FOLDER_BL/isc.tmp | sort -u | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 133 | if [ $DELETE == 1 ]; then 134 | rm -rf $BASE/$FOLDER_BL/suspiciousdomains_Low.tmp $BASE/$FOLDER_BL/suspiciousdomains_Medium.tmp 135 | rm -rf $BASE/$FOLDER_BL/suspiciousdomains_High.tmp $BASE/$FOLDER_BL/ISC.tmp $BASE/$FOLDER_BL/isc2.tmp 136 | fi 137 | fi 138 | 139 | 140 | ################################# 141 | ## Malcode 142 | ################################# 143 | if [ $MALCODE -ne 0 ]; then 144 | if [ $DOWNLOAD_FILES -ne 0 ]; then 145 | wget -t 3 http://malc0de.com/bl/ZONES -O $BASE/$FOLDER_BL/malcode.tmp 146 | fi 147 | more $BASE/$FOLDER_BL/malcode.tmp | cut -d'"' -f2 | grep -v -E "//|^$|#" \ 148 | | cut -d'?' -f1 | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 149 | if [ $DELETE == 1 ]; then rm -rf $BASE/$FOLDER_BL/malcode.tmp ; fi 150 | fi 151 | 152 | ################################# 153 | ## Sucuri 154 | ################################# 155 | if [ $SUCURI -ne 0 ]; then 156 | if [ $DOWNLOAD_FILES -ne 0 ]; then 157 | wget -t 3 http://labs.sucuri.net/?malware -O $BASE/$FOLDER_BL/index_sucuri.tmp 158 | fi 159 | more $BASE/$FOLDER_BL/index_sucuri.tmp | sed 's/iframe/\n\r/g; s/redirections/\n\r/g; s/javascript/\n\r/g'| awk '{ print $3 }' \ 160 | | tr = " " | tr \" " " | awk '{ print $3 }' | sed '/td><|>|<" | cut -d'?' -f1 | sed -e '/^M/d' >> $BASE/$FOLDER_BL/sucuri.tmp 162 | cat $BASE/$FOLDER_BL/sucuri.tmp | sort -u | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 163 | if [ $DELETE == 1 ]; then rm -rf $BASE/$FOLDER_BL/sucuri.tmp $BASE/$FOLDER_BL/index_sucuri.tmp ; fi 164 | fi 165 | 166 | ################################# 167 | ## Malware blacklist 168 | ################################# 169 | if [ $MALWAREBLACKLIST -ne 0 ]; then 170 | if [ $DOWNLOAD_FILES -ne 0 ]; then 171 | wget -t 3 www.malwareblacklist.com/mbl.xml -O $BASE/$FOLDER_BL/malwareblacklist.xml.tmp 172 | fi 173 | cat malwareblacklist.xml.tmp | grep Host: | sed 's/http://g' | tr \/ " " | awk '{ print $2 }' | sort | uniq \ 174 | | grep -v "[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}" \ 175 | | sed 's/\:[0-9 ].*//' | cut -d'?' -f1 | sed -e '/^M/d' >> $BASE/$FOLDER_BL/malwareblacklist.tmp 176 | cat $BASE/$FOLDER_BL/malwareblacklist.tmp | sort -u | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 177 | if [ $DELETE == 1 ]; then rm -rf $BASE/$FOLDER_BL/malwareblacklist.xml.tmp $BASE/$FOLDER_BL/malwareblacklist.tmp ; fi 178 | fi 179 | 180 | ################################################################################## 181 | # http://www.malwarepatrol.net 182 | ################################################################################## 183 | # Download Malware Patrol list Most Observed Malware-Related DNS Names 184 | if [ $MALWAREPATROL -ne 0 ]; then 185 | if [ $DOWNLOAD_FILES -ne 0 ]; then 186 | wget -t 3 http://www.malwarepatrol.net/cgi/submit?action=list_bind -O $BASE/$FOLDER_BL/malwarepatrol.tmp 187 | fi 188 | cat $BASE/$FOLDER_BL/malwarepatrol.tmp | awk '{ print $2 }' | sed 's/\"//g' \ 189 | | sed '/^$/d' | cut -d'?' -f1 | sed -e '/^M/d' >> $BASE/$FOLDER_BL/malwarepatrol2.tmp 190 | 191 | cat $BASE/$FOLDER_BL/malwarepatrol2.tmp | sort -u | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 192 | if [ $DELETE == 1 ]; then rm -rf $BASE/$FOLDER_BL/malwarepatrol.tmp $BASE/$FOLDER_BL/malwarepatrol2.tmp ; fi 193 | fi 194 | 195 | ################################################################################## 196 | # http://mtc.sri.com/live_data/malware_dns/ 197 | # Download a list of the most observed malware DNS names that we have seen looked 198 | # up during malware infections or embedded within malware binaries. 199 | ################################################################################## 200 | # Download SRI Malware Threat Center 201 | if [ $MTC_SRI -ne 0 ]; then 202 | if [ $DOWNLOAD_FILES -ne 0 ]; then 203 | wget -t 3 http://mtc.sri.com/live_data/malware_dns/ -O $BASE/$FOLDER_BL/sri.com.tmp 204 | fi 205 | cat $BASE/$FOLDER_BL/sri.com.tmp | grep -A 1 img | grep -E -v "img|--" \ 206 | | sed 's///g; s/<\/td>//g;' | cut -d'?' -f1 | sed -e '/^M/d' >> $BASE/$FOLDER_BL/sri.com2.tmp 207 | 208 | cat $BASE/$FOLDER_BL/sri.com.txt | sort -u | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 209 | if [ $DELETE == 1 ]; then rm -rf $BASE/$FOLDER_BL/sri.com.tmp $BASE/$FOLDER_BL/sri.com2.tmp ; fi 210 | fi 211 | 212 | ################################################################################## 213 | # http://exposure.iseclab.org/about.html 214 | # EXPOSURE is a service that identifies domain names that are involved in malicious activity 215 | # by performing large-scale passive DNS analysis. 216 | ################################################################################## 217 | # Download Exposure malicious DNS Names 218 | if [ $ISECLAB -ne 0 ]; then 219 | if [ $DOWNLOAD_FILES -ne 0 ]; then 220 | wget -t 3 http://exposure.iseclab.org/malware_domains.txt -O $BASE/$FOLDER_BL/iseclab.org.tmp 221 | fi 222 | cat $BASE/$FOLDER_BL/iseclab.org.tmp | sed '/^$/d' | cut -d'?' -f1 | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 223 | if [ $DELETE == 1 ]; then rm -rf $BASE/$FOLDER_BL/iseclab.org.tmp ; fi 224 | fi 225 | 226 | ########################################## 227 | ####### support.clean-mx.de/clean-mx 228 | ########################################## 229 | if [ $CLEANMX -ne 0 ]; then 230 | if [ $DOWNLOAD_FILES -ne 0 ]; then 231 | wget -t 3 'http://support.clean-mx.de/clean-mx/xmlviruses?format=xml&fields=review,url&response=alive' \ 232 | -O $BASE/$FOLDER_BL/clean.mx.txt 233 | fi 234 | more $BASE/$FOLDER_BL/clean.mx.txt | grep CDATA | cut -d'/' -f3 | cut -d']' -f1 |grep -v ':' \ 235 | | grep -v "[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}" \ 236 | | sort | uniq | cut -d'?' -f1 | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 237 | if [ $DELETE == 1 ]; then rm -rf $BASE/$FOLDER_BL/clean.mx.txt ; fi 238 | fi 239 | ######################################################### 240 | ####### http://www.nictasoft.com/ace/malware-urls/ 241 | ######################################################### 242 | if [ $NICTASOFT -ne 0 ]; then 243 | if [ $DOWNLOAD_FILES -ne 0 ]; then 244 | wget -t 3 http://www.nictasoft.com/ace/malware-urls/ -O $BASE/$FOLDER_BL/nictasoft.tmp 245 | fi 246 | more $BASE/$FOLDER_BL/nictasoft.tmp | grep -E "href" | grep "td" | cut -d'>' -f4 | cut -d'/' -f3 \ 247 | | cut -d'?' -f1 | grep -v -E "\.\.\.|nictasoft" | cut -d'<' -f 1 | cut -d':' -f1 \ 248 | | sort | uniq | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 249 | if [ $DELETE == 1 ]; then rm -rf $BASE/$FOLDER_BL/nictasoft.tmp ; fi 250 | fi 251 | ######################################################### 252 | ####### http://mirror1.malwaredomains.com/files/spywaredomains.zones 253 | ######################################################### 254 | if [ $MALWAREDOMAINS_SPY -ne 0 ]; then 255 | if [ $DOWNLOAD_FILES -ne 0 ]; then 256 | wget -t 3 "http://mirror1.malwaredomains.com/files/spywaredomains.zones" -O $BASE/$FOLDER_BL/malwaredomains_spy.tmp 257 | fi 258 | cat $BASE/$FOLDER_BL/malwaredomains_spy.tmp | cut -d'"' -f2 | cut -d'"' -f1 | grep -v '//' | sort \ 259 | | uniq | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 260 | if [ $DELETE == 1 ]; then rm -rf $BASE/$FOLDER_BL/malwaredomains_spy.tmp ; fi 261 | fi 262 | 263 | ######################################################### 264 | ####### http://www.malwaredomainlist.com/hostslist/hosts.txt 265 | ######################################################### 266 | if [ $MALWAREDOMAINLIST -ne 0 ]; then 267 | if [ $DOWNLOAD_FILES -ne 0 ]; then 268 | wget -t 3 "http://www.malwaredomainlist.com/hostslist/hosts.txt" -O $BASE/$FOLDER_BL/malwaredomainlist.tmp 269 | fi 270 | cat $BASE/$FOLDER_BL/malwaredomainlist.tmp | grep -v '#' | awk '{print $2}' | sed '/^$/d' | grep -v localhost \ 271 | | sort | uniq | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 272 | if [ $DELETE == 1 ]; then rm -rf $BASE/$FOLDER_BL/malwaredomainlist.tmp ; fi 273 | fi 274 | 275 | 276 | ## refining records.. remove rubbish.. files are the same.. 277 | cat $BASE/$FOLDER_BL/master.list | grep -v '<' | grep -v '>' | grep -v '#' | grep -v '//' \ 278 | | sed '/^$/d' | grep -v -E "\.$" | sort -u > $BASE/$FOLDER_BL/master.list.tmp 279 | rm -rf $BASE/$FOLDER_BL/master.list 280 | #perl -i -pe 's/$/\r/' $BASE/$FOLDER_BL/master.list.tmp 281 | #sed -e 's/.$//g' $BASE/$FOLDER_BL/master.list.tmp | sort | uniq > $BASE/$FOLDER_BL/master.list 282 | dos2unix $BASE/$FOLDER_BL/master.list.tmp 283 | cat $BASE/$FOLDER_BL/master.list.tmp | sort | uniq > $BASE/$FOLDER_BL/master.list 284 | rm -rf $BASE/$FOLDER_BL/master.list.tmp 285 | 286 | ## Whitelisting and blacklisting 287 | cat $BASE/$FOLDER_BL/tmp.blacklist >> $BASE/$FOLDER_BL/master.list 288 | $BASE/$FOLDER_BL/whitelist_checker.sh 289 | 290 | ## 291 | ## Outputting. Either in BIND format or UNBOUND format 292 | ## 293 | if [ $DNSSERVER == "bind" ]; then 294 | rm -rf $BASE/$FOLDER_BL/master.list.zones 295 | for a in `cat $BASE/$FOLDER_BL/master.list | grep -v '#'`; do 296 | echo "zone \"$a\" {type master; file \"/etc/bind/master.list.hosts\";};" >> $BASE/$FOLDER_BL/master.list.zones 297 | done 298 | echo "Configuration file generated : $BASE/$FOLDER_BL/master.list.zones" 299 | elif [ $DNSSERVER == 'unbound' ]; then 300 | rm -rf $BASE/$FOLDER_BL/blacklisted_domains.conf 301 | for a in `cat $BASE/$FOLDER_BL/master.list | grep -v '#'`; do 302 | echo 'local-data: "'$a' A 172.16.40.226"' >> $BASE/$FOLDER_BL/blacklisted_domains.conf 303 | done 304 | echo "Configuration file generated : $BASE/$FOLDER_BL/blacklisted_domains.conf" 305 | fi 306 | 307 | 308 | 309 | -------------------------------------------------------------------------------- /blackhole/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | today=`date "+%Y-%m-%d-%H-%M-%S"` 3 | 4 | BASE="/etc/unbound" 5 | FOLDER_BL="blackhole" 6 | 7 | #### Notes 8 | ### http://www.digriz.org.uk/network-layer-protection/dns 9 | ### https://calomel.org/unbound_dns.html 10 | 11 | ########## Configurations 12 | # http://dns-bh.sagadc.org/domains.txt / http://www.malwaredomains.com/ 13 | SAGADC=0 14 | # https://spyeyetracker.abuse.ch/blocklist.php?download=domainblocklist 15 | SPYEYE=1 16 | # http://www.abuse.ch/zeustracker/blocklist.php?download=domainblocklist 17 | ZEUSTRACKER=1 18 | # https://palevotracker.abuse.ch/blocklists.php?download=domainblocklist 19 | PALEVOTRACKER=1 20 | # https://isc.sans.edu/suspicious_domains.html#lists 21 | ISCSANS=1 22 | # http://malc0de.com/bl/ZONES 23 | MALCODE=1 24 | # http://labs.sucuri.net/?malware 25 | SUCURI=1 26 | # www.malwareblacklist.com/mbl.xml 27 | MALWAREBLACKLIST=1 28 | # http://www.malwarepatrol.net/cgi/submit?action=list_bind 29 | MALWAREPATROL=1 30 | # http://mtc.sri.com/live_data/malware_dns/ 31 | MTC_SRI=1 32 | # http://exposure.iseclab.org/malware_domains.txt 33 | ISECLAB=1 34 | # http://support.clean-mx.de/clean-mx/xmlviruses?format=xml&fields=review,url&response=alive 35 | CLEANMX=0 36 | # http://www.nictasoft.com/ace/malware-urls/ 37 | NICTASOFT=1 38 | # http://mirror1.malwaredomains.com/files/spywaredomains.zones 39 | MALWAREDOMAINS_SPY=1 40 | # http://www.malwaredomainlist.com/hostslist/hosts.txt 41 | MALWAREDOMAINLIST=1 42 | 43 | ## Choose which DNS server are you using, BIND of UNBOUND 44 | DNSSERVER="unbound" # bind or unbound 45 | 46 | ## Delete all downloaded tmp files? 47 | DELETE=1 48 | DOWNLOAD_FILES=0 49 | 50 | ############################################################ 51 | ############ END OF CONFIGURABLE OPTIONS ################ 52 | ############################################################ 53 | 54 | if [ ! -d $BASE/$FOLDER_BL/backup ]; then 55 | mkdir -p $BASE/$FOLDER_BL/backup 56 | fi 57 | 58 | ## Backing up previous files. 59 | mv $BASE/$FOLDER_BL/master.list $BASE/$FOLDER_BL/backup/master.list.$today.txt 60 | if [ $DNSSERVER == 'bind' ]; then 61 | mv $BASE/$FOLDER_BL/master.list.zones $BASE/$FOLDER_BL/backup/master.list.zones.$today.txt 62 | elif [ $DNSSERVER == 'unbound' ]; then 63 | mv $BASE/$FOLDER_BL/blacklisted_domains.conf $BASE/$FOLDER_BL/backup/blacklisted_domains.conf.$today.txt 64 | fi 65 | 66 | 67 | 68 | ############################################## 69 | ######### malwaredomains.com ############## 70 | ############################################## 71 | if [ $SAGADC -ne 0 ]; then 72 | if [ $DOWNLOAD_FILES -ne 0 ]; then 73 | wget http://dns-bh.sagadc.org/domains.txt -O $BASE/$FOLDER_BL/dns-bh.sagadc.org.tmp 74 | fi 75 | more $BASE/$FOLDER_BL/dns-bh.sagadc.org.tmp | grep -v '#' | awk '$1 ~ /^20/ {print}' \ 76 | | awk '$6 ~ /^20/ {print $2}' | sort -u | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 77 | more $BASE/$FOLDER_BL/dns-bh.sagadc.org.tmp | grep -v '#' | awk '$1 !~ /^20/ {print}' \ 78 | | awk '{print $1}' | sort -u | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 79 | #more $BASE/$FOLDER_BL/dns-bh.sagadc.org.tmp | grep -v '#' | awk '{print $2}' \ 80 | # | cut -d'?' -f1 >> $BASE/$FOLDER_BL/master.list 81 | if [ $DELETE == 1 ]; then rm -rf $BASE/$FOLDER_BL/dns-bh.sagadc.org.tmp ; fi 82 | fi 83 | 84 | ################################################## 85 | ######### spyeyetracker.abuse.ch ############## 86 | ################################################## 87 | if [ $SPYEYE -ne 0 ]; then 88 | if [ $DOWNLOAD_FILES -ne 0 ]; then 89 | wget --no-check-certificate -t 3 https://spyeyetracker.abuse.ch/blocklist.php?download=domainblocklist -O $BASE/$FOLDER_BL/spyeyetracker.tmp 90 | fi 91 | cat $BASE/$FOLDER_BL/spyeyetracker.tmp | grep -v '#' | cut -d'?' -f1 | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 92 | if [ $DELETE == 1 ]; then rm -rf $BASE/$FOLDER_BL/spyeyetracker.tmp ; fi 93 | fi 94 | ############################################## 95 | ############## zeustracker ################ 96 | ############################################## 97 | if [ $ZEUSTRACKER -ne 0 ]; then 98 | if [ $DOWNLOAD_FILES -ne 0 ]; then 99 | wget -t 3 http://www.abuse.ch/zeustracker/blocklist.php?download=domainblocklist -O $BASE/$FOLDER_BL/zeustracker.tmp 100 | fi 101 | cat $BASE/$FOLDER_BL/zeustracker.tmp | grep -v '#' | cut -d'?' -f1 | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 102 | if [ $DELETE == 1 ]; then rm -rf $BASE/$FOLDER_BL/zeustracker.tmp ; fi 103 | fi 104 | 105 | ############################################## 106 | ############## palevotracker ################ 107 | ############################################## 108 | if [ $PALEVOTRACKER -ne 0 ]; then 109 | if [ $DOWNLOAD_FILES -ne 0 ]; then 110 | wget --no-check-certificate -t 3 https://palevotracker.abuse.ch/blocklists.php?download=domainblocklist -O palevotracker.tmp 111 | fi 112 | cat $BASE/$FOLDER_BL/palevotracker.tmp | grep -v '#' | cut -d'?' -f1 | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 113 | if [ $DELETE == 1 ]; then rm -rf $BASE/$FOLDER_BL/palevotracker.tmp ; fi 114 | fi 115 | 116 | ####################################################################### 117 | # Download from ISC High list Most Observed Malware-Related DNS Names # 118 | ####################################################################### 119 | if [ $ISCSANS -ne 0 ]; then 120 | if [ $DOWNLOAD_FILES -ne 0 ]; then 121 | #wget -t 3 http://isc.sans.edu/feeds/suspiciousdomains_Low.txt -O $BASE/$FOLDER_BL/suspiciousdomains_Low.txt 122 | wget -t 3 http://isc.sans.edu/feeds/suspiciousdomains_Medium.txt -O $BASE/$FOLDER_BL/suspiciousdomains_Medium.tmp 123 | wget -t 3 http://isc.sans.edu/feeds/suspiciousdomains_High.txt -O $BASE/$FOLDER_BL/suspiciousdomains_High.tmp 124 | fi 125 | 126 | #cat $BASE/$FOLDER_BL/suspiciousdomains_Low.txt | grep -v ^# | grep -v ^Site | sed '/^$/d' > $BASE/$FOLDER_BL/ISC.txt 127 | cat $BASE/$FOLDER_BL/suspiciousdomains_Medium.tmp | grep -v ^# | grep -v ^Site | sed '/^$/d' >> $BASE/$FOLDER_BL/ISC.tmp 128 | cat $BASE/$FOLDER_BL/suspiciousdomains_High.tmp | grep -v ^# | grep -v ^Site | sed '/^$/d' >> $BASE/$FOLDER_BL/ISC.tmp 129 | 130 | cat $BASE/$FOLDER_BL/ISC.tmp | grep -v "[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}" \ 131 | | sort | uniq | cut -d'?' -f1 | sed -e '/^M/d' >> $BASE/$FOLDER_BL/isc2.tmp 132 | cat $BASE/$FOLDER_BL/isc.tmp | sort -u | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 133 | if [ $DELETE == 1 ]; then 134 | rm -rf $BASE/$FOLDER_BL/suspiciousdomains_Low.tmp $BASE/$FOLDER_BL/suspiciousdomains_Medium.tmp 135 | rm -rf $BASE/$FOLDER_BL/suspiciousdomains_High.tmp $BASE/$FOLDER_BL/ISC.tmp $BASE/$FOLDER_BL/isc2.tmp 136 | fi 137 | fi 138 | 139 | 140 | ################################# 141 | ## Malcode 142 | ################################# 143 | if [ $MALCODE -ne 0 ]; then 144 | if [ $DOWNLOAD_FILES -ne 0 ]; then 145 | wget -t 3 http://malc0de.com/bl/ZONES -O $BASE/$FOLDER_BL/malcode.tmp 146 | fi 147 | more $BASE/$FOLDER_BL/malcode.tmp | cut -d'"' -f2 | grep -v -E "//|^$|#" \ 148 | | cut -d'?' -f1 | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 149 | if [ $DELETE == 1 ]; then rm -rf $BASE/$FOLDER_BL/malcode.tmp ; fi 150 | fi 151 | 152 | ################################# 153 | ## Sucuri 154 | ################################# 155 | if [ $SUCURI -ne 0 ]; then 156 | if [ $DOWNLOAD_FILES -ne 0 ]; then 157 | wget -t 3 http://labs.sucuri.net/?malware -O $BASE/$FOLDER_BL/index_sucuri.tmp 158 | fi 159 | more $BASE/$FOLDER_BL/index_sucuri.tmp | sed 's/iframe/\n\r/g; s/redirections/\n\r/g; s/javascript/\n\r/g'| awk '{ print $3 }' \ 160 | | tr = " " | tr \" " " | awk '{ print $3 }' | sed '/td><|>|<" | cut -d'?' -f1 | sed -e '/^M/d' >> $BASE/$FOLDER_BL/sucuri.tmp 162 | cat $BASE/$FOLDER_BL/sucuri.tmp | sort -u | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 163 | if [ $DELETE == 1 ]; then rm -rf $BASE/$FOLDER_BL/sucuri.tmp $BASE/$FOLDER_BL/index_sucuri.tmp ; fi 164 | fi 165 | 166 | ################################# 167 | ## Malware blacklist 168 | ################################# 169 | if [ $MALWAREBLACKLIST -ne 0 ]; then 170 | if [ $DOWNLOAD_FILES -ne 0 ]; then 171 | wget -t 3 www.malwareblacklist.com/mbl.xml -O $BASE/$FOLDER_BL/malwareblacklist.xml.tmp 172 | fi 173 | cat malwareblacklist.xml.tmp | grep Host: | sed 's/http://g' | tr \/ " " | awk '{ print $2 }' | sort | uniq \ 174 | | grep -v "[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}" \ 175 | | sed 's/\:[0-9 ].*//' | cut -d'?' -f1 | sed -e '/^M/d' >> $BASE/$FOLDER_BL/malwareblacklist.tmp 176 | cat $BASE/$FOLDER_BL/malwareblacklist.tmp | sort -u | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 177 | if [ $DELETE == 1 ]; then rm -rf $BASE/$FOLDER_BL/malwareblacklist.xml.tmp $BASE/$FOLDER_BL/malwareblacklist.tmp ; fi 178 | fi 179 | 180 | ################################################################################## 181 | # http://www.malwarepatrol.net 182 | ################################################################################## 183 | # Download Malware Patrol list Most Observed Malware-Related DNS Names 184 | if [ $MALWAREPATROL -ne 0 ]; then 185 | if [ $DOWNLOAD_FILES -ne 0 ]; then 186 | wget -t 3 http://www.malwarepatrol.net/cgi/submit?action=list_bind -O $BASE/$FOLDER_BL/malwarepatrol.tmp 187 | fi 188 | cat $BASE/$FOLDER_BL/malwarepatrol.tmp | awk '{ print $2 }' | sed 's/\"//g' \ 189 | | sed '/^$/d' | cut -d'?' -f1 | sed -e '/^M/d' >> $BASE/$FOLDER_BL/malwarepatrol2.tmp 190 | 191 | cat $BASE/$FOLDER_BL/malwarepatrol2.tmp | sort -u | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 192 | if [ $DELETE == 1 ]; then rm -rf $BASE/$FOLDER_BL/malwarepatrol.tmp $BASE/$FOLDER_BL/malwarepatrol2.tmp ; fi 193 | fi 194 | 195 | ################################################################################## 196 | # http://mtc.sri.com/live_data/malware_dns/ 197 | # Download a list of the most observed malware DNS names that we have seen looked 198 | # up during malware infections or embedded within malware binaries. 199 | ################################################################################## 200 | # Download SRI Malware Threat Center 201 | if [ $MTC_SRI -ne 0 ]; then 202 | if [ $DOWNLOAD_FILES -ne 0 ]; then 203 | wget -t 3 http://mtc.sri.com/live_data/malware_dns/ -O $BASE/$FOLDER_BL/sri.com.tmp 204 | fi 205 | cat $BASE/$FOLDER_BL/sri.com.tmp | grep -A 1 img | grep -E -v "img|--" \ 206 | | sed 's///g; s/<\/td>//g;' | cut -d'?' -f1 | sed -e '/^M/d' >> $BASE/$FOLDER_BL/sri.com2.tmp 207 | 208 | cat $BASE/$FOLDER_BL/sri.com.txt | sort -u | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 209 | if [ $DELETE == 1 ]; then rm -rf $BASE/$FOLDER_BL/sri.com.tmp $BASE/$FOLDER_BL/sri.com2.tmp ; fi 210 | fi 211 | 212 | ################################################################################## 213 | # http://exposure.iseclab.org/about.html 214 | # EXPOSURE is a service that identifies domain names that are involved in malicious activity 215 | # by performing large-scale passive DNS analysis. 216 | ################################################################################## 217 | # Download Exposure malicious DNS Names 218 | if [ $ISECLAB -ne 0 ]; then 219 | if [ $DOWNLOAD_FILES -ne 0 ]; then 220 | wget -t 3 http://exposure.iseclab.org/malware_domains.txt -O $BASE/$FOLDER_BL/iseclab.org.tmp 221 | fi 222 | cat $BASE/$FOLDER_BL/iseclab.org.tmp | sed '/^$/d' | cut -d'?' -f1 | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 223 | if [ $DELETE == 1 ]; then rm -rf $BASE/$FOLDER_BL/iseclab.org.tmp ; fi 224 | fi 225 | 226 | ########################################## 227 | ####### support.clean-mx.de/clean-mx 228 | ########################################## 229 | if [ $CLEANMX -ne 0 ]; then 230 | if [ $DOWNLOAD_FILES -ne 0 ]; then 231 | wget -t 3 'http://support.clean-mx.de/clean-mx/xmlviruses?format=xml&fields=review,url&response=alive' \ 232 | -O $BASE/$FOLDER_BL/clean.mx.txt 233 | fi 234 | more $BASE/$FOLDER_BL/clean.mx.txt | grep CDATA | cut -d'/' -f3 | cut -d']' -f1 |grep -v ':' \ 235 | | grep -v "[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}" \ 236 | | sort | uniq | cut -d'?' -f1 | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 237 | if [ $DELETE == 1 ]; then rm -rf $BASE/$FOLDER_BL/clean.mx.txt ; fi 238 | fi 239 | ######################################################### 240 | ####### http://www.nictasoft.com/ace/malware-urls/ 241 | ######################################################### 242 | if [ $NICTASOFT -ne 0 ]; then 243 | if [ $DOWNLOAD_FILES -ne 0 ]; then 244 | wget -t 3 http://www.nictasoft.com/ace/malware-urls/ -O $BASE/$FOLDER_BL/nictasoft.tmp 245 | fi 246 | more $BASE/$FOLDER_BL/nictasoft.tmp | grep -E "href" | grep "td" | cut -d'>' -f4 | cut -d'/' -f3 \ 247 | | cut -d'?' -f1 | grep -v -E "\.\.\.|nictasoft" | cut -d'<' -f 1 | cut -d':' -f1 \ 248 | | sort | uniq | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 249 | if [ $DELETE == 1 ]; then rm -rf $BASE/$FOLDER_BL/nictasoft.tmp ; fi 250 | fi 251 | ######################################################### 252 | ####### http://mirror1.malwaredomains.com/files/spywaredomains.zones 253 | ######################################################### 254 | if [ $MALWAREDOMAINS_SPY -ne 0 ]; then 255 | if [ $DOWNLOAD_FILES -ne 0 ]; then 256 | wget -t 3 "http://mirror1.malwaredomains.com/files/spywaredomains.zones" -O $BASE/$FOLDER_BL/malwaredomains_spy.tmp 257 | fi 258 | cat $BASE/$FOLDER_BL/malwaredomains_spy.tmp | cut -d'"' -f2 | cut -d'"' -f1 | grep -v '//' | sort \ 259 | | uniq | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 260 | if [ $DELETE == 1 ]; then rm -rf $BASE/$FOLDER_BL/malwaredomains_spy.tmp ; fi 261 | fi 262 | 263 | ######################################################### 264 | ####### http://www.malwaredomainlist.com/hostslist/hosts.txt 265 | ######################################################### 266 | if [ $MALWAREDOMAINLIST -ne 0 ]; then 267 | if [ $DOWNLOAD_FILES -ne 0 ]; then 268 | wget -t 3 "http://www.malwaredomainlist.com/hostslist/hosts.txt" -O $BASE/$FOLDER_BL/malwaredomainlist.tmp 269 | fi 270 | cat $BASE/$FOLDER_BL/malwaredomainlist.tmp | grep -v '#' | awk '{print $2}' | sed '/^$/d' | grep -v localhost \ 271 | | sort | uniq | sed -e '/^M/d' >> $BASE/$FOLDER_BL/master.list 272 | if [ $DELETE == 1 ]; then rm -rf $BASE/$FOLDER_BL/malwaredomainlist.tmp ; fi 273 | fi 274 | 275 | 276 | ## refining records.. remove rubbish.. files are the same.. 277 | cat $BASE/$FOLDER_BL/master.list | grep -v '<' | grep -v '>' | grep -v '#' | grep -v '//' \ 278 | | sed '/^$/d' | grep -v -E "\.$" | sort -u > $BASE/$FOLDER_BL/master.list.tmp 279 | rm -rf $BASE/$FOLDER_BL/master.list 280 | #perl -i -pe 's/$/\r/' $BASE/$FOLDER_BL/master.list.tmp 281 | #sed -e 's/.$//g' $BASE/$FOLDER_BL/master.list.tmp | sort | uniq > $BASE/$FOLDER_BL/master.list 282 | dos2unix $BASE/$FOLDER_BL/master.list.tmp 283 | cat $BASE/$FOLDER_BL/master.list.tmp | sort | uniq > $BASE/$FOLDER_BL/master.list 284 | rm -rf $BASE/$FOLDER_BL/master.list.tmp 285 | 286 | ## Whitelisting and blacklisting 287 | cat $BASE/$FOLDER_BL/tmp.blacklist >> $BASE/$FOLDER_BL/master.list 288 | $BASE/$FOLDER_BL/whitelist_checker.sh 289 | 290 | ## 291 | ## Outputting. Either in BIND format or UNBOUND format 292 | ## 293 | if [ $DNSSERVER == "bind" ]; then 294 | rm -rf $BASE/$FOLDER_BL/master.list.zones 295 | for a in `cat $BASE/$FOLDER_BL/master.list | grep -v '#'`; do 296 | echo "zone \"$a\" {type master; file \"/etc/bind/master.list.hosts\";};" >> $BASE/$FOLDER_BL/master.list.zones 297 | done 298 | echo "Configuration file generated : $BASE/$FOLDER_BL/master.list.zones" 299 | elif [ $DNSSERVER == 'unbound' ]; then 300 | rm -rf $BASE/$FOLDER_BL/blacklisted_domains.conf 301 | for a in `cat $BASE/$FOLDER_BL/master.list | grep -v '#'`; do 302 | echo 'local-data: "'$a' A 172.16.40.226"' >> $BASE/$FOLDER_BL/blacklisted_domains.conf 303 | done 304 | echo "Configuration file generated : $BASE/$FOLDER_BL/blacklisted_domains.conf" 305 | fi 306 | 307 | 308 | 309 | -------------------------------------------------------------------------------- /blackhole/tmp.blacklist: -------------------------------------------------------------------------------- 1 | media.fbc.com.fj 2 | -------------------------------------------------------------------------------- /blackhole/tmp.whitelist: -------------------------------------------------------------------------------- 1 | dropbox.com 2 | amazonaws.com 3 | avast.com 4 | files.avast.com 5 | -------------------------------------------------------------------------------- /blackhole/whitelist_checker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | dns_config_file="/etc/unbound/blackhole/blacklisted_domains.conf" 4 | 5 | 6 | if [ ! -f tmp.whitelist ]; then 7 | touch tmp.whitelist 8 | fi 9 | 10 | for a in `cat tmp.whitelist`; do 11 | sed -i '/'$a'/d' $dns_config_file 12 | done 13 | 14 | -------------------------------------------------------------------------------- /unbound.conf: -------------------------------------------------------------------------------- 1 | 2 | server: 3 | ##################### Start of Server configuration ################## 4 | num-threads: 3 5 | interface: 6 | interface: 7 | port: 53 8 | msg-cache-size: 8Mb 9 | num-queries-per-thread: 1024 10 | do-ip4: yes 11 | do-udp: yes 12 | access-control: 0.0.0.0/0 allow 13 | do-daemonize: yes 14 | chroot: "/etc/unbound" 15 | logfile: "/var/log/unbound.log" 16 | log-queries: yes 17 | pidfile: "/etc/unbound/unbound.pid" 18 | 19 | ## This is the file which contains all of the blacklisted domains 20 | include: "/etc/unbound/blackhole/blacklisted_domains.conf" 21 | 22 | #Additional, hard-coded domains to be blacklisted 23 | local-data: "malicious-domain.com A 127.0.0.1" 24 | local-data: "malware-domains.com A 127.0.0.1" 25 | 26 | ##################### End of Server configuration ################## 27 | ##################### GO TO END OF FILE FOR DNS FORWARDER ############### 28 | 29 | # verbosity number, 0 is least verbose. 1 is default. 30 | verbosity: 1 31 | 32 | # print statistics to the log (for every thread) every N seconds. 33 | # Set to "" or 0 to disable. Default is disabled. 34 | # statistics-interval: 0 35 | 36 | # enable cumulative statistics, without clearing them after printing. 37 | # statistics-cumulative: no 38 | 39 | # enable extended statistics (query types, answer codes, status) 40 | # printed from unbound-control. default off, because of speed. 41 | # extended-statistics: no 42 | 43 | # number of threads to create. 1 disables threading. 44 | # num-threads: 3 45 | 46 | # specify the interfaces to answer queries from by ip-address. 47 | # The default is to listen to localhost (127.0.0.1 and ::1). 48 | # specify 0.0.0.0 and ::0 to bind to all available interfaces. 49 | # specify every interface[@port] on a new 'interface:' labelled line. 50 | # The listen interfaces are not changed on reload, only on restart. 51 | # interface: 192.0.2.153 52 | # interface: 192.0.2.154 53 | # interface: 192.0.2.154@5003 54 | # interface: 2001:DB8::5 55 | 56 | # enable this feature to copy the source address of queries to reply. 57 | # Socket options are not supported on all platforms. experimental. 58 | # interface-automatic: no 59 | 60 | # port to answer queries from 61 | # port: 53 62 | 63 | # specify the interfaces to send outgoing queries to authoritative 64 | # server from by ip-address. If none, the default (all) interface 65 | # is used. Specify every interface on a 'outgoing-interface:' line. 66 | # outgoing-interface: 192.0.2.153 67 | # outgoing-interface: 2001:DB8::5 68 | # outgoing-interface: 2001:DB8::6 69 | 70 | # number of ports to allocate per thread, determines the size of the 71 | # port range that can be open simultaneously. About double the 72 | # num-queries-per-thread, or, use as many as the OS will allow you. 73 | # outgoing-range: 4096 74 | 75 | # permit unbound to use this port number or port range for 76 | # making outgoing queries, using an outgoing interface. 77 | # outgoing-port-permit: 32768 78 | 79 | # deny unbound the use this of port number or port range for 80 | # making outgoing queries, using an outgoing interface. 81 | # Use this to make sure unbound does not grab a UDP port that some 82 | # other server on this computer needs. The default is to avoid 83 | # IANA-assigned port numbers. 84 | outgoing-port-avoid: "3200-3208" 85 | 86 | # number of outgoing simultaneous tcp buffers to hold per thread. 87 | # outgoing-num-tcp: 10 88 | 89 | # number of incoming simultaneous tcp buffers to hold per thread. 90 | # incoming-num-tcp: 10 91 | 92 | # buffer size for UDP port 53 incoming (SO_RCVBUF socket option). 93 | # 0 is system default. Use 4m to catch query spikes for busy servers. 94 | # so-rcvbuf: 0 95 | 96 | # buffer size for UDP port 53 outgoing (SO_SNDBUF socket option). 97 | # 0 is system default. Use 4m to handle spikes on very busy servers. 98 | # so-sndbuf: 0 99 | 100 | # EDNS reassembly buffer to advertise to UDP peers (the actual buffer 101 | # is set with msg-buffer-size). 1480 can solve fragmentation (timeouts). 102 | # edns-buffer-size: 4096 103 | 104 | # buffer size for handling DNS data. No messages larger than this 105 | # size can be sent or received, by UDP or TCP. In bytes. 106 | # msg-buffer-size: 65552 107 | 108 | # the amount of memory to use for the message cache. 109 | # plain value in bytes or you can append k, m or G. default is "4Mb". 110 | # msg-cache-size: 8Mb 111 | 112 | # the number of slabs to use for the message cache. 113 | # the number of slabs must be a power of 2. 114 | # more slabs reduce lock contention, but fragment memory usage. 115 | # msg-cache-slabs: 4 116 | 117 | # the number of queries that a thread gets to service. 118 | # num-queries-per-thread: 1024 119 | 120 | # if very busy, 50% queries run to completion, 50% get timeout in msec 121 | # jostle-timeout: 200 122 | 123 | # the amount of memory to use for the RRset cache. 124 | # plain value in bytes or you can append k, m or G. default is "4Mb". 125 | # rrset-cache-size: 4m 126 | 127 | # the number of slabs to use for the RRset cache. 128 | # the number of slabs must be a power of 2. 129 | # more slabs reduce lock contention, but fragment memory usage. 130 | # rrset-cache-slabs: 4 131 | 132 | # the time to live (TTL) value lower bound, in seconds. Default 0. 133 | # If more than an hour could easily give trouble due to stale data. 134 | # cache-min-ttl: 0 135 | 136 | # the time to live (TTL) value cap for RRsets and messages in the 137 | # cache. Items are not cached for longer. In seconds. 138 | # cache-max-ttl: 86400 139 | 140 | # the time to live (TTL) value for cached roundtrip times, lameness and 141 | # EDNS version information for hosts. In seconds. 142 | # infra-host-ttl: 900 143 | 144 | # the number of slabs to use for the Infrastructure cache. 145 | # the number of slabs must be a power of 2. 146 | # more slabs reduce lock contention, but fragment memory usage. 147 | # infra-cache-slabs: 4 148 | 149 | # the maximum number of hosts that are cached (roundtrip, EDNS, lame). 150 | # infra-cache-numhosts: 10000 151 | 152 | # Enable IPv4, "yes" or "no". 153 | # do-ip4: yes 154 | 155 | # Enable IPv6, "yes" or "no". 156 | # do-ip6: yes 157 | 158 | # Enable UDP, "yes" or "no". 159 | # do-udp: yes 160 | 161 | # Enable TCP, "yes" or "no". 162 | # do-tcp: yes 163 | 164 | # upstream connections use TCP only (and no UDP), "yes" or "no" 165 | # useful for tunneling scenarios, default no. 166 | # tcp-upstream: no 167 | 168 | # Detach from the terminal, run in background, "yes" or "no". 169 | # do-daemonize: yes 170 | 171 | # control which clients are allowed to make (recursive) queries 172 | # to this server. Specify classless netblocks with /size and action. 173 | # By default everything is refused, except for localhost. 174 | # Choose deny (drop message), refuse (polite error reply), 175 | # allow (recursive ok), allow_snoop (recursive and nonrecursive ok) 176 | # access-control: 0.0.0.0/0 allow 177 | # access-control: 127.0.0.0/8 allow 178 | # access-control: ::0/0 refuse 179 | # access-control: ::1 allow 180 | # access-control: ::ffff:127.0.0.1 allow 181 | 182 | # if given, a chroot(2) is done to the given directory. 183 | # i.e. you can chroot to the working directory, for example, 184 | # for extra security, but make sure all files are in that directory. 185 | # 186 | # If chroot is enabled, you should pass the configfile (from the 187 | # commandline) as a full path from the original root. After the 188 | # chroot has been performed the now defunct portion of the config 189 | # file path is removed to be able to reread the config after a reload. 190 | # 191 | # All other file paths (working dir, logfile, roothints, and 192 | # key files) can be specified in several ways: 193 | # o as an absolute path relative to the new root. 194 | # o as a relative path to the working directory. 195 | # o as an absolute path relative to the original root. 196 | # In the last case the path is adjusted to remove the unused portion. 197 | # 198 | # The pid file can be absolute and outside of the chroot, it is 199 | # written just prior to performing the chroot and dropping permissions. 200 | # 201 | # Additionally, unbound may need to access /dev/random (for entropy). 202 | # How to do this is specific to your OS. 203 | # 204 | # If you give "" no chroot is performed. The path must not end in a /. 205 | # chroot: "/etc/unbound" 206 | 207 | # if given, user privileges are dropped (after binding port), 208 | # and the given username is assumed. Default is user "unbound". 209 | # If you give "" no privileges are dropped. 210 | # username: "unbound" 211 | 212 | # the working directory. The relative files in this config are 213 | # relative to this directory. If you give "" the working directory 214 | # is not changed. 215 | # directory: "/etc/unbound" 216 | 217 | # the log file, "" means log to stderr. 218 | # Use of this option sets use-syslog to "no". 219 | # logfile: "/var/log/unbound.log" 220 | 221 | # Log to syslog(3) if yes. The log facility LOG_DAEMON is used to 222 | # log to, with identity "unbound". If yes, it overrides the logfile. 223 | # use-syslog: yes 224 | 225 | # print UTC timestamp in ascii to logfile, default is epoch in seconds. 226 | # log-time-ascii: no 227 | 228 | # print one line with time, IP, name, type, class for every query. 229 | # log-queries: yes 230 | 231 | # the pid file. Can be an absolute path outside of chroot/work dir. 232 | # pidfile: "/etc/unbound/unbound.pid" 233 | 234 | # file to read root hints from. 235 | # get one from ftp://FTP.INTERNIC.NET/domain/named.cache 236 | # root-hints: "" 237 | 238 | # enable to not answer id.server and hostname.bind queries. 239 | # hide-identity: no 240 | 241 | # enable to not answer version.server and version.bind queries. 242 | # hide-version: no 243 | 244 | # the identity to report. Leave "" or default to return hostname. 245 | # identity: "" 246 | 247 | # the version to report. Leave "" or default to return package version. 248 | # version: "" 249 | 250 | # the target fetch policy. 251 | # series of integers describing the policy per dependency depth. 252 | # The number of values in the list determines the maximum dependency 253 | # depth the recursor will pursue before giving up. Each integer means: 254 | # -1 : fetch all targets opportunistically, 255 | # 0: fetch on demand, 256 | # positive value: fetch that many targets opportunistically. 257 | # Enclose the list of numbers between quotes (""). 258 | # target-fetch-policy: "3 2 1 0 0" 259 | 260 | # Harden against very small EDNS buffer sizes. 261 | # harden-short-bufsize: no 262 | 263 | # Harden against unseemly large queries. 264 | # harden-large-queries: no 265 | 266 | # Harden against out of zone rrsets, to avoid spoofing attempts. 267 | # harden-glue: yes 268 | 269 | # Harden against receiving dnssec-stripped data. If you turn it 270 | # off, failing to validate dnskey data for a trustanchor will 271 | # trigger insecure mode for that zone (like without a trustanchor). 272 | # Default on, which insists on dnssec data for trust-anchored zones. 273 | # harden-dnssec-stripped: yes 274 | 275 | # Harden against queries that fall under dnssec-signed nxdomain names. 276 | # harden-below-nxdomain: no 277 | 278 | # Harden the referral path by performing additional queries for 279 | # infrastructure data. Validates the replies (if possible). 280 | # Default off, because the lookups burden the server. Experimental 281 | # implementation of draft-wijngaards-dnsext-resolver-side-mitigation. 282 | # harden-referral-path: no 283 | 284 | # Use 0x20-encoded random bits in the query to foil spoof attempts. 285 | # This feature is an experimental implementation of draft dns-0x20. 286 | # use-caps-for-id: no 287 | 288 | # Enforce privacy of these addresses. Strips them away from answers. 289 | # It may cause DNSSEC validation to additionally mark it as bogus. 290 | # Protects against 'DNS Rebinding' (uses browser as network proxy). 291 | # Only 'private-domain' and 'local-data' names are allowed to have 292 | # these private addresses. No default. 293 | # private-address: 10.0.0.0/8 294 | # private-address: 172.16.0.0/12 295 | # private-address: 192.168.0.0/16 296 | # private-address: 169.254.0.0/16 297 | # private-address: fd00::/8 298 | # private-address: fe80::/10 299 | 300 | # Allow the domain (and its subdomains) to contain private addresses. 301 | # local-data statements are allowed to contain private addresses too. 302 | # private-domain: "example.com" 303 | 304 | # If nonzero, unwanted replies are not only reported in statistics, 305 | # but also a running total is kept per thread. If it reaches the 306 | # threshold, a warning is printed and a defensive action is taken, 307 | # the cache is cleared to flush potential poison out of it. 308 | # A suggested value is 10000000, the default is 0 (turned off). 309 | # unwanted-reply-threshold: 0 310 | 311 | # Do not query the following addresses. No DNS queries are sent there. 312 | # List one address per entry. List classless netblocks with /size, 313 | # do-not-query-address: 127.0.0.1/8 314 | # do-not-query-address: ::1 315 | 316 | # if yes, the above default do-not-query-address entries are present. 317 | # if no, localhost can be queried (for testing and debugging). 318 | # do-not-query-localhost: yes 319 | 320 | # if yes, perform prefetching of almost expired message cache entries. 321 | # prefetch: no 322 | 323 | # if yes, perform key lookups adjacent to normal lookups. 324 | # prefetch-key: no 325 | 326 | # module configuration of the server. A string with identifiers 327 | # separated by spaces. "iterator" or "validator iterator" 328 | # module-config: "validator iterator" 329 | 330 | # File with trusted keys, kept uptodate using RFC5011 probes, 331 | # initial file like trust-anchor-file, then it stores metadata. 332 | # Use several entries, one per domain name, to track multiple zones. 333 | # 334 | # If you want to perform DNSSEC validation, run unbound-anchor before 335 | # you start unbound (i.e. in the system boot scripts). And enable: 336 | # Please note usage of unbound-anchor root anchor is at your own risk 337 | # and under the terms of our LICENSE (see that file in the source). 338 | # auto-trust-anchor-file: "/etc/unbound/root.key" 339 | 340 | # File with DLV trusted keys. Same format as trust-anchor-file. 341 | # There can be only one DLV configured, it is trusted from root down. 342 | # Download http://ftp.isc.org/www/dlv/dlv.isc.org.key 343 | # dlv-anchor-file: "dlv.isc.org.key" 344 | 345 | # File with trusted keys for validation. Specify more than one file 346 | # with several entries, one file per entry. 347 | # Zone file format, with DS and DNSKEY entries. 348 | # Note this gets out of date, use auto-trust-anchor-file please. 349 | # trust-anchor-file: "" 350 | 351 | # Trusted key for validation. DS or DNSKEY. specify the RR on a 352 | # single line, surrounded by "". TTL is ignored. class is IN default. 353 | # Note this gets out of date, use auto-trust-anchor-file please. 354 | # (These examples are from August 2007 and may not be valid anymore). 355 | # trust-anchor: "nlnetlabs.nl. DNSKEY 257 3 5 AQPzzTWMz8qSWIQlfRnPckx2BiVmkVN6LPupO3mbz7FhLSnm26n6iG9N Lby97Ji453aWZY3M5/xJBSOS2vWtco2t8C0+xeO1bc/d6ZTy32DHchpW 6rDH1vp86Ll+ha0tmwyy9QP7y2bVw5zSbFCrefk8qCUBgfHm9bHzMG1U BYtEIQ==" 356 | # trust-anchor: "jelte.nlnetlabs.nl. DS 42860 5 1 14D739EB566D2B1A5E216A0BA4D17FA9B038BE4A" 357 | 358 | # File with trusted keys for validation. Specify more than one file 359 | # with several entries, one file per entry. Like trust-anchor-file 360 | # but has a different file format. Format is BIND-9 style format, 361 | # the trusted-keys { name flag proto algo "key"; }; clauses are read. 362 | # you need external update procedures to track changes in keys. 363 | # trusted-keys-file: "" 364 | 365 | # Ignore chain of trust. Domain is treated as insecure. 366 | # domain-insecure: "example.com" 367 | 368 | # Override the date for validation with a specific fixed date. 369 | # Do not set this unless you are debugging signature inception 370 | # and expiration. "" or "0" turns the feature off. -1 ignores date. 371 | # val-override-date: "" 372 | 373 | # The time to live for bogus data, rrsets and messages. This avoids 374 | # some of the revalidation, until the time interval expires. in secs. 375 | # val-bogus-ttl: 60 376 | 377 | # The signature inception and expiration dates are allowed to be off 378 | # by 10% of the signature lifetime (expir-incep) from our local clock. 379 | # This leeway is capped with a minimum and a maximum. In seconds. 380 | # val-sig-skew-min: 3600 381 | # val-sig-skew-max: 86400 382 | 383 | # Should additional section of secure message also be kept clean of 384 | # unsecure data. Useful to shield the users of this validator from 385 | # potential bogus data in the additional section. All unsigned data 386 | # in the additional section is removed from secure messages. 387 | # val-clean-additional: yes 388 | 389 | # Turn permissive mode on to permit bogus messages. Thus, messages 390 | # for which security checks failed will be returned to clients, 391 | # instead of SERVFAIL. It still performs the security checks, which 392 | # result in interesting log files and possibly the AD bit in 393 | # replies if the message is found secure. The default is off. 394 | # val-permissive-mode: no 395 | 396 | # Ignore the CD flag in incoming queries and refuse them bogus data. 397 | # Enable it if the only clients of unbound are legacy servers (w2008) 398 | # that set CD but cannot validate themselves. 399 | # ignore-cd-flag: no 400 | 401 | # Have the validator log failed validations for your diagnosis. 402 | # 0: off. 1: A line per failed user query. 2: With reason and bad IP. 403 | # val-log-level: 0 404 | 405 | # It is possible to configure NSEC3 maximum iteration counts per 406 | # keysize. Keep this table very short, as linear search is done. 407 | # A message with an NSEC3 with larger count is marked insecure. 408 | # List in ascending order the keysize and count values. 409 | # val-nsec3-keysize-iterations: "1024 150 2048 500 4096 2500" 410 | 411 | # instruct the auto-trust-anchor-file probing to add anchors after ttl. 412 | # add-holddown: 2592000 # 30 days 413 | 414 | # instruct the auto-trust-anchor-file probing to del anchors after ttl. 415 | # del-holddown: 2592000 # 30 days 416 | 417 | # auto-trust-anchor-file probing removes missing anchors after ttl. 418 | # If the value 0 is given, missing anchors are not removed. 419 | # keep-missing: 31622400 # 366 days 420 | 421 | # the amount of memory to use for the key cache. 422 | # plain value in bytes or you can append k, m or G. default is "4Mb". 423 | key-cache-size: 8Mb 424 | 425 | # the number of slabs to use for the key cache. 426 | # the number of slabs must be a power of 2. 427 | # more slabs reduce lock contention, but fragment memory usage. 428 | # key-cache-slabs: 8 429 | 430 | # the amount of memory to use for the negative cache (used for DLV). 431 | # plain value in bytes or you can append k, m or G. default is "1Mb". 432 | # neg-cache-size: 1m 433 | 434 | # a number of locally served zones can be configured. 435 | # local-zone: 436 | # local-data: "" 437 | # o deny serves local data (if any), else, drops queries. 438 | # o refuse serves local data (if any), else, replies with error. 439 | # o static serves local data, else, nxdomain or nodata answer. 440 | # o transparent gives local data, but resolves normally for other names 441 | # o redirect serves the zone data for any subdomain in the zone. 442 | # o nodefault can be used to normally resolve AS112 zones. 443 | # o typetransparent resolves normally for other types and other names 444 | # 445 | # defaults are localhost address, reverse for 127.0.0.1 and ::1 446 | # and nxdomain for AS112 zones. If you configure one of these zones 447 | # the default content is omitted, or you can omit it with 'nodefault'. 448 | # 449 | # If you configure local-data without specifying local-zone, by 450 | # default a transparent local-zone is created for the data. 451 | # 452 | # You can add locally served data with 453 | # local-zone: "local." static 454 | # local-data: "mycomputer.local. IN A 192.0.2.51" 455 | # local-data: 'mytext.local TXT "content of text record"' 456 | # 457 | # You can override certain queries with 458 | # local-data: "adserver.example.com A 127.0.0.1" 459 | # 460 | # You can redirect a domain to a fixed address with 461 | # (this makes example.com, www.example.com, etc, all go to 192.0.2.3) 462 | # local-zone: "example.com" redirect 463 | # local-data: "example.com A 192.0.2.3" 464 | 465 | # local-data: "kuaibo.com A 172.16.40.226" 466 | # local-data: "qvod.com A 172.16.40.226" 467 | # include: "/etc/unbound/blackhole/blacklisted_domains.conf" 468 | 469 | # 470 | # Shorthand to make PTR records, "IPv4 name" or "IPv6 name". 471 | # You can also add PTR records using local-data directly, but then 472 | # you need to do the reverse notation yourself. 473 | # local-data-ptr: "192.0.2.3 www.example.com" 474 | 475 | # service clients over SSL (on the TCP sockets), with plain DNS inside 476 | # the SSL stream. Give the certificate to use and private key. 477 | # default is "" (disabled). requires restart to take effect. 478 | # ssl-service-key: "path/to/privatekeyfile.key" 479 | # ssl-service-pem: "path/to/publiccertfile.pem" 480 | # ssl-port: 443 481 | 482 | # request upstream over SSL (with plain DNS inside the SSL stream). 483 | # Default is no. Can be turned on and off with unbound-control. 484 | # ssl-upstream: no 485 | 486 | 487 | # Python config section. To enable: 488 | # o use --with-pythonmodule to configure before compiling. 489 | # o list python in the module-config string (above) to enable. 490 | # o and give a python-script to run. 491 | python: 492 | # Script file to load 493 | # python-script: "/etc/unbound/ubmodule-tst.py" 494 | 495 | # Remote control config section. 496 | remote-control: 497 | # Enable remote control with unbound-control(8) here. 498 | # set up the keys and certificates with unbound-control-setup. 499 | control-enable: no 500 | 501 | # what interfaces are listened to for remote control. 502 | # give 0.0.0.0 and ::0 to listen to all interfaces. 503 | # control-interface: 127.0.0.1 504 | # control-interface: ::1 505 | 506 | # port number for remote control operations. 507 | # control-port: 8953 508 | 509 | # unbound server key file. 510 | # server-key-file: "/etc/unbound/unbound_server.key" 511 | 512 | # unbound server certificate file. 513 | # server-cert-file: "/etc/unbound/unbound_server.pem" 514 | 515 | # unbound-control key file. 516 | # control-key-file: "/etc/unbound/unbound_control.key" 517 | 518 | # unbound-control certificate file. 519 | # control-cert-file: "/etc/unbound/unbound_control.pem" 520 | 521 | # Stub zones. 522 | # Create entries like below, to make all queries for 'example.com' and 523 | # 'example.org' go to the given list of nameservers. list zero or more 524 | # nameservers by hostname or by ipaddress. If you set stub-prime to yes, 525 | # the list is treated as priming hints (default is no). 526 | # stub-zone: 527 | # name: "example.org" 528 | # stub-host: ns.example.com. 529 | 530 | # Forward zones 531 | # Create entries like below, to make all queries for 'example.com' and 532 | # 'example.org' go to the given list of servers. These servers have to handle 533 | # recursion to other nameservers. List zero or more nameservers by hostname 534 | # or by ipaddress. Use an entry with name "." to forward all queries. 535 | # forward-zone: 536 | # name: "example.com" 537 | # forward-addr: 192.0.2.68 538 | # forward-addr: 192.0.2.73@5355 # forward to port 5355. 539 | forward-zone: 540 | name: "." 541 | forward-addr: 8.8.8.8 542 | forward-addr: 543 | forward-addr: 544 | --------------------------------------------------------------------------------