<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Azria David on Medium]]></title>
        <description><![CDATA[Stories by Azria David on Medium]]></description>
        <link>https://medium.com/@azria.david?source=rss-9f5c81cd8e81------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Azria David on Medium</title>
            <link>https://medium.com/@azria.david?source=rss-9f5c81cd8e81------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 11:27:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@azria.david/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Extracting Encrypted Credentials from Common Tools]]></title>
            <link>https://medium.com/xm-cyber/extracting-encrypted-credentials-from-common-tools-ceb83e7304ce?source=rss-9f5c81cd8e81------2</link>
            <guid isPermaLink="false">https://medium.com/p/ceb83e7304ce</guid>
            <dc:creator><![CDATA[Azria David]]></dc:creator>
            <pubDate>Sun, 01 Jan 2023 10:34:29 GMT</pubDate>
            <atom:updated>2023-01-01T10:34:29.198Z</atom:updated>
            <content:encoded><![CDATA[<p>Written by <a href="https://medium.com/@azria.david">David Azria</a> &amp; <a href="https://medium.com/@zurulianitzky">Zur Ulianitzky</a> — Jan 01,2023</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*51Le4PJaLCkNSALYcJB_Sg.jpeg" /></figure><h3>Overview</h3><p>During our day to day research, we face the question of what can be extracted from a compromised machine in order to move laterally or extract sensitive information.</p><p>Organizations use multiple tools to authenticate to servers and databases using SSH, FTP, TELNET or RDP protocols. These tools offer a way to save credentials in order to authenticate more quickly.</p><p>In this blog post, we will show how an attacker can extract non-cleartext credentials in order to authenticate to databases and servers.</p><p>We will cover the following tools:</p><ul><li>WinSCP</li><li>RoboMongo</li><li>MobaXterm</li></ul><p><strong>Note:</strong></p><p>We used reverse engineering techniques to understand how the credentials are decrypted by the different tools. <strong>The methods described here do not involve exploitation of vulnerabilities</strong>.</p><h3>WinSCP</h3><p>The first tool we looked at was WinSCP. It offers the option to save the credential details used to connect to remote machines via SSH. WinSCP obfuscates the credentials and saves them in the Windows registry. The credentials are not encrypted at all, and anyone who knows the algorithm used to obfuscate can gain access to the credentials.</p><p>The credentials saved in the registry:</p><p>Computer\HKEY_CURRENT_USER\SOFTWARE\Martin Prikryl\WinSCP 2\Sessions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Gk244OMc5zY1oxGP" /></figure><p>WinSCP’s source code is available on GitHub, and we found the obfuscation algorithm used:</p><p><a href="https://github.com/winscp/winscp/blob/master/source/core/Security.cpp">https://github.com/winscp/winscp/blob/master/source/core/Security.cpp</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/0*kLpfOaJKcHoqbZ8U" /></figure><p>We used a tool that implemented the same algorithm to de-obfuscate the credentials, and we gained access to the credentials in cleartext:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/436/0*g31_BIzHJYC24UuO" /></figure><p>Implementing an obfuscation algorithm to secure credentials stored is not best practice, as it can be easily reversed and lead to credential theft. Let’s see if the next tool analyzed uses a better approach to secure credential storage.</p><h3>RoboMongo</h3><p>RoboMongo is a MongoDB client used to connect to Mongo database servers. When you save your credentials, they are encrypted and saved in a JSON file:</p><p>%USERPROFILE%\.3T\robo-3t\1.4.4\robo3t.json</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/0*yANSn1Izr-Bcsa1L" /></figure><p>However, the secret key used to encrypt the credentials is also saved in a file, in cleartext:</p><p>%USERPROFILE\.3T\robo-3t\robo3t.key:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/282/0*1M2KcgFvKI4Lpvb3" /></figure><p>That means that an attacker who gains access to a machine can use the key saved in cleartext to decrypt the credentials.</p><p>RoboMongo is open source, so we decided to look at the source code, which is available on GitHub to understand how the key is used to encrypt the password. We found that the SimplCrypt lib from Qt is used to encrypt and decrypt the credentials:</p><p><a href="https://github.com/Studio3T/robomongo/blob/master/src/robomongo/utils/SimpleCrypt.cpp">https://github.com/Studio3T/robomongo/blob/master/src/robomongo/utils/SimpleCrypt.cpp</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/0*x-HYYLSubck88VE0" /></figure><p>This library is accessible to everyone, so we can use it to decrypt the credentials:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/0*01YowbsvAfJuvBBG" /></figure><p>RoboMongo uses encryption to securely store credentials, but the secret key is saved in cleartext, which is also not best practice. The key is stored in cleartext and any user with access to the workstation can decrypt the credentials. Let’s see another tool and analyze how the credentials are saved.</p><h3>MobaXterm</h3><p>MobaXTerm is a powerful tool used to connect to remote machines using various protocols such as SSH, Telnet, RDP, FTP and so on. A user who wants to save credentials within MobaXTerm will be asked to create a Master Password to protect their sensitive data.</p><p>The default option is that MobaXTerm will ask to enter this Master Password only on a new computer:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yDjfs7HopxSaUjuY" /></figure><p>That means that the Master Password is saved somewhere, and MobaXTerm will retrieve it to access the credentials saved encrypted. We used Procmon from the Sysinternals Suite to map all the registry key and files accessed by MobaXTerm, and we found that the Master Password is saved in the following registry entry:</p><p>Computer\HKEY_CURRENT_USER\SOFTWARE\Mobatek\MobaXterm\M</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HhKf5X2i-78YbfAn" /></figure><p>Credentials and Passwords are saved in the C and P registry keys respectively, while the M registry key contains the Master Password.</p><p>The Master Password seems to be encrypted using DPAPI, but we failed to decrypt it.</p><p>After decoding it with base64, and comparing it with a standard encrypted password with DPAPI, we understood that the first twenty DPAPI bytes, which are always the same, were removed.</p><p>You can see below, the first line is a cipher that we have encrypted using DPAPI and the second line is the encrypted value found in the registry.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*J_YPvQ8N4iMxJOY7" /></figure><p>After shifting it to the right, we can see that the bytes are identical. Effectively, encrypted data with DPAPI consistently has first constant ~60 bytes metadata.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xhVcu39oCNLghwyJ" /></figure><p>We added the first twenty bytes, and we succeeded in decrypting the DPAPI cipher, and it corresponds to the SHA512 hash of the Master Password. This hash is used to encrypt and decrypt credentials.</p><p>We wrote a tool that can decrypt the saved credentials using the methods described above:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/0*vLq_9xr-vMBN6-N0" /></figure><p>Here, the encryption key used to securely store the credentials is saved using DPAPI. That means that only the user who saved the credentials can access them. However, a user with administrator access, or an attacker who gains access to the victim’s session can also decrypt the credentials stored on the machine.</p><h3>Open Source Tool</h3><p>All the tools used above are available in open source on our <a href="https://github.com/XMCyber/XMCredentialsDecryptor">Github</a> repo. Just run it and you will get all the credentials saved in cleartext.<br>Keep updated with the tool — we’ll be adding more capabilities in the future!</p><p><a href="https://github.com/XMCyber/XMCredentialsDecryptor">https://github.com/XMCyber/XMCredentialsDecryptor</a></p><h3>Summary</h3><p>Developers, DevOps and IT use various tools to connect to remote machines and manage these access details. Vendors have to store this sensitive information in the most secure way. However, encryption is always on the client side, and an attacker can replicate the tool behavior in order to decrypt the credentials.</p><p>References:</p><p><a href="https://docs.microsoft.com/en-us/sysinternals/">https://docs.microsoft.com/en-us/sysinternals/</a></p><p><a href="https://github.com/AlessandroZ/LaZagne">https://github.com/AlessandroZ/LaZagne</a></p><p><a href="https://medium.com/xm-cyber/decrypting-vmware-workstation-passwords-for-fun-f34284c5b9cd">https://medium.com/xm-cyber/decrypting-vmware-workstation-passwords-for-fun-f34284c5b9cd</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ceb83e7304ce" width="1" height="1" alt=""><hr><p><a href="https://medium.com/xm-cyber/extracting-encrypted-credentials-from-common-tools-ceb83e7304ce">Extracting Encrypted Credentials from Common Tools</a> was originally published in <a href="https://medium.com/xm-cyber">XM Cyber</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Decrypting VMware Workstation Passwords for Fun]]></title>
            <link>https://medium.com/xm-cyber/decrypting-vmware-workstation-passwords-for-fun-f34284c5b9cd?source=rss-9f5c81cd8e81------2</link>
            <guid isPermaLink="false">https://medium.com/p/f34284c5b9cd</guid>
            <dc:creator><![CDATA[Azria David]]></dc:creator>
            <pubDate>Mon, 23 May 2022 12:53:08 GMT</pubDate>
            <atom:updated>2022-05-23T12:53:08.646Z</atom:updated>
            <content:encoded><![CDATA[<p>Written by <a href="https://medium.com/@azria.david">David Azria</a> &amp; <a href="https://medium.com/@zurulianitzky">Zur Ulianitzky</a> — May 23,2022</p><h3>Overview</h3><p>At XM Cyber, we have been hard at work on the techniques that attackers use against your VMware environments. What you’re about to read is the fruit of our ongoing research.</p><p>You might think that your VMware passwords are safe. But to an experienced hacker, even these are up for grabs.</p><p>When you connect to an ESXi or Vsphere server from your VMware Workstation, you have the option to save the connection details on the computer, including the password. On your next connection to the server, you won’t have to enter the credentials again.</p><p>A classic “remember me” feature.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/0*4oQ3mKM3892lMkZ4" /></figure><p>Using reverse-engineering methods, we analyzed the decryption flow and found that we can decrypt the saved VMware credentials on our own. And if we can do it, there are experienced hackers that can do the same.</p><p>In this blog, we’ll show you how the hacker steals your VMware credentials, step by step. At the end, we’ll present to you the tool that we created that does exactly this, to make red teamers’ lives easier.</p><p>Let’s jump into the research.</p><h3>Decryption flow</h3><p>We started the research by supposing that the credentials are saved locally, within a file or a registry key. In order to find exactly where, we used Procmon from the SysInternals tools.</p><p>We can see that when we add or remove credentials through the Workstation, the following files are being accessed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*M3dM_E0X9LmU09aD" /></figure><p>Let’s take a look at these two files:</p><ul><li><em>%AppData%\VMware\preferences-private.ini</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/0*_6rCpq1HexNo0Jjg" /></figure><ul><li><em>%AppData%\VMware\ace.dat</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/0*g2sTNOh3-slcHvVs" /></figure><p>The files seem to be encrypted. So we need to understand how, and to decrypt them. We will start with the preferences-private.ini file.</p><h3>preferences-private.ini</h3><p>The file contains the properties: .encoding, encryption.userKey, encryption.keySafe, encryption.data</p><p>The encryption.userKey value is encrypted with Data Protection API (DPAPI), recognizable with the first constant ~60 bytes metadata.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/0*yQliIi6SQRByoLjY" /></figure><p>DPAPI allows to encrypt data using information from the current user. Thus, only the user that performs the encryption can decrypt the data.</p><p>Let’s write a simple .Net application that uses the Unprotect function and try to decrypt the data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*63WRpH0-XgtmMZOG" /></figure><p>We execute the application and get the decrypted data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/0*O1fR8ZzNy4RKwA2j" /></figure><p>We got an encryption algorithm type, AES-256 — and we also got a key. Let’s call it KEY_1.</p><p>We now need to decrypt the values of the other properties found in the preferences-private.ini file, which are encryption.keySafe and encryption.data. To do that we need to know, for each of the properties, the algorithm used, the Initialization Vector (IV), and the secret key.</p><p>To find these unknowns, we will use static and dynamic reverse engineering analysis techniques. Looking at the call stack in Procmon shows us which DLL files and functions required the access to the encrypted files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ra-u3XmWieDiZZ_N" /></figure><p>In the vmwarebase.dll file, we find a call to the <a href="https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptdecrypt">BCryptDecrypt</a> function, a WinAPI function used to decrypt data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gDcGPd2QSGl-XXjs" /></figure><p>Right before the function call, we can see the IV, as well as the encrypted data sent to the function and the decrypted data returned, pushed to the stack. Looking at the MSDN documentation tells us that the last parameter sent to the function, hKey, is a handle of the key used to decrypt the data. This handle is obtained from the <a href="https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgeneratesymmetrickey">BCryptGenerateSymmetricKey</a> key creation function:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/0*w1QPzwPMypK0FMsl" /></figure><p>The pbSecret parameter contains the key (after base64 decoding) used for the encryption and decryption process.</p><p>Dynamic analysis should help us get the actual IV and secret key values, and to understand the full decryption flow. Let’s debug vmware.exe with WinDBG, sync the address base image with IDA, insert breakpoints, and analyze the flow.</p><p>We insert a breakpoint on the BCryptGenerateSymmetricKey function call, and then we display the content of the fifth parameter on the stack, pbSecret, which is the secret key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/0*bzVYJ-blBYhwTLmt" /></figure><p>After base64 encoding, we get:</p><p>mXhLLOJnBFo0tNr7PVAxuzmaxwOsWsR/i0k8RAJf9cs=</p><p>This is our KEY_1, obtained from the DPAPI decryption above.</p><p>Now we insert a breakpoint on the BCryptDecrypt function call, and then we will see which payload is decrypted with this key and which IV is used:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/0*jRy82wX-jXPf5VYh" /></figure><p>The second parameter on the stack is the encrypted payload and the fifth is the IV:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/0*UQElM1F7ErQBNk7T" /></figure><p>After base64 encoding, we can see that this data corresponds to the encryption.keySafe value from the preferences-private.ini file. The first 16 bytes are the IV, and the rest is the encrypted data.</p><p>The decryption result is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/0*MpbZSVqDdgrtgm32" /></figure><p>In brief, KEY_1 is used to decrypt the encryption.keySafe value, and the decrypted value is another secret key, which we’ll call KEY_2:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/0*4yIwYX5XXALtVf-D" /></figure><p>Moving forward, we can use the same method, debugging calls to the BCryptDecrypt function, in order to complete our understanding of the decryption flow.</p><p>Using KEY_2, we’re able to decrypt the encryption.data property. Again, the first 16 bytes are the IV, and with the AES-256 algorithm, the decrypted value is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/0*imj1spcy0KM-zj5f" /></figure><p>Good, we succeeded in decrypting the configuration, and we have the hostname and username. But… the password is still encrypted. What is the decryption key for the password?</p><p>For that, we’ll move on to the second file saved by the Workstation, ace.dat.</p><h3>ace.dat</h3><p>Here is the content of the file:</p><p><em>%AppData%\VMware\ace.dat</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/0*tIkerq7n53maiGUe" /></figure><p>You can see that the data value is encrypted. We’ll call it DATA_1.</p><p>Tracing the stack call to the BCryptGenerateSymmetricKey function takes us to a hardcoded key in the vmwarebase.dll file. This key is used to decrypt the ace.dat file content:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/0*A7BAyv08560eGdBF" /></figure><p>Let’s use it and decrypt the DATA_1 value. Here is the decrypted data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/0*jVLoOeHGOSDZaqhI" /></figure><p>The data contains a key derivation function, PBKDF2-HMAC-SHA-1, a salt, and an encrypted data value, which we’ll call DATA_2.</p><p>The PBKDF2 algorithm is used to generate a key based on a secret value and a salt. The secret value is hardcoded in the vmwarebase.dll file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/0*ILsBk5XC1CQCwfwQ" /></figure><p>Let’s generate the key and call it KEY_3:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ga01St4zJTvdy08R" /></figure><p>Using KEY_3, we’ll decrypt the DATA_2 value.</p><p>Here is the decrypted data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/0*g9KHsSuP2d61LL-O" /></figure><p>And we get another key. Using this key, we decrypt the passwords from the configuration decrypted above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/0*JB7njxSbFHMIe1zG" /></figure><p>The IV used is the first 16 bytes of the encrypted password.</p><p>Finally, here’s the password in clear text!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/155/0*KGjaaegcx-Ye0_G_" /></figure><h3>Open source tool</h3><p><a href="https://github.com/XMCyber/VmwarePasswordDecryptor">https://github.com/XMCyber/VmwarePasswordDecryptor</a></p><p>The above decryption flow is quite long and complex, so we also wrote a tool that will do the job. Just run it and it will decrypt the VMware Workstation configuration file, including the password.</p><p>It can also verify that the extracted credentials are valid by trying to connect to the server.</p><p>Enjoy!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f34284c5b9cd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/xm-cyber/decrypting-vmware-workstation-passwords-for-fun-f34284c5b9cd">Decrypting VMware Workstation Passwords for Fun</a> was originally published in <a href="https://medium.com/xm-cyber">XM Cyber</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>