├── .github └── workflows │ └── ai_team_mgr.yml ├── README.md ├── Ubuntu-Walkthrough.md ├── bindconf ├── named.acl ├── named.conf.local ├── named.logging └── named.rpzones └── scripts ├── COPYING ├── assemble_cidr_zone.sh ├── assemble_dname_zone.sh ├── local_white_block.README ├── nsupdate_block.sh ├── nsupdate_hits.sh ├── nsupdate_hits_alternative.sh ├── nsupdate_white.sh ├── nsupdate_zone.sh ├── refresh_alexa.sh ├── refresh_drop.sh ├── ubuntu.crontab └── zone.header.example /.github/workflows/ai_team_mgr.yml: -------------------------------------------------------------------------------- 1 | name: Get Commits in Last Hour from All Branches 2 | 3 | on: 4 | push: 5 | branches: "**/**" 6 | issues: 7 | types: [opened, edited, deleted, transferred, pinned, unpinned, closed, reopened, assigned, unassigned, labeled, unlabeled, locked, unlocked, milestoned, demilestoned] 8 | issue_comment: 9 | types: [created, deleted, edited] 10 | jobs: 11 | get-commits: 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - name: Checkout repository 16 | uses: actions/checkout@v3 17 | 18 | - name: Get commits in the last hour from all branches 19 | run: | 20 | TOKEN=${{ secrets.GITHUB_TOKEN }} 21 | REPO_OWNER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1) 22 | REPO_NAME=$(echo $GITHUB_REPOSITORY | cut -d'/' -f2) 23 | 24 | # Get current time and time an hour ago in ISO 8601 format 25 | CURRENT_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ") 26 | ONE_HOUR_AGO=$(date -u -d '-1 hour' +"%Y-%m-%dT%H:%M:%SZ") 27 | 28 | # Fetch all branches 29 | BRANCHES=$(curl -s -H "Authorization: token $TOKEN" \ 30 | "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/branches" | jq -r '.[].name') 31 | 32 | # Initialize an empty JSON array 33 | ALL_COMMITS="[]" 34 | 35 | # Loop through all branches and aggregate commits 36 | for BRANCH in $BRANCHES; do 37 | COMMITS=$(curl -s -H "Authorization: token $TOKEN" \ 38 | "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/commits?sha=$BRANCH&since=$ONE_HOUR_AGO&until=$CURRENT_TIME") 39 | 40 | # Merge the commits from this branch into the aggregated JSON array 41 | ALL_COMMITS=$(echo $ALL_COMMITS $COMMITS | jq -s '.[0] + .[1]') 42 | done 43 | 44 | echo "Combined commits from all branches:" 45 | echo $ALL_COMMITS 46 | 47 | # Save the combined JSON array to a file 48 | echo $ALL_COMMITS > commits.json 49 | - name: Get Issue Events, Tags, Contributors 50 | run: | 51 | TOKEN=${{ secrets.GITHUB_TOKEN }} 52 | REPO_OWNER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1) 53 | REPO_NAME=$(echo $GITHUB_REPOSITORY | cut -d'/' -f2) 54 | 55 | ONE_HOUR_AGO=$(date -u -d '-1 hour' +"%Y-%m-%dT%H:%M:%SZ") 56 | 57 | ISSUE_EVENTS=$(curl -s -H "Authorization: token $TOKEN" \ 58 | "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/issues/events") 59 | ISSUE_COMMENTS=$(curl -s -H "Authorization: token $TOKEN" \ 60 | "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/issues/comments?per_page=100&since=$ONE_HOUR_AGO") 61 | # Pagination to get all issues. 62 | ALL_ISSUES=() 63 | PAGE=1 64 | while :; do 65 | RESPONSE=$(curl -s -H "Authorization: token $TOKEN" "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/issues?state=all&per_page=100&page=$PAGE") 66 | if [[ $(echo "$RESPONSE" | jq '. | length') -eq 0 ]]; then 67 | break 68 | fi 69 | ALL_ISSUES+=("$RESPONSE") 70 | 71 | ((PAGE++)) 72 | done 73 | ALL_ISSUES_JSON=$(echo "${ALL_ISSUES[@]}" | jq -s 'add') 74 | ALL_LABELS=$(curl -s -H "Authorization: token $TOKEN" \ 75 | "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/labels") 76 | ALL_USERS=$(curl -s -H "Authorization: token $TOKEN" \ 77 | "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/assignees") 78 | echo $ISSUE_EVENTS > issues.json 79 | echo $ISSUE_COMMENTS > comments.json 80 | echo $ALL_ISSUES_JSON > ishlist.json 81 | echo $ALL_LABELS > labels.json 82 | echo $ALL_USERS > contributors.json 83 | 84 | 85 | - name: Clone target repository 86 | run: | 87 | git clone https://${{ secrets.GH_ACTIONS_TARGET_PAT }}@github.com/secure411dotorg/gh_actions_target.git target-repo 88 | 89 | cd target-repo 90 | git config user.name "github-actions[bot]" 91 | git config user.email "github-actions[bot]@users.noreply.github.com" 92 | git config pull.ff only 93 | - name: Copy commits file to target repository 94 | continue-on-error: true 95 | run: | 96 | REPO_NAME=$(echo $GITHUB_REPOSITORY | cut -d'/' -f2) 97 | mkdir -p target-repo/${REPO_NAME} 98 | cp commits.json target-repo/${REPO_NAME}/ 99 | cp issues.json target-repo/${REPO_NAME}/ 100 | cp comments.json target-repo/${REPO_NAME}/ 101 | cp ishlist.json target-repo/${REPO_NAME}/ 102 | cp labels.json target-repo/${REPO_NAME}/ 103 | cp contributors.json target-repo/${REPO_NAME}/ 104 | 105 | cd target-repo 106 | git add ${REPO_NAME} 107 | git commit -m "Update ${REPO_NAME} with latest commits and issues info" 108 | git pull && git push https://${{ secrets.GH_ACTIONS_TARGET_PAT }}@github.com/secure411dotorg/gh_actions_target.git main 109 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | AWS AMI for easy experimenting with DNS Firewalls & Response Rate Limiting 2 | ====== 3 | 4 | The purpose of this git repository is to encourage the use of Response Policy Zones feature of BIND by making it easy to start up your own instance on your own AWS account and 5 | 6 | * Immediately test and use RPZ2 with an already-working config. 7 | * [Helper scripts](https://github.com/secure411dotorg/rpzone/tree/master/scripts) to assist in maintaining white and block zones are included in this repository. 8 | * Facilitate folks providing free or commercial RPZones to each other. 9 | 10 | Resources about the Response Policy Zones feature of BIND are provided [here](https://github.com/secure411dotorg/rpzone/wiki/RPZ-Resources-Wiki-on-GitHub). 11 | 12 | For reasons of security, we detail how the instance was created in the file named [Ubuntu-Walkthrough.md](https://github.com/secure411dotorg/rpzone/blob/master/Ubuntu-Walkthrough.md). 13 | 14 | If you don't want to use DNS Firewall features and are just trying out Response Rate Limiting, don't do the configuration below. Just go [here](https://github.com/secure411dotorg/rpzone/wiki/Response-Rate-Limiting). 15 | 16 | *** 17 | ###First time config for DNS Firewall use: 18 | 19 | Request the AMI to be shared with your AWS account by sending your AWS account number and identifying yourself to @secure411dotorg 20 | 21 | Or search community AMIs for the term rpzone 22 | 23 | Start the instance up on your own AWS account which will use your own ssh key and security group. 24 | 25 | ssh into the instance 26 | 27 | ```sudo /etc/init.d/bind9 stop``` *stop BIND in case it is running* 28 | 29 | ```sudo /usr/sbin/rndc-confgen -a``` *generate a new rndc.key unique to your instance* 30 | 31 | grep -l CONFIGME /etc/bind/*named* will list the files you need to edit 32 | 33 | To restart BIND: ```sudo /etc/init.d/bind9 start``` 34 | 35 | *If BIND does not start, check /var/log/syslog to find out what you need to fix.* 36 | 37 | 38 | [Send test queries](https://github.com/secure411dotorg/rpzone/wiki/Test-Queries) 39 | 40 | *** 41 | ###Example white and block lists 42 | 43 | A working config with [D.R.O.P.](http://www.spamhaus.org/drop/) as blocklist and the top 5000 sites from Alexa as the [whitelist](https://github.com/secure411dotorg/rpzone/wiki/Free-Whitelist-Response-Policy-Zones) is provided. 44 | 45 | **Outline of the list updating process:** 46 | 47 | Data is refreshed by a [script](https://github.com/secure411dotorg/rpzone/blob/master/scripts/refresh_drop.sh) on a [crontab](https://github.com/secure411dotorg/rpzone/blob/master/scripts/ubuntu.crontab) 48 | 49 | /opt/rpzone/scripts$ ./refresh_drop.sh 50 | 51 | New data is detected by polling on crontab for a new data flag file. 52 | 53 | You can lower the propagation delay and elminated zone reloading for your own zones 54 | by using the nsupdate command. See [Minimize Propagation Delay for High Update Frequency Blocklists](https://github.com/secure411dotorg/rpzone/wiki/Minimize-Propagation-Delay-for-High-Update-Frequency-Blocklists) 55 | 56 | 57 | **See also:** 58 | 59 | * [How to Add a Local Zone](https://github.com/secure411dotorg/rpzone/wiki/How-to-Add-a-Local-Zone) 60 | * [Add Zones Maintained by Other People](https://github.com/secure411dotorg/rpzone/wiki/Add-Zones-Maintained-by-Other-People) 61 | * [Share your Zones](https://github.com/secure411dotorg/rpzone/wiki/Share-your-Zones) 62 | 63 | 64 | *** 65 | ###NOTES 66 | 67 | BIND is very picky about syntax. Always check the log file after altering a config file, restarting BIND, or using rndc reconfig. rndc reconfig will not show an error message for syntax issues with a config file. The log will show the error. Look at running processes such as by using ```ps auxfwww1``` to see if named is in the process list. 68 | 69 | *** 70 | 71 | Port 53 TCP needs to be open for IXFR. allow-query must include slaves because they will send an SOA query. 72 | 73 | -------------------------------------------------------------------------------- /Ubuntu-Walkthrough.md: -------------------------------------------------------------------------------- 1 | *** 2 | How the AWS instance was created 3 | --- 4 | 5 | AMI: ubuntu-trusty-14.04-amd64-server-20140607.1 (ami-864d84ee) 6 | 7 | apt-get dependencies, wget bind and patch, compile 8 | 9 | ``` 10 | sudo apt-get update 11 | sudo apt-get install unzip libssl-dev build-essential bind9 bind9utils 12 | ``` 13 | 14 | At this point we only have an older default Ubuntu version of BIND installed. 15 | 16 | ```named -V``` shows us the config, dirs, et al: 17 | 18 | ``` 19 | $ named -V 20 | BIND 9.9.5-3-Ubuntu (Extended Support Version) built by make with '--prefix=/usr' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--sysconfdir=/etc/bind' '--localstatedir=/var' '--enable-threads' '--enable-largefile' '--with-libtool' '--enable-shared' '--enable-static' '--with-openssl=/usr' '--with-gssapi=/usr' '--with-gnu-ld' '--with-geoip=/usr' '--with-atf=no' '--enable-ipv6' '--enable-rrl' '--enable-filter-aaaa' 'CFLAGS=-fno-strict-aliasing -DDIG_SIGCHASE -O2' 21 | compiled by GCC 4.8.2 22 | using OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014 23 | using libxml2 version: 2.9.1 24 | ``` 25 | 26 | Ubuntu apt-get installed BIND 9.9.5-3 and now we need the RPZ patch for 9.9.5: 27 | 28 | ``` 29 | wget http://ftp.isc.org/isc/bind9/9.9.5/bind-9.9.5.tar.gz 30 | 31 | tar zxf bind-9.9.5.tar.gz 32 | 33 | cd bind-9.9.5 34 | 35 | wget http://ss.vix.su/%7Evjs/rpz2+rl-9.9.5.patch 36 | 37 | patch -s -p0 -i rpz2+rl-9.9.5.patch 38 | 39 | ``` 40 | 41 | ``` 42 | Response Rate Limiting (--enable-rrl) 43 | GSS-API (--with-gssapi) 44 | PKCS#11/Cryptoki support (--with-pkcs11) 45 | New statistics (--enable-newstats) 46 | Allow 'fixed' rrset-order (--enable-fixed-rrset) 47 | Automated Testing Framework (--with-atf) 48 | XML statistics (--with-libxml2) 49 | ``` 50 | 51 | 52 | ``` 53 | ./configure '--prefix=/usr' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--sysconfdir=/etc/bind' '--localstatedir=/var' '--enable-threads' '--enable-largefile' '--with-libtool' '--enable-shared' '--enable-static' '--enable-rrl' '--enable-newstats' '--enable-fixed-rrset' '--with-atf' '--with-openssl=/usr' '--with-gnu-ld' '--with-geoip=/usr' '--enable-ipv6' 'CFLAGS=-fno-strict-aliasing -DDIG_SIGCHASE -O2 -g' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro' 'CPPFLAGS=-D_FORTIFY_SOURCE=2' 54 | ``` 55 | 56 | If the machine you are building on is low power, make can take a very long time: 57 | 58 | ``` 59 | make 60 | 61 | sudo make install 62 | ``` 63 | 64 | On an AWS ec2 t2.micro, for make: 65 | 66 | ``` 67 | real 4m59.081s 68 | user 4m32.221s 69 | sys 0m22.056s 70 | ``` 71 | 72 | 73 | Run named -V again to verify that the newer patched version is now active: 74 | 75 | ``` 76 | named -V 77 | 78 | BIND 9.9.5-rpz2+rl.14038.05 (Extended Support Version) built by make with '--prefix=/usr' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--sysconfdir=/etc/bind' '--localstatedir=/var' '--enable-threads' '--enable-largefile' '--with-libtool' '--enable-shared' '--enable-static' '--enable-rrl' '--with-gssapi' '--with-pkcs11' '--enable-newstats' '--enable-fixed-rrset' '--with-atf' '--with-libxml2' '--with-openssl=/usr' '--with-gnu-ld' '--with-geoip=/usr' '--enable-ipv6' 'CFLAGS=-fno-strict-aliasing -DDIG_SIGCHASE -O2 -g' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro' 'CPPFLAGS=-D_FORTIFY_SOURCE=2' 79 | compiled by GCC 4.8.2 80 | using OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014 81 | ``` 82 | 83 | The queryperf utility needs to be compiled: 84 | 85 | ``` 86 | cd contrib/queryperf 87 | sh configure 88 | make 89 | cd ../.. 90 | ``` 91 | 92 | In order to run the rpz tests, changes to /etc/network/interfaces are needed: 93 | 94 | ``` 95 | cd bin/tests/system 96 | sudo ./ifconfig.sh up 97 | ``` 98 | 99 | Run the rpz tests: 100 | 101 | ``` 102 | ~/bind-9.9.2-P1/bin/tests/system$ sh run.sh rpz 103 | 104 | S:rpz:Sat Aug 16 23:08:25 UTC 2014 105 | T:rpz:1:A 106 | A:System test rpz 107 | I:checking QNAME rewrites 108 | I:checking IP rewrites 109 | I:checking radix tree deletions 110 | I:checking NSDNAME rewrites 111 | I:checking NSIP rewrites 112 | I:checking walled garden NSIP rewrites 113 | I:checking policy overrides 114 | I:checking crashes 115 | I:checking performance with RPZ 116 | I:checking performance without RPZ 117 | I:13752 qps with RPZ is 85% of 16267 qps without RPZ 118 | I:checking that ttl values are not zeroed when qtype is '*' 119 | I:exit status: 0 120 | R:PASS 121 | E:rpz:Sat Aug 16 23:08:39 UTC 2014 122 | 123 | ``` 124 | 125 | The above "performance" was on a t2.micro, the smallest Amazon current generation instance size. 126 | 127 | ###DEVIATIONS FROM DEFAULT INSTALL: 128 | 129 | Each line of named.conf.options has been commented out because no views were required for this install and the options{} clause is located in the named.conf.local file. 130 | 131 | ```sudo vi /etc/apparmor.d/usr.sbin.named``` 132 | 133 | Add these lines: 134 | 135 | ``` 136 | # RPZones 137 | /opt/rpz-deliverables/** rw, 138 | /opt/rpz-deliverables/ rw, 139 | ``` 140 | 141 | ```sudo /etc/init.d/apparmor reload`` 142 | 143 | ```sudo mkdir /var/log/named``` 144 | -------------------------------------------------------------------------------- /bindconf/named.acl: -------------------------------------------------------------------------------- 1 | // CONFIGME 2 | // You can name groups of CIDRs here, whatever helps you remember 3 | // such as groups named by location or a particular customer 4 | // or purpose that you might want to add or remove as a group 5 | // or assign certain permissions to as a group 6 | // These acl group names can be used anywhere in the 7 | // named options files 8 | 9 | // REMOVE 1.2.3.4/32 and replace with your own masters (IPs you get other peoples zones from) 10 | // and slaves (IPs you allow to copy your zones) 11 | 12 | // Add your own IPs to client_networks (IPs you will test this RPZ server from) 13 | // and superadmin_networks (IPs you want to give more admin access to beyond making recursive requests) 14 | 15 | // Example showing multiple IPs in an acl group: 16 | // acl "foo" { 1.2.3.0/24; 1.2.3.4; 4.3.0.0/16 }; 17 | 18 | acl "myresolvers" { 1.2.3.4/32; 4.3.2.1/32; }; 19 | 20 | acl "mytrustedfriends" { 1.2.3.4/32; }; 21 | 22 | masters "ixfr_masters" { 1.2.3.4/32; }; 23 | 24 | acl "ixfr_slaves" { 1.2.3.4/32; }; 25 | 26 | acl "superadmin" { 127.0.0.1; }; 27 | 28 | -------------------------------------------------------------------------------- /bindconf/named.conf.local: -------------------------------------------------------------------------------- 1 | // CONFIGME each time you want to add or remove an RPZone 2 | 3 | // Each file with an include statement here 4 | // will have the same effect as if the file 5 | // contents are in this file 6 | 7 | include "/etc/bind/named.acl"; 8 | include "/etc/bind/named.rpzones"; 9 | include "/etc/bind/named.logging"; 10 | 11 | 12 | // allow-recursion is the place to list the names from named.acl 13 | // of the IP/CIDR groups you want to allow to get RPZ-protected answers 14 | // from this server 15 | 16 | // response-policy overrides the responses given next to each 17 | // rpz line in the zones. GIVEN as the response-policy will use what is in the zone 18 | 19 | 20 | options { 21 | //directory "/etc/bind"; 22 | directory "/var/cache/bind"; 23 | allow-recursion { superadmin; myresolvers; mytrustedfriends; }; 24 | version "no thank you"; 25 | notify yes; 26 | 27 | response-policy { 28 | zone "alexa5000" policy PASSTHRU; 29 | zone "shdrop" policy GIVEN; 30 | // zone "toprules" policy GIVEN; 31 | } 32 | qname-wait-recurse no 33 | break-dnssec yes; 34 | 35 | 36 | // If there is a firewall between you and nameservers you want 37 | // to talk to, you may need to fix the firewall to allow multiple 38 | // ports to talk. See http://www.kb.cert.org/vuls/id/800113 39 | 40 | listen-on port 53 { any; }; 41 | // listen-on-v6 { any; }; 42 | 43 | dnssec-validation auto; 44 | 45 | auth-nxdomain no; # conform to RFC1035 46 | }; 47 | 48 | -------------------------------------------------------------------------------- /bindconf/named.logging: -------------------------------------------------------------------------------- 1 | //FIXME check with others on sane defaults for versions size and rotation 2 | 3 | logging { 4 | channel xfer { 5 | severity debug; file "/var/log/named/xfer.log" versions 3 size 10m; 6 | print-category yes; print-time yes; print-severity yes; 7 | }; 8 | channel rpzchannel { 9 | severity debug; file "/var/log/named/rpz.log" versions 3 size 10m; 10 | print-category yes; print-time yes; print-severity yes; 11 | }; 12 | category "rpz" { "rpzchannel"; }; 13 | category "xfer-in" { "xfer"; }; 14 | category "xfer-out" { "xfer"; }; 15 | }; 16 | -------------------------------------------------------------------------------- /bindconf/named.rpzones: -------------------------------------------------------------------------------- 1 | // CONFIGME 2 | 3 | // Don't type IP addresses and CIDRS in this file 4 | // IP addresses and CIDRS go in the named.acl file 5 | // Just type the names of the groups from named.acl here 6 | 7 | // allow-query restrictions here are not for ordinary resolver clients 8 | // Only allow-query for yourself or special purposes as it allows 9 | // directly examining zone contents 10 | 11 | // allow-transfer is for additional RPZ feature enabled resolvers 12 | // of your own or parties you trust 13 | // that you want to allow to copy your zones, getting updates by IXFR 14 | 15 | // The order you list the zones in here matters. 16 | 17 | 18 | // RPZones I manage myself and I am the master for 19 | 20 | zone "alexa5000" { 21 | type master; 22 | file "/opt/rpz-deliverables/alexa5000.db"; 23 | allow-query { superadmin; }; 24 | allow-transfer { superadmin; myresolvers; mytrustedfriends; }; 25 | allow-update{localhost;}; 26 | }; 27 | 28 | 29 | zone "shdrop" { 30 | type master; 31 | file "/opt/rpz-deliverables/shdrop.db"; 32 | allow-query { superadmin; }; 33 | allow-transfer { superadmin; myresolvers; mytrustedfriends; }; 34 | allow-update{localhost;}; 35 | }; 36 | 37 | // RPZones I buy or get free from others - they are the master, my server is a slave for these zones 38 | // and I get the updates by IXFR 39 | 40 | // The toprules zone is a free zone from https://service.DissectCyber.com 41 | // The criteria for the zone is to include the top NNN rules seen in current hits to 42 | // Dissect Cyber's subscription based services 43 | // Request IXFR zone access by emailing your RPZ server IP to data@dissectcyber.com 44 | 45 | // Uncomment the zone definition here and in the named.local.conf response-policy section 46 | 47 | // This serves as an example for slave zones 48 | 49 | // zone "toprules" { 50 | // type slave; 51 | // file "/opt/rpz-deliverables/toprules.db"; 52 | // allow-query { superadmin; }; 53 | // masters { 54.224.18.150; }; 54 | // }; 55 | -------------------------------------------------------------------------------- /scripts/COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | -------------------------------------------------------------------------------- /scripts/assemble_cidr_zone.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # PURPOSE: bring together the data from multiple sources 3 | # Update the header, update the serial, validate the resulting file 4 | # Replace the existing zone and run rndc reload 5 | # 6 | # NAME: assemble_cidr_zone.sh (part of rpzone helper scripts) 7 | # Copyright (C) 2012 April Lorenzen 8 | # 9 | # Paper mail contact: April Lorenzen, PO Box 293, Jamestown RI 02835 10 | # Electronic contact: https://github.com/secure411dotorg/rpzone/issues 11 | # 12 | # This program is free software: you can redistribute it and/or modify 13 | # it under the terms of the GNU General Public License as published by 14 | # the Free Software Foundation, either version 3 of the License, or 15 | # (at your option) any later version. 16 | # 17 | # This program is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | # GNU General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU General Public License 23 | # along with this program. If not, see 24 | 25 | # NOTE: other processes update or create the source data 26 | # This script just checks for the existence of a new data flag file 27 | # 28 | source /opt/process-locking/process-locking-header.sh 29 | 30 | if [ -z "${1}" ];then 31 | echo "No zone specified - Nothing done" 32 | echo " " 33 | echo "USAGE: ./assemble_cidr_zone.sh ZONENAME" 34 | else 35 | 36 | #FIXME most of the rest of the file needs indenting another level 37 | # FIXME needs more error checking for file existence 38 | 39 | ZONENAME="${1}" 40 | DEPENDENCIESDIR="/opt/rpz-dependencies" 41 | DELIVERABLESDIR="/opt/rpz-deliverables" 42 | 43 | cd ${DELIVERABLESDIR} 44 | 45 | THEPOCH=`date +%s` 46 | 47 | # Check for new source file flags 48 | if [ -f "${DEPENDENCIESDIR}/${ZONENAME}_rpz_new.flag" ]; then 49 | 50 | # Use a header template file to an empty zone file.tmp with new serial 51 | sed "s/ZONENAME/$ZONENAME/g;s/SERIAL/$THEPOCH/g" ${DEPENDENCIESDIR}/rpzone.header > ${DELIVERABLESDIR}/${ZONENAME}.db.tmp 52 | 53 | # Append the rpz format files to the zone file.tmp with a POLICY appended to each line 54 | cat ${DEPENDENCIESDIR}/${ZONENAME}.rpz-*ip |\ 55 | sort -u|sed '/^$/d'|sed 's/$/ CNAME \./' >> ${DELIVERABLESDIR}/${ZONENAME}.db.tmp 56 | 57 | echo "zone ${ZONENAME} { type master; file \"${DELIVERABLESDIR}/${ZONENAME}.db.tmp\"; };" > ${DEPENDENCIESDIR}/${ZONENAME}.validator 58 | 59 | # Validate the syntax of the zone 60 | /usr/sbin/named-checkconf -z ${DEPENDENCIESDIR}/${ZONENAME}.validator 61 | 62 | # if valid - Replace zone file with zone file.tmp - else log error FIXME 63 | if [ ${?} -eq "0" ];then 64 | cp ${DELIVERABLESDIR}/${ZONENAME}.db.tmp ${DELIVERABLESDIR}/${ZONENAME}.db 65 | # Run rndc reload zone 66 | sudo /usr/sbin/rndc reload ${ZONENAME} 67 | sudo rm ${DEPENDENCIESDIR}/${ZONENAME}_rpz_new.flag 68 | else 69 | /usr/bin/logger "WARN: rpzone ${ZONENAME}.db.tmp has a syntax error" 70 | fi 71 | else 72 | echo "no new source data files yet" 73 | fi 74 | 75 | fi 76 | 77 | source /opt/process-locking/process-locking-footer.sh 78 | 79 | -------------------------------------------------------------------------------- /scripts/assemble_dname_zone.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # PURPOSE: bring together the data from multiple sources 3 | # Update the header, update the serial, validate the resulting file 4 | # Replace the existing zone and run rndc reload 5 | # 6 | # NAME: assemble_dname_zone.sh (part of rpzone helper scripts) 7 | # Copyright (C) 2012 April Lorenzen 8 | # 9 | # Paper mail contact: April Lorenzen, PO Box 293, Jamestown RI 02835 10 | # Electronic contact: https://github.com/secure411dotorg/rpzone/issues 11 | # 12 | # This program is free software: you can redistribute it and/or modify 13 | # it under the terms of the GNU General Public License as published by 14 | # the Free Software Foundation, either version 3 of the License, or 15 | # (at your option) any later version. 16 | # 17 | # This program is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | # GNU General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU General Public License 23 | # along with this program. If not, see 24 | # 25 | # NOTE: other processes update or create the source data 26 | # This script just checks for the existence of a new data flag file 27 | # 28 | source /opt/process-locking/process-locking-header.sh 29 | 30 | if [ -z "${1}" ];then 31 | echo "No zone specified - Nothing done" 32 | echo " " 33 | echo "USAGE: ./assemble_dname_zone.sh ZONENAME" 34 | else 35 | 36 | #FIXME most of the rest of the file needs indenting another level 37 | # FIXME needs more error checking for file existence 38 | 39 | ZONENAME="${1}" 40 | DEPENDENCIESDIR="/opt/rpz-dependencies" 41 | DELIVERABLESDIR="/opt/rpz-deliverables" 42 | 43 | cd ${DELIVERABLESDIR} 44 | 45 | THEPOCH=`date +%s` 46 | 47 | # Check for new source file flags 48 | if [ -f "${DEPENDENCIESDIR}/${ZONENAME}_rpz_new.flag" ]; then 49 | 50 | # Use a header template file to an empty zone file.tmp with new serial 51 | sed "s/ZONENAME/$ZONENAME/g;s/SERIAL/$THEPOCH/g" ${DEPENDENCIESDIR}/rpzone.header > ${DELIVERABLESDIR}/${ZONENAME}.db.tmp 52 | 53 | # Append the rpz format files to the zone file.tmp with a POLICY appended to each line 54 | # FIXME provide option to change policy from CNAME . to A 127.0.0.2 for dnsbl style responses 55 | cat ${DEPENDENCIESDIR}/${ZONENAME}.rpz-nsdname ${DEPENDENCIESDIR}/${ZONENAME}.domains ${DEPENDENCIESDIR}/${ZONENAME}.wildcarddomains|\ 56 | sort -u|sed '/^$/d'|sed 's/$/ CNAME \./' >> ${DELIVERABLESDIR}/${ZONENAME}.db.tmp 57 | 58 | echo "zone ${ZONENAME} { type master; file \"${DELIVERABLESDIR}/${ZONENAME}.db.tmp\"; };" > ${DEPENDENCIESDIR}/${ZONENAME}.validator 59 | 60 | # Validate the syntax of the zone 61 | /usr/sbin/named-checkconf -z ${DEPENDENCIESDIR}/${ZONENAME}.validator 62 | 63 | # if valid - Replace zone file with zone file.tmp - else log error FIXME 64 | if [ ${?} -eq "0" ];then 65 | cp ${DELIVERABLESDIR}/${ZONENAME}.db.tmp ${DELIVERABLESDIR}/${ZONENAME}.db 66 | # Run rndc reload zone 67 | sudo /usr/sbin/rndc reload ${ZONENAME} 68 | sudo rm ${DEPENDENCIESDIR}/${ZONENAME}_rpz_new.flag 69 | else 70 | /usr/bin/logger "WARN: rpzone ${ZONENAME}.db.tmp has a syntax error" 71 | fi 72 | else 73 | echo "no new source data files yet" 74 | fi 75 | 76 | fi 77 | 78 | source /opt/process-locking/process-locking-footer.sh 79 | 80 | -------------------------------------------------------------------------------- /scripts/local_white_block.README: -------------------------------------------------------------------------------- 1 | # Do not manually edit localwhite.db nor localblock.db 2 | # 3 | # Use nsupdate_white.sh 4 | # Use nsupdate_block.sh 5 | # 6 | # 7 | -------------------------------------------------------------------------------- /scripts/nsupdate_block.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # PURPOSE: Accept an instruction, host and zonename 3 | # and instruct an RPZ bind server to add or delete a rule 4 | # 5 | # NAME: nsupdate_block.sh (part of rpzone helper scripts) 6 | # Copyright (C) 2012 April Lorenzen 7 | # 8 | # Paper mail contact: April Lorenzen, PO Box 293, Jamestown RI 02835 9 | # Electronic contact: https://github.com/secure411dotorg/rpzone/issues 10 | # 11 | # This program is free software: you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation, either version 3 of the License, or 14 | # (at your option) any later version. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program. If not, see 23 | # 24 | 25 | if [ -z "${1}" ] || [ -z "${2}" ] || [ -z "${3}" ];then 26 | echo "instruction or host or zone named was not specified - Nothing was done" 27 | echo " " 28 | echo "USAGE: ./nsupdate_block.sh INSTRUCTION HOST ZONENAME" 29 | echo " " 30 | echo "EXAMPLE: ./nsupdate_block.sh add example.com localblock" 31 | echo " " 32 | echo "EXAMPLE: ./nsupdate_block.sh add *.example.com localblock" 33 | echo " " 34 | echo "EXAMPLE: ./nsupdate_block.sh add *.example.com.rpz-nsdname localblock" 35 | 36 | else 37 | 38 | INSTRUCTION="${1}" 39 | THEHOST="${2}" 40 | ZONENAME="${3}" 41 | ZONESERVER="localhost" 42 | QCDIR="/opt/rpz-quality" 43 | 44 | ZONETYPE=`echo "${THEHOST}"|rev|cut -d. -f2|rev` 45 | x=1 46 | while [ $x -le 1 ];do 47 | TSTAMP=`date +%s` 48 | echo "zone ${ZONENAME}" 49 | echo "update ${INSTRUCTION} ${THEHOST}.${ZONENAME} 60 A 127.0.0.2" 50 | echo "show" 51 | echo "send" 52 | echo "answer" 53 | x=$(( $x + 1 )) 54 | echo "${TSTAMP}|update ${INSTRUCTION} ${THEHOST}.${ZONENAME} 60 A 127.0.0.2" >> ${QCDIR}/audit_trail_manual.csv 55 | done |sudo /usr/bin/nsupdate -l 56 | 57 | fi 58 | 59 | -------------------------------------------------------------------------------- /scripts/nsupdate_hits.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # PURPOSE: Update a zone that is only used to pass a record of hits 3 | # between RPZ servers using IXFR 4 | # 5 | # Intended to run on crontab periodically such as hourly 6 | # 7 | # Set response-policy for zone "hits" to DISABLED 8 | 9 | # 10 | # NAME: nsupdate_hits.sh (part of rpzone helper scripts) 11 | # Copyright (C) 2012 April Lorenzen 12 | # 13 | # Paper mail contact: April Lorenzen, PO Box 293, Jamestown RI 02835 14 | # Electronic contact: https://github.com/secure411dotorg/rpzone/issues 15 | # 16 | # This program is free software: you can redistribute it and/or modify 17 | # it under the terms of the GNU General Public License as published by 18 | # the Free Software Foundation, either version 3 of the License, or 19 | # (at your option) any later version. 20 | # 21 | # This program is distributed in the hope that it will be useful, 22 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | # GNU General Public License for more details. 25 | # 26 | # You should have received a copy of the GNU General Public License 27 | # along with this program. If not, see 28 | 29 | 30 | # FIXME test if any response-policy is even needed for this zone 31 | # FIXME add protection from running multiple copies of script 32 | 33 | TODAY=`date +%d-%b-%Y` 34 | 35 | QCDIR="/etc/bind/rpz-quality" 36 | INSTRUCTION="add" 37 | ZONENAME="hits-YOURCOMPANY" 38 | ZONESERVER="localhost" 39 | 40 | TODAY=`date +%d-%b-%Y` 41 | grep -F "${TODAY}" /var/log/named/rpz.log |grep -vF "PASSTHRU"|grep -vF ": disabled "|awk '{print $12,$NF}'|sort -u |\ 42 | while read QNAME RULE;do 43 | RULEHIT=`echo "${RULE}"|rev|cut -d"." -f2-10|rev` 44 | ZONEHIT=`echo "${RULE}"|rev|cut -d"." -f1|rev` 45 | TTL="86400" 46 | 47 | x=1 48 | while [ $x -le 1 ];do 49 | UNIXTIME=`date +%s` 50 | echo "zone ${ZONENAME}" 51 | echo "update ${INSTRUCTION} ${UNIXTIME}.${QNAME}.${ZONENAME} ${TTL} CNAME ${RULEHIT}.${ZONEHIT}" 52 | echo "show" 53 | echo "send" 54 | echo "answer" 55 | x=$(( $x + 1 )) 56 | echo "${UNIXTIME}|update ${INSTRUCTION} ${UNIXTIME}.${QNAME}.${ZONENAME} ${TTL} CNAME ${RULEHIT}.${ZONEHIT}" >> ${QCDIR}/audit_trail_hits.csv 57 | done |sudo /usr/bin/nsupdate -l 58 | done 59 | 60 | 61 | -------------------------------------------------------------------------------- /scripts/nsupdate_hits_alternative.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # From: https://github.com/secure411dotorg/rpzone/blob/master/scripts/nsupdate_hits.sh 4 | 5 | # PURPOSE: Update a zone that is only used to pass a record of hits 6 | # between RPZ servers using IXFR 7 | # 8 | # Intended to run on crontab periodically such as hourly 9 | # 10 | # Set response-policy for zone "hits" to DISABLED 11 | 12 | # 13 | # NAME: nsupdate_hits_alternative.sh (part of rpzone helper scripts) 14 | 15 | # Alternative re-write by Hugo Connery 16 | 17 | # Copyright (C) 2012 April Lorenzen 18 | # 19 | # Paper mail contact: April Lorenzen, PO Box 293, Jamestown RI 02835 20 | # Electronic contact: https://github.com/secure411dotorg/rpzone/issues 21 | # 22 | # This program is free software: you can redistribute it and/or modify 23 | # it under the terms of the GNU General Public License as published by 24 | # the Free Software Foundation, either version 3 of the License, or 25 | # (at your option) any later version. 26 | # 27 | # This program is distributed in the hope that it will be useful, 28 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 29 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 30 | # GNU General Public License for more details. 31 | # 32 | # You should have received a copy of the GNU General Public License 33 | # along with this program. If not, see 34 | # 35 | # FIXME test if any response-policy is even needed for this zone 36 | # FIXME add protection from running multiple copies of script 37 | 38 | TODAY=`date +%d-%b-%Y` 39 | 40 | # Source data 41 | SOURCE="/var/named/data/named.log.rpz" 42 | 43 | # Auditing 44 | QCDIR="/var/named/rpz-quality" 45 | QCLOG="audit_trail_hits.txt" 46 | QC_LOG="$QCDIR/$QCLOG" 47 | 48 | # RPZ / Zone interaction 49 | INSTRUCTION="add" 50 | ZONENAME="dc-feedback" 51 | 52 | function update() 53 | { 54 | local tstamp=$1 55 | local the_host=$2 56 | local hit=$3 57 | local hit_zone=$4 58 | echo "zone ${ZONENAME}" 59 | echo -n "update ${INSTRUCTION} ${the_host}.${ZONENAME} " 60 | echo "60 CNAME ${hit}.${hit_zone}" 61 | echo -e "show\nsend\nanswer" 62 | # Report to our log 63 | echo "${tstamp}|update ${INSTRUCTION} ${the_host}.${ZONENAME} 60 CNAME ${hit}.${hit_zone}" >> ${QC_LOG} 64 | } 65 | 66 | # More full approach using white listing ... 67 | # grep -F "${TODAY}" $SOURCE |awk '{print $12,$NF}'|sort -u|grep -v alexa5000|grep -v white |\ 68 | 69 | grep -F "${TODAY}" $SOURCE |awk '{print $12,$NF}'|sort -u| \ 70 | while read HIT RULE;do 71 | # Pull values 72 | THEHOST=`echo "${RULE}"|rev|cut -d"." -f2-10|rev` 73 | HITZONE=`echo "${RULE}"|rev|cut -d"." -f1|rev` 74 | TSTAMP=`date +%s` 75 | # process, audit log, and update 76 | update $TSTAMP $THEHOST $HIT $HITZONE | sudo /usr/bin/nsupdate -l 77 | done 78 | 79 | exit 0 80 | -------------------------------------------------------------------------------- /scripts/nsupdate_white.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # PURPOSE: Accept an instruction, host and zonename 3 | # and instruct an RPZ bind server to add or delete a rule 4 | # 5 | # NAME: nsupdate_white.sh (part of rpzone helper scripts) 6 | # Copyright (C) 2012 April Lorenzen 7 | # 8 | # Paper mail contact: April Lorenzen, PO Box 293, Jamestown RI 02835 9 | # Electronic contact: https://github.com/secure411dotorg/rpzone/issues 10 | # 11 | # This program is free software: you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation, either version 3 of the License, or 14 | # (at your option) any later version. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program. If not, see 23 | # 24 | 25 | if [ -z "${1}" ] || [ -z "${2}" ] || [ -z "${3}" ];then 26 | echo "instruction or host or zone named was not specified - Nothing was done" 27 | echo " " 28 | echo "USAGE: ./nsupdate_white.sh INSTRUCTION HOST ZONENAME" 29 | echo " " 30 | echo "EXAMPLE: ./nsupdate_white.sh add example.com localwhite" 31 | echo " " 32 | echo "EXAMPLE: ./nsupdate_white.sh delete example.com localwhite" 33 | echo " " 34 | 35 | else 36 | 37 | INSTRUCTION="${1}" 38 | THEHOST="${2}" 39 | ZONENAME="${3}" 40 | ZONESERVER="localhost" 41 | QCDIR="/etc/bind/rpz-quality" 42 | 43 | ZONETYPE=`echo "${THEHOST}"|rev|cut -d. -f2|rev` 44 | x=1 45 | while [ $x -le 1 ];do 46 | TSTAMP=`date +%s` 47 | echo "zone ${ZONENAME}" 48 | echo "update ${INSTRUCTION} ${THEHOST}.${ZONENAME} 60 CNAME ." 49 | echo "show" 50 | echo "send" 51 | echo "answer" 52 | x=$(( $x + 1 )) 53 | echo "${TSTAMP}|update ${INSTRUCTION} ${THEHOST}.${ZONENAME} 60 CNAME ." >> ${QCDIR}/audit_trail_manual.csv 54 | done |sudo /usr/bin/nsupdate -l 55 | 56 | fi 57 | 58 | -------------------------------------------------------------------------------- /scripts/nsupdate_zone.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # PURPOSE: Accept an instruction, host and zonename 3 | # and instruct an RPZ bind server to add or delete a rule 4 | # 5 | # NAME: nsupdate_zone.sh (part of rpzone helper scripts) 6 | # Copyright (C) 2012 April Lorenzen 7 | # 8 | # Paper mail contact: April Lorenzen, PO Box 293, Jamestown RI 02835 9 | # Electronic contact: https://github.com/secure411dotorg/rpzone/issues 10 | # 11 | # This program is free software: you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation, either version 3 of the License, or 14 | # (at your option) any later version. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program. If not, see 23 | # 24 | INSTRUCTION="${1}" 25 | THEHOST="${2}" 26 | ZONENAME="${3}" 27 | ZONESERVER="localhost" 28 | QCDIR="/opt/rpz-quality" 29 | 30 | ZONETYPE=`echo "${THEHOST}"|rev|cut -d. -f2|rev` 31 | 32 | # EXAMPLE: If you also need to add to a database 33 | #if [ "${ZONETYPE}" = "rpz-nsip" ];then 34 | #IPADDR=`echo "${THEHOST}"|awk -F"." '{print $5"."$4"."$3"."$2}'` 35 | #NETMASK=`echo "${THEHOST}"|cut -d. -f1` 36 | #echo "IPADDR is $IPADDR and NETMASK is $NETMASK" 37 | 38 | #if [ "${INSTRUCTION}" = "delete" ];then 39 | # SQLRESULT=`psql -h pg.example.com rz -U postgres -At -c "DELETE FROM mytable WHERE address <<= '${IPADDR}/${NETMASK}';"` 40 | # echo "${ZONETYPE} ${IPADDR} ${NETMASK} ${SQLRESULT}" >> ${QCDIR}/reviewcandidates.sql 41 | #else 42 | # SQLRESULT=`psql -h pg.example.com rz -U postgres -At -c "INSERT INTO mytable (address,my,other,columns) VALUES ('${IPADDR}/${NETMASK}',my,other,values);"` 43 | #fi 44 | #TSTAMP=`date +%s` 45 | #echo "${TSTAMP} ${ZONETYPE} ${IPADDR} ${NETMASK} ${SQLRESULT}" >> ${QCDIR}/sql.audit_trail 46 | #echo "${ZONETYPE} ${IPADDR} ${NETMASK} ${SQLRESULT}" 47 | #echo " " 48 | #fi 49 | #if [ "${ZONETYPE}" = "rpz-nsdname" ];then 50 | #NSWILD=`echo "${THEHOST}"|rev|cut -d. -f3-10|rev|sed 's/^*/\%/'` 51 | #if [ "${INSTRUCTION}" = "delete" ];then 52 | # SQLRESULT=`echo "DELETE FROM mytable WHERE pattern ilike '${NSWILD}';"|psql -h pg.example.com rz -U postgres` 53 | # echo "${ZONETYPE} ${NSWILD} ${SQLRESULT}" >> ${QCDIR}/reviewcandidates.sql 54 | #else 55 | # NSHOST=`echo "${NSWILD}"|sed 's/^\%\.//'` 56 | # D8S=`dig +short txt @MYASSIGNEDHOST.d8s.us ${NSHOST}` 57 | # echo "${D8S}" 58 | # echo "${D8S}" >> ${QCDIR}/${ZONENAME}.d8s 59 | # CTIME=`echo "${D8S}"|grep -o "c:.*"|cut -d, -f1|sed 's/c://'` 60 | # if [ -n "${CTIME}" ];then 61 | # SQLVALS="'${NSWILD}','${CTIME}'" 62 | # SQLRESULT=`echo "INSERT INTO mytable (my,various,columns) VALUES (${SQLVALS});"|psql -h pg.example.com rz -U postgres` 63 | # else 64 | # echo "${NSWILD} ${D8S}" >> ${QCDIR}/rpz-nsdname.prune 65 | # fi 66 | #fi 67 | #TSTAMP=`date +%s` 68 | #echo "${TSTAMP} ${ZONETYPE} ${NSWILD} ${SQLRESULT}" >> ${QCDIR}/sql.audit_trail 69 | #echo "${ZONETYPE} ${NSWILD} ${SQLRESULT}" 70 | #echo " " 71 | #fi 72 | x=1 73 | while [ $x -le 1 ] 74 | do 75 | TSTAMP=`date +%s` 76 | #echo "server ${ZONESERVER}" 77 | echo "zone ${ZONENAME}" 78 | echo "update ${INSTRUCTION} ${THEHOST}.${ZONENAME} 60 A 127.0.0.2" 79 | echo "show" 80 | echo "send" 81 | echo "answer" 82 | x=$(( $x + 1 )) 83 | echo "${TSTAMP}|update ${INSTRUCTION} ${THEHOST}.${ZONENAME} 60 A 127.0.0.2" >> ${QCDIR}/audit_trail_manual.csv 84 | done |sudo /usr/bin/nsupdate -l 85 | 86 | -------------------------------------------------------------------------------- /scripts/refresh_alexa.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # PURPOSE: Update the dependencies with 3 | # current Alexa 1 million and 5000 for whitelists 4 | # 5 | # NAME: refresh_alexa.sh (part of rpzone helper scripts) 6 | # Copyright (C) 2012 April Lorenzen 7 | # 8 | # Paper mail contact: April Lorenzen, PO Box 293, Jamestown RI 02835 9 | # Electronic contact: https://github.com/secure411dotorg/rpzone/issues 10 | # 11 | # This program is free software: you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation, either version 3 of the License, or 14 | # (at your option) any later version. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program. If not, see 23 | 24 | source /opt/process-locking/process-locking-header.sh 25 | 26 | DEPENDENCIESDIR="/opt/rpz-dependencies" 27 | DELIVERABLESDIR="/opt/rpz-deliverables" 28 | 29 | /usr/bin/wget -O /tmp/alexa.zip http://s3.amazonaws.com/alexa-static/top-1m.csv.zip 30 | 31 | /usr/bin/unzip -p /tmp/alexa.zip|cut -d"," -f2 > ${DEPENDENCIESDIR}/alexa.domains 32 | 33 | # Preserve existing copy of our source data to facilitate diffing 34 | mv ${DEPENDENCIESDIR}/alexa5000.domains ${DEPENDENCIESDIR}/alexa5000.domains.prev 35 | 36 | # Create files with every record which can be used to initialize or recreate a zone 37 | head -n5000 ${DEPENDENCIESDIR}/alexa.domains|sort > ${DEPENDENCIESDIR}/alexa5000.domains 38 | cat ${DEPENDENCIESDIR}/alexa5000.domains|sed 's/$/\.rpz-nsdname/;s/^/*\./g' > ${DEPENDENCIESDIR}/alexa5000.rpz-nsdname 39 | cat ${DEPENDENCIESDIR}/alexa5000.domains|sed 's/^/*\./g' > ${DEPENDENCIESDIR}/alexa5000.wildcarddomains 40 | 41 | # Diff the old and new list of domains 42 | /usr/bin/comm -23 ${DEPENDENCIESDIR}/alexa5000.domains.prev ${DEPENDENCIESDIR}/alexa5000.domains >> ${DEPENDENCIESDIR}/alexa5000.domains.add 43 | /usr/bin/comm -23 ${DEPENDENCIESDIR}/alexa5000.domains ${DEPENDENCIESDIR}/alexa5000.domains.prev >> ${DEPENDENCIESDIR}/alexa5000.domains.del 44 | 45 | # FIXME optimze speed of nsupdate, verify adds and removes 46 | # nsupdate the zone with added domains 47 | while read DNAME;do 48 | /opt/rpzone/scripts/nsupdate_zone.sh add ${DNAME} alexa5000 49 | /opt/rpzone/scripts/nsupdate_zone.sh add *.${DNAME} alexa5000 50 | /opt/rpzone/scripts/nsupdate_zone.sh add *.${DNAME}.rpz-nsdname alexa5000 51 | done < ${DEPENDENCIESDIR}/alexa5000.domains.add 52 | rm ${DEPENDENCIESDIR}/alexa5000.domains.add 53 | # nsupdate the zone with removed domains 54 | while read DNAME;do 55 | /opt/rpzone/scripts/nsupdate_zone.sh delete ${DNAME} alexa5000 56 | /opt/rpzone/scripts/nsupdate_zone.sh delete *.${DNAME} alexa5000 57 | /opt/rpzone/scripts/nsupdate_zone.sh delete *.${DNAME}.rpz-nsdname alexa5000 58 | done < ${DEPENDENCIESDIR}/alexa5000.domains.del 59 | rm ${DEPENDENCIESDIR}/alexa5000.domains.del 60 | 61 | touch ${DEPENDENCIESDIR}/alexa5000_rpz_new.flag 62 | 63 | rm /tmp/alexa.zip 64 | 65 | source /opt/process-locking/process-locking-footer.sh 66 | 67 | -------------------------------------------------------------------------------- /scripts/refresh_drop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # PURPOSE: Update the dependencies with 3 | # current SH Do Not Route or Peer (DROP) as a blocklist 4 | # 5 | # NAME: refresh_drop.sh (part of rpzone helper scripts) 6 | # Copyright (C) 2012 April Lorenzen 7 | # 8 | # Paper mail contact: April Lorenzen, PO Box 293, Jamestown RI 02835 9 | # Electronic contact: https://github.com/secure411dotorg/rpzone/issues 10 | # 11 | # This program is free software: you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation, either version 3 of the License, or 14 | # (at your option) any later version. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program. If not, see 23 | 24 | source /opt/process-locking/process-locking-header.sh 25 | 26 | DEPENDENCIESDIR="/opt/rpz-dependencies" 27 | DELIVERABLESDIR="/opt/rpz-deliverables" 28 | 29 | /usr/bin/wget -O /tmp/edrop.txt http://www.spamhaus.org/drop/edrop.txt 30 | /usr/bin/wget -O /tmp/drop.txt http://www.spamhaus.org/drop/drop.txt 31 | 32 | # Preserve existing copy of our source data to facilitate diffing 33 | mv ${DEPENDENCIESDIR}/shdrop.rCIDR ${DEPENDENCIESDIR}/shdrop.rCIDR.prev 34 | 35 | cat /tmp/drop.txt /tmp/edrop.txt|grep -v "^;"|cut -d" " -f1|sed 's/\//\./' |\ 36 | awk -F"." '{print $5"."$4"."$3"."$2"."$1}' > ${DEPENDENCIESDIR}/shdrop.rCIDR 37 | 38 | cat /tmp/drop.txt /tmp/edrop.txt|grep -v "^;"|cut -d" " -f1|sed 's/\//\./' |\ 39 | awk -F"." '{print $5"."$4"."$3"."$2"."$1".rpz-ip"}' > ${DEPENDENCIESDIR}/shdrop.rpz-ip 40 | 41 | cat /tmp/drop.txt /tmp/edrop.txt|grep -v "^;"|cut -d" " -f1|sed 's/\//\./' |\ 42 | awk -F"." '{print $5"."$4"."$3"."$2"."$1".rpz-nsip"}' > ${DEPENDENCIESDIR}/shdrop.rpz-nsip 43 | 44 | # Diff the old and new list of domains 45 | /usr/bin/comm -23 ${DEPENDENCIESDIR}/shdrop.rCIDR.prev ${DEPENDENCIESDIR}/shdrop.rCIDR >> ${DEPENDENCIESDIR}/shdrop.rCIDR.add 46 | /usr/bin/comm -23 ${DEPENDENCIESDIR}/shdrop.rCIDR ${DEPENDENCIESDIR}/shdrop.rCIDR.prev >> ${DEPENDENCIESDIR}/shdrop.rCIDR.del 47 | 48 | # FIXME optimze speed of nsupdate, verify adds and removes 49 | # nsupdate the zone with added domains 50 | while read RCIDR;do 51 | /opt/rpzone/scripts/nsupdate_zone.sh add ${RCIDR}.rpz-ip shdrop 52 | /opt/rpzone/scripts/nsupdate_zone.sh add ${RCIDR}.rpz-nsip shdrop 53 | done < ${DEPENDENCIESDIR}/shdrop.rCIDR.add 54 | rm ${DEPENDENCIESDIR}/shdrop.rCIDR.add 55 | # nsupdate the zone with removed domains 56 | while read RCIDR;do 57 | /opt/rpzone/scripts/nsupdate_zone.sh delete ${RCIDR}.rpz-ip shdrop 58 | /opt/rpzone/scripts/nsupdate_zone.sh delete ${RCIDR}.rpz-nsip shdrop 59 | done < ${DEPENDENCIESDIR}/shdrop.rCIDR.del 60 | rm ${DEPENDENCIESDIR}/shdrop.rCIDR.del 61 | 62 | 63 | touch ${DEPENDENCIESDIR}/shdrop_rpz_new.flag 64 | 65 | rm /tmp/edrop.txt 66 | rm /tmp/drop.txt 67 | 68 | source /opt/process-locking/process-locking-footer.sh 69 | 70 | -------------------------------------------------------------------------------- /scripts/ubuntu.crontab: -------------------------------------------------------------------------------- 1 | # Edit this file to introduce tasks to be run by cron. 2 | # 3 | # Each task to run has to be defined through a single line 4 | # indicating with different fields when the task will be run 5 | # and what command to run for the task 6 | # 7 | # To define the time you can provide concrete values for 8 | # minute (m), hour (h), day of month (dom), month (mon), 9 | # and day of week (dow) or use '*' in these fields (for 'any').# 10 | # Notice that tasks will be started based on the cron's system 11 | # daemon's notion of time and timezones. 12 | # 13 | # Output of the crontab jobs (including errors) is sent through 14 | # email to the user the crontab file belongs to (unless redirected). 15 | # 16 | # For example, you can run a backup of all your user accounts 17 | # at 5 a.m every week with: 18 | # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ 19 | # 20 | # For more information see the manual pages of crontab(5) and cron(8) 21 | # 22 | # m h dom mon dow command 23 | # 24 | # REFRESH SOURCE DATA FOR ZONES 25 | 30 0 */7 * * /opt/rpzone/scripts/refresh_alexa.sh 26 | 30 * * * * /opt/rpzone/scripts/refresh_drop.sh 27 | 28 | -------------------------------------------------------------------------------- /scripts/zone.header.example: -------------------------------------------------------------------------------- 1 | $ORIGIN . 2 | $TTL 120 ; 2 minutes 3 | YOURZONENAMEHERE IN SOA . hostmaster.ns.YOURZONENAMEHERE. ( 4 | 1 ; serial 5 | 3600 ; refresh (1 hour) 6 | 1200 ; retry (20 minutes) 7 | 604800 ; expire (1 week) 8 | 60 ; minimum (1 minute) 9 | ) 10 | NS ns.YOURZONENAMEHERE. 11 | ns.YOURZONENAMEHERE. A 127.0.0.1 12 | test-point A 127.0.0.2 13 | 14 | --------------------------------------------------------------------------------