Guest User

Untitled

a guest
Apr 1st, 2018
502
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.31 KB | None | 0 0
  1. User-agent: Mediapartners-Google
  2. Disallow:
  3. User-agent: Googlebot
  4. Disallow:
  5. User-agent: Adsbot-Google
  6. Disallow:
  7. User-agent: Googlebot-Image
  8. Disallow:
  9. User-agent: Googlebot-Mobile
  10. Disallow:
  11. User-agent: MSNBot
  12. Disallow:
  13. User-agent: bingbot
  14. Disallow:
  15. User-agent: Slurp
  16. Disallow:
  17. User-Agent: Yahoo! Slurp
  18. Disallow:
  19. # Directories
  20. User-agent: *
  21. Disallow: /
  22. Disallow: /cgi-bin/
  23. Disallow: /ads/
  24. Disallow: /assets/
  25. Disallow: /cgi-bin/
  26. Disallow: /phone/
  27. Disallow: /scripts/
  28. # Files
  29. Disallow: /ads/random_ads.php
  30. Disallow: /scripts/rss2html.php
  31. Disallow: /scripts/search_terms.php
  32. Disallow: /scripts/template.html
  33. Disallow: /scripts/template_mobile.html
  34.  
  35. ErrorDocument 400 http://english-1329329990.spampoison.com
  36. ErrorDocument 401 http://english-1329329990.spampoison.com
  37. ErrorDocument 403 http://english-1329329990.spampoison.com
  38. ErrorDocument 404 /index.php
  39. SetEnvIfNoCase User-Agent "^Yandex*" bad_bot
  40. SetEnvIfNoCase User-Agent "^baidu*" bad_bot
  41. Order Deny,Allow
  42. Deny from env=bad_bot
  43. RewriteEngine on
  44. RewriteCond %{HTTP_user_agent} bot* [OR]
  45. RewriteCond %{HTTP_user_agent} *bot
  46. RewriteRule ^.*$ http://english-1329329990.spampoison.com [R,L]
  47. RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|%3D) [OR]
  48. # Block out any script trying to base64_encode crap to send via URL
  49. RewriteCond %{QUERY_STRING} base64_encode.*(.*) [OR]
  50. # Block out any script that includes a <script> tag in URL
  51. RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3E) [NC,OR]
  52. # Block out any script trying to set a PHP GLOBALS variable via URL
  53. RewriteCond %{QUERY_STRING} GLOBALS(=|[|%[0-9A-Z]{0,2}) [OR]
  54. # Block out any script trying to modify a _REQUEST variable via URL
  55. RewriteCond %{QUERY_STRING} _REQUEST(=|[|%[0-9A-Z]{0,2})
  56. # Send all blocked request to homepage with 403 Forbidden error!
  57. RewriteRule ^(.*)$ index.php [F,L]
  58. RewriteCond %{REQUEST_FILENAME} !-f
  59. RewriteCond %{REQUEST_FILENAME} !-d
  60. RewriteCond %{REQUEST_URI} !^/index.php
  61. RewriteCond %{REQUEST_URI} (/|.php|.html|.htm|.feed|.pdf|.raw|/[^.]*)$ [NC]
  62. RewriteRule (.*) index.php
  63. RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
  64. # Don't show directory listings for directories that do not contain an index file (index.php, default.asp etc.)
  65. Options -Indexes
  66. <Files http://english-1329329990.spampoison.com>
  67. order allow,deny
  68. allow from all
  69. </Files>
  70. deny from 108.
  71. deny from 123.
  72. deny from 180.
  73. deny from 100.43.83.132
  74.  
  75. <?php
  76. function botcheck(){
  77. $spiders = array(
  78. array('AdsBot-Google','google.com'),
  79. array('Googlebot','google.com'),
  80. array('Googlebot-Image','google.com'),
  81. array('Googlebot-Mobile','google.com'),
  82. array('Mediapartners','google.com'),
  83. array('Mediapartners-Google','google.com'),
  84. array('msnbot','search.msn.com'),
  85. array('bingbot','bing.com'),
  86. array('Slurp','help.yahoo.com'),
  87. array('Yahoo! Slurp','help.yahoo.com')
  88. );
  89. $useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
  90. foreach($spiders as $bot) {
  91. if(preg_match("/$bot[0]/i",$useragent)){
  92. $ipaddress = $_SERVER['REMOTE_ADDR'];
  93. $hostname = gethostbyaddr($ipaddress);
  94. $iphostname = gethostbyname($hostname);
  95. if (preg_match("/$bot[1]/i",$hostname) && $ipaddress == $iphostname){return true;}
  96. }
  97. }
  98. }
  99. if(botcheck() == false) {
  100. // User Login - Read Cookie values
  101. $username = $_COOKIE['username'];
  102. $password = $_COOKIE['password'];
  103. $radio_1 = $_COOKIE['radio_1'];
  104. $radio_2 = $_COOKIE['radio_2'];
  105. if (($username == 'm3s36G6S9v' && $password == 'S4er5h8QN2') || ($radio_1 == '2' && $radio_2 == '5')) {
  106. } else {
  107. $selected_username = $_POST['username'];
  108. $selected_password = $_POST['password'];
  109. $selected_radio_1 = $_POST['group1'];
  110. $selected_radio_2 = $_POST['group2'];
  111. if (($selected_username == 'm3s36G6S9v' && $selected_password == 'S4er5h8QN2') || ($selected_radio_1 == '2' && $selected_radio_2 == '5')) {
  112. setcookie("username", $selected_username, time()+3600, "/");
  113. setcookie("password", $selected_password, time()+3600, "/");
  114. setcookie("radio_1", $selected_radio_1, time()+3600, "/");
  115. setcookie("radio_2", $selected_radio_2, time()+3600, "/");
  116. } else {
  117. header("Location: login.html");
  118. }
  119. }
  120. }
  121. ?>
  122.  
  123. // Checks to see if this script was called by the main site pages, (i.e. index.php or mobile.php) and if not, then sends to main page
  124. session_start();
  125. if(isset($_SESSION['views'])){$_SESSION['views'] = $_SESSION['views']+ 1;} else {$_SESSION['views'] = 1;}
  126. if($_SESSION['views'] > 1) {header("Location: http://website.com/index.php");}
  127.  
  128. if(isset($_SERVER['HTTP_USER_AGENT'])){
  129. $agent = $_SERVER['HTTP_USER_AGENT'];
  130. }
  131.  
  132. if(preg_match('/^Googlebot/i',$agent)){
  133. http_response_code(301);
  134. header("HTTP/1.1 301 Moved Permanently");
  135. header("Location: http://www.google.com/");
  136. exit;
  137. }
  138.  
  139. if (preg_match("/$bot[1]/i",$hostname) && $ipaddress == $iphostname)
  140.  
  141. /* Function which can Block unwanted Requests
  142. * @return boolean/array status
  143. */
  144. function requestBlocker()
  145. {
  146. /*
  147. Version 1.0 11 Jan 2013
  148. Author: Szczepan K
  149. http://www.szczepan.info
  150. me[@] szczepan [dot] info
  151. ###Description###
  152. A PHP function which can Block unwanted Requests to reduce your Website-Traffic.
  153. God for Spiders, Bots and annoying Clients.
  154.  
  155. */
  156.  
  157. $dir = 'requestBlocker/'; ## Create & set directory writeable!!!!
  158.  
  159. $rules = array(
  160. #You can add multiple Rules in a array like this one here
  161. #Notice that large "sec definitions" (like 60*60*60) will blow up your client File
  162. array(
  163. //if >5 requests in 5 Seconds then Block client 15 Seconds
  164. 'requests' => 5, //5 requests
  165. 'sek' => 5, //5 requests in 5 Seconds
  166. 'blockTime' => 15 // Block client 15 Seconds
  167. ),
  168. array(
  169. //if >10 requests in 30 Seconds then Block client 20 Seconds
  170. 'requests' => 10, //10 requests
  171. 'sek' => 30, //10 requests in 30 Seconds
  172. 'blockTime' => 20 // Block client 20 Seconds
  173. ),
  174. array(
  175. //if >200 requests in 1 Hour then Block client 10 Minutes
  176. 'requests' => 200, //200 requests
  177. 'sek' => 60 * 60, //200 requests in 1 Hour
  178. 'blockTime' => 60 * 10 // Block client 10 Minutes
  179. )
  180. );
  181. $time = time();
  182. $blockIt = array();
  183. $user = array();
  184.  
  185. #Set Unique Name for each Client-File
  186. $user[] = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'IP_unknown';
  187. $user[] = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
  188. $user[] = strtolower(gethostbyaddr($user[0]));
  189.  
  190. # Notice that i use files because bots does not accept Sessions
  191. $botFile = $dir . substr($user[0], 0, 8) . '_' . substr(md5(join('', $user)), 0, 5) . '.txt';
  192.  
  193.  
  194. if (file_exists($botFile)) {
  195. $file = file_get_contents($botFile);
  196. $client = unserialize($file);
  197.  
  198. } else {
  199. $client = array();
  200. $client['time'][$time] = 0;
  201. }
  202.  
  203. # Set/Unset Blocktime for blocked Clients
  204. if (isset($client['block'])) {
  205. foreach ($client['block'] as $ruleNr => $timestampPast) {
  206. $left = $time - $timestampPast;
  207. if (($left) > $rules[$ruleNr]['blockTime']) {
  208. unset($client['block'][$ruleNr]);
  209. continue;
  210. }
  211. $blockIt[] = 'Block active for Rule: ' . $ruleNr . ' - unlock in ' . ($left - $rules[$ruleNr]['blockTime']) . ' Sec.';
  212. }
  213. if (!empty($blockIt)) {
  214. return $blockIt;
  215. }
  216. }
  217.  
  218. # log/count each access
  219. if (!isset($client['time'][$time])) {
  220. $client['time'][$time] = 1;
  221. } else {
  222. $client['time'][$time]++;
  223.  
  224. }
  225.  
  226. #check the Rules for Client
  227. $min = array(
  228. 0
  229. );
  230. foreach ($rules as $ruleNr => $v) {
  231. $i = 0;
  232. $tr = false;
  233. $sum[$ruleNr] = '';
  234. $requests = $v['requests'];
  235. $sek = $v['sek'];
  236. foreach ($client['time'] as $timestampPast => $count) {
  237. if (($time - $timestampPast) < $sek) {
  238. $sum[$ruleNr] += $count;
  239. if ($tr == false) {
  240. #register non-use Timestamps for File
  241. $min[] = $i;
  242. unset($min[0]);
  243. $tr = true;
  244. }
  245. }
  246. $i++;
  247. }
  248.  
  249. if ($sum[$ruleNr] > $requests) {
  250. $blockIt[] = 'Limit : ' . $ruleNr . '=' . $requests . ' requests in ' . $sek . ' seconds!';
  251. $client['block'][$ruleNr] = $time;
  252. }
  253. }
  254. $min = min($min) - 1;
  255. #drop non-use Timestamps in File
  256. foreach ($client['time'] as $k => $v) {
  257. if (!($min <= $i)) {
  258. unset($client['time'][$k]);
  259. }
  260. }
  261. $file = file_put_contents($botFile, serialize($client));
  262.  
  263.  
  264. return $blockIt;
  265.  
  266. }
  267.  
  268.  
  269. if ($t = requestBlocker()) {
  270. echo 'dont pass here!';
  271. print_R($t);
  272. } else {
  273. echo "go on!";
  274. }
  275.  
  276. RewriteCond %{HTTP_USER_AGENT} ^GoogleBot [OR]
  277. RewriteCond %{HTTP_USER_AGENT} ^OtherAbusiveBot
  278. RewriteRule ^/$ /static_page_for_bots.html [L]
  279.  
  280. RewriteCond %{HTTP_USER_AGENT} ^GoogleBot [OR]
  281. RewriteCond %{HTTP_USER_AGENT} ^OtherAbusiveBot
  282. RewriteRule ^rss2html.php$ /static.html [L]
  283.  
  284. // Checks to see if this script was called by the main site pages,
  285. // (i.e. index.php or mobile.php) and if not, then sends to main page
  286. session_start();
  287. if (isset($_SESSION['views'])) {$_SESSION['views'] = $_SESSION['views']+ 1;} else {$_SESSION['views'] = 1;}
  288. if ($_SESSION['views'] > 1) {header("Location: http://website.com/index.php");}
Add Comment
Please, Sign In to add comment