4 By: Junkbuster Developers
6 $Id: user-manual.sgml,v 1.32 2002/03/03 09:26:06 joergs Exp $
8 The user manual gives the users information on how to install and
9 configure Internet Junkbuster. Internet Junkbuster is an application
10 that provides privacy and security to users of the World Wide Web.
12 You can find the latest version of the user manual at
13 [1]http://ijbswa.sourceforge.net/user-manual/.
15 Feel free to send a note to the developers at
16 <[2]ijbswa-developers@lists.sourceforge.net>.
17 _________________________________________________________________
33 3. [12]Junkbuster Configuration
35 3.1. [13]The Main Configuration File
36 3.2. [14]The Actions File
37 3.3. [15]The Filter File
40 4. [17]Quickstart to Using Junkbuster
41 5. [18]Contact the Developers
42 6. [19]Copyright and History
50 8.1. [24]Regular Expressions
54 Internet Junkbuster is a web proxy with advanced filtering
55 capabilities for protecting privacy, filtering web page content,
56 managing cookies, controlling access, and removing ads, banners,
57 pop-ups and other obnoxious Internet Junk. Junkbuster has a very
58 flexible configuration and can be customized to suit individual needs
59 and tastes. Internet Junkbuster has application for both stand-alone
60 systems and multi-user networks.
62 This documentation is included with the current BETA version of
63 Internet Junkbuster and is incomplete at this point. The most up to
64 date reference for the time being is still the comments in the source
65 files and in the individual configuration files. Development of
66 version 3.0 is currently nearing completion, and includes many
67 significant changes and enhancements over earlier versions. The target
68 release date for stable v3.0 RSN.
70 Since this is a BETA version, not all new features are well tested.
71 This documentation may be slightly out of sync as a result. And there
72 may be bugs, though hopefully not many!
73 _________________________________________________________________
77 In addition to Junkbuster's traditional features of ad and banner
78 blocking and cookie management, this is a list of new features
79 currently under development:
81 * Integrated browser based configuration and control utility
82 ([25]http://i.j.b). Browser-based tracing of rule and filter
84 * Modularized configuration that will allow for system wide
85 settings, and individual user settings. (not implemented yet,
86 probably a 3.1 feature)
87 * Blocking of annoying pop-up browser windows.
88 * HTTP/1.1 compliant (most, but not all 1.1 features are supported).
89 * Support for Perl Compatible Regular Expressions in the
90 configuration files, and generally a more sophisticated and
91 flexible configuration syntax over previous versions.
93 * Web page content filtering (removes banners based on size,
94 invisible "web-bugs", JavaScript, pop-ups, status bar abuse, etc.)
95 * Bypass many click-tracking scripts (avoids script redirection).
96 * Multi-threaded (POSIX and native threads).
97 * Auto-detection and re-reading of config file changes.
98 * User-customizable HTML templates (e.g. 404 error page).
99 * Improved cookie management features (e.g. session based cookies).
100 * Builds from source on most UNIX-like systems. Packages available
101 for: Linux (RedHat, SuSE, or Debian), Windows, Sun Solaris, Mac
103 * In addition, the configuration is much more powerful and versatile
105 _________________________________________________________________
109 Junkbuster is available as raw source code, or pre-compiled binaries.
110 See the [26]Junkbuster Home Page for current release info. Junkbuster
111 is also available via [27]CVS. This is the recommended approach at
112 this time. But please be aware that CVS is constantly changing, and it
113 may break in mysterious ways.
114 _________________________________________________________________
118 For gzipped tar archives, unpack the source:
120 tar xzvf ijb_source_* [.tgz or .tar.gz]
121 cd ijb_source_2.9.10_beta
123 For retrieving the current CVS sources, you'll need the CVS package
124 installed first. To download CVS source:
126 cvs -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa login
127 cvs -z3 -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa co cu
131 This will create a directory named current/, which will contain the
134 Then, in either case, to build from tarball/CVS source:
136 ./configure (--help to see options)
137 make (the make from gnu, gmake for *BSD)
139 make -n install (to see where all the files will go)
140 make install (to really install)
142 For Redhat and SuSE Linux RPM packages, see below.
143 _________________________________________________________________
147 To build Redhat RPM packages, install source as above. Then:
149 autoheader [suggested for CVS source]
150 autoconf [suggested for CVS source]
154 This will create both binary and src RPMs in the usual places.
157 /usr/src/redhat/RPMS/i686/junkbuster-2.9.10-1.i686.rpm
159 /usr/src/redhat/SRPMS/junkbuster-2.9.10-1.src.rpm
161 To install, of course:
163 rpm -Uvv /usr/src/redhat/RPMS/i686/junkbuster-2.9.10-1.i686.rpm
165 This will place the Junkbuster configuration files in
166 /etc/junkbuster/, and log files in /var/log/junkbuster/.
167 _________________________________________________________________
171 To build SuSE RPM packages, install source as above. Then:
173 autoheader [suggested for CVS source]
174 autoconf [suggested for CVS source]
178 This will create both binary and src RPMs in the usual places.
181 /usr/src/packages/RPMS/i686/junkbuster-2.9.10-1.i686.rpm
183 /usr/src/packages/SRPMS/junkbuster-2.9.10-1.src.rpm
185 To install, of course:
187 rpm -Uvv /usr/src/packages/RPMS/i686/junkbuster-2.9.10-1.i686.rpm
189 This will place the Junkbuster configuration files in
190 /etc/junkbuster/, and log files in /var/log/junkbuster/.
191 _________________________________________________________________
195 Junkbuster is packaged in a WarpIN self- installing archive. The
196 self-installing program will be named depending on the release
197 version, something like: ijbos2_setup_1.2.3.exe. In order to install
198 it, simply run this executable or double-click on its icon and follow
199 the WarpIN installation panels. A shadow of the Junkbuster executable
200 will be placed in your startup folder so it will start automatically
201 whenever OS/2 starts.
203 The directory you choose to install Junkbuster into will contain all
204 of the configuration files.
206 If you would like to build binary images on OS/2 yourself, you will
207 need a few Unix-like tools: autoconf, autoheader and sh. These tools
208 will be used to create the required config.h file, which is not part
209 of the source distribution because it differs based on platform. You
210 will also need a compiler. The distribution has been created using IBM
211 VisualAge compilers, but you can use any compiler you like. GCC/EMX
212 has the disadvantage of needing to be single-threaded due to a
213 limitation of EMX's implementation of the select() socket call.
215 In addition to needing the source code distribution as outlined
216 earlier, you will want to extract the os2seutp directory from CVS:
217 cvs -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa login
219 cvs -z3 -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa co os2
222 This will create a directory named os2setup/, which will contain the
223 Makefile.vac makefile and os2build.cmd which is used to completely
224 create the binary distribution. The sequence of events for building
225 the executable for yourself goes something like this:
231 nmake -f Makefile.vac
233 You will see this sequence laid out in os2build.cmd.
234 _________________________________________________________________
238 Click-click. (I need help on this. Not a clue here. Also for
239 configuration section below. HB.)
240 _________________________________________________________________
244 Some quick notes on other Operating Systems.
246 For FreeBSD (and other *BSDs?), the build will require gmake instead
247 of the included make. gmake is available from [28]http://www.gnu.org.
248 The rest should be the same as above for Linux/Unix.
249 _________________________________________________________________
251 3. Junkbuster Configuration
253 For Unix, *BSD and Linux, all configuration files are located in
254 /etc/junkbuster/ by default. For MS Windows, OS/2, and AmigaOS these
255 are all in the same directory as the Junkbuster executable. The name
256 and number of configuration files has changed from previous versions,
257 and is subject to change as development progresses.
259 The installed defaults provide a reasonable starting point, though
260 possibly aggressive by some standards. For the time being, there are
261 only three default configuration files (this will change in time):
263 * The main configuration file is named config on Linux, Unix, BSD,
264 OS/2, and AmigaOS and config.txt on Windows.
265 * The ijb.action file is used to define various "actions" relating
266 to images, banners, pop-ups, access restrictions, banners and
267 cookies. There is a CGI based editor for this file that can be
268 accessed via [29]http://i.j.b. This is the easiest method of
269 configuring actions. (Other actions files are included as well
270 with differing levels of filtering and blocking, e.g.
272 * The re_filterfile file can be used to rewrite the raw page
273 content, including text as well as embedded HTML and JavaScript.
275 ijb.action and re_filterfile can use Perl style regular expressions
276 for maximum flexibility. All files use the "#" character to denote a
277 comment. Such lines are not processed by Junkbuster. After making any
278 changes, there is no need to restart Junkbuster in order for the
279 changes to take effect. Junkbuster should detect such changes
282 While under development, the configuration content is subject to
283 change. The below documentation may not be accurate by the time you
284 read this. Also, what constitutes a "default" setting, may change, so
285 please check all your configuration files on important issues.
286 _________________________________________________________________
288 3.1. The Main Configuration File
290 Again, the main configuration file is named config on Linux/Unix/BSD
291 and OS/2, and config.txt on Windows. Configuration lines consist of an
292 initial keyword followed by a list of values, all separated by
293 whitespace (any number of spaces or tabs). For example:
295 blockfile blocklist.ini
297 Indicates that the blockfile is named "blocklist.ini".
299 A "#" indicates a comment. Any part of a line following a "#" is
300 ignored, except if the "#" is preceded by a "\".
302 Thus, by placing a "#" at the start of an existing configuration line,
303 you can make it a comment and it will be treated as if it weren't
304 there. This is called "commenting out" an option and can be useful to
305 turn off features: If you comment out the "logfile" line, junkbuster
306 will not log to a file at all. Watch for the "default:" section in
307 each explanation to see what happens if the option is left unset (or
310 Long lines can be continued on the next line by using a "\" as the
313 There are various aspects of Junkbuster behavior that can be tuned.
314 _________________________________________________________________
316 3.1.1. Defining Other Configuration Files
318 Junkbuster can use a number of other files to tell it what ads to
319 block, what cookies to accept, etc. This section of the configuration
320 file tells Junkbuster where to find all those other files.
322 On Windows and AmigaOS, Junkbuster looks for these files in the same
323 directory as the executable. On Unix and OS/2, Junkbuster looks for
324 these files in the current working directory. In either case, an
325 absolute path name can be used to avoid problems.
327 When development goes modular and multi-user, the blocker, filter, and
328 per-user config will be stored in subdirectories of "confdir". For
329 now, only confdir/templates is used for storing HTML templates for CGI
332 The location of the configuration files:
334 confdir /etc/junkbuster # No trailing /, please.
336 The directory where all logging (i.e. logfile and jarfile) takes
337 place. No trailing "/", please:
339 logdir /var/log/junkbuster
341 Note that all file specifications below are relative to the above two
344 The "ijb.action" file contains patterns to specify the actions to
345 apply to requests for each site. Default: Cookies to and from all
346 destinations are kept only during the current browser session (i.e.
347 they are not saved to disk). Pop-ups are disabled for all sites. All
348 sites are filtered if "re_filterfile" specified. No sites are blocked.
349 An empty image is displayed for filtered ads and other images
350 (formerly "tinygif"). The syntax of this file is explained in detail
353 actionsfile ijb.action
355 The "re_filterfile" file contains content modification rules. These
356 rules permit powerful changes on the content of Web pages, e.g., you
357 could disable your favorite JavaScript annoyances, rewrite the actual
358 content, or just have some fun replacing "Microsoft" with "MicroSuck"
359 wherever it appears on a Web page. Default: No content modification,
360 or whatever the developers are playing with :-/
362 re_filterfile re_filterfile
364 The logfile is where all logging and error messages are written. The
365 logfile can be useful for tracking down a problem with Junkbuster
366 (e.g., it's not blocking an ad you think it should block) but in most
367 cases you probably will never look at it.
369 Your logfile will grow indefinitely, and you will probably want to
370 periodically remove it. On Unix systems, you can do this with a cron
371 job (see "man cron"). For Redhat, a logrotate script has been
374 On SuSE Linux systems, you can place a line like
375 "/var/log/junkbuster.* +1024k 644 nobody.nogroup" in /etc/logfiles,
376 with the effect that cron.daily will automatically archive, gzip, and
377 empty the log, when it exceeds 1M size.
379 Default: Log to the a file named logfile. Comment out to disable
384 The "jarfile" defines where Junkbuster stores the cookies it
385 intercepts. Note that if you use a "jarfile", it may grow quite large.
386 Default: Don't store intercepted cookies.
390 If you specify a "trustfile", Junkbuster will only allow access to
391 sites that are named in the trustfile. You can also mark sites as
392 trusted referrers, with the effect that access to untrusted sites will
393 be granted, if a link from a trusted referrer was used. The link
394 target will then be added to the "trustfile". This is a very
395 restrictive feature that typical users most probably want to leave
396 disabled. Default: Disabled, don't use the trust mechanism.
400 If you use the trust mechanism, it is a good idea to write up some
401 on-line documentation about your blocking policy and to specify the
402 URL(s) here. They will appear on the page that your users receive when
403 they try to access untrusted content. Use multiple times for multiple
404 URLs. Default: Don't display links on the "untrusted" info page.
406 trust-info-url http://www.your-site.com/why_we_block.html
407 trust-info-url http://www.your-site.com/what_we_allow.html
408 _________________________________________________________________
410 3.1.2. Other Configuration Options
412 This part of the configuration file contains options that control how
415 "Admin-address" should be set to the email address of the proxy
416 administrator. It is used in many of the proxy-generated pages.
417 Default: fill@me.in.please.
419 #admin-address fill@me.in.please
421 "Proxy-info-url" can be set to a URL that contains more info about
422 this Junkbuster installation, it's configuration and policies. It is
423 used in many of the proxy-generated pages and its use is highly
424 recommended in multi-user installations, since your users will want to
425 know why certain content is blocked or modified. Default: Don't show a
426 link to on-line documentation.
428 proxy-info-url http://www.your-site.com/proxy.html
430 "Listen-address" specifies the address and port where Junkbuster will
431 listen for connections from your Web browser. The default is to listen
432 on the localhost port 8000, and this is suitable for most users. (In
433 your web browser, under proxy configuration, list the proxy server as
434 "localhost" and the port as "8000").
436 If you already have another service running on port 8000, or if you
437 want to serve requests from other machines (e.g. on your local
438 network) as well, you will need to override the default. The syntax is
439 "listen-address [<ip-address>]:<port>". If you leave out the IP
440 address, junkbuster will bind to all interfaces (addresses) on your
441 machine and may become reachable from the Internet. In that case,
442 consider using access control lists (acl's) (see "aclfile" above), or
445 For example, suppose you are running Junkbuster on a machine which has
446 the address 192.168.0.1 on your local private network (192.168.0.0)
447 and has another outside connection with a different address. You want
448 it to serve requests from inside only:
450 listen-address 192.168.0.1:8000
452 If you want it to listen on all addresses (including the outside
457 If you do this, consider using ACLs (see "aclfile" above). Note: you
458 will need to point your browser(s) to the address and port that you
459 have configured here. Default: localhost:8000 (127.0.0.1:8000).
461 The debug option sets the level of debugging information to log in the
462 logfile (and to the console in the Windows version). A debug level of
463 1 is informative because it will show you each request as it happens.
464 Higher levels of debug are probably only of interest to developers.
466 debug 1 # GPC = show each GET/POST/CONNECT request
467 debug 2 # CONN = show each connection status
468 debug 4 # IO = show I/O status
469 debug 8 # HDR = show header parsing
470 debug 16 # LOG = log all data into the logfile
471 debug 32 # FRC = debug force feature
472 debug 64 # REF = debug regular expression filter
473 debug 128 # = debug fast redirects
474 debug 256 # = debug GIF de-animation
475 debug 512 # CLF = Common Log Format
476 debug 1024 # = debug kill pop-ups
477 debug 4096 # INFO = Startup banner and warnings.
478 debug 8192 # ERROR = Non-fatal errors
480 It is highly recommended that you enable ERROR reporting (debug 8192),
481 at least until the next stable release.
483 The reporting of FATAL errors (i.e. ones which crash JunkBuster) is
484 always on and cannot be disabled.
486 If you want to use CLF (Common Log Format), you should set "debug 512"
487 ONLY, do not enable anything else.
489 Multiple "debug" directives, are OK - they're logical-OR'd together.
491 debug 15 # same as setting the first 4 listed above
497 debug 8192 # Errors - *we highly recommended enabling this*
499 Junkbuster normally uses "multi-threading", a software technique that
500 permits it to handle many different requests simultaneously. In some
501 cases you may wish to disable this -- particularly if you're trying to
502 debug a problem. The "single-threaded" option forces Junkbuster to
503 handle requests sequentially. Default: Multi-threaded mode.
507 "toggle" allows you to temporarily disable all Junkbuster's filtering.
510 The Windows version of Junkbuster puts an icon in the system tray,
511 which also allows you to change this option. If you right-click on
512 that icon (or select the "Options" menu), one choice is "Enable".
513 Clicking on enable toggles Junkbuster on and off. This is useful if
514 you want to temporarily disable Junkbuster, e.g., to access a site
515 that requires cookies which you would otherwise have blocked. This can
516 also be toggled via a web browser at the Junkbuster internal address
517 of [31]http://i.j.b on any platform.
519 "toggle 1" means Junkbuster runs normally, "toggle 0" means that
520 Junkbuster becomes a non-anonymizing non-blocking proxy. Default: 1
525 For content filtering, i.e. the "+filter" and "+deanimate-gif"
526 actions, it is necessary that Junkbuster buffers the entire document
527 body. This can be potentially dangerous, since a server could just
528 keep sending data indefinitely and wait for your RAM to exhaust. With
531 The buffer-limit option lets you set the maximum size in Kbytes that
532 each buffer may use. When the documents buffer exceeds this size, it
533 is flushed to the client unfiltered and no further attempt to filter
534 the rest of it is made. Remember that there may multiple threads
535 running, which might require increasing the "buffer-limit" Kbytes
536 each, unless you have enabled "single-threaded" above.
540 To enable the web-based ijb.action file editor set enable-edit-actions
541 to 1, or 0 to disable. Note that you must have compiled JunkBuster
542 with support for this feature, otherwise this option has no effect.
543 This internal page can be reached at [32]http://i.j.b.
545 Security note: If this is enabled, anyone who can use the proxy can
546 edit the actions file, and their changes will affect all users. For
547 shared proxies, you probably want to disable this. Default: enabled.
549 enable-edit-actions 1
551 Allow JunkBuster to be toggled on and off remotely, using your web
552 browser. Set "enable-remote-toggle"to 1 to enable, and 0 to disable.
553 Note that you must have compiled JunkBuster with support for this
554 feature, otherwise this option has no effect.
556 Security note: If this is enabled, anyone who can use the proxy can
557 toggle it on or off (see [33]http://i.j.b), and their changes will
558 affect all users. For shared proxies, you probably want to disable
559 this. Default: enabled.
561 enable-remote-toggle 1
562 _________________________________________________________________
564 3.1.3. Access Control List (ACL)
566 Access controls are included at the request of some ISPs and systems
567 administrators, and are not usually needed by individual users. Please
568 note the warnings in the FAQ that this proxy is not intended to be a
569 substitute for a firewall or to encourage anyone to defer addressing
570 basic security weaknesses.
572 If no access settings are specified, the proxy talks to anyone that
573 connects. If any access settings file are specified, then the proxy
574 talks only to IP addresses permitted somewhere in this file and not
575 denied later in this file.
577 Summary -- if using an ACL:
579 Client must have permission to receive service.
581 LAST match in ACL wins.
583 Default behavior is to deny service.
585 The syntax for an entry in the Access Control List is:
587 ACTION SRC_ADDR[/SRC_MASKLEN] [ DST_ADDR[/DST_MASKLEN] ]
589 Where the individual fields are:
591 ACTION = "permit-access" or "deny-access"
592 SRC_ADDR = client hostname or dotted IP address
593 SRC_MASKLEN = number of bits in the subnet mask for the source
594 DST_ADDR = server or forwarder hostname or dotted IP address
595 DST_MASKLEN = number of bits in the subnet mask for the target
597 The field separator (FS) is whitespace (space or tab).
599 IMPORTANT NOTE: If the junkbuster is using a forwarder (see below) or
600 a gateway for a particular destination URL, the DST_ADDR that is
601 examined is the address of the forwarder or the gateway and NOT the
602 address of the ultimate target. This is necessary because it may be
603 impossible for the local Junkbuster to determine the address of the
604 ultimate target (that's often what gateways are used for).
606 Here are a few examples to show how the ACL features work:
608 "localhost" is OK -- no DST_ADDR implies that ALL destination
611 permit-access localhost
613 A silly example to illustrate permitting any host on the class-C
614 subnet with Junkbuster to go anywhere:
616 permit-access www.junkbusters.com/24
618 Except deny one particular IP address from using it at all:
620 deny-access ident.junkbusters.com
622 You can also specify an explicit network address and subnet mask.
623 Explicit addresses do not have to be resolved to be used.
625 permit-access 207.153.200.0/24
627 A subnet mask of 0 matches anything, so the next line permits
630 permit-access 0.0.0.0/0
632 Note, you cannot say:
636 to allow all *.org domains. Every IP address listed must resolve
639 An ISP may want to provide a Junkbuster that is accessible by "the
640 world" and yet restrict use of some of their private content to hosts
641 on its internal network (i.e. its own subscribers). Say, for instance
642 the ISP owns the Class-B IP address block 123.124.0.0 (a 16 bit
643 netmask). This is how they could do it:
645 permit-access 0.0.0.0/0 0.0.0.0/0 # other clients can go anywhere
646 # with the following exceptions
649 deny-access 0.0.0.0/0 123.124.0.0/16 # block all external request
651 # sites on the ISP's network
652 permit 0.0.0.0/0 www.my_isp.com # except for the ISP's main
654 permit 123.124.0.0/16 0.0.0.0/0 # the ISP's clients can go
657 Note that if some hostnames are listed with multiple IP addresses, the
658 primary value returned by DNS (via gethostbyname()) is used. Default:
659 Anyone can access the proxy.
660 _________________________________________________________________
664 This feature allows chaining of HTTP requests via multiple proxies. It
665 can be used to better protect privacy and confidentiality when
666 accessing specific domains by routing requests to those domains to a
667 special purpose filtering proxy such as lpwa.com. Or to use a caching
668 proxy to speed up browsing.
670 It can also be used in an environment with multiple networks to route
671 requests via multiple gateways allowing transparent access to multiple
672 networks without having to modify browser configurations.
674 Also specified here are SOCKS proxies. Junkbuster SOCKS 4 and SOCKS
675 4A. The difference is that SOCKS 4A will resolve the target hostname
676 using DNS on the SOCKS server, not our local DNS client.
678 The syntax of each line is:
680 forward target_domain[:port] http_proxy_host[:port]
681 forward-socks4 target_domain[:port] socks_proxy_host[:port]
682 http_proxy_host[:port]
683 forward-socks4a target_domain[:port] socks_proxy_host[:port]
684 http_proxy_host[:port]
686 If http_proxy_host is ".", then requests are not forwarded to a HTTP
687 proxy but are made directly to the web servers.
689 Lines are checked in sequence, and the last match wins.
691 There is an implicit line equivalent to the following, which specifies
692 that anything not finding a match on the list is to go out without
693 forwarding or gateway protocol, like so:
695 forward .* . # implicit
697 In the following common configuration, everything goes to Lucent's
698 LPWA, except SSL on port 443 (which it doesn't handle):
700 forward .* lpwa.com:8000
703 See the FAQ for instructions on how to automate the login procedure
704 for LPWA. Some users have reported difficulties related to LPWA's use
705 of "." as the last element of the domain, and have said that this can
708 forward lpwa. lpwa.com:8000
710 (NOTE: the syntax for specifying target_domain has changed since the
711 previous paragraph was written -- it will not work now. More
712 information is welcome.)
714 In this fictitious example, everything goes via an ISP's caching
715 proxy, except requests to that ISP:
717 forward .* caching.myisp.net:8000
720 For the @home network, we're told the forwarding configuration is
723 forward .* proxy:8080
725 Also, we're told they insist on getting cookies and JavaScript, so you
726 should add home.com to the cookie file. We consider JavaScript a
727 security risk. Java need not be enabled.
729 In this example direct connections are made to all "internal" domains,
730 but everything else goes through Lucent's LPWA by way of the company's
731 SOCKS gateway to the Internet.
733 forward-socks4 .* lpwa.com:8000 firewall.my_company.com:1080
734 forward my_company.com .
736 This is how you could set up a site that always uses SOCKS but no
739 forward-socks4a .* . firewall.my_company.com:1080
741 An advanced example for network administrators:
743 If you have links to multiple ISPs that provide various special
744 content to their subscribers, you can configure forwarding to pass
745 requests to the specific host that's connected to that ISP so that
746 everybody can see all of the content on all of the ISPs.
748 This is a bit tricky, but here's an example:
750 host-a has a PPP connection to isp-a.com. And host-b has a PPP
751 connection to isp-b.com. host-a can run a Junkbuster proxy with
752 forwarding like this:
755 forward isp-b.com host-b:8000
757 host-b can run a Junkbuster proxy with forwarding like this:
760 forward isp-a.com host-a:8000
762 Now, anyone on the Internet (including users on host-a and host-b) can
763 set their browser's proxy to either host-a or host-b and be able to
764 browse the content on isp-a or isp-b.
766 Here's another practical example, for University of Kent at Canterbury
767 students with a network connection in their room, who need to use the
768 University's Squid web cache.
770 forward *. ssbcache.ukc.ac.uk:3128 # Use the proxy, except for:
771 forward .ukc.ac.uk . # Anything on the same domain as us
772 forward * . # Host with no domain specified
773 forward 129.12.*.* . # A dotted IP on our /16 network.
774 forward 127.*.*.* . # Loopback address
775 forward localhost.localdomain . # Loopback address
776 forward www.ukc.mirror.ac.uk . # Specific host
778 If you intend to chain Junkbuster and squid locally, then chain as
779 browser -> squid -> junkbuster is the recommended way.
781 Your squid configuration could then look like this:
783 # Define junkbuster as parent cache
785 cache_peer 127.0.0.1 parent 8000 0 no-query
787 # Define ACL for protocol FTP
789 # Do not forward ACL FTP to junkbuster
790 always_direct allow FTP
791 # Do not forward ACL CONNECT (https) to junkbuster
792 always_direct allow CONNECT
793 # Forward the rest to junkbuster
794 never_direct allow all
795 _________________________________________________________________
797 3.1.5. Windows GUI Options
799 Junkbuster has a number of options specific to the Windows GUI
802 If "activity-animation" is set to 1, the Junkbuster icon will animate
803 when "Junkbuster" is active. To turn off, set to 0.
807 If "log-messages" is set to 1, Junkbuster will log messages to the
812 If "log-buffer-size" is set to 1, the size of the log buffer, i.e. the
813 amount of memory used for the log messages displayed in the console
814 window, will be limited to "log-max-lines" (see below).
816 Warning: Setting this to 0 will result in the buffer to grow
817 infinitely and eat up all your memory!
821 log-max-lines is the maximum number of lines held in the log buffer.
826 If "log-highlight-messages" is set to 1, Junkbuster will highlight
827 portions of the log messages with a bold-faced font:
829 log-highlight-messages 1
831 The font used in the console window:
833 log-font-name Comic Sans MS
835 Font size used in the console window:
839 "show-on-task-bar" controls whether or not Junkbuster will appear as a
840 button on the Task bar when minimized:
844 If "close-button-minimizes" is set to 1, the Windows close button will
845 minimize Junkbuster instead of closing the program (close with the
846 exit option on the File menu).
848 close-button-minimizes 1
850 The "hide-console" option is specific to the MS-Win console version of
851 JunkBuster. If this option is used, Junkbuster will disconnect from
852 and hide the command console.
855 _________________________________________________________________
857 3.2. The Actions File
859 The "ijb.action" file (formerly actionsfile) is used to define what
860 actions Junkbuster takes, and thus determines how images, cookies and
861 various other aspects of HTTP content and transactions are handled.
862 Images can be anything you want, including ads, banners, or just some
863 obnoxious image that you would rather not see. Cookies can be accepted
864 or rejected, or accepted only during the current browser session (i.e.
865 not written to disk). Changes to ijb.action should be immediately
866 visible to Junkbuster without the need to restart.
868 To determine which actions apply to a request, the URL of the request
869 is compared to all patterns in this file. Every time it matches, the
870 list of applicable actions for the URL is incrementally updated. You
871 can trace this process by visiting [34]http://i.j.b/show-url-info.
873 The actions file can be edited with a browser by loading
874 [35]http://i.j.b/, and then select "Edit Actions".
876 There are four types of lines in this file: comments (begin with a "#"
877 character), actions, aliases and patterns, all of which are explained
878 below, as well as the configuration file syntax that Junkbuster
880 _________________________________________________________________
882 3.2.1. URL Domain and Path Syntax
884 Generally, a pattern has the form <domain>/<path>, where both the
885 <domain> and <path> part are optional. If you only specify a domain
886 part, the "/" can be left out:
888 www.example.com - is a domain only pattern and will match any request
889 to "www.example.com".
891 www.example.com/ - means exactly the same.
893 www.example.com/index.html - matches only the single document
894 "/index.html" on "www.example.com".
896 /index.html - matches the document "/index.html", regardless of the
899 index.html - matches nothing, since it would be interpreted as a
900 domain name and there is no top-level domain called ".html".
902 The matching of the domain part offers some flexible options: if the
903 domain starts or ends with a dot, it becomes unanchored at that end.
906 .example.com - matches any domain that ENDS in ".example.com".
908 www. - matches any domain that STARTS with "www".
910 Additionally, there are wild-cards that you can use in the domain
911 names themselves. They work pretty similar to shell wild-cards: "*"
912 stands for zero or more arbitrary characters, "?" stands for any
913 single character. And you can define character classes in square
914 brackets and they can be freely mixed:
916 ad*.example.com - matches "adserver.example.com", "ads.example.com",
917 etc but not "sfads.example.com".
919 *ad*.example.com - matches all of the above, and then some.
921 .?pix.com - matches "www.ipix.com", "pictures.epix.com",
922 "a.b.c.d.e.upix.com", etc.
924 www[1-9a-ez].example.com - matches "www1.example.com",
925 "www4.example.com", "wwwd.example.com", "wwwz.example.com", etc., but
926 not "wwww.example.com".
928 If Junkbuster was compiled with "pcre" support (default), Perl
929 compatible regular expressions can be used. See the pcre/docs/
930 directory or "man perlre" (also available on
931 [36]http://www.perldoc.com/perl5.6/pod/perlre.html) for details. A
932 brief discussion of regular expressions is in the [37]Appendix. For
935 /.*/advert[0-9]+\.jpe?g - would match a URL from any domain, with any
936 path that includes "advert" followed immediately by one or more
937 digits, then a "." and ending in either "jpeg" or "jpg". So we match
938 "example.com/ads/advert2.jpg", and
939 "www.example.com/ads/banners/advert39.jpeg", but not
940 "www.example.com/ads/banners/advert39.gif" (no gifs in the example
943 Please note that matching in the path is case INSENSITIVE by default,
944 but you can switch to case sensitive at any point in the pattern by
945 using the "(?-i)" switch:
947 www.example.com/(?-i)PaTtErN.* - will match only documents whose path
948 starts with "PaTtErN" in exactly this capitalization.
949 _________________________________________________________________
953 Actions are enabled if preceded with a "+", and disabled if preceded
954 with a "-". Actions are invoked by enclosing the action name in curly
955 braces (e.g. {+some_action}), followed by a list of URLs to which the
956 action applies. There are three classes of actions:
958 * Boolean (e.g. "+/-block"):
959 {+name} # enable this action
960 {-name} # disable this action
962 * parameterized (e.g. "+/-hide-user-agent"):
963 {+name{param}} # enable action and set parameter to "param"
964 {-name} # disable action
966 * Multi-value (e.g. "{+/-add-header{Name: value}}",
967 "{+/-wafer{name=value}}"):
968 {+name{param}} # enable action and add parameter "param"
969 {-name{param}} # remove the parameter "param"
970 {-name} # disable this action totally
972 If nothing is specified in this file, no "actions" are taken. So in
973 this case JunkBuster would just be a normal, non-blocking,
974 non-anonymizing proxy. You must specifically enable the privacy and
975 blocking features you need (although the provided default ijb.action
976 file will give a good starting point).
978 Later defined actions always over-ride earlier ones. For multi-valued
979 actions, the actions are applied in the order they are specified.
981 The list of valid Junkbuster "actions" are:
983 * Add the specified HTTP header, which is not checked for validity.
984 You may specify this many times to specify many different headers:
985 +add-header{Name: value}
987 * Block this URL totally.
990 * De-animate all animated GIF images, i.e. reduce them to their last
991 frame. This will also shrink the images considerably (in bytes,
992 not pixels!). If the option "first" is given, the first frame of
993 the animation is used as the replacement. If "last" is given, the
994 last frame of the animation is used instead, which probably makes
995 more sense for most banner animations, but also has the risk of
996 not showing the entire last frame (if it is only a delta to an
998 +deanimate-gifs{last}
999 +deanimate-gifs{first}
1001 * "+downgrade" will downgrade HTTP/1.1 client requests to HTTP/1.0
1002 and downgrade the responses as well. Use this action for servers
1003 that use HTTP/1.1 protocol features that Junkbuster doesn't handle
1004 well yet. HTTP/1.1 is only partially implemented. Default is not
1005 to downgrade requests.
1008 * Many sites, like yahoo.com, don't just link to other sites.
1009 Instead, they will link to some script on their own server, giving
1010 the destination as a parameter, which will then redirect you to
1011 the final target. URLs resulting from this scheme typically look
1012 like: http://some.place/some_script?http://some.where-else.
1013 Sometimes, there are even multiple consecutive redirects encoded
1014 in the URL. These redirections via scripts make your web browsing
1015 more traceable, since the server from which you follow such a link
1016 can see where you go to. Apart from that, valuable bandwidth and
1017 time is wasted, while your browser ask the server for one redirect
1018 after the other. Plus, it feeds the advertisers.
1019 The "+fast-redirects" option enables interception of these
1020 requests by Junkbuster, who will cut off all but the last valid
1021 URL in the request and send a local redirect back to your browser
1022 without contacting the remote site.
1025 * Filter the website through the re_filterfile:
1028 * Block any existing X-Forwarded-for header, and do not add a new
1032 * If the browser sends a "From:" header containing your e-mail
1033 address, this either completely removes the header ("block"), or
1034 changes it to the specified e-mail address.
1036 +hide-from{spam@sittingduck.xqq}
1038 * Don't send the "Referer:" (sic) header to the web site. You can
1039 block it, forge a URL to the same server as the request (which is
1040 preferred because some sites will not send images otherwise) or
1041 set it to a constant string of your choice.
1042 +hide-referer{block}
1043 +hide-referer{forge}
1044 +hide-referer{http://nowhere.com}
1046 * Alternative spelling of "+hide-referer". It has the same
1047 parameters, and can be freely mixed with, "+hide-referer".
1048 ("referrer" is the correct English spelling, however the HTTP
1049 specification has a bug - it requires it to be spelled "referer".)
1052 * Change the "User-Agent:" header so web servers can't tell your
1053 browser type. Warning! This breaks many web sites. Specify the
1054 user-agent value you want. Example, pretend to be using Netscape
1056 +hide-user-agent{Mozilla (X11; I; Linux 2.0.32 i586)}
1058 * Treat this URL as an image. This only matters if it's also
1059 "+block"ed, in which case a "blocked" image can be sent rather
1060 than a HTML page. See "+image-blocker{}" below for the control
1061 over what is actually sent.
1064 * Decides what to do with URLs that end up tagged with "{+block
1065 +image}". There are 4 options. "-image-blocker" will send a HTML
1066 "blocked" page, usually resulting in a "broken image" icon.
1067 "+image-blocker{logo}" will send a "JunkBuster" image.
1068 "+image-blocker{blank}" will send a 1x1 transparent GIF image. And
1069 finally, "+image-blocker{http://xyz.com}" will send a HTTP
1070 temporary redirect to the specified image. This has the advantage
1071 of the icon being being cached by the browser, which will speed up
1073 +image-blocker{logo}
1074 +image-blocker{blank}
1075 +image-blocker{http://i.j.b/send-banner}
1077 * By default (i.e. in the absence of a "+limit-connect" action),
1078 Junkbuster will only allow CONNECT requests to port 443, which is
1079 the standard port for https as a precaution.
1080 The CONNECT methods exists in HTTP to allow access to secure
1081 websites (https:// URLs) through proxies. It works very simply:
1082 the proxy connects to the server on the specified port, and then
1083 short-circuits its connections to the client and to the remote
1084 proxy. This can be a big security hole, since CONNECT-enabled
1085 proxies can be abused as TCP relays very easily.
1086 If you want to allow CONNECT for more ports than this, or want to
1087 forbid CONNECT altogether, you can specify a comma separated list
1088 of ports and port ranges (the latter using dashes, with the
1089 minimum defaulting to 0 and max to 65K):
1090 +limit-connect{443} # This is the default and need no be
1092 +limit-connect{80,443} # Ports 80 and 443 are OK.
1093 +limit-connect{-3, 7, 20-100, 500-} # Port less than 3, 7, 20 to
1095 #and above 500 are OK.
1097 * "+no-compression" prevents the website from compressing the data.
1098 Some websites do this, which can be a problem for Junkbuster,
1099 since "+filter", "+no-popup" and "+gif-deanimate" will not work on
1100 compressed data. This will slow down connections to those
1101 websites, though. Default is "nocompression" is turned on.
1104 * If the website sets cookies, "no-cookies-keep" will make sure they
1105 are erased when you exit and restart your web browser. This makes
1106 profiling cookies useless, but won't break sites which require
1107 cookies so that you can log in for transactions. Default: on.
1110 * Prevent the website from reading cookies:
1113 * Prevent the website from setting cookies:
1116 * Filter the website through a built-in filter to disable those
1117 obnoxious JavaScript pop-up windows via window.open(), etc. The
1118 two alternative spellings are equivalent.
1122 * This action only applies if you are using a jarfile for saving
1123 cookies. It sends a cookie to every site stating that you do not
1124 accept any copyright on cookies sent to you, and asking them not
1125 to track you. Of course, this is a (relatively) unique header they
1126 could use to track you.
1129 * This allows you to add an arbitrary cookie. It can be specified
1130 multiple times in order to add as many cookies as you like.
1133 The meaning of any of the above is reversed by preceding the action
1134 with a "-", in place of the "+".
1138 Turn off cookies by default, then allow a few through for specified
1141 # Turn off all persistent cookies
1142 { +no-cookies-read }
1144 # Allow cookies for this browser session ONLY
1145 { +no-cookies-keep }
1146 # Exceptions to the above, sites that benefit from persistent cookies
1147 { -no-cookies-read }
1149 { -no-cookies-keep }
1155 # Alternative way of saying the same thing
1156 {-no-cookies-set -no-cookies-read -no-cookies-keep}
1160 Now turn off "fast redirects", and then we allow two exceptions:
1165 # Reverse it for these two sites, which don't work right without it.
1167 www.ukc.ac.uk/cgi-bin/wac\.cgi\?
1170 Turn on page filtering, with one exception for sourceforge:
1172 # Run everything through the default filter file (re_filterfile):
1175 # But please don't re_filter code from sourceforge!
1177 .cvs.sourceforge.net
1179 Now some URLs that we want "blocked", ie we won't see them. Many of
1180 these use regular expressions that will expand to match multiple URLs:
1184 /.*/(.*[-_.])?ads?[0-9]?(/|[-_.].*|\.(gif|jpe?g))
1185 /.*/(.*[-_.])?count(er)?(\.cgi|\.dll|\.exe|[?/])
1186 /.*/(ng)?adclient\.cgi
1187 /.*/(plain|live|rotate)[-_.]?ads?/
1188 /.*/(sponsor)s?[0-9]?/
1189 /.*/_?(plain|live)?ads?(-banners)?/
1191 /.*/ad(sdna_image|gifs?)/
1192 /.*/ad(server|stream|juggler)\.(cgi|pl|dll|exe)
1196 /.*/adv((er)?ts?|ertis(ing|ements?))?/
1200 /.*/cgi-bin/centralad/getimage
1201 /.*/images/addver\.gif
1202 /.*/images/marketing/.*\.(gif|jpe?g)
1206 /.*/sponsors?[0-9]?/
1207 /.*/advert[0-9]+\.jpg
1214 /graphics/defaultAd/
1216 /image\.ng/transactionID
1217 /images/.*/.*_anim\.gif # alvin brattli
1218 /ip_img/.*\.(gif|jpe?g)
1222 /cgi-bin/nph-adclick.exe/
1223 /.*/Image/BannerAdvertising/
1225 /.*/adlib/server\.cgi
1227 _________________________________________________________________
1231 Custom "actions", known to Junkbuster as "aliases", can be defined by
1232 combining other "actions". These can in turn be invoked just like the
1233 built-in "actions". Currently, an alias can contain any character
1234 except space, tab, "=", "{" or "}". But please use only "a"- "z",
1235 "0"-"9", "+", and "-". Alias names are not case sensitive, and must be
1236 defined before anything else in the ijb.actionfile ! And there can
1237 only be one set of "aliases" defined.
1239 Now let's define a few aliases:
1241 # Useful customer aliases we can use later. These must come first!
1243 +no-cookies = +no-cookies-set +no-cookies-read
1244 -no-cookies = -no-cookies-set -no-cookies-read
1245 fragile = -block -no-cookies -filter -fast-redirects -hide-refere
1247 shop = -no-cookies -filter -fast-redirects
1248 +imageblock = +block +image
1249 #For people who don't like to type too much: ;-)
1252 c2 = -no-cookies-set +no-cookies-read
1253 c3 = +no-cookies-set -no-cookies-read
1254 #... etc. Customize to your heart's content.
1256 Some examples using our "shop" and "fragile" aliases from above:
1258 # These sites are very complex and require
1259 # minimal interference.
1261 .office.microsoft.com
1262 .windowsupdate.microsoft.com
1264 # Shopping sites - still want to block ads.
1267 .worldpay.com # for quietpc.com
1270 # These shops require pop-ups
1274 _________________________________________________________________
1276 3.3. The Filter File
1278 The filter file defines what filtering of web pages Junkbuster does.
1279 The default filter file is re_filterfile, located in the config
1280 directory. In this file, any document content, whether viewable text
1281 or embedded non-visible content, can be changed.
1283 This file uses regular expressions to alter or remove any string in
1284 the target page. Some examples from the included default
1287 Stop web pages from displaying annoying messages in the status bar by
1288 deleting such references:
1290 # The status bar is for displaying link targets, not pointless buzzwo
1292 # Again, check it out on http://www.airport-cgn.de/.
1293 s/status='.*?';*//ig
1295 Just for kicks, replace any occurrence of "Microsoft" with
1298 s/microsoft(?!.com)/MicroSuck/ig
1300 Kill those auto-refresh tags:
1302 # Kill refresh tags. I like to refresh myself. Manually.
1303 # check it out on http://www.airport-cgn.de/ and go to the arrivals p
1306 s/<meta[^>]*http-equiv[^>]*refresh.*URL=([^>]*?)"?>/<link rev="x-refr
1308 s/<meta[^>]*http-equiv="?page-enter"?[^>]*content=[^>]*>/<!--no page
1310 _________________________________________________________________
1314 When Junkbuster displays one of its internal pages, such as a 404 Not
1315 Found error page, it uses the appropriate template. On Linux, BSD, and
1316 Unix, these are locate in /etc/junkbuster/templates by default. These
1317 may be customized, if desired.
1318 _________________________________________________________________
1320 4. Quickstart to Using Junkbuster
1322 Install package, then run and enjoy! JunkBuster accepts only one
1323 command line option -- the configuration file to be used. Example Unix
1327 # /usr/sbin/junkbuster /etc/junkbuster/config
1330 An init script is provided for SuSE and Redhat.
1332 For for SuSE: /etc/rc.d/junkbuster start
1334 For RedHat: /etc/rc.d/init.d/junkbuster start
1336 If no configuration file is specified on the command line, Junkbuster
1337 will look for a file named config in the current directory. Except on
1338 Win32 where it will try config.txt. If no file is specified on the
1339 command line and no default configuration file can be found,
1340 Junkbuster will fail to start.
1342 Be sure your browser is set to use the proxy which is by default at
1343 localhost, port 8000. With Netscape (and Mozilla), this can be set
1344 under Edit -> Preferences -> Advanced -> Proxies -> HTTP Proxy. For
1345 Internet Explorer: Tools > Internet Properties -> Connections -> LAN
1346 Setting. Then, check "Use Proxy" and fill in the appropriate info
1347 (Address: localhost, Port: 8000). Include if HTTPS proxy support too.
1349 The included default configuration files should give a reasonable
1350 starting point, though may be somewhat aggressive in blocking junk.
1351 You will probably want to keep an eye out for sites that require
1352 persistent cookies, and add these to ijb.action as needed. By default,
1353 most of these will be accepted only during the current browser
1354 session, until you add them to the configuration. If you want the
1355 browser to handle this instead, you will need to edit ijb.action and
1356 disable this feature. If you use more than one browser, it would make
1357 more sense to let Junkbuster handle this. In which case, the
1358 browser(s) should be set to accept all cookies.
1360 If a particular site shows problems loading properly, try adding it to
1361 the {fragile} section of ijb.action. This will turn off most actions
1364 HTTP/1.1 support is not fully implemented. If browsers that support
1365 HTTP/1.1 (like Mozilla or recent versions of I.E.) experience
1366 problems, you might try to force HTTP/1.0 compatibility. For Mozilla,
1367 look under Edit -> Preferences -> Debug -> Networking. Or set the
1368 "+downgrade" config option in ijb.action.
1370 After running Junkbuster for a while, you can start to fine tune the
1371 configuration to suit your personal, or site, preferences and
1372 requirements. There are many, many aspects that can be customized.
1373 "Actions" (as specified in ijb.action) can be adjusted by pointing
1374 your browser to [38]http://i.j.b/, and then follow the link to "edit
1375 the actions list". (This is an internal page and does not require
1378 In fact, various aspects of Junkbuster configuration can be viewed
1379 from this page, including current configuration parameters, source
1380 code version numbers, the browser's request headers, and "actions"
1381 that apply to a given URL. In addition to the ijb.action file editor
1382 mentioned above, Junkbuster can also be turned "on" and "off" from
1385 If you encounter problems, please verify it is a Junkbuster bug, by
1386 disabling Junkbuster, and then trying the same page. Also, try another
1387 browser if possible to eliminate browser or site problems. Before
1388 reporting it as a bug, see if there is not a configuration option that
1389 is enabled that is causing the page not to load. You can then add an
1390 exception for that page or site. If a bug, please report it to the
1391 developers (see below).
1392 _________________________________________________________________
1394 5. Contact the Developers
1396 Feature requests and other questions should be posted to the
1397 [39]Feature request page at SourceForge. There is also an archive
1400 Anyone interested in actively participating in development and related
1401 discussions can join the appropriate mailing list [40]here. Archives
1402 are available here too.
1404 Please report bugs, using the form at [41]Sourceforge. Please try to
1405 verify that it is a Junkbuster bug, and not a browser or site bug
1406 first. Also, check to make sure this is not already a known bug.
1407 _________________________________________________________________
1409 6. Copyright and History
1413 Internet Junkbuster is free software; you can redistribute it and/or
1414 modify it under the terms of the GNU General Public License as
1415 published by the Free Software Foundation; either version 2 of the
1416 License, or (at your option) any later version.
1418 This program is distributed in the hope that it will be useful, but
1419 WITHOUT ANY WARRANTY; without even the implied warranty of
1420 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1421 General Public License for more details, which is available from
1422 [42]the Free Software Foundation, Inc, 59 Temple Place - Suite 330,
1423 Boston, MA 02111-1307, USA.
1424 _________________________________________________________________
1428 Junkbuster was originally written by Anonymous Coders and
1429 [43]Junkbuster's Corporation, and was released as free open-source
1430 software under the GNU GPL. [44]Stefan Waldherr made many
1431 improvements, and started the [45]SourceForge project to rekindle
1432 development. The last stable release was v2.0.2, which has now grown
1434 _________________________________________________________________
1438 [46]http://sourceforge.net/projects/ijbswa
1440 [47]http://ijbswa.sourceforge.net/
1444 [49]http://www.junkbusters.com/ht/en/cookies.html
1446 [50]http://www.waldherr.org/junkbuster/
1448 [51]http://privacy.net/analyze/
1450 [52]http://www.squid-cache.org/
1451 _________________________________________________________________
1455 8.1. Regular Expressions
1457 Junkbuster can use "regular expressions" in various config files.
1458 Assuming support for "pcre" (Perl Compatible Regular Expressions) is
1459 compiled in, which is the default. Such configuration directives do
1460 not require regular expressions, but they can be used to increase
1461 flexibility by matching a pattern with wild-cards against URLs.
1463 If you are reading this, you probably don't understand what "regular
1464 expressions" are, or what they can do. So this will be a very brief
1465 introduction only. A full explanation would require a book ;-)
1467 "Regular expressions" is a way of matching one character expression
1468 against another to see if it matches or not. One of the "expressions"
1469 is a literal string of readable characters (letter, numbers, etc), and
1470 the other is a complex string of literal characters combined with
1471 wild-cards, and other special characters, called meta-characters. The
1472 "meta-characters" have special meanings and are used to build the
1473 complex pattern to be matched against. Perl Compatible Regular
1474 Expressions is an enhanced form of the regular expression language
1475 with backward compatibility.
1477 To make a simple analogy, we do something similar when we use
1478 wild-card characters when listing files with the dir command in DOS.
1479 *.* matches all filenames. The "special" character here is the
1480 asterisk which matches any and all characters. We can be more specific
1481 and use ? to match just individual characters. So "dir file?.text"
1482 would match "file1.txt", "file2.txt", etc. We are pattern matching,
1483 using a similar technique to "regular expressions"!
1485 Regular expressions do essentially the same thing, but are much, much
1486 more powerful. There are many more "special characters" and ways of
1487 building complex patterns however. Let's look at a few of the common
1488 ones, and then some examples:
1490 . - Matches any single character, e.g. "a", "A", "4", ":", or "@".
1492 ? - The preceding character or expression is matched ZERO or ONE
1495 + - The preceding character or expression is matched ONE or MORE
1498 * - The preceding character or expression is matched ZERO or MORE
1501 \ - The "escape" character denotes that the following character should
1502 be taken literally. This is used where one of the special characters
1503 (e.g. ".") needs to be taken literally and not as a special
1506 [] - Characters enclosed in brackets will be matched if any of the
1507 enclosed characters are encountered.
1509 () - parentheses are used to group a sub-expression, or multiple
1512 | - The "bar" character works like an "or" conditional statement. A
1513 match is successful if the sub-expression on either side of "|"
1516 s/string1/string2/g - This is used to rewrite strings of text.
1517 "string1" is replaced by "string2" in this example.
1519 These are just some of the ones you are likely to use when matching
1520 URLs with Junkbuster, and is a long way from a definitive list. This
1521 is enough to get us started with a few simple examples which may be
1524 /.*/banners/.* - A simple example that uses the common combination of
1525 "." and "*" to denote any character, zero or more times. In other
1526 words, any string at all. So we start with a literal forward slash,
1527 then our regular expression pattern (".*") another literal forward
1528 slash, the string "banners", another forward slash, and lastly another
1529 ".*". We are building a directory path here. This will match any file
1530 with the path that has a directory named "banners" in it. The ".*"
1531 matches any characters, and this could conceivably be more forward
1532 slashes, so it might expand into a much longer looking path. For
1533 example, this could match:
1534 "/eye/hate/spammers/banners/annoy_me_please.gif", or just
1535 "/banners/annoying.html", or almost an infinite number of other
1536 possible combinations, just so it has "banners" in the path somewhere.
1538 A now something a little more complex:
1540 /.*/adv((er)?ts?|ertis(ing|ements?))?/ - We have several literal
1541 forward slashes again ("/"), so we are building another expression
1542 that is a file path statement. We have another ".*", so we are
1543 matching against any conceivable sub-path, just so it matches our
1544 expression. The only true literal that must match our pattern is adv,
1545 together with the forward slashes. What comes after the "adv" string
1546 is the interesting part.
1548 Remember the "?" means the preceding expression (either a literal
1549 character or anything grouped with "(...)" in this case) can exist or
1550 not, since this means either zero or one match. So
1551 "((er)?ts?|ertis(ing|ements?))" is optional, as are the individual
1552 sub-expressions: "(er)", "(ing|ements?)", and the "s". The "|" means
1553 "or". We have two of those. For instance, "(ing|ements?)", can expand
1554 to match either "ing" OR "ements?". What is being done here, is an
1555 attempt at matching as many variations of "advertisement", and
1556 similar, as possible. So this would expand to match just "adv", or
1557 "advert", or "adverts", or "advertising", or "advertisement", or
1558 "advertisements". You get the idea. But it would not match
1559 "advertizements" (with a "z"). We could fix that by changing our
1560 regular expression to: "/.*/adv((er)?ts?|erti(s|z)(ing|ements?))?/",
1561 which would then match either spelling.
1563 /.*/advert[0-9]+\.(gif|jpe?g) - Again another path statement with
1564 forward slashes. Anything in the square brackets "[]" can be matched.
1565 This is using "0-9" as a shorthand expression to mean any digit one
1566 through nine. It is the same as saying "0123456789". So any digit
1567 matches. The "+" means one or more of the preceding expression must be
1568 included. The preceding expression here is what is in the square
1569 brackets -- in this case, any digit one through nine. Then, at the
1570 end, we have a grouping: "(gif|jpe?g)". This includes a "|", so this
1571 needs to match the expression on either side of that bar character
1572 also. A simple "gif" on one side, and the other side will in turn
1573 match either "jpeg" or "jpg", since the "?" means the letter "e" is
1574 optional and can be matched once or not at all. So we are building an
1575 expression here to match image GIF or JPEG type image file. It must
1576 include the literal string "advert", then one or more digits, and a
1577 "." (which is now a literal, and not a special character, since it is
1578 escaped with "\"), and lastly either "gif", or "jpeg", or "jpg". Some
1579 possible matches would include: "//advert1.jpg",
1580 "/nasty/ads/advert1234.gif", "/banners/from/hell/advert99.jpg". It
1581 would not match "advert1.gif" (no leading slash), or "/adverts232.jpg"
1582 (the expression does not include an "s"), or "/advert1.jsp" ("jsp" is
1583 not in the expression anywhere).
1585 s/microsoft(?!.com)/MicroSuck/i - This is a substitution. "MicroSuck"
1586 will replace any occurrence of "microsoft". The "i" at the end of the
1587 expression means ignore case. The "(?!.com)" means the match should
1588 fail if "microsoft" is followed by ".com". In other words, this acts
1589 like a "NOT" modifier. In case this is a hyperlink, we don't want to
1592 We are barely scratching the surface of regular expressions here so
1593 that you can understand the default Junkbuster configuration files,
1594 and maybe use this knowledge to customize your own installation. There
1595 is much, much more that can be done with regular expressions. Now that
1596 you know enough to get started, you can learn more on your own :/
1598 More reading on Perl Compatible Regular expressions:
1599 [53]http://www.perldoc.com/perl5.6/pod/perlre.html
1603 1. http://ijbswa.sourceforge.net/user-manual/
1604 2. mailto:ijbswa-developers@lists.sourceforge.net
1605 3. file://localhost/home/swa/sf/current/doc/source/tmp.html#INTRODUCTION
1606 4. file://localhost/home/swa/sf/current/doc/source/tmp.html#AEN27
1607 5. file://localhost/home/swa/sf/current/doc/source/tmp.html#INSTALLATION
1608 6. file://localhost/home/swa/sf/current/doc/source/tmp.html#INSTALLATION-SOURCE
1609 7. file://localhost/home/swa/sf/current/doc/source/tmp.html#INSTALLATION-RH
1610 8. file://localhost/home/swa/sf/current/doc/source/tmp.html#INSTALLATION-SUSE
1611 9. file://localhost/home/swa/sf/current/doc/source/tmp.html#INSTALLATION-OS2
1612 10. file://localhost/home/swa/sf/current/doc/source/tmp.html#INSTALLATION-WIN
1613 11. file://localhost/home/swa/sf/current/doc/source/tmp.html#INSTALLATION-OTHER
1614 12. file://localhost/home/swa/sf/current/doc/source/tmp.html#CONFIGURATION
1615 13. file://localhost/home/swa/sf/current/doc/source/tmp.html#AEN172
1616 14. file://localhost/home/swa/sf/current/doc/source/tmp.html#ACTIONSFILE
1617 15. file://localhost/home/swa/sf/current/doc/source/tmp.html#FILTERFILE
1618 16. file://localhost/home/swa/sf/current/doc/source/tmp.html#AEN1130
1619 17. file://localhost/home/swa/sf/current/doc/source/tmp.html#QUICKSTART
1620 18. file://localhost/home/swa/sf/current/doc/source/tmp.html#CONTACT
1621 19. file://localhost/home/swa/sf/current/doc/source/tmp.html#COPYRIGHT
1622 20. file://localhost/home/swa/sf/current/doc/source/tmp.html#AEN1195
1623 21. file://localhost/home/swa/sf/current/doc/source/tmp.html#AEN1201
1624 22. file://localhost/home/swa/sf/current/doc/source/tmp.html#SEEALSO
1625 23. file://localhost/home/swa/sf/current/doc/source/tmp.html#APPENDIX
1626 24. file://localhost/home/swa/sf/current/doc/source/tmp.html#REGEX
1628 26. http://sourceforge.net/projects/ijbswa/
1629 27. http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/ijbswa/current/
1630 28. http://www.gnu.org/
1632 30. file://localhost/home/swa/sf/current/doc/source/tmp.html#ACTIONSFILE
1636 34. http://i.j.b/show-url-info
1638 36. http://www.perldoc.com/perl5.6/pod/perlre.html
1639 37. file://localhost/home/swa/sf/current/doc/source/tmp.html#REGEX
1641 39. http://sourceforge.net/tracker/?atid=361118&group_id=11118&func=browse
1642 40. http://sourceforge.net/mail/?group_id=11118
1643 41. http://sourceforge.net/tracker/?group_id=11118&atid=111118
1644 42. http://www.gnu.org/copyleft/gpl.html
1645 43. http://www.junkbusters.com/ht/en/ijbfaq.html
1646 44. http://www.waldherr.org/junkbuster/
1647 45. http://sourceforge.net/projects/ijbswa/
1648 46. http://sourceforge.net/projects/ijbswa
1649 47. http://ijbswa.sourceforge.net/
1651 49. http://www.junkbusters.com/ht/en/cookies.html
1652 50. http://www.waldherr.org/junkbuster/
1653 51. http://privacy.net/analyze/
1654 52. http://www.squid-cache.org/
1655 53. http://www.perldoc.com/perl5.6/pod/perlre.html