Version Description
Download this release
Release Info
Developer | error |
Plugin | Bad Behavior |
Version | 1.1.4 |
Comparing to | |
See all releases |
Code changes from version 1.1.3 to 1.1.4
- bad-behavior-user-agent.php +1 -1
- bad-behavior/COPYING +339 -0
- bad-behavior/README.txt +41 -0
- bad-behavior/bad-behavior-accept.php +40 -0
- bad-behavior/bad-behavior-banned.php +71 -0
- bad-behavior/bad-behavior-core.php +119 -0
- bad-behavior/bad-behavior-database.php +86 -0
- bad-behavior/bad-behavior-functions.php +46 -0
- bad-behavior/bad-behavior-generic.php +80 -0
- bad-behavior/bad-behavior-google.php +14 -0
- bad-behavior/bad-behavior-http-headers.php +37 -0
- bad-behavior/bad-behavior-konqueror.php +23 -0
- bad-behavior/bad-behavior-lynx.php +13 -0
- bad-behavior/bad-behavior-mediawiki.php +108 -0
- bad-behavior/bad-behavior-movabletype.php +23 -0
- bad-behavior/bad-behavior-mozilla.php +23 -0
- bad-behavior/bad-behavior-msie.php +31 -0
- bad-behavior/bad-behavior-msnbot.php +18 -0
- bad-behavior/bad-behavior-opera.php +13 -0
- bad-behavior/bad-behavior-php4.php +10 -0
- bad-behavior/bad-behavior-referer.php +25 -0
- bad-behavior/bad-behavior-safari.php +12 -0
- bad-behavior/bad-behavior-user-agent.php +62 -0
- bad-behavior/bad-behavior-wordpress.php +98 -0
bad-behavior-user-agent.php
CHANGED
@@ -15,6 +15,7 @@ $wp_bb_spambots_str0 = array(
|
|
15 |
"Email Siphon", // spam harvester
|
16 |
"grub crawler", // misc comment/email spam
|
17 |
// "Java 1.", // Some doubt about this one
|
|
|
18 |
"LWP", // exploited boxes
|
19 |
"Microsoft URL", // spam harvester
|
20 |
"Missigua", // spam harvester
|
@@ -29,7 +30,6 @@ $wp_bb_spambots_str = array(
|
|
29 |
"DTS Agent", // misc comment/email spam
|
30 |
"grub-client", // search engine ignores robots.txt
|
31 |
"Indy Library", // misc comment/email spam
|
32 |
-
"libwww-perl", // exploited boxes
|
33 |
".NET CLR 1)", // free poker, etc.
|
34 |
"POE-Component-Client", // free poker, etc.
|
35 |
"WISEbot", // spam harvester
|
15 |
"Email Siphon", // spam harvester
|
16 |
"grub crawler", // misc comment/email spam
|
17 |
// "Java 1.", // Some doubt about this one
|
18 |
+
"libwww-perl", // spambot scripts
|
19 |
"LWP", // exploited boxes
|
20 |
"Microsoft URL", // spam harvester
|
21 |
"Missigua", // spam harvester
|
30 |
"DTS Agent", // misc comment/email spam
|
31 |
"grub-client", // search engine ignores robots.txt
|
32 |
"Indy Library", // misc comment/email spam
|
|
|
33 |
".NET CLR 1)", // free poker, etc.
|
34 |
"POE-Component-Client", // free poker, etc.
|
35 |
"WISEbot", // spam harvester
|
bad-behavior/COPYING
ADDED
@@ -0,0 +1,339 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GNU GENERAL PUBLIC LICENSE
|
2 |
+
Version 2, June 1991
|
3 |
+
|
4 |
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
5 |
+
675 Mass Ave, Cambridge, MA 02139, USA
|
6 |
+
Everyone is permitted to copy and distribute verbatim copies
|
7 |
+
of this license document, but changing it is not allowed.
|
8 |
+
|
9 |
+
Preamble
|
10 |
+
|
11 |
+
The licenses for most software are designed to take away your
|
12 |
+
freedom to share and change it. By contrast, the GNU General Public
|
13 |
+
License is intended to guarantee your freedom to share and change free
|
14 |
+
software--to make sure the software is free for all its users. This
|
15 |
+
General Public License applies to most of the Free Software
|
16 |
+
Foundation's software and to any other program whose authors commit to
|
17 |
+
using it. (Some other Free Software Foundation software is covered by
|
18 |
+
the GNU Library General Public License instead.) You can apply it to
|
19 |
+
your programs, too.
|
20 |
+
|
21 |
+
When we speak of free software, we are referring to freedom, not
|
22 |
+
price. Our General Public Licenses are designed to make sure that you
|
23 |
+
have the freedom to distribute copies of free software (and charge for
|
24 |
+
this service if you wish), that you receive source code or can get it
|
25 |
+
if you want it, that you can change the software or use pieces of it
|
26 |
+
in new free programs; and that you know you can do these things.
|
27 |
+
|
28 |
+
To protect your rights, we need to make restrictions that forbid
|
29 |
+
anyone to deny you these rights or to ask you to surrender the rights.
|
30 |
+
These restrictions translate to certain responsibilities for you if you
|
31 |
+
distribute copies of the software, or if you modify it.
|
32 |
+
|
33 |
+
For example, if you distribute copies of such a program, whether
|
34 |
+
gratis or for a fee, you must give the recipients all the rights that
|
35 |
+
you have. You must make sure that they, too, receive or can get the
|
36 |
+
source code. And you must show them these terms so they know their
|
37 |
+
rights.
|
38 |
+
|
39 |
+
We protect your rights with two steps: (1) copyright the software, and
|
40 |
+
(2) offer you this license which gives you legal permission to copy,
|
41 |
+
distribute and/or modify the software.
|
42 |
+
|
43 |
+
Also, for each author's protection and ours, we want to make certain
|
44 |
+
that everyone understands that there is no warranty for this free
|
45 |
+
software. If the software is modified by someone else and passed on, we
|
46 |
+
want its recipients to know that what they have is not the original, so
|
47 |
+
that any problems introduced by others will not reflect on the original
|
48 |
+
authors' reputations.
|
49 |
+
|
50 |
+
Finally, any free program is threatened constantly by software
|
51 |
+
patents. We wish to avoid the danger that redistributors of a free
|
52 |
+
program will individually obtain patent licenses, in effect making the
|
53 |
+
program proprietary. To prevent this, we have made it clear that any
|
54 |
+
patent must be licensed for everyone's free use or not licensed at all.
|
55 |
+
|
56 |
+
The precise terms and conditions for copying, distribution and
|
57 |
+
modification follow.
|
58 |
+
|
59 |
+
GNU GENERAL PUBLIC LICENSE
|
60 |
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
61 |
+
|
62 |
+
0. This License applies to any program or other work which contains
|
63 |
+
a notice placed by the copyright holder saying it may be distributed
|
64 |
+
under the terms of this General Public License. The "Program", below,
|
65 |
+
refers to any such program or work, and a "work based on the Program"
|
66 |
+
means either the Program or any derivative work under copyright law:
|
67 |
+
that is to say, a work containing the Program or a portion of it,
|
68 |
+
either verbatim or with modifications and/or translated into another
|
69 |
+
language. (Hereinafter, translation is included without limitation in
|
70 |
+
the term "modification".) Each licensee is addressed as "you".
|
71 |
+
|
72 |
+
Activities other than copying, distribution and modification are not
|
73 |
+
covered by this License; they are outside its scope. The act of
|
74 |
+
running the Program is not restricted, and the output from the Program
|
75 |
+
is covered only if its contents constitute a work based on the
|
76 |
+
Program (independent of having been made by running the Program).
|
77 |
+
Whether that is true depends on what the Program does.
|
78 |
+
|
79 |
+
1. You may copy and distribute verbatim copies of the Program's
|
80 |
+
source code as you receive it, in any medium, provided that you
|
81 |
+
conspicuously and appropriately publish on each copy an appropriate
|
82 |
+
copyright notice and disclaimer of warranty; keep intact all the
|
83 |
+
notices that refer to this License and to the absence of any warranty;
|
84 |
+
and give any other recipients of the Program a copy of this License
|
85 |
+
along with the Program.
|
86 |
+
|
87 |
+
You may charge a fee for the physical act of transferring a copy, and
|
88 |
+
you may at your option offer warranty protection in exchange for a fee.
|
89 |
+
|
90 |
+
2. You may modify your copy or copies of the Program or any portion
|
91 |
+
of it, thus forming a work based on the Program, and copy and
|
92 |
+
distribute such modifications or work under the terms of Section 1
|
93 |
+
above, provided that you also meet all of these conditions:
|
94 |
+
|
95 |
+
a) You must cause the modified files to carry prominent notices
|
96 |
+
stating that you changed the files and the date of any change.
|
97 |
+
|
98 |
+
b) You must cause any work that you distribute or publish, that in
|
99 |
+
whole or in part contains or is derived from the Program or any
|
100 |
+
part thereof, to be licensed as a whole at no charge to all third
|
101 |
+
parties under the terms of this License.
|
102 |
+
|
103 |
+
c) If the modified program normally reads commands interactively
|
104 |
+
when run, you must cause it, when started running for such
|
105 |
+
interactive use in the most ordinary way, to print or display an
|
106 |
+
announcement including an appropriate copyright notice and a
|
107 |
+
notice that there is no warranty (or else, saying that you provide
|
108 |
+
a warranty) and that users may redistribute the program under
|
109 |
+
these conditions, and telling the user how to view a copy of this
|
110 |
+
License. (Exception: if the Program itself is interactive but
|
111 |
+
does not normally print such an announcement, your work based on
|
112 |
+
the Program is not required to print an announcement.)
|
113 |
+
|
114 |
+
These requirements apply to the modified work as a whole. If
|
115 |
+
identifiable sections of that work are not derived from the Program,
|
116 |
+
and can be reasonably considered independent and separate works in
|
117 |
+
themselves, then this License, and its terms, do not apply to those
|
118 |
+
sections when you distribute them as separate works. But when you
|
119 |
+
distribute the same sections as part of a whole which is a work based
|
120 |
+
on the Program, the distribution of the whole must be on the terms of
|
121 |
+
this License, whose permissions for other licensees extend to the
|
122 |
+
entire whole, and thus to each and every part regardless of who wrote it.
|
123 |
+
|
124 |
+
Thus, it is not the intent of this section to claim rights or contest
|
125 |
+
your rights to work written entirely by you; rather, the intent is to
|
126 |
+
exercise the right to control the distribution of derivative or
|
127 |
+
collective works based on the Program.
|
128 |
+
|
129 |
+
In addition, mere aggregation of another work not based on the Program
|
130 |
+
with the Program (or with a work based on the Program) on a volume of
|
131 |
+
a storage or distribution medium does not bring the other work under
|
132 |
+
the scope of this License.
|
133 |
+
|
134 |
+
3. You may copy and distribute the Program (or a work based on it,
|
135 |
+
under Section 2) in object code or executable form under the terms of
|
136 |
+
Sections 1 and 2 above provided that you also do one of the following:
|
137 |
+
|
138 |
+
a) Accompany it with the complete corresponding machine-readable
|
139 |
+
source code, which must be distributed under the terms of Sections
|
140 |
+
1 and 2 above on a medium customarily used for software interchange; or,
|
141 |
+
|
142 |
+
b) Accompany it with a written offer, valid for at least three
|
143 |
+
years, to give any third party, for a charge no more than your
|
144 |
+
cost of physically performing source distribution, a complete
|
145 |
+
machine-readable copy of the corresponding source code, to be
|
146 |
+
distributed under the terms of Sections 1 and 2 above on a medium
|
147 |
+
customarily used for software interchange; or,
|
148 |
+
|
149 |
+
c) Accompany it with the information you received as to the offer
|
150 |
+
to distribute corresponding source code. (This alternative is
|
151 |
+
allowed only for noncommercial distribution and only if you
|
152 |
+
received the program in object code or executable form with such
|
153 |
+
an offer, in accord with Subsection b above.)
|
154 |
+
|
155 |
+
The source code for a work means the preferred form of the work for
|
156 |
+
making modifications to it. For an executable work, complete source
|
157 |
+
code means all the source code for all modules it contains, plus any
|
158 |
+
associated interface definition files, plus the scripts used to
|
159 |
+
control compilation and installation of the executable. However, as a
|
160 |
+
special exception, the source code distributed need not include
|
161 |
+
anything that is normally distributed (in either source or binary
|
162 |
+
form) with the major components (compiler, kernel, and so on) of the
|
163 |
+
operating system on which the executable runs, unless that component
|
164 |
+
itself accompanies the executable.
|
165 |
+
|
166 |
+
If distribution of executable or object code is made by offering
|
167 |
+
access to copy from a designated place, then offering equivalent
|
168 |
+
access to copy the source code from the same place counts as
|
169 |
+
distribution of the source code, even though third parties are not
|
170 |
+
compelled to copy the source along with the object code.
|
171 |
+
|
172 |
+
4. You may not copy, modify, sublicense, or distribute the Program
|
173 |
+
except as expressly provided under this License. Any attempt
|
174 |
+
otherwise to copy, modify, sublicense or distribute the Program is
|
175 |
+
void, and will automatically terminate your rights under this License.
|
176 |
+
However, parties who have received copies, or rights, from you under
|
177 |
+
this License will not have their licenses terminated so long as such
|
178 |
+
parties remain in full compliance.
|
179 |
+
|
180 |
+
5. You are not required to accept this License, since you have not
|
181 |
+
signed it. However, nothing else grants you permission to modify or
|
182 |
+
distribute the Program or its derivative works. These actions are
|
183 |
+
prohibited by law if you do not accept this License. Therefore, by
|
184 |
+
modifying or distributing the Program (or any work based on the
|
185 |
+
Program), you indicate your acceptance of this License to do so, and
|
186 |
+
all its terms and conditions for copying, distributing or modifying
|
187 |
+
the Program or works based on it.
|
188 |
+
|
189 |
+
6. Each time you redistribute the Program (or any work based on the
|
190 |
+
Program), the recipient automatically receives a license from the
|
191 |
+
original licensor to copy, distribute or modify the Program subject to
|
192 |
+
these terms and conditions. You may not impose any further
|
193 |
+
restrictions on the recipients' exercise of the rights granted herein.
|
194 |
+
You are not responsible for enforcing compliance by third parties to
|
195 |
+
this License.
|
196 |
+
|
197 |
+
7. If, as a consequence of a court judgment or allegation of patent
|
198 |
+
infringement or for any other reason (not limited to patent issues),
|
199 |
+
conditions are imposed on you (whether by court order, agreement or
|
200 |
+
otherwise) that contradict the conditions of this License, they do not
|
201 |
+
excuse you from the conditions of this License. If you cannot
|
202 |
+
distribute so as to satisfy simultaneously your obligations under this
|
203 |
+
License and any other pertinent obligations, then as a consequence you
|
204 |
+
may not distribute the Program at all. For example, if a patent
|
205 |
+
license would not permit royalty-free redistribution of the Program by
|
206 |
+
all those who receive copies directly or indirectly through you, then
|
207 |
+
the only way you could satisfy both it and this License would be to
|
208 |
+
refrain entirely from distribution of the Program.
|
209 |
+
|
210 |
+
If any portion of this section is held invalid or unenforceable under
|
211 |
+
any particular circumstance, the balance of the section is intended to
|
212 |
+
apply and the section as a whole is intended to apply in other
|
213 |
+
circumstances.
|
214 |
+
|
215 |
+
It is not the purpose of this section to induce you to infringe any
|
216 |
+
patents or other property right claims or to contest validity of any
|
217 |
+
such claims; this section has the sole purpose of protecting the
|
218 |
+
integrity of the free software distribution system, which is
|
219 |
+
implemented by public license practices. Many people have made
|
220 |
+
generous contributions to the wide range of software distributed
|
221 |
+
through that system in reliance on consistent application of that
|
222 |
+
system; it is up to the author/donor to decide if he or she is willing
|
223 |
+
to distribute software through any other system and a licensee cannot
|
224 |
+
impose that choice.
|
225 |
+
|
226 |
+
This section is intended to make thoroughly clear what is believed to
|
227 |
+
be a consequence of the rest of this License.
|
228 |
+
|
229 |
+
8. If the distribution and/or use of the Program is restricted in
|
230 |
+
certain countries either by patents or by copyrighted interfaces, the
|
231 |
+
original copyright holder who places the Program under this License
|
232 |
+
may add an explicit geographical distribution limitation excluding
|
233 |
+
those countries, so that distribution is permitted only in or among
|
234 |
+
countries not thus excluded. In such case, this License incorporates
|
235 |
+
the limitation as if written in the body of this License.
|
236 |
+
|
237 |
+
9. The Free Software Foundation may publish revised and/or new versions
|
238 |
+
of the General Public License from time to time. Such new versions will
|
239 |
+
be similar in spirit to the present version, but may differ in detail to
|
240 |
+
address new problems or concerns.
|
241 |
+
|
242 |
+
Each version is given a distinguishing version number. If the Program
|
243 |
+
specifies a version number of this License which applies to it and "any
|
244 |
+
later version", you have the option of following the terms and conditions
|
245 |
+
either of that version or of any later version published by the Free
|
246 |
+
Software Foundation. If the Program does not specify a version number of
|
247 |
+
this License, you may choose any version ever published by the Free Software
|
248 |
+
Foundation.
|
249 |
+
|
250 |
+
10. If you wish to incorporate parts of the Program into other free
|
251 |
+
programs whose distribution conditions are different, write to the author
|
252 |
+
to ask for permission. For software which is copyrighted by the Free
|
253 |
+
Software Foundation, write to the Free Software Foundation; we sometimes
|
254 |
+
make exceptions for this. Our decision will be guided by the two goals
|
255 |
+
of preserving the free status of all derivatives of our free software and
|
256 |
+
of promoting the sharing and reuse of software generally.
|
257 |
+
|
258 |
+
NO WARRANTY
|
259 |
+
|
260 |
+
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
261 |
+
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
262 |
+
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
263 |
+
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
264 |
+
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
265 |
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
266 |
+
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
267 |
+
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
268 |
+
REPAIR OR CORRECTION.
|
269 |
+
|
270 |
+
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
271 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
272 |
+
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
273 |
+
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
274 |
+
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
275 |
+
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
276 |
+
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
277 |
+
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
278 |
+
POSSIBILITY OF SUCH DAMAGES.
|
279 |
+
|
280 |
+
END OF TERMS AND CONDITIONS
|
281 |
+
|
282 |
+
Appendix: How to Apply These Terms to Your New Programs
|
283 |
+
|
284 |
+
If you develop a new program, and you want it to be of the greatest
|
285 |
+
possible use to the public, the best way to achieve this is to make it
|
286 |
+
free software which everyone can redistribute and change under these terms.
|
287 |
+
|
288 |
+
To do so, attach the following notices to the program. It is safest
|
289 |
+
to attach them to the start of each source file to most effectively
|
290 |
+
convey the exclusion of warranty; and each file should have at least
|
291 |
+
the "copyright" line and a pointer to where the full notice is found.
|
292 |
+
|
293 |
+
<one line to give the program's name and a brief idea of what it does.>
|
294 |
+
Copyright (C) 19yy <name of author>
|
295 |
+
|
296 |
+
This program is free software; you can redistribute it and/or modify
|
297 |
+
it under the terms of the GNU General Public License as published by
|
298 |
+
the Free Software Foundation; either version 2 of the License, or
|
299 |
+
(at your option) any later version.
|
300 |
+
|
301 |
+
This program is distributed in the hope that it will be useful,
|
302 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
303 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
304 |
+
GNU General Public License for more details.
|
305 |
+
|
306 |
+
You should have received a copy of the GNU General Public License
|
307 |
+
along with this program; if not, write to the Free Software
|
308 |
+
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
309 |
+
|
310 |
+
Also add information on how to contact you by electronic and paper mail.
|
311 |
+
|
312 |
+
If the program is interactive, make it output a short notice like this
|
313 |
+
when it starts in an interactive mode:
|
314 |
+
|
315 |
+
Gnomovision version 69, Copyright (C) 19yy name of author
|
316 |
+
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
317 |
+
This is free software, and you are welcome to redistribute it
|
318 |
+
under certain conditions; type `show c' for details.
|
319 |
+
|
320 |
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
321 |
+
parts of the General Public License. Of course, the commands you use may
|
322 |
+
be called something other than `show w' and `show c'; they could even be
|
323 |
+
mouse-clicks or menu items--whatever suits your program.
|
324 |
+
|
325 |
+
You should also get your employer (if you work as a programmer) or your
|
326 |
+
school, if any, to sign a "copyright disclaimer" for the program, if
|
327 |
+
necessary. Here is a sample; alter the names:
|
328 |
+
|
329 |
+
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
330 |
+
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
331 |
+
|
332 |
+
<signature of Ty Coon>, 1 April 1989
|
333 |
+
Ty Coon, President of Vice
|
334 |
+
|
335 |
+
This General Public License does not permit incorporating your program into
|
336 |
+
proprietary programs. If your program is a subroutine library, you may
|
337 |
+
consider it more useful to permit linking proprietary applications with the
|
338 |
+
library. If this is what you want to do, use the GNU Library General
|
339 |
+
Public License instead of this License.
|
bad-behavior/README.txt
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Bad Behavior ===
|
2 |
+
Tags: comment,trackback,referrer,spam,robot,antispam
|
3 |
+
Contributors: MichaelHampton,MarkJaquith,FirasDurri
|
4 |
+
SeeAlso: http://www.ioerror.us/software/bad-behavior/
|
5 |
+
|
6 |
+
This README.txt file applies to WordPress installations. For other types of
|
7 |
+
installations, please see the documentation at
|
8 |
+
http://www.ioerror.us/software/bad-behavior/installing-and-using-bad-behavior/
|
9 |
+
.
|
10 |
+
|
11 |
+
Bad Behavior is a set of PHP scripts which prevents spambots from accessing your site by analyzing their actual HTTP requests and comparing them to profiles from known spambots. It goes far beyond User-Agent and Referer, however.
|
12 |
+
|
13 |
+
The problem: Spammers run automated scripts which read everything on your web site, harvest email addresses, and if you have a blog, forum or wiki, will post spam directly to your site. They also put false referrers in your server log trying to get their links posted through your stats page.
|
14 |
+
|
15 |
+
As the operator of a Web site, this can cause you several problems. First, the spammers are wasting your bandwidth, which you may well be paying for. Second, they are posting comments to any form they can find, filling your web site with unwanted (and unpaid!) ads for their products. Last but not least, they harvest any email addresses they can find and sell those to other spammers, who fill your inbox with more unwanted ads.
|
16 |
+
|
17 |
+
Bad Behavior intends to target any malicious software directed at a Web site, whether it be a spambot, ill-designed search engine bot, or system crackers. In that spirit, it is not limited to WordPress users; a generic interface has been provided whereby it can be integrated into virtually any PHP-based software.
|
18 |
+
|
19 |
+
== Installation ==
|
20 |
+
SeeAlso: http://www.ioerror.us/software/bad-behavior/installing-and-using-bad-behavior/on-wordpress/
|
21 |
+
|
22 |
+
1. Bad Behavior installs like any other multi-file WordPress plugin. Unzip the bad-behavior.zip file, and you will have a bad-behavior folder containing all the Bad Behavior files.
|
23 |
+
|
24 |
+
2. Before uploading, edit the bad-behavior/bad-behavior-wordpress.php file and customize the configuration variables there. When logging is on, all blocked requests will be logged. When verbose logging is on, all requests - successful or not - will be logged. And the logging duration specifies how many days worth of logs will be stored in the database. I recommend not using verbose logging without a really good reason, as your database will fill up fast.
|
25 |
+
|
26 |
+
3. Upload the folder and its contents to your wp-content/plugins directory, taking care to use ASCII mode. Once on the server, activate the plugin from your admin page.
|
27 |
+
|
28 |
+
== Frequently Asked Questions ==
|
29 |
+
SeeAlso: http://www.ioerror.us/software/bad-behavior/bad-behavior-faq/
|
30 |
+
|
31 |
+
= I have been blocked by Bad Behavior! What do I do? =
|
32 |
+
|
33 |
+
In extremely rare circumstances, Bad Behavior may block actual human visitors. Bad Behavior was designed to target robots, not people. If this happens, the profile presented by your browser matched that seen from actual malicious robots. In most cases, this is caused by over-aggressive personal firewall/browser privacy software. In some cases, this is caused by improperly configured Web proxy server software.
|
34 |
+
|
35 |
+
Try disabling the browser privacy settings in your personal firewall/browser privacy software, and/or bypassing the Web proxy and making a direct connection. Disable any download accelerators in use, especially if you are on dialup and your ISP provided you one. (These so-called accelerators rarely speed up anything; our analysis of these accelerators indicate they usually slow things down!) If all else fails, try a different Web browser with a new user profile.
|
36 |
+
|
37 |
+
If you continue to have trouble, contact me and provide a copy of the logs which Bad Behavior stores in the database showing where your IP address was blocked. I will provide further assistance until the trouble is resolved.
|
38 |
+
|
39 |
+
= How can I view Bad Behavior's log files? =
|
40 |
+
|
41 |
+
To view the Bad Behavior log, you will need a copy of phpMyAdmin installed, or some other way to view the database. Bad Behavior stores its log in the wp_bad_behavior_log table in your WordPress database. Browse or search through it with phpMyAdmin, the MySQL command line, or another tool. At this time Bad Behavior does not come with a built-in log viewer, though this feature is planned.
|
bad-behavior/bad-behavior-accept.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Check for various Accept: headers
|
4 |
+
|
5 |
+
if (!defined('WP_BB_CWD'))
|
6 |
+
die('');
|
7 |
+
|
8 |
+
function wp_bb_check_accept() {
|
9 |
+
global $wp_bb_http_headers_mixed;
|
10 |
+
if (!array_key_exists('Accept', $wp_bb_http_headers_mixed)) {
|
11 |
+
wp_bb_spammer();
|
12 |
+
}
|
13 |
+
}
|
14 |
+
|
15 |
+
function wp_bb_check_accept_encoding() {
|
16 |
+
global $wp_bb_http_headers, $wp_bb_http_headers_mixed;
|
17 |
+
|
18 |
+
// FIXME: skip this check; too many examples of legit user agents
|
19 |
+
// are omitting Accept-Encoding; come back to it later when more
|
20 |
+
// data is available
|
21 |
+
return;
|
22 |
+
|
23 |
+
// In some cases we can skip this check
|
24 |
+
// HTTP proxies munch the Accept-Encoding header
|
25 |
+
if (array_key_exists('X-BlueCoat-Via', $wp_bb_http_headers_mixed) ||
|
26 |
+
array_key_exists('X-Forwarded-For', $wp_bb_http_headers) ||
|
27 |
+
array_key_exists('Via', $wp_bb_http_headers)) {
|
28 |
+
return;
|
29 |
+
}
|
30 |
+
|
31 |
+
// Check for Accept-Encoding
|
32 |
+
if (!array_key_exists('Accept-Encoding', $wp_bb_http_headers_mixed) &&
|
33 |
+
!array_key_exists('~~~~~~~~~~~~~~~', $wp_bb_http_headers) &&
|
34 |
+
!array_key_exists('---------------', $wp_bb_http_headers) &&
|
35 |
+
!array_key_exists('XXXXXXXXXXXXXXX', $wp_bb_http_headers)) {
|
36 |
+
wp_bb_spammer();
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
?>
|
bad-behavior/bad-behavior-banned.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// This function is called when there is absolutely no hope for redemption for
|
3 |
+
// the offending spammer.
|
4 |
+
function wp_bb_banned() {
|
5 |
+
global $wp_bb_request_uri, $wp_bb_remote_addr, $wp_bb_server_signature;
|
6 |
+
global $wp_bb_email;
|
7 |
+
|
8 |
+
wp_bb_log(403);
|
9 |
+
header("HTTP/1.0 412 Precondition Failed");
|
10 |
+
header("Status: 412 Precondition Failed");
|
11 |
+
?>
|
12 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
13 |
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
14 |
+
<head>
|
15 |
+
<title>412 Precondition Failed</title>
|
16 |
+
</head>
|
17 |
+
<body>
|
18 |
+
<h1>Precondition Failed</h1>
|
19 |
+
<p>We're sorry, but we could not fulfill your request for
|
20 |
+
<?php echo htmlspecialchars($wp_bb_request_uri) ?> on this server.</p>
|
21 |
+
<p>We have established rules for access to this server, and any person or robot
|
22 |
+
that violates these rules will be unable to access this site.</p>
|
23 |
+
<p>To resolve this problem, please try the following steps:</p>
|
24 |
+
<ul>
|
25 |
+
<li>Ensure that your computer is free of viruses, Trojan horses, spyware or
|
26 |
+
any other sort of malicious software.</li>
|
27 |
+
<li>If you are using any sort of personal firewall or browser privacy
|
28 |
+
software, check to ensure that its settings do not cause your web browser to
|
29 |
+
inadvertently violate any of the rules listed below.</li>
|
30 |
+
<li>If you are behind a Web proxy or corporate firewall, the proxy must
|
31 |
+
conform to the <a href="http://www.isi.edu/in-notes/rfc2616.txt">HTTP
|
32 |
+
specification</a> with respect to proxy servers. Contact your network
|
33 |
+
administrator if the trouble persists, or bypass the proxy and connect
|
34 |
+
directly if possible.</li>
|
35 |
+
<li>Disable any download accelerators you may be using. They don't speed up
|
36 |
+
your downloads anyway; in most cases, they actually run slower!</li>
|
37 |
+
<li>If all else fails, try using a different Web browser, such as
|
38 |
+
<a href="http://www.spreadfirefox.com/?q=affiliates&id=32135&t=71">Firefox</a>.</li>
|
39 |
+
</ul>
|
40 |
+
<p>If you still need assistance, please contact <a href="mailto:<?php echo htmlspecialchars(str_replace("@", "+nospam@nospam.", $wp_bb_email)); ?>"><?php echo htmlspecialchars(str_replace("@", " at ", $wp_bb_email)); ?></a>.</p>
|
41 |
+
<h2>More Information</h2>
|
42 |
+
<p>For your reference, the conditions for access to this server are:</p>
|
43 |
+
<h3>Robots:</h3>
|
44 |
+
<ul>
|
45 |
+
<li>MUST read and obey <a href="http://www.robotstxt.org/">robots.txt</a>.</li>
|
46 |
+
<li>MUST identify themselves properly; for example MUST NOT identify as Mozilla.</li>
|
47 |
+
<li>MUST NOT pretend to be a human.</li>
|
48 |
+
</ul>
|
49 |
+
<h3>Humans:</h3>
|
50 |
+
<ul>
|
51 |
+
<li>MUST NOT pretend to be a robot.</li>
|
52 |
+
<li>MUST NOT use a computer infected with viruses, Trojan horses or other
|
53 |
+
malicious software.</li>
|
54 |
+
</ul>
|
55 |
+
<h3>Both:</h3>
|
56 |
+
<ul>
|
57 |
+
<li>MUST NOT harvest email addresses.</li>
|
58 |
+
<li>MUST NOT attempt to send spam.</li>
|
59 |
+
<li>MUST NOT attempt to compromise server security.</li>
|
60 |
+
<li>MUST NOT use excessive amounts of bandwidth or other server resources.</li>
|
61 |
+
</ul>
|
62 |
+
<p>The precondition on the request for the URL
|
63 |
+
<?php echo htmlspecialchars($wp_bb_request_uri); ?> evaluated to false.</p>
|
64 |
+
<hr>
|
65 |
+
<?php echo htmlspecialchars($wp_bb_server_signature); ?>
|
66 |
+
</body>
|
67 |
+
</html>
|
68 |
+
<?php
|
69 |
+
die('');
|
70 |
+
}
|
71 |
+
?>
|
bad-behavior/bad-behavior-core.php
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!defined('WP_BB_CWD'))
|
4 |
+
die('');
|
5 |
+
|
6 |
+
require_once(WP_BB_CWD . "/bad-behavior-functions.php");
|
7 |
+
|
8 |
+
// Write to the log file.
|
9 |
+
function wp_bb_log($response) {
|
10 |
+
global $wp_bb_logging, $wp_bb_verbose_logging;
|
11 |
+
|
12 |
+
if (($wp_bb_verbose_logging) || ($wp_bb_logging && $response == 403)) {
|
13 |
+
require_once(WP_BB_CWD . "/bad-behavior-database.php");
|
14 |
+
wp_bb_db_log($response);
|
15 |
+
}
|
16 |
+
}
|
17 |
+
|
18 |
+
// This function is called when there is absolutely no hope for redemption for
|
19 |
+
// the offending spammer.
|
20 |
+
function wp_bb_spammer() {
|
21 |
+
require_once(WP_BB_CWD . "/bad-behavior-banned.php");
|
22 |
+
wp_bb_banned();
|
23 |
+
}
|
24 |
+
|
25 |
+
// Load up PHP4 specific stuff if needed
|
26 |
+
if (version_compare(phpversion(), "5.0.0") < 0) {
|
27 |
+
require_once(WP_BB_CWD . "/bad-behavior-php4.php");
|
28 |
+
}
|
29 |
+
|
30 |
+
// Set up some initial variables.
|
31 |
+
$wp_bb_approved = 2;
|
32 |
+
$wp_bb_db_failure = FALSE;
|
33 |
+
$wp_bb_remote_addr = $_SERVER['REMOTE_ADDR'];
|
34 |
+
$wp_bb_request_method = $_SERVER['REQUEST_METHOD'];
|
35 |
+
$wp_bb_http_host = $_SERVER['HTTP_HOST'];
|
36 |
+
$wp_bb_request_uri = $_SERVER['REQUEST_URI'];
|
37 |
+
$wp_bb_server_protocol = $_SERVER['SERVER_PROTOCOL'];
|
38 |
+
if (array_key_exists('HTTP_REFERER', $_SERVER))
|
39 |
+
$wp_bb_http_referer = $_SERVER['HTTP_REFERER'];
|
40 |
+
else
|
41 |
+
$wp_bb_http_referer = '';
|
42 |
+
$wp_bb_http_user_agent = $_SERVER['HTTP_USER_AGENT'];
|
43 |
+
$wp_bb_server_signature = $_SERVER['SERVER_SIGNATURE'];
|
44 |
+
|
45 |
+
// Load up database stuff only if requested
|
46 |
+
if ($wp_bb_verbose_logging || $wp_bb_logging) {
|
47 |
+
require_once(WP_BB_CWD . "/bad-behavior-database.php");
|
48 |
+
}
|
49 |
+
|
50 |
+
// Reconstruct the entire HTTP headers as received.
|
51 |
+
$wp_bb_headers = "$wp_bb_request_method $wp_bb_request_uri $wp_bb_server_protocol\n";
|
52 |
+
$wp_bb_http_headers = getheaders();
|
53 |
+
foreach ($wp_bb_http_headers as $wp_bb_header => $wp_bb_value) {
|
54 |
+
$wp_bb_headers .= "$wp_bb_header: $wp_bb_value\n";
|
55 |
+
}
|
56 |
+
|
57 |
+
// Reconstruct the HTTP entity, if present.
|
58 |
+
if (!strcasecmp($wp_bb_request_method, "POST")) {
|
59 |
+
foreach ($_POST as $wp_bb_header => $wp_bb_value) {
|
60 |
+
$wp_bb_request_entity .= "$wp_bb_header: $wp_bb_value\n";
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
// Postprocess the headers to mixed-case
|
65 |
+
// FIXME: get the world to stop using PHP as CGI
|
66 |
+
foreach ($wp_bb_http_headers as $h=>$v)
|
67 |
+
$wp_bb_http_headers_mixed[uc_all($h)]=$v;
|
68 |
+
|
69 |
+
// Easy stuff: Ban known bad user-agents
|
70 |
+
require_once(WP_BB_CWD . "/bad-behavior-user-agent.php");
|
71 |
+
|
72 |
+
// Now analyze requests coming from "MSIE"
|
73 |
+
if (stripos($wp_bb_http_user_agent, "MSIE") !== FALSE) {
|
74 |
+
if (stripos($wp_bb_http_user_agent, "Opera") === FALSE) {
|
75 |
+
require_once(WP_BB_CWD . "/bad-behavior-msie.php");
|
76 |
+
} else {
|
77 |
+
require_once(WP_BB_CWD . "/bad-behavior-opera.php");
|
78 |
+
}
|
79 |
+
}
|
80 |
+
elseif (stripos($wp_bb_http_user_agent, "msnbot") !== FALSE) {
|
81 |
+
require_once(WP_BB_CWD . "/bad-behavior-msnbot.php");
|
82 |
+
}
|
83 |
+
elseif (stripos($wp_bb_http_user_agent, "Googlebot") !== FALSE ||
|
84 |
+
stripos($wp_bb_http_user_agent, "Mediapartners-Google") !== FALSE) {
|
85 |
+
require_once(WP_BB_CWD . "/bad-behavior-google.php");
|
86 |
+
}
|
87 |
+
// Now analyze requests coming from "Konqueror"
|
88 |
+
elseif (stripos($wp_bb_http_user_agent, "Konqueror") !== FALSE) {
|
89 |
+
require_once(WP_BB_CWD . "/bad-behavior-konqueror.php");
|
90 |
+
}
|
91 |
+
elseif (stripos($wp_bb_http_user_agent, "Opera") !== FALSE) {
|
92 |
+
require_once(WP_BB_CWD . "/bad-behavior-opera.php");
|
93 |
+
}
|
94 |
+
elseif (stripos($wp_bb_http_user_agent, "Safari") !== FALSE) {
|
95 |
+
require_once(WP_BB_CWD . "/bad-behavior-safari.php");
|
96 |
+
}
|
97 |
+
elseif (stripos($wp_bb_http_user_agent, "Lynx") !== FALSE) {
|
98 |
+
require_once(WP_BB_CWD . "/bad-behavior-lynx.php");
|
99 |
+
}
|
100 |
+
elseif (stripos($wp_bb_http_user_agent, "MovableType") !== FALSE) {
|
101 |
+
require_once(WP_BB_CWD . "/bad-behavior-movabletype.php");
|
102 |
+
}
|
103 |
+
elseif (stripos($wp_bb_http_user_agent, "Mozilla") !== FALSE &&
|
104 |
+
stripos($wp_bb_http_user_agent, "Mozilla") == 0) {
|
105 |
+
require_once(WP_BB_CWD . "/bad-behavior-mozilla.php");
|
106 |
+
}
|
107 |
+
|
108 |
+
// Analyze the Referer, if present
|
109 |
+
if (array_key_exists('Referer', $wp_bb_http_headers_mixed)) {
|
110 |
+
require_once(WP_BB_CWD . "/bad-behavior-referer.php");
|
111 |
+
}
|
112 |
+
|
113 |
+
// Now analyze all other requests
|
114 |
+
require_once(WP_BB_CWD . "/bad-behavior-http-headers.php");
|
115 |
+
|
116 |
+
// If we get this far, the client is probably OK
|
117 |
+
wp_bb_log(200);
|
118 |
+
|
119 |
+
?>
|
bad-behavior/bad-behavior-database.php
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Database functions. This needs review to ensure it isn't MySQL specific;
|
4 |
+
// it certainly is right now.
|
5 |
+
|
6 |
+
if (!defined('WP_BB_CWD'))
|
7 |
+
die('');
|
8 |
+
|
9 |
+
function wp_bb_db_create_tables() {
|
10 |
+
global $wp_bb_db_failure;
|
11 |
+
|
12 |
+
if (defined("WP_BB_NO_CREATE"))
|
13 |
+
return;
|
14 |
+
|
15 |
+
$query = "CREATE TABLE IF NOT EXISTS `" . WP_BB_LOG . "` (
|
16 |
+
`id` int(11) NOT NULL auto_increment,
|
17 |
+
`ip` text NOT NULL,
|
18 |
+
`date` datetime NOT NULL default '0000-00-00 00:00:00',
|
19 |
+
`request_method` text NOT NULL,
|
20 |
+
`http_host` text,
|
21 |
+
`request_uri` text NOT NULL,
|
22 |
+
`server_protocol` text NOT NULL,
|
23 |
+
`http_referer` text,
|
24 |
+
`http_user_agent` text,
|
25 |
+
`http_headers` text NOT NULL,
|
26 |
+
`http_response` int(3) NOT NULL,
|
27 |
+
PRIMARY KEY (`id`) );";
|
28 |
+
if (wp_bb_db_query($query) === FALSE) {
|
29 |
+
$wp_bb_db_failure = TRUE;
|
30 |
+
}
|
31 |
+
// Upgrades from 1.0
|
32 |
+
$query = "DESCRIBE `" . WP_BB_LOG . "` `request_entity`;";
|
33 |
+
if (wp_bb_db_query($query) == 0) {
|
34 |
+
$query = "ALTER TABLE `" . WP_BB_LOG . "` ADD `request_entity` TEXT AFTER `http_headers`;";
|
35 |
+
if (wp_bb_db_query($query) === FALSE) {
|
36 |
+
$wp_bb_db_failure = TRUE;
|
37 |
+
}
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
function wp_bb_db_clear_old_entries() {
|
42 |
+
global $wp_bb_logging_duration;
|
43 |
+
|
44 |
+
$query = "DELETE FROM `" . WP_BB_LOG . "` WHERE
|
45 |
+
`date` < DATE_SUB('" . gmstrftime("%Y-%m-%d %H:%M:%S") .
|
46 |
+
"', INTERVAL $wp_bb_logging_duration DAY)";
|
47 |
+
if (wp_bb_db_query($query) === FALSE) {
|
48 |
+
$wp_bb_db_failure = TRUE;
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
// This sanitizes input for SQL! not necessarily for anything else
|
53 |
+
function wp_bb_db_sanitize($untrusted_input) {
|
54 |
+
return addslashes($untrusted_input);
|
55 |
+
}
|
56 |
+
|
57 |
+
function wp_bb_db_log($response) {
|
58 |
+
global $wp_bb_remote_addr, $wp_bb_request_method, $wp_bb_http_host;
|
59 |
+
global $wp_bb_request_uri, $wp_bb_server_protocol, $wp_bb_http_referer;
|
60 |
+
global $wp_bb_http_user_agent, $wp_bb_headers;
|
61 |
+
global $wp_bb_request_entity;
|
62 |
+
|
63 |
+
// Sanitize input
|
64 |
+
$remote_addr = wp_bb_db_sanitize($wp_bb_remote_addr);
|
65 |
+
$request_method = wp_bb_db_sanitize($wp_bb_request_method);
|
66 |
+
$host = wp_bb_db_sanitize($wp_bb_http_host);
|
67 |
+
$request_uri = wp_bb_db_sanitize($wp_bb_request_uri);
|
68 |
+
$server_protocol = wp_bb_db_sanitize($wp_bb_server_protocol);
|
69 |
+
$referer = wp_bb_db_sanitize($wp_bb_http_referer);
|
70 |
+
$user_agent = wp_bb_db_sanitize($wp_bb_http_user_agent);
|
71 |
+
$headers = wp_bb_db_sanitize($wp_bb_headers);
|
72 |
+
$request_entity = wp_bb_db_sanitize($wp_bb_request_entity);
|
73 |
+
$response = intval($response);
|
74 |
+
|
75 |
+
$date = wp_bb_date();
|
76 |
+
$query = "INSERT INTO `" . WP_BB_LOG . "`
|
77 |
+
(`ip`, `date`, `request_method`, `http_host`, `request_uri`, `server_protocol`, `http_referer`, `http_user_agent`, `http_headers`, `request_entity`, `http_response`) VALUES
|
78 |
+
('$remote_addr', '$date', '$request_method', '$host', '$request_uri', '$server_protocol', '$referer', '$user_agent', '$headers', '$request_entity', '$response')";
|
79 |
+
if (wp_bb_db_query($query) === FALSE) {
|
80 |
+
$wp_bb_db_failure = TRUE;
|
81 |
+
}
|
82 |
+
}
|
83 |
+
|
84 |
+
wp_bb_db_create_tables();
|
85 |
+
wp_bb_db_clear_old_entries();
|
86 |
+
?>
|
bad-behavior/bad-behavior-functions.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Convert a string to mixed-case on word boundaries
|
4 |
+
function uc_all($string) {
|
5 |
+
$temp = preg_split('/(\W)/', str_replace("_", "-", $string), -1, PREG_SPLIT_DELIM_CAPTURE );
|
6 |
+
foreach ($temp as $key=>$word) {
|
7 |
+
$temp[$key] = ucfirst(strtolower($word));
|
8 |
+
}
|
9 |
+
return join ('', $temp);
|
10 |
+
}
|
11 |
+
|
12 |
+
// Obtain all the HTTP headers.
|
13 |
+
// NB: on PHP-CGI we hve to fake it out a bit, since we can't get the raw
|
14 |
+
// headers
|
15 |
+
function getheaders() {
|
16 |
+
if (!is_callable('getallheaders')) {
|
17 |
+
foreach($_SERVER as $h=>$v)
|
18 |
+
if(ereg('HTTP_(.+)',$h,$hp))
|
19 |
+
$headers[str_replace("_", "-", uc_all($hp[1]))]=$v;
|
20 |
+
return $headers;
|
21 |
+
} else {
|
22 |
+
return getallheaders();
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
// $addr should be an ip address in the format '0.0.0.0'
|
27 |
+
// $cidr should be a string in the format '100/8'
|
28 |
+
// or an array where each element is in the above format
|
29 |
+
function matchCIDR($addr, $cidr) {
|
30 |
+
$output = false;
|
31 |
+
|
32 |
+
if ( is_array($cidr) ) {
|
33 |
+
foreach ( $cidr as $cidrlet ) {
|
34 |
+
if ( matchCIDR( $addr, $cidrlet) ) {
|
35 |
+
$output = true;
|
36 |
+
}
|
37 |
+
}
|
38 |
+
} else {
|
39 |
+
list($ip, $mask) = explode('/', $cidr);
|
40 |
+
$mask = 0xffffffff << (32 - $mask);
|
41 |
+
$output = ((ip2long($addr) & $mask) == (ip2long($ip) & $mask));
|
42 |
+
}
|
43 |
+
return $output;
|
44 |
+
}
|
45 |
+
|
46 |
+
?>
|
bad-behavior/bad-behavior-generic.php
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
http://www.ioerror.us/software/bad-behavior/
|
4 |
+
|
5 |
+
Bad Behavior - detects and blocks unwanted Web accesses
|
6 |
+
Copyright (C) 2005 Michael Hampton
|
7 |
+
|
8 |
+
This program is free software; you can redistribute it and/or modify
|
9 |
+
it under the terms of the GNU General Public License as published by
|
10 |
+
the Free Software Foundation; either version 2 of the License, or
|
11 |
+
(at your option) any later version.
|
12 |
+
|
13 |
+
This program is distributed in the hope that it will be useful,
|
14 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
+
GNU General Public License for more details.
|
17 |
+
|
18 |
+
You should have received a copy of the GNU General Public License
|
19 |
+
along with this program; if not, write to the Free Software
|
20 |
+
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
21 |
+
*/
|
22 |
+
|
23 |
+
// This file is the entry point for Bad Behavior.
|
24 |
+
// See below to customize it for your particular CMS or PHP application.
|
25 |
+
// Preferably by the time this file is loaded, everything in your app will
|
26 |
+
// be initialized, but no output sent to the browser. If output has been
|
27 |
+
// sent, Bad Behavior will fail.
|
28 |
+
|
29 |
+
###############################################################################
|
30 |
+
###############################################################################
|
31 |
+
|
32 |
+
// Configuration
|
33 |
+
// Nothing will be written to a DB unless you implement DB queries below
|
34 |
+
|
35 |
+
// Log failed requests to the database.
|
36 |
+
$wp_bb_logging = TRUE;
|
37 |
+
|
38 |
+
// Log all requests to the database, not just failed requests.
|
39 |
+
$wp_bb_verbose_logging = FALSE;
|
40 |
+
|
41 |
+
// How long to keep the logs around (in days).
|
42 |
+
$wp_bb_logging_duration = 7;
|
43 |
+
|
44 |
+
// Email address to contact you in case of problems
|
45 |
+
// This will be shown to users on the error page, which means it will
|
46 |
+
// be exposed to spammers! Bad Behavior will munge it automatically; you
|
47 |
+
// should NOT munge it here!
|
48 |
+
$wp_bb_email = "badbots@ioerror.us";
|
49 |
+
|
50 |
+
// The database table name to use.
|
51 |
+
// You can customize the table name if necessary.
|
52 |
+
define('WP_BB_LOG', /* $software_specific_prefix . */ 'bad_behavior_log');
|
53 |
+
|
54 |
+
###############################################################################
|
55 |
+
|
56 |
+
# DO NOT EDIT BELOW THIS LINE
|
57 |
+
|
58 |
+
###############################################################################
|
59 |
+
|
60 |
+
define('WP_BB_CWD', dirname(__FILE__));
|
61 |
+
|
62 |
+
// Callbacks
|
63 |
+
|
64 |
+
// generic code; you should reimplement these if you want logging and
|
65 |
+
// database functions
|
66 |
+
|
67 |
+
// return a UTC date in the format preferred by your database
|
68 |
+
function wp_bb_date() {
|
69 |
+
return gmdate('Y-m-d H:i:s');
|
70 |
+
}
|
71 |
+
|
72 |
+
// run a SQL query and return # of rows affected, or FALSE if query failed
|
73 |
+
function wp_bb_db_query($query) {
|
74 |
+
return FALSE;
|
75 |
+
}
|
76 |
+
|
77 |
+
// Load core functions and do initial checks
|
78 |
+
require_once(WP_BB_CWD . "/bad-behavior-core.php");
|
79 |
+
|
80 |
+
?>
|
bad-behavior/bad-behavior-google.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// This file is included only when the user-agent is claiming to be Google
|
4 |
+
|
5 |
+
if (!defined('WP_BB_CWD'))
|
6 |
+
die('');
|
7 |
+
|
8 |
+
// require_once(WP_BB_CWD . "/bad-behavior-accept.php");
|
9 |
+
|
10 |
+
if (matchCIDR($wp_bb_remote_addr, "66.249.64.0/19") === FALSE) {
|
11 |
+
wp_bb_spammer();
|
12 |
+
}
|
13 |
+
|
14 |
+
?>
|
bad-behavior/bad-behavior-http-headers.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!defined('WP_BB_CWD'))
|
4 |
+
die('');
|
5 |
+
|
6 |
+
// Analyze the headers of all user-agents
|
7 |
+
// These checks apply to any user-agent regardless of identification
|
8 |
+
|
9 |
+
// Range: field exists and begins with 0
|
10 |
+
// Real user-agents do not start ranges at 0
|
11 |
+
// NOTE: this blocks the whois.sc bot. No big loss.
|
12 |
+
// FIXME: whitelist whois.sc netblocks when rwhoisd.ccom.net becomes available
|
13 |
+
if (array_key_exists('Range', $wp_bb_http_headers_mixed) &&
|
14 |
+
strpos($wp_bb_http_headers_mixed['Range'], "=0-") !== FALSE) {
|
15 |
+
if (strncmp($wp_bb_http_user_agent, "MovableType", 11))
|
16 |
+
wp_bb_spammer();
|
17 |
+
}
|
18 |
+
|
19 |
+
// Lowercase via is used by open proxies/referrer spammers
|
20 |
+
if (array_key_exists('via', $wp_bb_http_headers)) {
|
21 |
+
wp_bb_spammer();
|
22 |
+
}
|
23 |
+
// pinappleproxy is used by referrer spammers
|
24 |
+
if (array_key_exists('Via', $wp_bb_http_headers_mixed)) {
|
25 |
+
if (stripos($wp_bb_http_headers_mixed['Via'], "pinappleproxy") !== FALSE ||
|
26 |
+
stripos($wp_bb_http_headers_mixed['Via'], "PCNETSERVER") !== FALSE) {
|
27 |
+
wp_bb_spammer();
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
// Headers which are not seen from normal user agents; only malicious bots
|
32 |
+
if (array_key_exists('X-Aaaaaaaaaaaa', $wp_bb_http_headers_mixed) ||
|
33 |
+
array_key_exists('X-Aaaaaaaaaa', $wp_bb_http_headers_mixed)) {
|
34 |
+
wp_bb_spammer();
|
35 |
+
}
|
36 |
+
|
37 |
+
?>
|
bad-behavior/bad-behavior-konqueror.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// This file is included only when the user-agent is claiming to be Konqueror
|
4 |
+
// (or some variant thereof). We check the HTTP headers to see if it really
|
5 |
+
// is Konqueror.
|
6 |
+
|
7 |
+
if (!defined('WP_BB_CWD'))
|
8 |
+
die('');
|
9 |
+
|
10 |
+
require_once(WP_BB_CWD . "/bad-behavior-accept.php");
|
11 |
+
|
12 |
+
// CafeKelsa is a dev project at Yahoo which indexes job listings for
|
13 |
+
// Yahoo! HotJobs. It identifies as Konqueror so we skip these checks.
|
14 |
+
if (stripos($wp_bb_http_user_agent, "YahooSeeker/CafeKelsa") === FALSE ||
|
15 |
+
matchCIDR($wp_bb_remote_addr, "209.73.160.0/19") === FALSE) {
|
16 |
+
// Konqueror always sends the Accept: header.
|
17 |
+
wp_bb_check_accept();
|
18 |
+
|
19 |
+
// Konqueror always sends the Accept-Encoding: header.
|
20 |
+
wp_bb_check_accept_encoding();
|
21 |
+
}
|
22 |
+
|
23 |
+
?>
|
bad-behavior/bad-behavior-lynx.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Analyze user agents claiming to be Lynx
|
4 |
+
|
5 |
+
if (!defined('WP_BB_CWD'))
|
6 |
+
die('');
|
7 |
+
|
8 |
+
require_once(WP_BB_CWD . "/bad-behavior-accept.php");
|
9 |
+
|
10 |
+
wp_bb_check_accept();
|
11 |
+
wp_bb_check_accept_encoding();
|
12 |
+
|
13 |
+
?>
|
bad-behavior/bad-behavior-mediawiki.php
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
http://www.ioerror.us/software/bad-behavior/
|
4 |
+
|
5 |
+
Bad Behavior - detects and blocks unwanted Web accesses
|
6 |
+
Copyright (C) 2005 Michael Hampton
|
7 |
+
|
8 |
+
This program is free software; you can redistribute it and/or modify
|
9 |
+
it under the terms of the GNU General Public License as published by
|
10 |
+
the Free Software Foundation; either version 2 of the License, or
|
11 |
+
(at your option) any later version.
|
12 |
+
|
13 |
+
This program is distributed in the hope that it will be useful,
|
14 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
+
GNU General Public License for more details.
|
17 |
+
|
18 |
+
You should have received a copy of the GNU General Public License
|
19 |
+
along with this program; if not, write to the Free Software
|
20 |
+
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
21 |
+
*/
|
22 |
+
|
23 |
+
// This file is the entry point for Bad Behavior.
|
24 |
+
// See below to customize it for your particular CMS or PHP application.
|
25 |
+
// Preferably by the time this file is loaded, everything in your app will
|
26 |
+
// be initialized, but no output sent to the browser. If output has been
|
27 |
+
// sent, Bad Behavior will fail.
|
28 |
+
|
29 |
+
if (!defined('MEDIAWIKI'))
|
30 |
+
die('');
|
31 |
+
|
32 |
+
###############################################################################
|
33 |
+
###############################################################################
|
34 |
+
|
35 |
+
// Configuration
|
36 |
+
// To change the following settings, override them in MediaWiki's
|
37 |
+
// LocalSettings.php after including this file.
|
38 |
+
|
39 |
+
// In some configurations the automatic table creation may fail.
|
40 |
+
// You can create the table manually (see query in bad-behavior-database.php)
|
41 |
+
// and add this line to your LocalSettings.php:
|
42 |
+
//
|
43 |
+
// define('WP_BB_NO_CREATE', true);
|
44 |
+
|
45 |
+
// Log failed requests to the database.
|
46 |
+
$wp_bb_logging = TRUE;
|
47 |
+
|
48 |
+
// Log all requests to the database, not just failed requests.
|
49 |
+
$wp_bb_verbose_logging = FALSE;
|
50 |
+
|
51 |
+
// How long to keep the logs around (in days).
|
52 |
+
$wp_bb_logging_duration = 7;
|
53 |
+
|
54 |
+
// Email address to contact you in case of problems
|
55 |
+
// This will be shown to users on the error page, which means it will
|
56 |
+
// be exposed to spammers! Bad Behavior will munge it automatically; you
|
57 |
+
// should NOT munge it here!
|
58 |
+
$wp_bb_email = $wgEmergencyContact;
|
59 |
+
|
60 |
+
// The database table name to use.
|
61 |
+
// You can customize the table name if necessary.
|
62 |
+
define('WP_BB_LOG', $wgDBprefix . 'bad_behavior_log');
|
63 |
+
|
64 |
+
###############################################################################
|
65 |
+
|
66 |
+
# DO NOT EDIT BELOW THIS LINE
|
67 |
+
|
68 |
+
###############################################################################
|
69 |
+
|
70 |
+
define('WP_BB_CWD', dirname(__FILE__));
|
71 |
+
|
72 |
+
// Callbacks
|
73 |
+
|
74 |
+
// generic code; you should reimplement these if you want logging and
|
75 |
+
// database functions
|
76 |
+
|
77 |
+
// return a UTC date in the format preferred by your database
|
78 |
+
function wp_bb_date() {
|
79 |
+
return gmdate('Y-m-d H:i:s');
|
80 |
+
}
|
81 |
+
|
82 |
+
// run a SQL query and return # of rows affected, or FALSE if query failed
|
83 |
+
function wp_bb_db_query($query) {
|
84 |
+
return wfQuery($query, DB_WRITE);
|
85 |
+
}
|
86 |
+
|
87 |
+
// Load core functions and do initial checks
|
88 |
+
// This will be run during extension initialization at the end of Setup.php
|
89 |
+
function wp_bb_mediawiki_run() {
|
90 |
+
// globals defined here
|
91 |
+
global $wp_bb_logging, $wp_bb_verbose_logging, $wp_bb_logging_duration, $wp_bb_email;
|
92 |
+
|
93 |
+
// globals defined in core
|
94 |
+
global $wp_bb_approved, $wp_bb_db_failure;
|
95 |
+
global $wp_bb_remote_addr, $wp_bb_request_method, $wp_bb_http_host;
|
96 |
+
global $wp_bb_request_uri, $wp_bb_server_protocol, $wp_bb_http_referer;
|
97 |
+
global $wp_bb_http_user_agent, $wp_bb_server_signature;
|
98 |
+
global $wp_bb_headers, $wp_bb_http_headers, $wp_bb_http_headers_mixed;
|
99 |
+
global $wp_bb_request_entity;
|
100 |
+
|
101 |
+
// Don't try to run for command-line maintenance scripts.
|
102 |
+
if (php_sapi_name() != 'cli')
|
103 |
+
require_once(WP_BB_CWD . "/bad-behavior-core.php");
|
104 |
+
}
|
105 |
+
|
106 |
+
$wgExtensionFunctions[] = 'wp_bb_mediawiki_run';
|
107 |
+
|
108 |
+
?>
|
bad-behavior/bad-behavior-movabletype.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Analyze user agents claiming to be MovableType
|
4 |
+
|
5 |
+
if (!defined('WP_BB_CWD'))
|
6 |
+
die('');
|
7 |
+
|
8 |
+
// Is it a trackback? If so, do a quick check on the URI
|
9 |
+
// It must resolve to the same IP as the blog sending it.
|
10 |
+
// TODO: DNS lookups take too long; skip the check for now :(
|
11 |
+
if (strcasecmp($wp_bb_request_method, "POST")) {
|
12 |
+
if (strcmp($wp_bb_http_headers_mixed['Range'], "bytes=0-99999")) {
|
13 |
+
wp_bb_spammer();
|
14 |
+
}
|
15 |
+
// $uri = parse_url($_POST['url']);
|
16 |
+
// $host = $uri['host'];
|
17 |
+
// $ip = gethostbyname($host);
|
18 |
+
// if ($ip != $host && $ip != $wp_bb_remote_addr) {
|
19 |
+
// wp_bb_spammer();
|
20 |
+
// }
|
21 |
+
}
|
22 |
+
|
23 |
+
?>
|
bad-behavior/bad-behavior-mozilla.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Analyze user agents claiming to be Mozilla
|
4 |
+
|
5 |
+
// Bots:
|
6 |
+
// Yahoo! Slurp passes these checks
|
7 |
+
|
8 |
+
if (!defined('WP_BB_CWD'))
|
9 |
+
die('');
|
10 |
+
|
11 |
+
require_once(WP_BB_CWD . "/bad-behavior-accept.php");
|
12 |
+
|
13 |
+
wp_bb_check_accept();
|
14 |
+
// AvantGo mobile browser needs a different check
|
15 |
+
if (strpos($wp_bb_http_user_agent, "AvantGo") !== FALSE) {
|
16 |
+
if (!array_key_exists('X-Avantgo-Screensize', $wp_bb_http_headers_mixed)) {
|
17 |
+
wp_bb_spammer();
|
18 |
+
}
|
19 |
+
} else {
|
20 |
+
wp_bb_check_accept_encoding();
|
21 |
+
}
|
22 |
+
|
23 |
+
?>
|
bad-behavior/bad-behavior-msie.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// This file is included only when the user-agent is claiming to be MSIE
|
4 |
+
// (or some variant thereof). We check the HTTP headers to see if it really
|
5 |
+
// is MSIE.
|
6 |
+
|
7 |
+
if (!defined('WP_BB_CWD'))
|
8 |
+
die('');
|
9 |
+
|
10 |
+
require_once(WP_BB_CWD . "/bad-behavior-accept.php");
|
11 |
+
|
12 |
+
// MSIE always sends the Accept: header.
|
13 |
+
wp_bb_check_accept();
|
14 |
+
|
15 |
+
// MSIE 6.0+ always sends the Accept-Encoding: header.
|
16 |
+
// BecomeBot does not.
|
17 |
+
if (strpos($wp_bb_http_user_agent, "MSIE 6") !== FALSE) {
|
18 |
+
if (stripos($wp_bb_http_user_agent, "BecomeBot") === FALSE ||
|
19 |
+
matchCIDR($wp_bb_remote_addr, "64.124.85.0/24") === FALSE) {
|
20 |
+
wp_bb_check_accept_encoding();
|
21 |
+
}
|
22 |
+
}
|
23 |
+
|
24 |
+
// MSIE does NOT send "Windows ME" or "Windows XP" in the user agent
|
25 |
+
if (strpos($wp_bb_http_user_agent, "Windows ME") !== FALSE ||
|
26 |
+
strpos($wp_bb_http_user_agent, "Windows XP") !== FALSE ||
|
27 |
+
strpos($wp_bb_http_user_agent, "Windows 2000") !== FALSE) {
|
28 |
+
wp_bb_spammer();
|
29 |
+
}
|
30 |
+
|
31 |
+
?>
|
bad-behavior/bad-behavior-msnbot.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// This file is included only when the user-agent is claiming to be msnbot
|
4 |
+
|
5 |
+
if (!defined('WP_BB_CWD'))
|
6 |
+
die('');
|
7 |
+
|
8 |
+
// require_once(WP_BB_CWD . "/bad-behavior-accept.php");
|
9 |
+
|
10 |
+
if (matchCIDR($wp_bb_remote_addr, "207.46.0.0/16") === FALSE &&
|
11 |
+
matchCIDR($wp_bb_remote_addr, "65.52.0.0/14") === FALSE &&
|
12 |
+
matchCIDR($wp_bb_remote_addr, "207.68.128.0/18") === FALSE &&
|
13 |
+
matchCIDR($wp_bb_remote_addr, "207.68.192.0/20") === FALSE &&
|
14 |
+
matchCIDR($wp_bb_remote_addr, "64.4.0.0/18") === FALSE) {
|
15 |
+
wp_bb_spammer();
|
16 |
+
}
|
17 |
+
|
18 |
+
?>
|
bad-behavior/bad-behavior-opera.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Analyze user agents claiming to be Opera
|
4 |
+
|
5 |
+
if (!defined('WP_BB_CWD'))
|
6 |
+
die('');
|
7 |
+
|
8 |
+
require_once(WP_BB_CWD . "/bad-behavior-accept.php");
|
9 |
+
|
10 |
+
wp_bb_check_accept();
|
11 |
+
wp_bb_check_accept_encoding();
|
12 |
+
|
13 |
+
?>
|
bad-behavior/bad-behavior-php4.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Contains
|
3 |
+
|
4 |
+
// Helper functions
|
5 |
+
// stripos() needed because stripos is only present on PHP 5
|
6 |
+
function stripos($haystack,$needle,$offset = 0) {
|
7 |
+
return(strpos(strtolower($haystack),strtolower($needle),$offset));
|
8 |
+
}
|
9 |
+
|
10 |
+
?>
|
bad-behavior/bad-behavior-referer.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!defined('WP_BB_CWD'))
|
4 |
+
die('');
|
5 |
+
|
6 |
+
// Analyze the Referer: field
|
7 |
+
|
8 |
+
function wp_bb_referer() {
|
9 |
+
global $wp_bb_http_headers_mixed;
|
10 |
+
|
11 |
+
// Referer, if it exists, must not be blank
|
12 |
+
if (empty($wp_bb_http_headers_mixed['Referer'])) {
|
13 |
+
wp_bb_spammer();
|
14 |
+
}
|
15 |
+
|
16 |
+
// Referer, if it exists, must contain a :
|
17 |
+
// While a relative URL is technically valid in Referer, all known
|
18 |
+
// legit user-agents send an absolute URL
|
19 |
+
if (strpos($wp_bb_http_headers_mixed['Referer'], ":") === FALSE) {
|
20 |
+
wp_bb_spammer();
|
21 |
+
}
|
22 |
+
return;
|
23 |
+
}
|
24 |
+
|
25 |
+
?>
|
bad-behavior/bad-behavior-safari.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Analyze user agents claiming to be Safari
|
4 |
+
|
5 |
+
if (!defined('WP_BB_CWD'))
|
6 |
+
die('');
|
7 |
+
|
8 |
+
require_once(WP_BB_CWD . "/bad-behavior-accept.php");
|
9 |
+
|
10 |
+
wp_bb_check_accept();
|
11 |
+
|
12 |
+
?>
|
bad-behavior/bad-behavior-user-agent.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!defined('WP_BB_CWD'))
|
4 |
+
die('');
|
5 |
+
|
6 |
+
// Is the user-agent a known spambot?
|
7 |
+
// Occurs at the beginning of the string
|
8 |
+
$wp_bb_spambots_str0 = array(
|
9 |
+
"8484 Boston Project", // video poker/porn spam
|
10 |
+
"autoemailspider", // spam harvester
|
11 |
+
"Digger", // spam harvester
|
12 |
+
"ecollector", // spam harvester
|
13 |
+
"EmailCollector", // spam harvester
|
14 |
+
"Email Extractor", // spam harvester
|
15 |
+
"Email Siphon", // spam harvester
|
16 |
+
"grub crawler", // misc comment/email spam
|
17 |
+
// "Java 1.", // Some doubt about this one
|
18 |
+
"libwww-perl", // spambot scripts
|
19 |
+
"LWP", // exploited boxes
|
20 |
+
"Microsoft URL", // spam harvester
|
21 |
+
"Missigua", // spam harvester
|
22 |
+
"Mozilla ", // forum exploits
|
23 |
+
"Shockwave Flash", // spam harvester
|
24 |
+
"Wordpress Hash Grabber",// malicious software
|
25 |
+
"www.weblogs.com", // referrer spam (not the real www.weblogs.com)
|
26 |
+
);
|
27 |
+
// Occurs anywhere in the string
|
28 |
+
$wp_bb_spambots_str = array(
|
29 |
+
"compatible ; MSIE", // misc comment/email spam
|
30 |
+
"DTS Agent", // misc comment/email spam
|
31 |
+
"grub-client", // search engine ignores robots.txt
|
32 |
+
"Indy Library", // misc comment/email spam
|
33 |
+
".NET CLR 1)", // free poker, etc.
|
34 |
+
"POE-Component-Client", // free poker, etc.
|
35 |
+
"WISEbot", // spam harvester
|
36 |
+
"WISEnutbot", // spam harvester
|
37 |
+
);
|
38 |
+
// Regex matching
|
39 |
+
$wp_bb_spambots_reg = array(
|
40 |
+
"/^[A-Z]{10}$/", // misc email spam
|
41 |
+
"/^Mozilla...0$/i", // fake user agent/email spam
|
42 |
+
// "/MSIE.*Windows XP/", // misc comment spam
|
43 |
+
);
|
44 |
+
|
45 |
+
foreach ($wp_bb_spambots_str0 as $wp_bb_spambot) {
|
46 |
+
$pos = stripos($wp_bb_http_user_agent, $wp_bb_spambot);
|
47 |
+
if ($pos !== FALSE && $pos == 0) {
|
48 |
+
wp_bb_spammer(); // does not return
|
49 |
+
}
|
50 |
+
}
|
51 |
+
foreach ($wp_bb_spambots_str as $wp_bb_spambot) {
|
52 |
+
if (stripos($wp_bb_http_user_agent, $wp_bb_spambot) !== FALSE) {
|
53 |
+
wp_bb_spammer(); // does not return
|
54 |
+
}
|
55 |
+
}
|
56 |
+
foreach ($wp_bb_spambots_reg as $wp_bb_spambot) {
|
57 |
+
if (preg_match($wp_bb_spambot, $wp_bb_http_user_agent)) {
|
58 |
+
wp_bb_spammer(); // does not return
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
?>
|
bad-behavior/bad-behavior-wordpress.php
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Bad Behavior
|
4 |
+
Version: 1.1.4
|
5 |
+
Plugin URI: http://www.ioerror.us/software/bad-behavior/
|
6 |
+
Description: Stop comment spam before it starts by trapping and blocking spambots before they have a chance to post comments.
|
7 |
+
Author: Michael Hampton
|
8 |
+
Author URI: http://www.ioerror.us/
|
9 |
+
License: GPL
|
10 |
+
|
11 |
+
Bad Behavior - detects and blocks unwanted Web accesses
|
12 |
+
Copyright (C) 2005 Michael Hampton
|
13 |
+
|
14 |
+
This program is free software; you can redistribute it and/or modify
|
15 |
+
it under the terms of the GNU General Public License as published by
|
16 |
+
the Free Software Foundation; either version 2 of the License, or
|
17 |
+
(at your option) any later version.
|
18 |
+
|
19 |
+
This program is distributed in the hope that it will be useful,
|
20 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
21 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
22 |
+
GNU General Public License for more details.
|
23 |
+
|
24 |
+
You should have received a copy of the GNU General Public License
|
25 |
+
along with this program; if not, write to the Free Software
|
26 |
+
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
27 |
+
|
28 |
+
|
29 |
+
This is beta software so please report any problems to
|
30 |
+
badbots AT ioerror DOT us
|
31 |
+
*/
|
32 |
+
|
33 |
+
###############################################################################
|
34 |
+
###############################################################################
|
35 |
+
|
36 |
+
// Configuration
|
37 |
+
|
38 |
+
// Log failed requests to the database.
|
39 |
+
$wp_bb_logging = TRUE;
|
40 |
+
|
41 |
+
// Log all requests to the database, not just failed requests.
|
42 |
+
$wp_bb_verbose_logging = FALSE;
|
43 |
+
|
44 |
+
// How long to keep the logs around (in days).
|
45 |
+
$wp_bb_logging_duration = 7;
|
46 |
+
|
47 |
+
// Email address to contact you in case of problems
|
48 |
+
// This will be shown to users on the error page, which means it will
|
49 |
+
// be exposed to spammers! Bad Behavior will munge it automatically; you
|
50 |
+
// should NOT munge it here!
|
51 |
+
$wp_bb_email = get_bloginfo('admin_email');
|
52 |
+
//$wp_bb_email = "badbots@ioerror.us";
|
53 |
+
|
54 |
+
// The database table name to use.
|
55 |
+
// You can customize the table name if necessary.
|
56 |
+
define('WP_BB_LOG', $table_prefix . 'bad_behavior_log');
|
57 |
+
|
58 |
+
###############################################################################
|
59 |
+
|
60 |
+
# DO NOT EDIT BELOW THIS LINE
|
61 |
+
|
62 |
+
###############################################################################
|
63 |
+
|
64 |
+
$wp_bb_mtime = explode(' ', microtime());
|
65 |
+
$wp_bb_timer_start = $wp_bb_mtime[1] + $wp_bb_mtime[0];
|
66 |
+
define('WP_BB_CWD', dirname(__FILE__));
|
67 |
+
|
68 |
+
// WordPress-specific code
|
69 |
+
|
70 |
+
function wp_bb_date() {
|
71 |
+
return get_gmt_from_date(current_time('mysql'));
|
72 |
+
}
|
73 |
+
|
74 |
+
function wp_bb_db_query($query) {
|
75 |
+
global $wpdb;
|
76 |
+
|
77 |
+
$result = $wpdb->query($query);
|
78 |
+
if (mysql_error()) {
|
79 |
+
return FALSE;
|
80 |
+
}
|
81 |
+
return $result;
|
82 |
+
}
|
83 |
+
|
84 |
+
// Load core functions and do initial checks
|
85 |
+
require_once(WP_BB_CWD . "/bad-behavior-core.php");
|
86 |
+
|
87 |
+
$wp_bb_mtime = explode(' ', microtime());
|
88 |
+
$wp_bb_timer_stop = $wp_bb_mtime[1] + $wp_bb_mtime[0];
|
89 |
+
$wp_bb_timer_total = $wp_bb_timer_stop - $wp_bb_timer_start;
|
90 |
+
|
91 |
+
function wp_bb_timer_display() {
|
92 |
+
global $wp_bb_timer_total;
|
93 |
+
echo "\n<!-- Bad Behavior run time: " . number_format($wp_bb_timer_total, 3) . " seconds -->\n";
|
94 |
+
}
|
95 |
+
|
96 |
+
add_action('wp_head', 'wp_bb_timer_display');
|
97 |
+
|
98 |
+
?>
|