unspam 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +69 -15
- data/lib/unspam/cli.rb +8 -2
- data/lib/unspam/version.rb +1 -1
- data/unspam.gemspec +1 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3af9375e8a756b3389903f1fa2c8c8108fd8e10
|
4
|
+
data.tar.gz: 61e660aa192baa1a9bf338371ad063d4586c0517
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 749981ed9fc33f20ca341b9f8034f96b901f9f83e42ee8fd71db85b50d7b42d4c6acc676e054ebfcdf88a69e919781759aeb1eac0da0c1cb78d189a86801e079
|
7
|
+
data.tar.gz: 4aed52af696f1e2a153128f2db90a9a7f490695d373241bb7a22d5e922732b64ca611f138219faba914d97636fcb51d0218ddd5d91d6bcb1f0a3e328b332f6a4
|
data/README.md
CHANGED
@@ -1,29 +1,83 @@
|
|
1
1
|
# Unspam
|
2
2
|
|
3
|
-
|
3
|
+
Ultra simple tool to create postfix-compatible IP-blocklists based on AS-Numbers or IP-addresses. This is a very brutal way and should be limited to known spam providers.
|
4
4
|
|
5
5
|
## Installation
|
6
|
+
|
7
|
+
Install Ruby 1.9.3+
|
8
|
+
then:
|
6
9
|
|
7
|
-
|
10
|
+
$ gem install unspam
|
8
11
|
|
9
|
-
|
12
|
+
## Usage/Example
|
10
13
|
|
11
|
-
|
14
|
+
So you received another "Casino"-spam from e.g.
|
12
15
|
|
13
|
-
|
16
|
+
```
|
17
|
+
Received: from ab19c8d9.dutxng.net (171.25.200.217.static.clcksthrough.com [171.25.200.217]) by …
|
18
|
+
```
|
14
19
|
|
15
|
-
|
20
|
+
After some research you come to the conclusion, that the ISP behind 171.25.200.217 looks like a spam hoster that sent you spam mails for years and don't react on abuse notifications. It's time to let it go!
|
16
21
|
|
17
|
-
$ gem install unspam
|
18
22
|
|
19
|
-
|
23
|
+
```shell
|
24
|
+
$ unspam nets 171.25.200.217 REJECT
|
25
|
+
171.25.200.0/23 REJECT
|
26
|
+
178.20.96.0/21 REJECT
|
27
|
+
185.51.232.0/22 REJECT
|
28
|
+
185.57.88.0/22 REJECT
|
29
|
+
188.64.40.0/22 REJECT
|
30
|
+
188.64.44.0/23 REJECT
|
31
|
+
188.64.46.0/23 REJECT
|
32
|
+
193.104.98.0/24 REJECT
|
33
|
+
193.105.250.0/24 REJECT
|
34
|
+
193.22.255.0/24 REJECT
|
35
|
+
193.25.114.0/23 REJECT
|
36
|
+
195.130.215.0/24 REJECT
|
37
|
+
195.225.148.0/22 REJECT
|
38
|
+
195.5.120.0/23 REJECT
|
39
|
+
195.82.152.0/23 REJECT
|
40
|
+
2a00:5300:0:1::/64 REJECT
|
41
|
+
2a00:5300:0:2::/64 REJECT
|
42
|
+
2a00:5300:0:3::/64 REJECT
|
43
|
+
2a00:5300::/32 REJECT
|
44
|
+
2a00:fa40::/32 REJECT
|
45
|
+
5.44.100.0/22 REJECT
|
46
|
+
5.44.108.0/22 REJECT
|
47
|
+
5.44.96.0/22 REJECT
|
48
|
+
81.88.16.0/21 REJECT
|
49
|
+
81.88.24.0/22 REJECT
|
50
|
+
81.88.28.0/22 REJECT
|
51
|
+
89.22.96.0/19 REJECT
|
52
|
+
91.203.128.0/22 REJECT
|
53
|
+
91.203.212.0/22 REJECT
|
54
|
+
91.206.142.0/23 REJECT
|
55
|
+
91.207.94.0/23 REJECT
|
56
|
+
91.226.88.0/22 REJECT
|
57
|
+
91.227.246.0/23 REJECT
|
58
|
+
91.235.208.0/22 REJECT
|
59
|
+
```
|
60
|
+
|
61
|
+
All announed prefixes of that spam ISP will be looked up using the [RIPE.net RESTful looking glass](https://stat.ripe.net/docs/data_api). Your optional message will appear right behind the net so you can easily paste/add this to your postfix client_checks file or wrap some shell commands around it.
|
62
|
+
|
63
|
+
You can use an IP-Address or AS-number to lookup the result.
|
64
|
+
|
65
|
+
e.g.
|
66
|
+
|
67
|
+
```shell
|
68
|
+
$ unspam net AS31342
|
69
|
+
```
|
70
|
+
|
71
|
+
will produce the identical result.
|
72
|
+
|
73
|
+
## Tricks
|
20
74
|
|
21
|
-
|
75
|
+
To see all announced IP-networks of Amazon AWS, DigitalOcean and Hetzner, try:
|
22
76
|
|
23
|
-
|
77
|
+
```shell
|
78
|
+
$ unspam nets $( dig a +short amazonaws.com | head -n1 )
|
79
|
+
$ unspam nets $( dig a +short digitalocean.com | head -n1 )
|
80
|
+
$ unspam nets $( dig a +short hetzner.de | head -n1 )
|
81
|
+
```
|
24
82
|
|
25
|
-
|
26
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
-
5. Create a new Pull Request
|
83
|
+
Enjoy!
|
data/lib/unspam/cli.rb
CHANGED
@@ -2,6 +2,7 @@ require 'thor'
|
|
2
2
|
require 'json'
|
3
3
|
require 'httparty'
|
4
4
|
require 'ipaddr'
|
5
|
+
require 'netaddr'
|
5
6
|
|
6
7
|
module Unspam
|
7
8
|
class CLI < Thor
|
@@ -37,10 +38,15 @@ module Unspam
|
|
37
38
|
end
|
38
39
|
|
39
40
|
def lookup_by_asn(asn)
|
40
|
-
response = HTTParty.get "https://stat.ripe.net/data/announced-prefixes/data.json?resource=#{asn}&min_peers_seeing=
|
41
|
+
response = HTTParty.get "https://stat.ripe.net/data/announced-prefixes/data.json?resource=#{asn}&min_peers_seeing=2"
|
41
42
|
result = JSON.parse(response.body)
|
42
43
|
|
43
|
-
|
44
|
+
prefixes = Array.new
|
45
|
+
result['data']['prefixes'].map { |h| h['prefix'] }.each do |prefix|
|
46
|
+
prefixes.push(prefix)
|
47
|
+
end
|
48
|
+
|
49
|
+
NetAddr.merge(prefixes.map{ |ip| NetAddr::CIDR.create(ip) }, :Short => true).each do |prefix|
|
44
50
|
printf("%-25s%5s\n", prefix, @msg)
|
45
51
|
end
|
46
52
|
end
|
data/lib/unspam/version.rb
CHANGED
data/unspam.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unspam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roland Moriz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: netaddr
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -105,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
119
|
version: '0'
|
106
120
|
requirements: []
|
107
121
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.
|
122
|
+
rubygems_version: 2.4.5
|
109
123
|
signing_key:
|
110
124
|
specification_version: 4
|
111
125
|
summary: returns IP prefixes by ASN.
|