-
Notifications
You must be signed in to change notification settings - Fork 7
/
adsuck.8
175 lines (175 loc) · 4.71 KB
/
adsuck.8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
.\"
.\" Copyright (c) 2009 Marco Peereboom <marco@peereboom.us>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate$
.Dt ADSUCK 1
.Os
.Sh NAME
.Nm adsuck
.Nd DNS blacklisting daemon
.Sh SYNOPSIS
.Nm adsuck
.Bk -words
.Op Fl Ddv
.Op Fl c Ar directory
.Op Fl f Ar resolv.conf
.Op Fl l Ar listen
.Op Fl p Ar port
.Op Fl r Ar regexfile
.Op Fl u Ar user
.Ar hostsfile ...
.Ek
.Sh DESCRIPTION
.Nm adsuck
is a small DNS server that spoofs blacklisted addresses and forwards all other
queries.
The idea is to be able to prevent connections to undesirable sites such as ad
servers, crawlers and other nasties.
It can be used locally, for the road warrior, or on the network perimeter in
order to protect machines from malicious sites.
.Pp
.Nm
replies to bad addresses with a spoofed DNS packet that has the NXdomain
flag set.
This in effect prevents the application that is resolving the address from
trying to connect to this address.
Addresses that are not matched are forwarded to the normal nameserver,
as provided by
.Xr resolv.conf 5 .
.Pp
Note that when applications try to be smart
and resolve an address with the local domain name appended,
it will still spoof the answer.
.Pp
All non-spoofed responses are cached for the duration of the provided DNS TTL
(Time To Live).
The cache will be purged when
.Nm
receives a
.Pa HUP
or
.Pa USR1
signal.
See the
.Pa SIGNALS
section for more details.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl c Ar directory
This is the chroot directory.
If it is not specified, it uses the home_dir entry from
.Pa /etc/passwd .
.It Fl D
Do not daemonize.
.It Fl d
Enable debug output.
.It Fl f Ar resolv.conf
This is a standard formatted resolv.conf file that contains the name server that
can resolve non-blacklisted entries.
.It Fl l Ar listen
This is the address
.Nm
will listen on.
The default is all IP addresses.
.It Fl p Ar port
This is the port number that
.Nm
will bind to.
The default is 53.
.It Fl r Ar regexfile
Filename of a file that contains one regex expression per line e.g.\&
banner|ads|stat|track|click.
When the expression is matched,
the DNS response will be spoofed.
The regex engine runs before the hostsfile match.
See
.Xr regex 3
and
.Xr re_format 7
for more information.
.It Fl u Ar user
This is the user that
.Nm
will drop privileges to after it binds to the listen address.
The default is _adsuck.
.It Fl v
Enable verbose output.
.It Ar hostsfile
This is a standard formatted hostsfile that contains all blacklisted entries.
Examples of good blacklist files:
.Bd -literal -offset indent
http://rlwpx.free.fr/WPFF/hosts.htm
http://www.mvps.org/winhelp2002/
.Ed
.El
.Pp
.Sh SIGNALS
The
.Nm
daemon reacts to the following signals:
.Bl -tag -width Ds -offset indent -compact
.It Cm HUP
reevaluate resolv.conf and purge cache
.It Cm USR1
reread hosts and regex files and purge cache
.It Cm USR2
output runtime stats using syslog
.El
.Pp
NOTE: when supported by the OS
.Nm
will monitor resolv.conf for changes and therefore alleviate the need for
external stimuli via HUP.
Currently only OS' with kqueue/kevent functionality support this.
.Sh FILES
.Bl -tag -width "resolv.confXXX"
.It Pa hostsfile
Blacklist entries in standard hostsfile format.
The entries must point to 127.0.0.1.
E.g. 127.0.0.1 badsite.com.
.Pp
If the entry points to a different address then the spoofing will not be done
via NXdomain but will instead return the provided IP address.
This enables the administrator to forward specific sites to an IP address that
might contain a warning.
In order to spoof badsite.com to 192.168.0.1 add "192.168.0.1 badsite.com" to a
hostsfile.
.It Pa resolv.conf
Standard resolv.conf file that contain the actual resolving
nameserver and options.
.Pp
Note: due to the way ldns works one can
.Pa NOT
specify a port in the
.Pa resolv.conf
file.
.El
.Sh SEE ALSO
.Xr resolv.conf 5
.Sh HISTORY
.Nm
was written to do some smarter ad blocking without using individual browser
components and to avoid lengthy hostsfile lookups.
.Sh AUTHORS
.An -nosplit
.Pp
.Nm
was written by
.An Marco Peereboom Aq marco@peereboom.us .
.Sh BUGS
Currently
.Nm
depends on ldns.