<?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>Forensicxs &#8211; @Forensicxs</title>
	<atom:link href="https://www.forensicxs.com/author/admin3971/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.forensicxs.com</link>
	<description>Ethical Hacking &#124; Cybersecurity</description>
	<lastBuildDate>Sun, 20 Oct 2024 19:56:19 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>Blockchain hacking : Ethernaut</title>
		<link>https://www.forensicxs.com/blockchain-hacking-ethernaut/</link>
					<comments>https://www.forensicxs.com/blockchain-hacking-ethernaut/#respond</comments>
		
		<dc:creator><![CDATA[Forensicxs]]></dc:creator>
		<pubDate>Sun, 20 Oct 2024 16:19:06 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[blockchain hacking]]></category>
		<category><![CDATA[ethereum]]></category>
		<category><![CDATA[ethernaut]]></category>
		<category><![CDATA[OpenZeppelin]]></category>
		<guid isPermaLink="false">https://www.forensicxs.com/?p=2922</guid>

					<description><![CDATA[In this article, I propose a few solutions to the Ethernaut challenge : https://ethernaut.openzeppelin.com/. I will release more solutions progressively It is an initiative from OpenZeppelin, which is a well known library for secure smart contract development. It proposes Ethereum based, open source challenges, written by several contributors There are already several solutions available. My &#8230; <p class="link-more"><a href="https://www.forensicxs.com/blockchain-hacking-ethernaut/" class="more-link">Continue reading<span class="screen-reader-text"> "Blockchain hacking : Ethernaut"</span></a></p>]]></description>
										<content:encoded><![CDATA[
<p>In this article, I propose a few solutions to the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Ethernaut</mark></strong> challenge : <a href="https://ethernaut.openzeppelin.com/">https://ethernaut.openzeppelin.com/</a>. I will release more solutions progressively</p>



<figure class="wp-block-image size-large is-resized"><img fetchpriority="high" decoding="async" width="1024" height="544" src="https://www.forensicxs.com/wp-content/uploads/2024/08/Capture-1-1024x544.jpg" alt="" class="wp-image-3262" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/Capture-1-1024x544.jpg 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/Capture-1-300x160.jpg 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/Capture-1-768x408.jpg 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/Capture-1.jpg 1373w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /><figcaption class="wp-element-caption">Run the challenge at : <a href="https://ethernaut.openzeppelin.com/">https://ethernaut.openzeppelin.com/</a></figcaption></figure>



<p>It is an initiative from <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">OpenZeppelin</mark></strong>, which is a well known <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">library</mark></strong> for secure smart contract development. It proposes <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Ethereum</mark></strong> based, open source challenges, written by several contributors</p>



<p>There are already several solutions available. My goal in this article is to provide a step by step walkthrough, that should help the most beginners among us. Please note that I have done the challenge using <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Google Chrome</mark></strong></p>



<p>Before starting, it is usefull to have an overview about the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Web3</mark></strong> process, in comparison to the usual Web2, as it will help understand why we use <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Javascript</mark></strong>, <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Metamask</mark></strong>, <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Solidity</mark></strong> and other such features</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="734" height="493" src="https://www.forensicxs.com/wp-content/uploads/2022/07/image-8.png" alt="" class="wp-image-2937" style="width:598px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2022/07/image-8.png 734w, https://www.forensicxs.com/wp-content/uploads/2022/07/image-8-300x201.png 300w" sizes="(max-width: 734px) 100vw, 734px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/3PphGCC" target="_blank" rel="noreferrer noopener">https://bit.ly/3PphGCC</a></figcaption></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">Level 0 : Hello Ethernaut</mark></strong></p>



<p>In this chapter, which is an introduction, we will set up MetaMask, get test Ether, and start our first interactions with the smart contract</p>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">Set up MetaMask</mark></strong></p>



<p>First of all, we need to install the Metamask browser extension : <a href="https://metamask.io/" target="_blank" rel="noreferrer noopener">https://metamask.io/</a>, and then create a password and a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">wallet key</mark></strong>. We need to select the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Sepolia test network</mark></strong>, which we will use for our hacking scenarios</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="330" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-87-1024x330.png" alt="" class="wp-image-3263" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-87-1024x330.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-87-300x97.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-87-768x247.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-87.png 1174w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">Open the browser&#8217;s console</mark></strong></p>



<p>The modern browsers provide hands-on tools for the web developers, such as the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">console</mark></strong>, in which one can input &#8220;live&#8221; Javascript instructions, check the data in memory, explore available functions and variables</p>



<p>In the Ethernaut browser session, let&#8217;s go in Tools -&gt; Developer tools (or just press F12). In the console view, we find the following informations</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="132" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-89-1024x132.png" alt="" class="wp-image-3265" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-89-1024x132.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-89-300x39.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-89-768x99.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-89.png 1123w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>You may get some errors, so please make sure to solve them before continuing. If needed, you may check the following actions :</p>



<ul class="wp-block-list">
<li>use Chrome</li>



<li>install Metamask after you reached the challenge page</li>



<li>select the Sepolia test network</li>



<li>refresh the page as per the need</li>
</ul>



<p>We get an Ethernaut address : <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">0xa3e7317E591D5A0F1c605be1b3aC4D2ae56104d6</mark></strong></p>



<p>My player number is : <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">0xe62f9927b2198669b5988993E52d3093854898b0</mark></strong>. In fact, this is my Metamask public address</p>



<p>You can check mine here in Etherscan, the well known ethereum blockchain explorer : <a rel="noreferrer noopener" href="https://bit.ly/3aP37JO" target="_blank">https://bit.ly/3aP37JO</a>. It corresponds, in my specific case, to the Ethereum Name Service &#8220;forensicxs.eth&#8221;</p>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">Level 0 : Hello Ethernaut</mark></strong></p>



<p>We click on the level &#8220;00&#8221; box</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="608" height="493" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-90.png" alt="" class="wp-image-3266" style="width:340px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-90.png 608w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-90-300x243.png 300w" sizes="(max-width: 608px) 100vw, 608px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">Use the console helpers</mark></strong></p>



<p>We are invited to type the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">help()</mark></strong> command in the console. Here is the output :</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="306" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-91-1024x306.png" alt="" class="wp-image-3267" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-91-1024x306.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-91-300x90.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-91-768x229.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-91.png 1078w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>We can check the balance of our account, with the function <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">getBalance(address)</mark></strong>. We need to input our actual address</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="509" height="83" src="https://www.forensicxs.com/wp-content/uploads/2022/07/image-6.png" alt="" class="wp-image-2934" style="width:424px;height:69px" srcset="https://www.forensicxs.com/wp-content/uploads/2022/07/image-6.png 509w, https://www.forensicxs.com/wp-content/uploads/2022/07/image-6-300x49.png 300w" sizes="(max-width: 509px) 100vw, 509px" /></figure>



<p>We see that the &#8220;Promise&#8221; has been fulfilled, and that our <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">balance is at zero</mark></strong>, as expected. You can find informations about Promises here : <a rel="noreferrer noopener" href="https://javascript.info/promise-basics" target="_blank">https://javascript.info/promise-basics</a></p>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">The ethernaut contract</mark></strong></p>



<p>Let&#8217;s look into the smart contrat. The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">ethernaut</mark></strong> command provides a lot of informations about the contract itself</p>



<figure class="wp-block-image size-full"><img decoding="async" width="1021" height="466" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-92.png" alt="" class="wp-image-3269" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-92.png 1021w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-92-300x137.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-92-768x351.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>We can see the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">public methods</mark></strong> available, such as <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">owner</mark></strong></p>



<p>We can see that the smart contract has an abi connector at the following address : <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">0xa3e7317E591D5A0F1c605be1b3aC4D2ae56104d6</mark></strong></p>



<p>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">abi, or Application Binary Interface</mark></strong>, gives a contract the ability to communicate and interact with external applications and other smart contracts. Here is the overall mechanism</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="586" height="342" src="https://www.forensicxs.com/wp-content/uploads/2022/07/image-9.png" alt="" class="wp-image-2938" srcset="https://www.forensicxs.com/wp-content/uploads/2022/07/image-9.png 586w, https://www.forensicxs.com/wp-content/uploads/2022/07/image-9-300x175.png 300w" sizes="(max-width: 586px) 100vw, 586px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/3zkRymT" target="_blank" rel="noreferrer noopener">https://bit.ly/3zkRymT</a></figcaption></figure>



<p>Here we are more interested in reading contracts FROM the Ethereum blockchain, but you can check the following link to get an overview how to <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">deploy a contrat</mark></strong> TO the blockchain : <a rel="noreferrer noopener" href="https://bit.ly/3OlkD5V" target="_blank">https://bit.ly/3OlkD5V</a></p>



<p>If we try to check the ethernaut owner, the query to the blockchain will need some <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">gas</mark></strong> to be able to run. In my case, the Metamask wallet balance is not sufficient, so I get an error message</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="776" height="322" src="https://www.forensicxs.com/wp-content/uploads/2022/07/image-10.png" alt="" class="wp-image-2939" style="width:405px;height:168px" srcset="https://www.forensicxs.com/wp-content/uploads/2022/07/image-10.png 776w, https://www.forensicxs.com/wp-content/uploads/2022/07/image-10-300x124.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/07/image-10-768x319.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">Get test ether</mark></strong></p>



<p>You can request test Ether with a Google account : <a href="https://tinyurl.com/5xe8r23z">https://tinyurl.com/5xe8r23z</a></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="975" height="415" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-88.png" alt="" class="wp-image-3264" style="width:551px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-88.png 975w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-88-300x128.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-88-768x327.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>This method is limited to 0.05 ETH per day, so it&#8217;s not quite enough to get started with the Ethernaut challenge</p>



<p>You can get more token on <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Alchemy</mark></strong> (requires a login and a small amount of real ETH on your metamask wallet)</p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" width="1024" height="529" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-93-1024x529.png" alt="" class="wp-image-3270" style="width:480px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-93-1024x529.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-93-300x155.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-93-768x397.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-93.png 1159w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /><figcaption class="wp-element-caption"><a href="https://www.alchemy.com/faucets/ethereum-sepolia">https://www.alchemy.com/faucets/ethereum-sepolia</a></figcaption></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">Getting a level instance</mark></strong></p>



<p>As indicated by the guide, let&#8217;s request our level instance, by pressing the &#8220;Get new instance&#8221; button. We are prompted by Metamask to authorize the transaction. In my case, the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">gas fee</mark></strong> to pay is 0.0228 Sepolia ETH (= test ETH)</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="338" height="574" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-94.png" alt="" class="wp-image-3271" style="width:282px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-94.png 338w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-94-177x300.png 177w" sizes="(max-width: 338px) 100vw, 338px" /></figure>



<p>The transaction is duly handled, and my instance is created, with a smart contract at the address <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">0x3A99561FA3026041B8647bdae4E7339c2Ebc45E9</mark></strong></p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="189" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-95-1024x189.png" alt="" class="wp-image-3272" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-95-1024x189.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-95-300x55.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-95-768x142.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-95.png 1077w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">Inspecting the contract</mark></strong></p>



<p>Let&#8217;s inspect briefly this contract instanciation, using the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">contract</mark></strong> command</p>



<figure class="wp-block-image size-full"><img decoding="async" width="1024" height="452" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-97.png" alt="" class="wp-image-3275" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-97.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-97-300x132.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-97-768x339.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>We have access to several <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">public functions</mark></strong>, including several ones that look interesting : info, info1, info2, info42, password. Let&#8217;s try to find additional informations about these functions</p>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">Interact with the contract to complete the level</mark></strong></p>



<p>In this paragraph, we take advantage of Solidity being an <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">OOP language</mark></strong> (object oriented programming), so that we can get informations about the functions by calling them, with their respective methods and arguments</p>



<p>Let&#8217;s run the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">contract.info()</mark></strong> command. We find a valuable text information &#8220;You will find what you need in info()&#8221;</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="546" height="230" src="https://www.forensicxs.com/wp-content/uploads/2022/07/image-21.png" alt="" class="wp-image-2952" style="width:385px;height:162px" srcset="https://www.forensicxs.com/wp-content/uploads/2022/07/image-21.png 546w, https://www.forensicxs.com/wp-content/uploads/2022/07/image-21-300x126.png 300w" sizes="(max-width: 546px) 100vw, 546px" /></figure>



<p>We continue with the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">contract.info1()</mark></strong> command. We find another text information &#8220;Try info2(), but with \&#8221;hello\&#8221; as a parameter.&#8221;</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="523" height="229" src="https://www.forensicxs.com/wp-content/uploads/2022/07/image-20.png" alt="" class="wp-image-2951" style="width:383px;height:168px" srcset="https://www.forensicxs.com/wp-content/uploads/2022/07/image-20.png 523w, https://www.forensicxs.com/wp-content/uploads/2022/07/image-20-300x131.png 300w" sizes="(max-width: 523px) 100vw, 523px" /></figure>



<p>Therefore, we continue with the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">contract.info2(&#8220;hello&#8221;)</mark></strong> command. </p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="693" height="229" src="https://www.forensicxs.com/wp-content/uploads/2022/07/image-22.png" alt="" class="wp-image-2953" style="width:475px;height:156px" srcset="https://www.forensicxs.com/wp-content/uploads/2022/07/image-22.png 693w, https://www.forensicxs.com/wp-content/uploads/2022/07/image-22-300x99.png 300w" sizes="(max-width: 693px) 100vw, 693px" /></figure>



<p>You get the idea. We have to follow a chain of information&#8230;let&#8217;s continue with the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">infoNum()</mark></strong> method. We see in the PromiseResult, the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">word 42</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="456" height="375" src="https://www.forensicxs.com/wp-content/uploads/2022/07/image-23.png" alt="" class="wp-image-2954" style="width:344px;height:283px" srcset="https://www.forensicxs.com/wp-content/uploads/2022/07/image-23.png 456w, https://www.forensicxs.com/wp-content/uploads/2022/07/image-23-300x247.png 300w" sizes="(max-width: 456px) 100vw, 456px" /></figure>



<p>Let&#8217;s look for <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">contract.info42()</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="535" height="230" src="https://www.forensicxs.com/wp-content/uploads/2022/07/image-24.png" alt="" class="wp-image-2955" style="width:393px;height:169px" srcset="https://www.forensicxs.com/wp-content/uploads/2022/07/image-24.png 535w, https://www.forensicxs.com/wp-content/uploads/2022/07/image-24-300x129.png 300w" sizes="(max-width: 535px) 100vw, 535px" /></figure>



<p>We have to look for &#8220;theMethodeName&#8221; as a method</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="506" height="229" src="https://www.forensicxs.com/wp-content/uploads/2022/07/image-25.png" alt="" class="wp-image-2956" style="width:403px;height:182px" srcset="https://www.forensicxs.com/wp-content/uploads/2022/07/image-25.png 506w, https://www.forensicxs.com/wp-content/uploads/2022/07/image-25-300x136.png 300w" sizes="(max-width: 506px) 100vw, 506px" /></figure>



<p>Let&#8217;s look into <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">contract.method7123949</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="546" height="229" src="https://www.forensicxs.com/wp-content/uploads/2022/07/image-26.png" alt="" class="wp-image-2957" style="width:415px;height:174px" srcset="https://www.forensicxs.com/wp-content/uploads/2022/07/image-26.png 546w, https://www.forensicxs.com/wp-content/uploads/2022/07/image-26-300x126.png 300w" sizes="(max-width: 546px) 100vw, 546px" /></figure>



<p>We are invited to find the password. We have noticed the function &#8220;password&#8221; in the contract. Let&#8217;s check it in <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">contract.password()</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="446" height="230" src="https://www.forensicxs.com/wp-content/uploads/2022/07/image-27.png" alt="" class="wp-image-2958" style="width:371px;height:191px" srcset="https://www.forensicxs.com/wp-content/uploads/2022/07/image-27.png 446w, https://www.forensicxs.com/wp-content/uploads/2022/07/image-27-300x155.png 300w" sizes="(max-width: 446px) 100vw, 446px" /></figure>



<p>We get the password &#8220;<strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">ethernaut0</mark></strong>&#8220;. Now, we can authenticate. We are prompted to accept the transaction by Metamask, a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">gas fee</mark></strong> of 0.023 Sepolia ETH is applied</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="326" height="489" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-98.png" alt="" class="wp-image-3276" style="width:240px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-98.png 326w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-98-200x300.png 200w" sizes="(max-width: 326px) 100vw, 326px" /></figure>



<p>The transaction is successfull, we can check it on <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Etherscan</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="985" height="620" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-99.png" alt="" class="wp-image-3277" style="width:566px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-99.png 985w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-99-300x189.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-99-768x483.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>To complete the level, you need to press &#8220;<strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">submit instance</mark></strong>&#8220;. Metamask prompts you to accept again the transaction as the blockchain consumes gas for any request</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="337" height="464" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-100.png" alt="" class="wp-image-3278" style="width:263px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-100.png 337w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-100-218x300.png 218w" sizes="(max-width: 337px) 100vw, 337px" /></figure>



<p>Our transaction is approved, we get a very graphic confirmation <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" width="1024" height="564" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-101-1024x564.png" alt="" class="wp-image-3279" style="width:558px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-101-1024x564.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-101-300x165.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-101-768x423.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-101.png 1062w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>We get a notification on the Ethernaut <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">website</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="766" height="252" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-102.png" alt="" class="wp-image-3280" style="width:521px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-102.png 766w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-102-300x99.png 300w" sizes="(max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px" /></figure>



<p>Just below, OpenZeppelin provides the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">contract code</mark></strong> we just interacted with, where we can confirm the steps and logic we just followed above</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="493" height="886" src="https://www.forensicxs.com/wp-content/uploads/2022/07/image-34.png" alt="" class="wp-image-2965" style="width:381px;height:684px" srcset="https://www.forensicxs.com/wp-content/uploads/2022/07/image-34.png 493w, https://www.forensicxs.com/wp-content/uploads/2022/07/image-34-167x300.png 167w" sizes="(max-width: 493px) 100vw, 493px" /></figure>



<p>This level is finished, let&#8217;s move to the next one</p>



<p>From now on, we will come closer to a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">realistic hacking</mark></strong> environment</p>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">Level 1 : Fallback</mark></strong></p>



<p>We are requested to inpect a smart contract code (here below), take ownership of it, and withdraw the available balance </p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="760" height="716" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-103.png" alt="" class="wp-image-3284" style="width:487px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-103.png 760w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-103-300x283.png 300w" sizes="(max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px" /></figure>



<p>In Solidity, a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">fallback</mark></strong> function does not take arguments and does not return any value. But a fallback function can receive ether and therefore be &#8220;payable&#8221;</p>



<p>Let&#8217;s get the instance of the contract by clicking &#8220;Get new instance&#8221;. We need to pay some gas</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="341" height="468" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-104.png" alt="" class="wp-image-3285" style="width:239px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-104.png 341w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-104-219x300.png 219w" sizes="(max-width: 341px) 100vw, 341px" /></figure>



<p>Our instance address is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">0xB386A21D3aAe67a9dAe0144aF2226b86c8EB6960</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="548" height="44" src="https://www.forensicxs.com/wp-content/uploads/2024/09/image-4.png" alt="" class="wp-image-3305" style="width:482px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/09/image-4.png 548w, https://www.forensicxs.com/wp-content/uploads/2024/09/image-4-300x24.png 300w" sizes="(max-width: 548px) 100vw, 548px" /></figure>



<p>We can analyse the contract code. The first <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">flaw</mark></strong> is in this code, as anyone can :</p>



<ul class="wp-block-list">
<li>call this function</li>



<li>send Ether</li>



<li>if the contribution gets higher than the one of the contract owner, take ownership of the contract</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="418" height="137" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-106.png" alt="" class="wp-image-3287" style="width:337px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-106.png 418w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-106-300x98.png 300w" sizes="(max-width: 418px) 100vw, 418px" /></figure>



<p>Then, the &#8220;owner&#8221; can withdraw the funds </p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="395" height="65" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-107.png" alt="" class="wp-image-3289" style="width:340px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-107.png 395w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-107-300x49.png 300w" sizes="(max-width: 395px) 100vw, 395px" /></figure>



<p>Therefore, the fallback contract allows users to contribute small amounts of Ether, and the maximum contributor becomes the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">owner</mark></strong> of the contract</p>



<p>But to take ownership of the contract, you would need to get more than 1000 ETH, as per the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">constructor</mark></strong>, because the owner has an initial contribution of 1000 ETH</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="412" height="86" src="https://www.forensicxs.com/wp-content/uploads/2024/09/image-6.png" alt="" class="wp-image-3307" style="width:343px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/09/image-6.png 412w, https://www.forensicxs.com/wp-content/uploads/2024/09/image-6-300x63.png 300w" sizes="(max-width: 412px) 100vw, 412px" /></figure>



<p>Fortunately for us, there is a second <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">flaw</mark></strong> to take ownership of the contract, whereby any sender can become the owner if :</p>



<ul class="wp-block-list">
<li>he sends a positive value of Ether (<strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">msg.value &gt; 0</mark></strong>)</li>



<li>he has already contributed (<strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">contributions[msg.sender] &gt; 0</mark></strong>)</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="453" height="85" src="https://www.forensicxs.com/wp-content/uploads/2024/09/image-7.png" alt="" class="wp-image-3308" style="width:354px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/09/image-7.png 453w, https://www.forensicxs.com/wp-content/uploads/2024/09/image-7-300x56.png 300w" sizes="(max-width: 453px) 100vw, 453px" /></figure>



<p>We can deposit Ether on the contract by using the necessary <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">arguments</mark></strong> of the function <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">contract.contribute()</mark></strong></p>



<p>We have to deposit less than 0.001 ETH, so we can choose 0.0009 ETH, just a decimal below. The help() function provides us some guidance about the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">method</mark></strong> to use, to send our transaction to the contract</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="756" height="21" src="https://www.forensicxs.com/wp-content/uploads/2024/09/image-2.png" alt="" class="wp-image-3300" style="width:735px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/09/image-2.png 756w, https://www.forensicxs.com/wp-content/uploads/2024/09/image-2-300x8.png 300w" sizes="(max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px" /></figure>



<p>We also need to send our transaction in <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Wei</mark></strong> (see here a converter, for information -&gt; <a href="https://eth-converter.com/">https://eth-converter.com/</a>), as generally required by smart contracts</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="811" height="22" src="https://www.forensicxs.com/wp-content/uploads/2024/09/image-3.png" alt="" class="wp-image-3301" style="width:737px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/09/image-3.png 811w, https://www.forensicxs.com/wp-content/uploads/2024/09/image-3-300x8.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/09/image-3-768x21.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>So in summary, the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">arguments</mark></strong> to provide to the contract.contribute() function are :</p>



<ul class="wp-block-list">
<li>from : our address is given automatically by our player address </li>



<li>value : the value of our deposit in Wei</li>
</ul>



<p>Here is the full transaction. It gets <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">fullfilled</mark></strong>, after we paid some smart contract gas fee</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="742" height="262" src="https://www.forensicxs.com/wp-content/uploads/2024/09/image-1.png" alt="" class="wp-image-3299" style="width:531px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/09/image-1.png 742w, https://www.forensicxs.com/wp-content/uploads/2024/09/image-1-300x106.png 300w" sizes="(max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px" /></figure>



<p>We can check our ether balance with the function <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">getBalance</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="440" height="103" src="https://www.forensicxs.com/wp-content/uploads/2024/09/image-5.png" alt="" class="wp-image-3306" style="width:327px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/09/image-5.png 440w, https://www.forensicxs.com/wp-content/uploads/2024/09/image-5-300x70.png 300w" sizes="(max-width: 440px) 100vw, 440px" /></figure>



<p>Then, as we have already contributed to the contract, we can take <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">ownership</mark></strong> by sending a positive deposit</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="661" height="187" src="https://www.forensicxs.com/wp-content/uploads/2024/09/image-8.png" alt="" class="wp-image-3309" style="width:481px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/09/image-8.png 661w, https://www.forensicxs.com/wp-content/uploads/2024/09/image-8-300x85.png 300w" sizes="(max-width: 661px) 100vw, 661px" /></figure>



<p>We can check the contract owner. This is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">my player</mark></strong> address, so I have claimed ownership</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="570" height="259" src="https://www.forensicxs.com/wp-content/uploads/2024/09/image-9.png" alt="" class="wp-image-3310" style="width:402px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/09/image-9.png 570w, https://www.forensicxs.com/wp-content/uploads/2024/09/image-9-300x136.png 300w" sizes="(max-width: 570px) 100vw, 570px" /></figure>



<p>Then we can drain the funds with the function <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">contract.withdraw()</mark></strong></p>



<p>We need to press the &#8220;<strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">submit instance</mark></strong>&#8221; button to validate this level. We get to this screen, we can press the &#8220;Go to the next level&#8221; button</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="703" height="567" src="https://www.forensicxs.com/wp-content/uploads/2024/09/image-10.png" alt="" class="wp-image-3311" style="width:402px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/09/image-10.png 703w, https://www.forensicxs.com/wp-content/uploads/2024/09/image-10-300x242.png 300w" sizes="(max-width: 703px) 100vw, 703px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">Level 2 : Fallout</mark></strong></p>



<p>The full smart contract code is below</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="763" height="737" src="https://www.forensicxs.com/wp-content/uploads/2024/09/image-14.png" alt="" class="wp-image-3320" style="width:508px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/09/image-14.png 763w, https://www.forensicxs.com/wp-content/uploads/2024/09/image-14-300x290.png 300w" sizes="(max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px" /></figure>



<p>To start with a quick analysis, I notice that the contract owner has a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">null value</mark></strong>, which is the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">default</mark></strong> address</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="543" height="259" src="https://www.forensicxs.com/wp-content/uploads/2024/09/image-11.png" alt="" class="wp-image-3314" style="width:372px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/09/image-11.png 543w, https://www.forensicxs.com/wp-content/uploads/2024/09/image-11-300x143.png 300w" sizes="(max-width: 543px) 100vw, 543px" /></figure>



<p>At the same time, this address has a huge amount of <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">ETH</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="497" height="101" src="https://www.forensicxs.com/wp-content/uploads/2024/09/image-12.png" alt="" class="wp-image-3316" style="width:374px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/09/image-12.png 497w, https://www.forensicxs.com/wp-content/uploads/2024/09/image-12-300x61.png 300w" sizes="(max-width: 497px) 100vw, 497px" /></figure>



<p>I notice also a discrepancy between the contract name <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Fallout</mark></strong> and the constructor <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Fal1out</mark></strong>, which means that the owner is not initiated properly (leading to the owner being the null address)</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="451" height="208" src="https://www.forensicxs.com/wp-content/uploads/2024/09/image-13.png" alt="" class="wp-image-3318" style="width:379px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/09/image-13.png 451w, https://www.forensicxs.com/wp-content/uploads/2024/09/image-13-300x138.png 300w" sizes="(max-width: 451px) 100vw, 451px" /></figure>



<p>So anyone can claim ownership of the contract. I just call the contract with <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">contract.Fal1out()</mark></strong> and here we go !</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="522" height="223" src="https://www.forensicxs.com/wp-content/uploads/2024/09/image-17.png" alt="" class="wp-image-3326" style="width:388px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/09/image-17.png 522w, https://www.forensicxs.com/wp-content/uploads/2024/09/image-17-300x128.png 300w" sizes="(max-width: 522px) 100vw, 522px" /></figure>



<p>We can check that I&#8217;m now the contract owner. The Promise result confirms this is my <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">player</mark></strong> address </p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="581" height="259" src="https://www.forensicxs.com/wp-content/uploads/2024/09/image-16.png" alt="" class="wp-image-3325" style="width:457px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/09/image-16.png 581w, https://www.forensicxs.com/wp-content/uploads/2024/09/image-16-300x134.png 300w" sizes="(max-width: 581px) 100vw, 581px" /></figure>



<p>I submit the instance. Level is completed</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="671" height="568" src="https://www.forensicxs.com/wp-content/uploads/2024/09/image-18.png" alt="" class="wp-image-3327" style="width:460px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/09/image-18.png 671w, https://www.forensicxs.com/wp-content/uploads/2024/09/image-18-300x254.png 300w" sizes="(max-width: 671px) 100vw, 671px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">Level 3 : Coin Flip</mark></strong></p>



<p>As per the description, this is a coin flipping game where we need to guess the outcome of a coin flip. To complete the level we need to guess the correct outcome <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">10 times in a row</mark></strong></p>



<p>The full code is provided here below</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="764" height="610" src="https://www.forensicxs.com/wp-content/uploads/2024/09/image-19.png" alt="" class="wp-image-3328" style="width:562px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/09/image-19.png 764w, https://www.forensicxs.com/wp-content/uploads/2024/09/image-19-300x240.png 300w" sizes="(max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px" /></figure>



<p>This code leverages the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">randomness of the blockchain&#8217;s state</mark></strong> (specifically, the last block&#8217;s hash of Ethereum) to simulate a coin flip</p>



<p>By dividing a large pseudo-random value (the block hash) by a large constant and interpreting the outcome, the contract creates an <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">unpredictable result</mark></strong> for the two possible outcomes of a coin flip (true or false)</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="348" height="68" src="https://www.forensicxs.com/wp-content/uploads/2024/10/image.png" alt="" class="wp-image-3331" style="width:314px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/10/image.png 348w, https://www.forensicxs.com/wp-content/uploads/2024/10/image-300x59.png 300w" sizes="(max-width: 348px) 100vw, 348px" /></figure>



<p>It is usefull to read this article about <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Ethereum</mark></strong>, and get to understand block <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">number</mark></strong>, block <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">hash</mark></strong> : <a href="https://bit.ly/3U878Mu">https://bit.ly/3U878Mu</a></p>



<p>In the code, <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">blockhash</mark></strong> is a global variable that takes block.number and returns the hash of the given block</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="444" height="46" src="https://www.forensicxs.com/wp-content/uploads/2024/10/image-5.png" alt="" class="wp-image-3342" style="width:371px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/10/image-5.png 444w, https://www.forensicxs.com/wp-content/uploads/2024/10/image-5-300x31.png 300w" sizes="(max-width: 444px) 100vw, 444px" /></figure>



<p>block.number -1 returns the block number of the previous block, as the current block is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">not yet mined</mark></strong></p>



<p>On Ethereum, the block hash changes every <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">12 seconds or so</mark></strong>, as shown on this chart</p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" width="1024" height="464" src="https://www.forensicxs.com/wp-content/uploads/2024/10/Capture-1024x464.jpg" alt="" class="wp-image-3334" style="width:612px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/10/Capture-1024x464.jpg 1024w, https://www.forensicxs.com/wp-content/uploads/2024/10/Capture-300x136.jpg 300w, https://www.forensicxs.com/wp-content/uploads/2024/10/Capture-768x348.jpg 768w, https://www.forensicxs.com/wp-content/uploads/2024/10/Capture.jpg 1192w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /><figcaption class="wp-element-caption"><a href="https://ycharts.com/indicators/ethereum_average_block_time">https://ycharts.com/indicators/ethereum_average_block_time</a></figcaption></figure>



<p>It means that within these 12 seconds, the blockhash <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">will not change</mark></strong> and the coinFlip will not be random at all. So we can somehow repeat the flip without any change to the result. However, there&#8217;s a protection against re-using the same blockhash several times, so we need to find another way</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="264" height="67" src="https://www.forensicxs.com/wp-content/uploads/2024/10/image-1.png" alt="" class="wp-image-3336" style="width:210px;height:auto"/></figure>



<p>We need the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">consecutiveWins</mark></strong> to reach 10. At the moment, it is stuck to zero</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="460" height="101" src="https://www.forensicxs.com/wp-content/uploads/2024/10/image-2.png" alt="" class="wp-image-3337" style="width:352px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/10/image-2.png 460w, https://www.forensicxs.com/wp-content/uploads/2024/10/image-2-300x66.png 300w" sizes="(max-width: 460px) 100vw, 460px" /></figure>



<p>We can perform a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Coin flip</mark></strong> by first getting the contract address</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="385" height="48" src="https://www.forensicxs.com/wp-content/uploads/2024/10/image-15.png" alt="" class="wp-image-3358" style="width:352px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/10/image-15.png 385w, https://www.forensicxs.com/wp-content/uploads/2024/10/image-15-300x37.png 300w" sizes="(max-width: 385px) 100vw, 385px" /></figure>



<p>Then we can flip the Coin, but it does not get fulfilled as the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">revert()</mark></strong> function cancels it</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="478" height="246" src="https://www.forensicxs.com/wp-content/uploads/2024/10/image-16.png" alt="" class="wp-image-3359" style="width:356px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/10/image-16.png 478w, https://www.forensicxs.com/wp-content/uploads/2024/10/image-16-300x154.png 300w" sizes="(max-width: 478px) 100vw, 478px" /></figure>



<p>We can use another contract to hack the CoinFlip code, that we are going to call <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">HackCoinFlip</mark></strong></p>



<p>We can <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">guess</mark></strong> the calculation of the hash of the CoinFlip contract, to generate the random number that we know this function is using. We can &#8220;<strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">intercept</mark></strong>&#8221; this result and pass it on to our HackCoinFlip contract. The code of this other contract is below</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="845" height="488" src="https://www.forensicxs.com/wp-content/uploads/2024/10/image-6.png" alt="" class="wp-image-3343" style="width:482px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/10/image-6.png 845w, https://www.forensicxs.com/wp-content/uploads/2024/10/image-6-300x173.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/10/image-6-768x444.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>The contract calls the flip function of the CoinFlip contract with the calculated <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">guess</mark></strong></p>



<p>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">constructor</mark></strong> initializes the coinFlipContract instance with the address of the deployed CoinFlip contract, to intercept the result</p>



<p>The CoinFlip contract’s outcome is determined by the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">block hash</mark></strong> of the last block when it is mined. So, by accessing the same block hash used by the CoinFlip, the HackCoinFlip contract can precisely calculate what the coin flip result will be</p>



<p>Because the hash of the last block is used to generate the random outcome and is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">publicly available</mark></strong> as part of the Ethereum blockchain, this contract can effectively &#8220;guess&#8221; the flip outcome before it happens</p>



<p>We need to deploy our code in our environnement. For that, we are going to use the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Remix IDE</mark></strong> : <a href="https://remix.ethereum.org/">https://remix.ethereum.org/</a></p>



<p>In Remix, we need to copy the code of our two contracts : <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">contract HackCoinFlip</mark></strong>, <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">contract CoinFlip</mark></strong></p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="591" src="https://www.forensicxs.com/wp-content/uploads/2024/10/image-7-1024x591.png" alt="" class="wp-image-3349" srcset="https://www.forensicxs.com/wp-content/uploads/2024/10/image-7-1024x591.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/10/image-7-300x173.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/10/image-7-768x443.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/10/image-7.png 1530w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>Then we can <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">compile</mark></strong> the code, correct any issues (with the help of the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">built-in AI</mark></strong>)</p>



<p>Afterwards, we deploy the code by selecting the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Metamask environnement</mark></strong> and our <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">instance adress 0x2B483868AD9862d8ab1EdE67BC2f3f4A4962C7f9</mark></strong></p>



<p>First, we deploy the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">HackCoinFlip</mark></strong> contract</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="352" height="719" src="https://www.forensicxs.com/wp-content/uploads/2024/10/image-19.png" alt="" class="wp-image-3362" style="width:264px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/10/image-19.png 352w, https://www.forensicxs.com/wp-content/uploads/2024/10/image-19-147x300.png 147w" sizes="(max-width: 352px) 100vw, 352px" /></figure>



<p>By pressing the Deploy button, we need to pay some <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">gas in Metamask</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="428" height="747" src="https://www.forensicxs.com/wp-content/uploads/2024/10/image-11.png" alt="" class="wp-image-3353" style="width:264px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/10/image-11.png 428w, https://www.forensicxs.com/wp-content/uploads/2024/10/image-11-172x300.png 172w" sizes="(max-width: 428px) 100vw, 428px" /></figure>



<p>Then we deploy the CoinFlip contract (we need to pay gas again)</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="348" height="754" src="https://www.forensicxs.com/wp-content/uploads/2024/10/image-18.png" alt="" class="wp-image-3361" style="width:279px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/10/image-18.png 348w, https://www.forensicxs.com/wp-content/uploads/2024/10/image-18-138x300.png 138w" sizes="(max-width: 348px) 100vw, 348px" /></figure>



<p>Then we can use our contracts to &#8220;flip and guess&#8221;. At the beginning, <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">ConsecutiveWins</mark></strong> is set to zero</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="287" height="542" src="https://www.forensicxs.com/wp-content/uploads/2024/10/image-20.png" alt="" class="wp-image-3363" style="width:230px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/10/image-20.png 287w, https://www.forensicxs.com/wp-content/uploads/2024/10/image-20-159x300.png 159w" sizes="(max-width: 287px) 100vw, 287px" /></figure>



<p>We need to execute <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">makeGuess</mark></strong> for 10 times, and check the consecutiveWins counter going to 10</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="289" height="530" src="https://www.forensicxs.com/wp-content/uploads/2024/10/image-21.png" alt="" class="wp-image-3364" style="width:235px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/10/image-21.png 289w, https://www.forensicxs.com/wp-content/uploads/2024/10/image-21-164x300.png 164w" sizes="(max-width: 289px) 100vw, 289px" /></figure>



<p>Then we can press the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Submit instance</mark></strong> button, and we pass the level</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="671" height="568" src="https://www.forensicxs.com/wp-content/uploads/2024/09/image-18.png" alt="" class="wp-image-3327" style="width:460px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/09/image-18.png 671w, https://www.forensicxs.com/wp-content/uploads/2024/09/image-18-300x254.png 300w" sizes="(max-width: 671px) 100vw, 671px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">Lessons learned</mark></strong> : this example highlights the importance of proper <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">random number generation</mark></strong> within smart contracts, as relying on block hashes for randomness can be easily exploited. In production, developers should use reliable sources of randomness, such as <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Oracles</mark></strong> or other decentralized solutions (like <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Chainlink VRF</mark></strong> : <a href="https://chain.link/vrf">https://chain.link/vrf</a>)</p>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.forensicxs.com/blockchain-hacking-ethernaut/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Bitcoin Core v0.1 : a code walkthrough</title>
		<link>https://www.forensicxs.com/bitcoin-core-v0-1-a-code-walkthrough/</link>
					<comments>https://www.forensicxs.com/bitcoin-core-v0-1-a-code-walkthrough/#respond</comments>
		
		<dc:creator><![CDATA[Forensicxs]]></dc:creator>
		<pubDate>Tue, 06 Aug 2024 14:56:38 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Bitcoin]]></category>
		<category><![CDATA[Bitcoin Core v0.1]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Satoshi Nakamoto]]></category>
		<guid isPermaLink="false">https://www.forensicxs.com/?p=3112</guid>

					<description><![CDATA[I have chosen to write a code explanation of the initial version of bitcoin, akka bitcoin v0.1. I hope it helps you to understand better the fundational concepts behind bitcoin, and get an overview how bitcoin actually works behind the scene. Thus, I hope it helps to provide you the necessary confidence to become a &#8230; <p class="link-more"><a href="https://www.forensicxs.com/bitcoin-core-v0-1-a-code-walkthrough/" class="more-link">Continue reading<span class="screen-reader-text"> "Bitcoin Core v0.1 : a code walkthrough"</span></a></p>]]></description>
										<content:encoded><![CDATA[
<p style="font-size:17px">I have chosen to write a code explanation of the initial version of bitcoin, akka <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">bitcoin v0.1</mark></strong>. I hope it helps you to understand better the fundational concepts behind bitcoin, and get an overview how bitcoin actually works behind the scene. Thus, I hope it helps to provide you the necessary confidence to become a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">long term investor</mark></strong> in bitcoin</p>



<p style="font-size:17px">The bitcoin v0.1 code is available here : <a href="https://tinyurl.com/k24m7p9c">https://tinyurl.com/k24m7p9c</a>. It is written mainly in <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">C++</mark></strong></p>



<p>It is released under the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">MIT X11 licence</mark></strong>, that means anyone can copy and modify it</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="901" height="253" src="https://www.forensicxs.com/wp-content/uploads/2024/07/image.png" alt="" class="wp-image-3117" style="width:495px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/07/image.png 901w, https://www.forensicxs.com/wp-content/uploads/2024/07/image-300x84.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/07/image-768x216.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p style="font-size:17px">The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">bitcoin Core</mark></strong> software <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">.exe</mark></strong> can be launched here : <a href="https://tinyurl.com/3ttejt9w">https://tinyurl.com/3ttejt9w</a></p>



<p>There are two <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">.dll</mark></strong> files included : </p>



<ul class="wp-block-list">
<li>libeay32.dll -&gt; this is the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">OpenSSL</mark></strong> encryption library, used by the .exe to create the encryption keys</li>



<li>mingwm10.dll -&gt; it is a free and open source Windows port of the GCC compiler. It is necessary to launch <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Qt</mark></strong>, which powers the GUI &#8220;Graphical User Interface&#8221; engine used by the .exe</li>
</ul>



<p>The bitcoin Core is mainly usefull to send bitcoin from one address to another address, without any intermediary</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="859" height="596" src="https://www.forensicxs.com/wp-content/uploads/2024/07/image-1.png" alt="" class="wp-image-3118" style="width:534px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/07/image-1.png 859w, https://www.forensicxs.com/wp-content/uploads/2024/07/image-1-300x208.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/07/image-1-768x533.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">Code summary</mark></strong></p>



<p>Now let&#8217;s go through the code. I have created a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">summary table</mark></strong>, to provide an overview, before going into the details of each file</p>



<p>Overall, bitcoin core v0.1 has <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">31 794 lines of code</mark></strong>. The biggest files being the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">GUI</mark></strong> management (Graphical User Interface) &#8211; by far the biggest &#8211; and the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">blockchain</mark></strong> operation (blocks, proof of work, cryptography). All the other files are much smaller but also an essential part of the software</p>



<figure class="wp-block-table is-style-regular has-small-font-size"><table><thead><tr><th class="has-text-align-center" data-align="center">          File</th><th class="has-text-align-center" data-align="center">                 Lines</th><th class="has-text-align-left" data-align="left">                                                                                  Purpose</th><th class="has-text-align-center" data-align="center">% of total lines</th></tr></thead><tbody><tr><td class="has-text-align-center" data-align="center">base58.h</td><td class="has-text-align-center" data-align="center">201</td><td class="has-text-align-left" data-align="left">Implements <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">base58</mark></strong> encoding and decoding functionalities specifically used for bitcoin addresses. base58 is a specific variant of base64 encoding that avoids visually similar characters and aims to produce more user-friendly output. The code includes methods for encoding and decoding both standard and checksum-enhanced base58 representations of bitcoin<mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-black-color"> </mark><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">addresses</mark></strong></td><td class="has-text-align-center" data-align="center">1%</td></tr><tr><td class="has-text-align-center" data-align="center">bignum.h</td><td class="has-text-align-center" data-align="center">498</td><td class="has-text-align-left" data-align="left">This code involves the definition and implementation of several classes and functions that deal with precision arithmetics for cryptographic applications. This kind of functionality is critical in blockchain technology, cryptocurrencies, and any applications that require handling<strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color"> large integers</mark></strong>, such as those used in cryptography</td><td class="has-text-align-center" data-align="center">2%</td></tr><tr><td class="has-text-align-center" data-align="center">db.cpp</td><td class="has-text-align-center" data-align="center">604</td><td class="has-text-align-left" data-align="left">This code focuses on<strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color"> database </mark></strong>operations for managing transactions, addresses, and wallets. It includes functionality for initializing the database, reading and writing to it, and managing the wallet&#8217;s state</td><td class="has-text-align-center" data-align="center">2%</td></tr><tr><td class="has-text-align-center" data-align="center">db.h</td><td class="has-text-align-center" data-align="center">420</td><td class="has-text-align-left" data-align="left">This code focuses on <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">database </mark></strong>operations for managing transactions, addresses, and wallets. It includes functionality for initializing the database, reading and writing to it, and managing the wallet&#8217;s state</td><td class="has-text-align-center" data-align="center">1%</td></tr><tr><td class="has-text-align-center" data-align="center">headers.h</td><td class="has-text-align-center" data-align="center">71</td><td class="has-text-align-left" data-align="left">This code <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">imports</mark></strong> many important <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">libraries</mark></strong> and links the .h files together. It is a small file but an essential part</td><td class="has-text-align-center" data-align="center">0%</td></tr><tr><td class="has-text-align-center" data-align="center">irc.cpp</td><td class="has-text-align-center" data-align="center"><br>265<br></td><td class="has-text-align-left" data-align="left">This code provides the infrastructure for managing <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">network </mark></strong>communications using <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">IRC</mark></strong>. The encoding and decoding functions ensure that addresses are processed safely and effectively, while the variant functions for sending and receiving data handle the specifics of socket communication. The threaded operation allows for asynchronous processing of network events, necessary in the context of real time and <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">peer to peer</mark></strong> transactions</td><td class="has-text-align-center" data-align="center">1%<br></td></tr><tr><td class="has-text-align-center" data-align="center">irc.h</td><td class="has-text-align-center" data-align="center">7</td><td class="has-text-align-left" data-align="left">This code is the header file of irc.cpp and is important to implement <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">asynchronous</mark></strong> connections and the network <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">decentralization</mark></strong></td><td class="has-text-align-center" data-align="center">0%</td></tr><tr><td class="has-text-align-center" data-align="center">key.h</td><td class="has-text-align-center" data-align="center">156</td><td class="has-text-align-left" data-align="left">This code defines the cryptographic key management system, using <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">elliptic curve</mark></strong> digital signature algorithm (ECDSA)</td><td class="has-text-align-center" data-align="center">0%</td></tr><tr><td class="has-text-align-center" data-align="center">main.cpp</td><td class="has-text-align-center" data-align="center">2660</td><td class="has-text-align-left" data-align="left">This code implements the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">blockchain</mark></strong> management of transactions, wallets, and blocks. It employs locking mechanisms to prevent data corruption in concurrent environments and maintains an <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">in-memory</mark></strong> database to facilitate quick access and updates</td><td class="has-text-align-center" data-align="center">8%</td></tr><tr><td class="has-text-align-center" data-align="center">main.h</td><td class="has-text-align-center" data-align="center">1297</td><td class="has-text-align-left" data-align="left">This code is the header file of main.cpp. The implementation includes mechanisms for <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">memory</mark></strong> management, transaction validation, and persistence in a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">database</mark></strong></td><td class="has-text-align-center" data-align="center">4%</td></tr><tr><td class="has-text-align-center" data-align="center">makefile</td><td class="has-text-align-center" data-align="center">83</td><td class="has-text-align-left" data-align="left">The provided code is designed to automate the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">compilation</mark></strong> and linking process, defining how to build the application, manage dependencies, and specify settings for the compiler</td><td class="has-text-align-center" data-align="center">0%</td></tr><tr><td class="has-text-align-center" data-align="center">makefile.vc</td><td class="has-text-align-center" data-align="center">77</td><td class="has-text-align-left" data-align="left">This file is used by makefile for building the bitcoin Windows application. It uses Microsoft Visual C++ compiler commands, preprocessor directives, and settings for linking with various libraries such as OpenSSL, wxWidgets, and Berkeley DB</td><td class="has-text-align-center" data-align="center">0%</td></tr><tr><td class="has-text-align-center" data-align="center">market.cpp</td><td class="has-text-align-center" data-align="center">264</td><td class="has-text-align-left" data-align="left">This is a partially completed distributed <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">market place</mark></strong>. It was not implemented in later versions of bitcoin core</td><td class="has-text-align-center" data-align="center">1%</td></tr><tr><td class="has-text-align-center" data-align="center">market.h</td><td class="has-text-align-center" data-align="center">182</td><td class="has-text-align-left" data-align="left">It is the header file of market.cpp. It ensures the market place can <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">securely</mark></strong> identify users and verify actions within the application</td><td class="has-text-align-center" data-align="center">1%</td></tr><tr><td class="has-text-align-center" data-align="center">net.cpp</td><td class="has-text-align-center" data-align="center">1020</td><td class="has-text-align-left" data-align="left">The code ensures that the application can reliably communicate over the peer to peer <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">network</mark></strong>, establish connection threads, and terminate operations when required</td><td class="has-text-align-center" data-align="center">3%</td></tr><tr><td class="has-text-align-center" data-align="center">net.h</td><td class="has-text-align-center" data-align="center">856</td><td class="has-text-align-left" data-align="left">This is the header file of net.cpp, implementing the communication between network <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">nodes</mark></strong></td><td class="has-text-align-center" data-align="center">3%</td></tr><tr><td class="has-text-align-center" data-align="center">script.cpp</td><td class="has-text-align-center" data-align="center">1127</td><td class="has-text-align-left" data-align="left">Bitcoin is programmable money. Bitcoin core uses <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">scripts</mark></strong> that are run into a stack, and <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">opcodes</mark></strong> are the underlying operations that help build the bitcoin scripts</td><td class="has-text-align-center" data-align="center">4%</td></tr><tr><td class="has-text-align-center" data-align="center">script.h</td><td class="has-text-align-center" data-align="center">597</td><td class="has-text-align-left" data-align="left">This is the header file of script.cpp. It defines the conditions under which <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">funds</mark></strong> can be unlocked and spent</td><td class="has-text-align-center" data-align="center">2%</td></tr><tr><td class="has-text-align-center" data-align="center">serialize.h</td><td class="has-text-align-center" data-align="center">1151</td><td class="has-text-align-left" data-align="left">This code implements <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">serialization</mark></strong>. The code converts objects of a particular class into a stream of <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">bytes</mark></strong>. It is used to store it in memory or transmit it over the network</td><td class="has-text-align-center" data-align="center">4%</td></tr><tr><td class="has-text-align-center" data-align="center">shap.cpp</td><td class="has-text-align-center" data-align="center">554</td><td class="has-text-align-left" data-align="left">This code is the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">hashing</mark></strong> utility and the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">cryptographic</mark></strong> foundation of bitcoin. Hash functions ensure that data is secure and allow users to verify the integrity of transaction data</td><td class="has-text-align-center" data-align="center">2%</td></tr><tr><td class="has-text-align-center" data-align="center">sha.h</td><td class="has-text-align-center" data-align="center">177</td><td class="has-text-align-left" data-align="left">This is the header file of sha.cpp. It is essential for initializing <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">hash states</mark></strong>, transforming data for hashing, and byte order manipulation</td><td class="has-text-align-center" data-align="center">1%</td></tr><tr><td class="has-text-align-center" data-align="center">ui.cpp</td><td class="has-text-align-center" data-align="center">3228</td><td class="has-text-align-left" data-align="left">This code implements the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">GUI</mark></strong> (Graphical User Interface). It uses the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">wxWidgets</mark></strong> library. The code includes several classes that represent different dialogs and interactions within the application, such as sending money and managing an address book</td><td class="has-text-align-center" data-align="center">10%</td></tr><tr><td class="has-text-align-center" data-align="center">ui.h</td><td class="has-text-align-center" data-align="center">412</td><td class="has-text-align-left" data-align="left">This is the header file of ui.cpp</td><td class="has-text-align-center" data-align="center">1%</td></tr><tr><td class="has-text-align-center" data-align="center">ui.rc</td><td class="has-text-align-center" data-align="center">14</td><td class="has-text-align-left" data-align="left">This resource file declares various <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">graphical</mark></strong> assets utilized in wxWidgets</td><td class="has-text-align-center" data-align="center">0%</td></tr><tr><td class="has-text-align-center" data-align="center">uibase.cpp</td><td class="has-text-align-center" data-align="center">1806</td><td class="has-text-align-left" data-align="left">This file structures the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">GUI </mark></strong>elements, manages events and functionalities related to user inputs, such as sending bitcoin</td><td class="has-text-align-center" data-align="center">6%</td></tr><tr><td class="has-text-align-center" data-align="center">uibase.h</td><td class="has-text-align-center" data-align="center">720</td><td class="has-text-align-left" data-align="left">This header file defines several base dialog classes generated with <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">wxFormBuilder</mark></strong></td><td class="has-text-align-center" data-align="center">2%</td></tr><tr><td class="has-text-align-center" data-align="center">unint256.h</td><td class="has-text-align-center" data-align="center">750</td><td class="has-text-align-left" data-align="left">This code includes definitions for handling large integers using the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">uint256</mark></strong> class. This class is necessary for managing values that exceed the size of standard built-in data types, as is the case for bitcoin hashes and addresses</td><td class="has-text-align-center" data-align="center">2%</td></tr><tr><td class="has-text-align-center" data-align="center">uiproject.fbp</td><td class="has-text-align-center" data-align="center">11825</td><td class="has-text-align-left" data-align="left">This code is the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">XML</mark></strong> representation of the wxWidgets. The XML format is used to describe various objects, properties, and events</td><td class="has-text-align-center" data-align="center">37%</td></tr><tr><td class="has-text-align-center" data-align="center">util.cpp</td><td class="has-text-align-center" data-align="center">373</td><td class="has-text-align-left" data-align="left">The code is responsible for various <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">utilities</mark></strong> in bitcoin, such as multithreading support for OpenSSL, generating random numbers, file management, time synchronization, and custom error handling</td><td class="has-text-align-center" data-align="center">1%</td></tr><tr><td class="has-text-align-center" data-align="center">util.h</td><td class="has-text-align-center" data-align="center">399</td><td class="has-text-align-left" data-align="left">This is the header file of util.cpp. It covers <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">type</mark></strong> definitions, error handling, hash functions, and more</td><td class="has-text-align-center" data-align="center">1%</td></tr></tbody></table></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">base58.h</mark></strong></p>



<p>This file implements base58 encoding and decoding functionalities specifically used for bitcoin addresses. Here is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">base58.h</mark></strong> : <a href="https://tinyurl.com/4j2rdrvj">https://tinyurl.com/4j2rdrvj</a></p>



<p>The first line defines the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">character set</mark></strong> for Base58 encoding. The characters&nbsp;<code>0</code>,&nbsp;<code>O</code>,&nbsp;<code>I</code>, and&nbsp;<code>l</code>&nbsp;are excluded to avoid visual ambiguity</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="926" height="57" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-31.png" alt="" class="wp-image-3174" style="width:640px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-31.png 926w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-31-300x18.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-31-768x47.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">EncodeBase58</mark></strong> encodes data into <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">base58</mark></strong> string format</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="788" height="26" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-32.png" alt="" class="wp-image-3175" style="width:642px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-32.png 788w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-32-300x10.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-32-768x25.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">EncodeBase58check</mark></strong> extends EncodeBase58 by appending a 4-byte hash (checksum) to the end of the data before encoding. This helps in verifying the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">integrity</mark></strong> of the address</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="749" height="201" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-33.png" alt="" class="wp-image-3176" style="width:548px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-33.png 749w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-33-300x81.png 300w" sizes="(max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">Hash160ToAddress</mark></strong> takes a hashed public key and prefixes it with a version byte before producing a Base58Check encoded string (<strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">bitcoin address</mark></strong>)</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="620" height="224" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-34.png" alt="" class="wp-image-3177" style="width:429px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-34.png 620w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-34-300x108.png 300w" sizes="(max-width: 620px) 100vw, 620px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">IsValidBitcoinAddress</mark></strong> checks whether a given address is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">valid</mark></strong> by attempting to decode it</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="603" height="250" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-35.png" alt="" class="wp-image-3178" style="width:447px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-35.png 603w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-35-300x124.png 300w" sizes="(max-width: 603px) 100vw, 603px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">PubKeyToAddress</mark></strong> converts a public key into its corresponding bitcoin <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">address</mark></strong> using Hash160 and Hash160ToAddress</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="704" height="103" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-36.png" alt="" class="wp-image-3179" style="width:556px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-36.png 704w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-36-300x44.png 300w" sizes="(max-width: 704px) 100vw, 704px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">bignum.h</mark></strong></p>



<p>This code is implemented to manage large integers in the cryptography component of bitcoin. Here is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">bignum.h</mark></strong> : <a href="https://tinyurl.com/43y92jb2">https://tinyurl.com/43y92jb2</a></p>



<ul class="wp-block-list">
<li>The code utilizes <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">OpenSSL big numbers</mark></strong> functionality</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="380" height="78" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-37.png" alt="" class="wp-image-3181" style="width:300px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-37.png 380w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-37-300x62.png 300w" sizes="(max-width: 380px) 100vw, 380px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">CBigNum</mark></strong> is a custom class that inherits from OpenSSL bignum. It includes some important methods (constructors, arithmetic operations, conversion methods,&#8230;), and also operators overload and bitwise operations</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="431" height="181" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-38.png" alt="" class="wp-image-3182" style="width:308px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-38.png 431w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-38-300x126.png 300w" sizes="(max-width: 431px) 100vw, 431px" /></figure>



<ul class="wp-block-list">
<li>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">serialize</mark></strong> methods allow for serialization and deserialization of CBigNum objects</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="693" height="328" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-39.png" alt="" class="wp-image-3183" style="width:530px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-39.png 693w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-39-300x142.png 300w" sizes="(max-width: 693px) 100vw, 693px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">db.cpp, db.h</mark></strong></p>



<p>This code focuses on database operations for managing transactions, addresses, and wallets. It includes functionality for initializing the database, reading and writing to it, and managing the wallet&#8217;s state. The database is based upon <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Berkeley DB</mark></strong> (<a href="https://tinyurl.com/mr2zb4hw">https://tinyurl.com/mr2zb4hw</a>)</p>



<p>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">db.cpp</mark></strong> file is here : <a href="https://tinyurl.com/3zfe8x4t">https://tinyurl.com/3zfe8x4t</a></p>



<ul class="wp-block-list">
<li>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">DbEnv</mark></strong> is an object representing the Berkeley DB environmnt</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="261" height="29" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-40.png" alt="" class="wp-image-3184" style="width:193px;height:auto"/></figure>



<ul class="wp-block-list">
<li> The class <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">CDBInit</mark></strong> <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">initializes</mark></strong> the database environment in its constructor</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="514" height="403" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-41.png" alt="" class="wp-image-3185" style="width:329px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-41.png 514w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-41-300x235.png 300w" sizes="(max-width: 514px) 100vw, 514px" /></figure>



<ul class="wp-block-list">
<li>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">CDB constructor</mark></strong> tries to <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">open</mark></strong> a database file with the specified mode (r, w, c, etc.) and initializes various settings associated with the BDB environment</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="725" height="376" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-42.png" alt="" class="wp-image-3187" style="width:502px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-42.png 725w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-42-300x156.png 300w" sizes="(max-width: 725px) 100vw, 725px" /></figure>



<ul class="wp-block-list">
<li>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">CTxDB class</mark></strong> handles <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">transaction</mark></strong> data in the database (reading, updating, deleting transaction entries based on their hashes)</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="662" height="153" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-43.png" alt="" class="wp-image-3188" style="width:505px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-43.png 662w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-43-300x69.png 300w" sizes="(max-width: 662px) 100vw, 662px" /></figure>



<ul class="wp-block-list">
<li>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">CAddrDB</mark></strong> class is responsible to manage addresses in the database (write new addresses, load existing ones)</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="672" height="625" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-44.png" alt="" class="wp-image-3189" style="width:512px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-44.png 672w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-44-300x279.png 300w" sizes="(max-width: 672px) 100vw, 672px" /></figure>



<ul class="wp-block-list">
<li>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">CWalletDB</mark></strong> class manages <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">wallet</mark></strong> data, including reading and writing wallet entries, such as addresses and transactions</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="514" height="104" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-45.png" alt="" class="wp-image-3190" style="width:414px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-45.png 514w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-45-300x61.png 300w" sizes="(max-width: 514px) 100vw, 514px" /></figure>



<p>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">db.h</mark></strong> file is here : <a href="https://tinyurl.com/ea39pj4s">https://tinyurl.com/ea39pj4s</a></p>



<ul class="wp-block-list">
<li>The code starts by including the Berkeley DB <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">header</mark></strong> and classes used throughout the database operations. It uses several external variables for managing the address book, client status, and database environment configuration</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="617" height="427" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-46.png" alt="" class="wp-image-3191" style="width:446px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-46.png 617w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-46-300x208.png 300w" sizes="(max-width: 617px) 100vw, 617px" /></figure>



<ul class="wp-block-list">
<li>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">CDB class</mark></strong> is defined, with a constructor taking the file name and opening the BD database, and handling transactions in argument, and with a destructor closing the database. </li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="782" height="354" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-47.png" alt="" class="wp-image-3192" style="width:519px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-47.png 782w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-47-300x136.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-47-768x348.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<ul class="wp-block-list">
<li>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">CTxDB</mark></strong> class manages transaction metadata</li>
</ul>



<figure class="wp-block-image size-large is-resized"><img decoding="async" width="1024" height="602" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-48-1024x602.png" alt="" class="wp-image-3193" style="width:636px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-48-1024x602.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-48-300x176.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-48-768x452.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-48.png 1029w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">headers.h</mark></strong></p>



<p>This code <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">imports</mark></strong> many important <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">libraries</mark></strong> and links the .h files together. Here is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">headers.h</mark></strong> :  <a href="https://tinyurl.com/yerp5r9s">https://tinyurl.com/yerp5r9s</a></p>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">Preprocessor</mark></strong> directives</li>
</ul>



<p>Theses <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">directives </mark></strong>check if the code is compiled with Microsoft Visual C++ and disable specific compiler warnings</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="381" height="125" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-49.png" alt="" class="wp-image-3194" style="width:295px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-49.png 381w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-49-300x98.png 300w" sizes="(max-width: 381px) 100vw, 381px" /></figure>



<p>It is also targeting <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Windows 95</mark></strong> (0x0400) instead of a later version</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="368" height="101" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-51.png" alt="" class="wp-image-3196" style="width:296px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-51.png 368w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-51-300x82.png 300w" sizes="(max-width: 368px) 100vw, 368px" /></figure>



<ul class="wp-block-list">
<li>These <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">libraries</mark></strong> provide a wide range of <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">functionalities</mark></strong>, from UI components and cryptography to standard I/O operations and memory management</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="543" height="525" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-52.png" alt="" class="wp-image-3197" style="width:408px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-52.png 543w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-52-300x290.png 300w" sizes="(max-width: 543px) 100vw, 543px" /></figure>



<ul class="wp-block-list">
<li>Additional <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">libraries</mark></strong> are included, to perform operations on data <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">structures</mark></strong> and algorithms. The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">boost</mark></strong> library is also used (<a href="https://www.boost.org/">https://www.boost.org/</a>)</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="471" height="375" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-53.png" alt="" class="wp-image-3198" style="width:360px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-53.png 471w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-53-300x239.png 300w" sizes="(max-width: 471px) 100vw, 471px" /></figure>



<ul class="wp-block-list">
<li>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">local headers</mark></strong> are also included, that contain <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">application-specific</mark></strong> code that deals with serialization, cryptography, transaction handling, user interface, and networking features</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="318" height="352" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-54.png" alt="" class="wp-image-3199" style="width:251px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-54.png 318w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-54-271x300.png 271w" sizes="(max-width: 318px) 100vw, 318px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">irc.cpp, irc.h</mark></strong></p>



<p>Support for the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">IRC</mark></strong> communication chanel was <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">removed</mark></strong> from bitcoin core in March 2014 (see this Wiki about IRC : <a href="https://en.wikipedia.org/wiki/IRC">https://en.wikipedia.org/wiki/IRC</a>)</p>



<p>Here is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">irc.cpp</mark></strong> : <a href="https://tinyurl.com/yvw3xnz2">https://tinyurl.com/yvw3xnz2</a></p>



<p>It enables the software to connect with other nodes using <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">IRC</mark></strong>, allowing for the exchange of information. Key functionalities include encoding and decoding addresses, sending and receiving messages, handling connections, and managing the state of sockets</p>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">ThreadIRCSeed</mark></strong> handles the connection to an IRC server for broadcasting and receiving bitcoin node messages. It processes various IRC commands, enabling interaction with other nodes in the network via IRC</li>
</ul>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="446" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-29-1024x446.png" alt="" class="wp-image-3158" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-29-1024x446.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-29-300x131.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-29-768x335.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-29.png 1377w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>Here is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">irc.h</mark></strong> : <a href="https://tinyurl.com/mrypzyt2">https://tinyurl.com/mrypzyt2</a></p>



<ul class="wp-block-list">
<li>It is used for the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">setup</mark></strong> of the network <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">socket</mark></strong> connection, and the corresponding <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">IRC thread</mark></strong></li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="714" height="181" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-30.png" alt="" class="wp-image-3172" style="width:460px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-30.png 714w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-30-300x76.png 300w" sizes="(max-width: 714px) 100vw, 714px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">key.h</mark></strong></p>



<p>This file is an implementation of key management and cryptographic operations using Elliptic Curve Cryptography (ECC), specifically bitcoin publick-key cryptography <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">secp256k1 </mark></strong>(<a href="https://en.bitcoin.it/wiki/Secp256k1">https://en.bitcoin.it/wiki/Secp256k1</a>), which is now commonly used in cryptocurrencies</p>



<p>Here is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">key.h</mark></strong> : <a href="https://tinyurl.com/3c3tc377">https://tinyurl.com/3c3tc377</a></p>



<ul class="wp-block-list">
<li>The code contains <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">commented constants</mark></strong> representing the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">sizes</mark></strong> of private keys, public keys, and signatures for elliptic curves</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="552" height="150" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-55.png" alt="" class="wp-image-3201" style="width:389px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-55.png 552w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-55-300x82.png 300w" sizes="(max-width: 552px) 100vw, 552px" /></figure>



<p>A secure_allocator is designed to manage sensitive data like <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">private keys</mark></strong>. The vector part represents a dynamic array that can hold bytes. This byte array is used to <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">store binary data</mark></strong>, such as private keys, serialized objects, or any byte sequence</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="773" height="54" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-56.png" alt="" class="wp-image-3202" style="width:528px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-56.png 773w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-56-300x21.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-56-768x54.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<ul class="wp-block-list">
<li>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">Ckey class</mark></strong> contains many important <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">methods</mark></strong> : constructor and desctructor, key management, public key management, signature operations, static signature methods</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="788" height="305" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-57.png" alt="" class="wp-image-3203" style="width:526px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-57.png 788w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-57-300x116.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-57-768x297.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">main.cpp</mark></strong></p>



<p>This code implements the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">blockchain</mark></strong> management of transactions, wallets, and blocks. Here is the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">main.cpp</mark></strong> : <a href="https://tinyurl.com/ujf6u85z">https://tinyurl.com/ujf6u85z</a></p>



<p>As the code is very long, I provide a summary table of each function or method. I then provide a few more detailed analysis</p>



<figure class="wp-block-table"><table><thead><tr><th>Function name</th><th>Start line</th><th>Purpose</th></tr></thead><tbody><tr><td>AddKey</td><td>65</td><td>Add a cryptographic <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">key</mark></strong> to the wallet, which will be used to handle Bitcoin transactions</td></tr><tr><td>GenerateNewKey</td><td>75</td><td>Generates a key, adds it to the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">wallet</mark></strong>, and returns the public part of the key</td></tr><tr><td>AddToWallet</td><td>92</td><td>Adds a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">transaction</mark></strong> (CWalletTx) to a Bitcoin wallet. It handles both inserting new transactions and updating existing transactions</td></tr><tr><td>AddToWalletIfMine</td><td>149</td><td>Adds a transaction to a wallet if it is determined that the wallet owns the corresponding coins (the transaction is &#8220;mine&#8221;). If the transaction is already present in the wallet, it ensures that it is updated appropriately</td></tr><tr><td>EraseFromWallet</td><td>162</td><td>Removes a transaction from a Bitcoin wallet based on its transaction hash. This function ensures that both the in-memory representation and persistent storage are updated</td></tr><tr><td>AddOrphanTx</td><td>185</td><td>Adds a transaction to a collection of orphan transactions in a Bitcoin wallet or node. Orphan transactions are those that cannot be fully processed because they depend on inputs that are not currently available in the local node&#8217;s memory</td></tr><tr><td>EraseOrphanTx</td><td>197</td><td>Removes a specified orphan transaction from the collection of orphan transactions in a Bitcoin wallet or node. This function ensures that orphan transactions are properly removed from memory when they are no longer needed</td></tr><tr><td>CTxIn::IsMine</td><td>231</td><td>Member function of the CTxIn class, which represents an input in a Bitcoin transaction. This function determines whether the output being referenced by the transaction input belongs to the wallet, meaning it checks if the wallet controls that specific input</td></tr><tr><td>CTxIn::GetDebit</td><td>247</td><td>Member function of the CTxIn class, which represents an input in a Bitcoin transaction. This function is used to calculate the debit amount for that specific transaction input, effectively determining how much currency is being spent from the wallet</td></tr><tr><td>CWalletTx::GetTxTime</td><td>263</td><td>Member function of the CWalletTx class, which represents a transaction in a wallet. This function determines the time associated with the transaction, either by using the time it was received or, if it wasn&#8217;t received directly, by using the time of the block in which it was included</td></tr><tr><td>CMerkleTx::<br>SetMerkleBranch</td><td>286</td><td>Sets the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Merkle branch</mark></strong> for a given transaction within a block in a Bitcoin wallet or node implementation. This branch allows the transaction to be verified as part of a block&#8217;s Merkle tree, which ensures the integrity and inclusion of the transaction in that block</td></tr><tr><td>CWalletTx::<br>AddSupportingTransactions</td><td>339</td><td>Retrieves and manages the supporting transactions that are associated with a given transaction (represented by CWalletTx). It gathers transactions that are inputs to the current transaction, enabling the wallet to maintain a complete context of the transactions involved</td></tr><tr><td>CTransaction::<br>AcceptTransaction</td><td>406</td><td>Validates and accepts a new transaction into memory or the transaction pool. It checks for errors, conflicts with existing transactions, and dependencies on previous transactions</td></tr><tr><td>CTransaction::<br>AddToMemoryPool</td><td>481</td><td>Adds a transaction to the in-memory transaction pool (<strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">mempool</mark></strong>). This function is designed to be called only by other functions (like AcceptTransaction), which ensures that the transaction is valid before it is added</td></tr><tr><td>CTransaction::<br>RemoveFromMemoryPool</td><td>497</td><td>Removes a transaction from the in-memory transaction pool (mempool)</td></tr><tr><td>CMerkleTx::<br>GetDepthInMainChain</td><td>515</td><td>Assesses where the transaction is within the blockchain, based on its position in the tree structure of blocks (and their associated transactions) and ensures that it is indeed part of the main chain</td></tr><tr><td>CMerkleTx::<br>GetBlocksToMaturity</td><td>540</td><td>Determines how many additional blocks need to be mined before a coinbase transaction (the first transaction in a block that creates new coins) can be considered mature and the funds can be spent</td></tr><tr><td>CMerkleTx::<br>AcceptTransaction</td><td>548</td><td>Accepts a transaction while considering whether it is being processed in a client mode or a full node mode</td></tr><tr><td>CWalletTx::<br>AcceptWalletTransaction</td><td>564</td><td>Accepts transactions into the wallet while checking any associated previous transactions (inputs) that the current transaction depends on</td></tr><tr><td>ReacceptWalletTransactions</td><td>583</td><td>Re-accepts transactions that belong to the wallet but are not currently associated with any blocks on the blockchain. This function loops through all transactions in the wallet and ensures they remain valid and are accepted into the wallet&#8217;s transaction pool again</td></tr><tr><td>CWalletTx::<br>RelayWalletTransaction</td><td>599</td><td>Broadcasts a wallet transaction and its associated previous transactions across the network to ensure that they are relayed to other nodes, as transactions need to be propagated for inclusion in blocks</td></tr><tr><td>RelayWalletTransactions</td><td>621</td><td>Relays transactions within the decentralized Bitcoin network</td></tr><tr><td>CBlock::ReadFromDisk</td><td>662</td><td>Member function of the CBlock class, responsible for reading a block from disk storage based on its index information</td></tr><tr><td>GetOrphanRoot</td><td>667</td><td>Determines the original block that is at the base of an orphan block tree</td></tr><tr><td>CBlock::GetBlockValue</td><td>675</td><td>Calculates the total value (or <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">reward</mark></strong>) that a block provides to the miner who successfully creates it, taking into account both the block subsidy and the transaction fees associated with the transactions included in the block</td></tr><tr><td>GetNextWorkRequired</td><td>685</td><td>Calculates the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">difficulty</mark></strong> target for the next block based on the time taken to mine previous blocks, ensuring that new blocks continue to be produced at a steady rate</td></tr><tr><td>CTransaction::<br>DisconnectInputs</td><td>739</td><td>Responsible for undoing the effects of a transaction, when a block is confirmed or re-processed. This function effectively &#8220;disconnects&#8221; a transaction by marking its inputs as unspent, allowing those outputs to be reused in future transactions</td></tr><tr><td>CTransaction::<br>ConnectInputs</td><td>772</td><td>Validates that the inputs of the transaction can be connected to the Bitcoin network by ensuring that they are currently unspent and that all signatures and conditions are met</td></tr><tr><td>CTransaction::<br>ClientConnectInputs</td><td>873</td><td>Checks and validates the inputs of a transaction specifically for a client (such as a lightweight client that does not have a full transaction database)</td></tr><tr><td>CBlock::DisconnectBlock</td><td>918</td><td>Removes the transactions contained in the block and updates the disk index accordingly</td></tr><tr><td>CBlock::ConnectBlock</td><td>937</td><td>Accepts a block and processes its transactions, ensuring they are valid and updating the blockchain state accordingly</td></tr><tr><td>Reorganize</td><td>974</td><td>Handles the transition between different branches of the blockchain. When the blockchain experiences a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">fork</mark></strong> (due to conflicting blocks), this function will reorganize the blockchain to ensure the longest valid chain is retained and that the state of transactions is accurately reflected</td></tr><tr><td>CBlock::AddToBlockIndex</td><td>1072</td><td>Adds a new <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">block</mark></strong> to the blockchain index, ensuring that the block&#8217;s information is properly recorded, and manages the relationships between different blocks in the blockchain</td></tr><tr><td>CBlock::CheckBlock</td><td>1154</td><td>Validates a block&#8217;s integrity and compliance with the protocol&#8217;s rules before it can be added to the blockchain, or even stored as an orphan block</td></tr><tr><td>CBlock::AcceptBlock</td><td>1194</td><td>Validates and accepts a block into the blockchain. It performs various essential checks and operations to ensure the integrity of the blockchain structure</td></tr><tr><td>ProcessBlock</td><td>1236</td><td>Handles incoming blocks from peers, validates them, and integrates them into the blockchain. This function first checks for duplicates, validates the block, and handles orphan blocks that depend on it</td></tr><tr><td>ScanMessageStart</td><td>1304</td><td>Scans a data stream for a specific message start prefix, which is a critical part of the Bitcoin protocol for ensuring that communications between nodes are properly formatted</td></tr><tr><td>GetAppDir</td><td>1344</td><td>Determines the application directory for the Bitcoin wallet application, returning a string that represents the path where the application data should be stored. It checks various locations, including environment variables, to set this directory</td></tr><tr><td>OpenBlockFile</td><td>1379</td><td>Handles reading and writing blocks to disk while ensuring that they fit within storage limits and perform necessary operations safely</td></tr><tr><td>AppendBlockFile</td><td>1399</td><td>Handles reading and writing blocks to disk while ensuring that they fit within storage limits and perform necessary operations safely</td></tr><tr><td>LoadBlockIndex</td><td>1420</td><td>Loads existing blocks from the transaction database but also handles the creation and addition of the genesis block, which is the very first block in the Bitcoin blockchain</td></tr><tr><td>PrintBlockTree</td><td>1496</td><td>Designed to visualize the structure of the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">blockchain</mark></strong> by printing the relationships between blocks in a tree-like format. It allows users or developers to see how blocks are linked in terms of their parent-child relationships, along with other relevant information such as transaction counts and timestamps</td></tr><tr><td>AlreadyHave</td><td>1592</td><td>Checks whether a specific item (transaction, block, review, or product) is already known to the node, allowing it to avoid reprocessing or requesting the same item again. This function is part of the inventory management aspect of a Bitcoin node, which helps optimize communication and bandwidth usage</td></tr><tr><td>ProcessMessages</td><td>1611</td><td>Handles incoming messages from other nodes in the Bitcoin network. It reads and processes messages, ensuring they conform to the expected format while efficiently managing the message buffer</td></tr><tr><td>ProcessMessage</td><td>1690</td><td>Processes incoming messages from other nodes, interprets them according to the command they represent, and performs the necessary actions based on the command type</td></tr><tr><td>SendMessages</td><td>2056</td><td>Sends various types of messages to a connected <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">peer node</mark></strong> in the Bitcoin network. It handles several tasks, including ensuring that only validated data is sent, managing inventory updates, and handling address propagation</td></tr><tr><td>FormatHashBlocks</td><td>2138</td><td>Prepares a byte buffer for hashing by ensuring it conforms to the requirements of the hashing algorithm used in Bitcoin (such as SHA-256). It properly pads and formats the input data for efficient hashing</td></tr><tr><td>BlockSHA256</td><td>2156</td><td>Computes the SHA-256 <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">hash</mark></strong> for a specified number of data blocks using the crypto library. It takes an array of input data, processes it in blocks, and outputs the resulting SHA-256 hash in a specified buffer</td></tr><tr><td>BitcoinMiner</td><td>2183</td><td>Responsible for the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">mining</mark></strong> process in the Bitcoin software. It works by repeatedly attempting to create a valid block by solving a computational puzzle known as proof-of-work</td></tr><tr><td>GetBalance</td><td>2386</td><td>Calculates the total <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">balance</mark></strong> of a Bitcoin wallet by summing the values of the unspent transactions that belong to the wallet</td></tr><tr><td>SelectCoins</td><td>2410</td><td>Selects a set of wallet transactions that meet a specified target value, which is crucial for constructing a new transaction with sufficient funds. This function attempts to find the optimal subset of Unspent Transaction Outputs (<strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">UTXO</mark></strong>s) that total close to the target value while also considering various conditions</td></tr><tr><td>CreateTransaction</td><td>2514</td><td>Facilitate the creation of a new transaction by selecting appropriate unspent transaction outputs (UTXOs), calculating <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">fees</mark></strong>, preparing inputs and outputs, and signing the transaction</td></tr><tr><td>CommitTransactionSpent</td><td>2595</td><td>Updates the wallet&#8217;s state after a transaction has been committed. Specifically, it marks the inputs of the newly added transaction as spent and updates the wallet&#8217;s transaction history, utilizing a critical section to ensure thread safety during concurrent access to shared data</td></tr><tr><td>SendMoney</td><td>2625</td><td>Handles the process of creating and sending transactions. It involves transaction creation, validation, fee calculations, modifications to the wallet state, and <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">broadcasting</mark></strong> the transaction across the network</td></tr></tbody></table></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">GetBlockValue</mark></strong> function is part of the CBlock class. This function calculates the total value of a newly created block, considering its subsidy and transaction fees</li>
</ul>



<p>int64 nFees  represents the total <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">transaction fees</mark></strong> included in the block.<br>Local Variable nSubsidy is initially set as 50 * COIN, which means that the standard subsidy for a new coinbase block is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">50 bitcoin</mark></strong> (50 coins)</p>



<p>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">subsidy</mark></strong> is designed to be <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">halved approximately every four years</mark></strong>. The condition nBestHeight / 210000 calculates how many 210,000 block intervals have been mined (since 210,000 blocks roughly correspond to four years at 10-minute block intervals). The expression nSubsidy &gt;&gt;= (nBestHeight / 210000) uses a right <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">bitwise shift operator</mark></strong> (&gt;&gt;=), effectively halving the subsidy for each completed interval of 210,000 blocks. This implements bitcoin&#8217;s block reward <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">halving</mark></strong> mechanism</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="560" height="228" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-69.png" alt="" class="wp-image-3217" style="width:390px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-69.png 560w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-69-300x122.png 300w" sizes="(max-width: 560px) 100vw, 560px" /></figure>



<p>The total <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">value of the block</mark></strong> is the sum of the current subsidy (after accounting for halvings) and any transaction fees associated with the transactions included in the block</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="393" height="27" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-70.png" alt="" class="wp-image-3218" style="width:340px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-70.png 393w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-70-300x21.png 300w" sizes="(max-width: 393px) 100vw, 393px" /></figure>



<p>The table below helps visualize the evolution of block subsidy rewards after each halving. From this table, the 21 000 000 bitcoin maximum quantity can be derived. That means that the hard cap of <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">21 million bitcoin is an implicit</mark></strong> <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">limit</mark></strong>, not an explicit limit</p>



<figure class="wp-block-image size-full"><img decoding="async" width="526" height="798" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-72.png" alt="" class="wp-image-3220" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-72.png 526w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-72-198x300.png 198w" sizes="(max-width: 526px) 100vw, 526px" /></figure>



<p>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">halving curve</mark></strong> can be visualized with this graph :</p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" width="1024" height="758" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-71-1024x758.png" alt="" class="wp-image-3219" style="width:575px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-71-1024x758.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-71-300x222.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-71-768x569.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-71.png 1051w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">GetNextWorkRequired</mark></strong> function is responsible for adjusting the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">mining difficulty</mark></strong> based on the time it took to mine the last set of blocks</li>
</ul>



<p>nTargetTimespan sets the ideal duration for mining 2016 blocks, which is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">two weeks</mark></strong></p>



<p>nTargetSpacing defines the desired time between blocks, set to <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">10 minutes</mark></strong></p>



<p>nInterval calculates the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">number of blocks</mark></strong> that should be adjusted for difficulty (2016 blocks in this case)</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="718" height="77" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-64.png" alt="" class="wp-image-3211" style="width:502px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-64.png 718w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-64-300x32.png 300w" sizes="(max-width: 718px) 100vw, 718px" /></figure>



<p>The lines below check if the current block height (nHeight) plus one is not a multiple of nInterval. If it isn&#8217;t, the function returns the current difficulty (nBits) without making any changes. This ensures that the difficulty is adjusted <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">only once every 2016 blocks</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="561" height="77" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-65.png" alt="" class="wp-image-3212" style="width:444px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-65.png 561w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-65-300x41.png 300w" sizes="(max-width: 561px) 100vw, 561px" /></figure>



<p>The function below calculates the actual time taken to mine the last nInterval blocks by subtracting the time of pindexFirst from pindexLast. This actual time span (nActualTimespan) is then <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">forced</mark></strong> to a minimum of 25% of the target timespan and a maximum of 400% to <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">prevent extreme adjustments in difficulty</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="719" height="178" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-66.png" alt="" class="wp-image-3213" style="width:503px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-66.png 719w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-66-300x74.png 300w" sizes="(max-width: 719px) 100vw, 719px" /></figure>



<p>The lines below create a new difficulty target (bnNew) based on the previous difficulty and the actual time span compared to the target timespan. If the new difficulty exceeds the defined proof-of-work limit, it caps it to the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">maximum allowable difficulty</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="523" height="204" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-67.png" alt="" class="wp-image-3214" style="width:359px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-67.png 523w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-67-300x117.png 300w" sizes="(max-width: 523px) 100vw, 523px" /></figure>



<p>Here below the evolution of the real network difficulty</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="594" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-74-1024x594.png" alt="" class="wp-image-3225" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-74-1024x594.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-74-300x174.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-74-768x445.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-74.png 1257w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">CheckBlock</mark></strong> function validates a block before it is processed further. It conducts several checks on the block&#8217;s properties to ensure that it adheres to the rules defined by the blockchain protocol</li>
</ul>



<p>It verifies that the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">block size</mark></strong> is valid</p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" width="1024" height="88" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-76-1024x88.png" alt="" class="wp-image-3228" style="width:619px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-76-1024x88.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-76-300x26.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-76-768x66.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-76.png 1128w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>It verifies that the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">timestamp</mark></strong> of the block is valid (not too far in the future as compared with the current time)</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="923" height="102" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-77.png" alt="" class="wp-image-3229" style="width:620px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-77.png 923w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-77-300x33.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-77-768x85.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>It verifies that the first transaction in the block is a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">coinbase</mark></strong> transaction (the special transaction that rewards miners for adding a block), and that there is only one coinbase transaction</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="965" height="193" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-78.png" alt="" class="wp-image-3230" style="width:546px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-78.png 965w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-78-300x60.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-78-768x154.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>It iterates through all <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">transactions</mark></strong> in the block (vtx) and calls the CheckTransaction() method on each. If any transaction fails its validity check, it returns an error</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="849" height="127" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-79.png" alt="" class="wp-image-3231" style="width:548px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-79.png 849w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-79-300x45.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-79-768x115.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>It validates the block&#8217;s <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">proof of work</mark></strong> (POW)</p>



<p>nBits value (which indicates the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">difficulty</mark></strong> of the proof of work) shall not exceed the predefined limit (bnProofOfWorkLimit)</p>



<p>Block&#8217;s <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">hash</mark></strong> (calculated by the GetHash() method) is less than or equal to the target dictated by nBits</p>



<p>If these checks fail, it returns an error</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="820" height="156" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-80.png" alt="" class="wp-image-3233" style="width:557px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-80.png 820w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-80-300x57.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-80-768x146.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>It validates that the hashMerkleRoot stored in the block matches the hash generated from the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Merkle tree</mark></strong> of the transactions in the block. If they don&#8217;t match, it returns an error</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="875" height="97" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-81.png" alt="" class="wp-image-3234" style="width:559px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-81.png 875w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-81-300x33.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-81-768x85.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>In the bitcoin protocol, a transaction will be stored in the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">mempool</mark></strong> (memory pool) until it is duly validated. You can visualize the live mempool size : <a href="https://tinyurl.com/2z8zujvk">https://tinyurl.com/2z8zujvk</a></p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="376" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-86-1024x376.png" alt="" class="wp-image-3259" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-86-1024x376.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-86-300x110.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-86-768x282.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-86-1536x564.png 1536w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-86.png 1881w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">main.h</mark></strong></p>



<p>This file defines constants, classes, methods used in main.cpp. I&#8217;m not going to detail the content, and just provide informations about important constants used in the program</p>



<p>Here is the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">main.h</mark></strong> : <a href="https://tinyurl.com/z8y66m7y">https://tinyurl.com/z8y66m7y</a></p>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">Constant</mark></strong> definitions</li>
</ul>



<p>The maximum <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">block size</mark></strong> in bytes is 0x02000000, or equivalent to about <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">32 MB</mark></strong> (32 * 1024 * 1024 bytes). In the bitcoin context, this can restrict the maximum block size to maintain efficiency and performance</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="543" height="31" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-59.png" alt="" class="wp-image-3206" style="width:398px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-59.png 543w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-59-300x17.png 300w" sizes="(max-width: 543px) 100vw, 543px" /></figure>



<p>In practice, the real block size is much lower, as can be seen on the graph below. The real block size usage has increased following an increase in the blockchain transactions</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="606" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-73-1024x606.png" alt="" class="wp-image-3224" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-73-1024x606.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-73-300x177.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-73-768x454.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-73.png 1261w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Coin</mark></strong> represents the base unit for a cryptocurrency, here defined as 1 Bitcoin being equal to <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">100,000,000 satoshis</mark></strong>. It allows for smaller denominations of Bitcoin to be used in transactions</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="408" height="27" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-60.png" alt="" class="wp-image-3207" style="width:331px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-60.png 408w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-60-300x20.png 300w" sizes="(max-width: 408px) 100vw, 408px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Cent</mark></strong> represents a smaller unit equivalent to one hundredth of a Bitcoin, or  1 Cent = <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">1,000,000 satoshis</mark></strong>, further allowing the representation of transactions in finer detail. It helps in calculations involving cents</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="416" height="26" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-61.png" alt="" class="wp-image-3208" style="width:331px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-61.png 416w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-61-300x19.png 300w" sizes="(max-width: 416px) 100vw, 416px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Coinbase maturity</mark></strong> indicates that newly mined coins (the output of a coinbase transaction) cannot be spent until a certain number of blocks (in this case, <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">100 blocks</mark></strong>) have been confirmed after the block containing the coinbase transaction. This rule is implemented to prevent <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">double-spending</mark></strong> in the case of newly created coins</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="468" height="27" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-62.png" alt="" class="wp-image-3209" style="width:370px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-62.png 468w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-62-300x17.png 300w" sizes="(max-width: 468px) 100vw, 468px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">bnProofOfWorkLimit</mark></strong> sets the limit for the proof of work <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">difficulty</mark></strong>. uint256(0) creates a value that represents the maximum possible value for a 256-bit unsigned integer (i.e., all bits are set). Shifting this value right by 32 bits effectively reduces the maximum target value by a factor of (2^{32}).</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="636" height="29" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-63.png" alt="" class="wp-image-3210" style="width:494px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-63.png 636w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-63-300x14.png 300w" sizes="(max-width: 636px) 100vw, 636px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">makefile, makefile.vc</mark></strong></p>



<p>Makefile is used by the make build automation tool to manage the compilation of the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">bitcoin.exe</mark></strong> target. The paths where the compiler will look for <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">header files</mark></strong> and where it will look for <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">libraries </mark></strong>are defined</p>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">makefile</mark></strong> is here : <a href="https://tinyurl.com/yah6ap9c">https://tinyurl.com/yah6ap9c</a></p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="420" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-82-1024x420.png" alt="" class="wp-image-3238" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-82-1024x420.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-82-300x123.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-82-768x315.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-82.png 1468w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">market.cpp, market.h</mark></strong></p>



<p>This is a partially completed distributed <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">market place</mark></strong>. It was not implemented in later versions of bitcoin core, so I&#8217;m not going to detail anything</p>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">market.cpp</mark></strong> is here : <a href="https://tinyurl.com/3u5x88cc">https://tinyurl.com/3u5x88cc</a></p>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">net.cpp, net.h</mark></strong></p>



<p>We all know that bitcoin is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">decentralized</mark></strong>, and based upon the synchronization of <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">nodes</mark></strong> (mainly operated by miners). net.cpp is an important file for the execution of this network layer</p>



<p>Here is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">net.cpp</mark></strong> : <a href="https://tinyurl.com/yju4rp55">https://tinyurl.com/yju4rp55</a></p>



<p>It manages <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">network</mark></strong> connections and threading in a Bitcoin node. This code handles aspects like network socket creation, listening for incoming connections, sending and receiving messages, handling of issues like connection failures and data integrity, and proper cleanup during shutdown</p>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">Global variables</mark></strong></li>
</ul>



<p>Here you find <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">address definitions</mark></strong>, flags, primitives. For example, vNodes keeps track of <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">connected nodes</mark></strong>, and mapAddresses stores <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">known network addresses</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="900" height="471" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-23.png" alt="" class="wp-image-3151" style="width:506px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-23.png 900w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-23-300x157.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-23-768x402.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">ConnectSocket function</mark></strong></li>
</ul>



<p>This function establishes a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">socket connection</mark></strong> to the specified address (addrConnect).<br>The function creates a socket, and attempts to connect. If successful, it returns true and sets hSocketRet to the connected socket</p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" width="1024" height="407" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-24-1024x407.png" alt="" class="wp-image-3152" style="width:715px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-24-1024x407.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-24-300x119.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-24-768x305.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-24.png 1349w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">GetMyExternalIP function</mark></strong></li>
</ul>



<p>This function attempts to determine the external IP address of the machine by connecting to a known address. After establishing a socket connection, it sends an <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">HTTP GET</mark></strong> request to retrieve the external IP and then processes the response. If successful, it sets ipRet to the detected external IP address</p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" width="1024" height="456" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-25-1024x456.png" alt="" class="wp-image-3154" style="width:715px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-25-1024x456.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-25-300x133.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-25-768x342.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-25.png 1209w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">ThreadSocketHandler</mark></strong>&nbsp;and&nbsp;<strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">ThreadOpenConnections</mark></strong>&nbsp;represent functions handling <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">socket connections</mark></strong> and messages, running indefinitely in their respective threads</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="708" height="538" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-26.png" alt="" class="wp-image-3155" style="width:415px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-26.png 708w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-26-300x228.png 300w" sizes="(max-width: 708px) 100vw, 708px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">ThreadMessageHandler</mark></strong></li>
</ul>



<p>This function is responsible for processing incoming and outgoing messages to <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">connected nodes</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="726" height="536" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-27.png" alt="" class="wp-image-3156" style="width:412px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-27.png 726w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-27-300x221.png 300w" sizes="(max-width: 726px) 100vw, 726px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">StartNode and StopNode functions</mark></strong></li>
</ul>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">StartNode</mark></strong> : this function initializes the networking components, binds to a local address, listens for incoming connections, and starts necessary threads<br><br><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">StopNode</mark></strong> : this function shuts down the node, marking a shutdown flag and ensuring all threads are complete before cleanup</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="338" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-28-1024x338.png" alt="" class="wp-image-3157" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-28-1024x338.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-28-300x99.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-28-768x254.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-28.png 1316w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">script.cpp, script.h</mark></strong></p>



<p>Bitcoin is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">programmable money</mark></strong>, and like any program, you can add commands to it to execute certain actions</p>



<p>For this purpose, bitcoin Core uses <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">scripts</mark></strong> that are run into a stack, and <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">opcodes</mark></strong> are the underlying operations that help build the bitcoin scripts</p>



<p>Technically, the scripting language is based upon <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Forth</mark></strong> : <a href="https://tinyurl.com/43tpat57">https://tinyurl.com/43tpat57</a></p>



<p>The use of such a scripting language is like having an embedded, <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">assembly-like language</mark></strong>, to use for specific tasks inside the application. As such, the opcodes are similar to the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">mnemonics</mark></strong> used in assembly programming</p>



<p>You can find a complete list of opcodes here : <a href="https://tinyurl.com/5e8kaypr">https://tinyurl.com/5e8kaypr</a></p>



<p>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">script.h</mark></strong> file can be found here : <a href="https://tinyurl.com/b9u8s2bd">https://tinyurl.com/b9u8s2bd</a>. You will find inside :</p>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">Opcode enumeration</mark></strong></li>
</ul>



<p>The enum contains different opcodes representing <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">operations</mark></strong> in bitcoin script. They include commands for pushing data, control flow, stack manipulation, bitwise operations, cryptography, and more</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="544" height="398" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-2.png" alt="" class="wp-image-3127" style="width:331px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-2.png 544w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-2-300x219.png 300w" sizes="(max-width: 544px) 100vw, 544px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">Function to get opcode names</mark></strong></li>
</ul>



<p>This function returns a string representation of an opcode based on its <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">enum value</mark></strong>. If the opcode doesn&#8217;t match any known type, it returns &#8220;UNKNOWN_OPCODE&#8221;</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="696" height="392" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-1.png" alt="" class="wp-image-3126" style="width:400px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-1.png 696w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-1-300x169.png 300w" sizes="(max-width: 696px) 100vw, 696px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">CScript Class</mark></strong></li>
</ul>



<p>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">class</mark></strong> CScript is used for <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">script management and manipulation</mark></strong>. It has various constructors and operator overloads</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="967" height="333" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-5.png" alt="" class="wp-image-3130" style="width:555px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-5.png 967w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-5-300x103.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-5-768x264.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>These operators can handle different data types and build scripts, and <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">pushing values</mark></strong> onto the stack</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="623" height="422" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-4.png" alt="" class="wp-image-3129" style="width:380px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-4.png 623w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-4-300x203.png 300w" sizes="(max-width: 623px) 100vw, 623px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">Script parsing</mark></strong></li>
</ul>



<p>This method retrieves the next opcode from the script and updates the program counter</p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" width="1024" height="450" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-6-1024x450.png" alt="" class="wp-image-3131" style="width:711px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-6-1024x450.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-6-300x132.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-6-768x337.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-6.png 1166w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">script.cpp</mark></strong> file can be found here : <a href="https://tinyurl.com/mt29va73">https://tinyurl.com/mt29va73</a></p>



<p>This file includes functions that are important and used for <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">transaction verification and execution</mark></strong>. They are used extensively within the Bitcoin network, for verifying transactions and ensuring that they are executed correctly according to the provided scripts</p>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">EvalScript</mark></strong> is essential for executing and validating Bitcoin scripts. It processes opcodes sequentially, modifying the execution stack as required and handles both control flow and <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">cryptographic</mark></strong> operations to ensure each script fulfills its intended purpose correctly. Each opcode has specific logic that defines how it interacts with the stack and how it affects the program&#8217;s flow</li>
</ul>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="338" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-15-1024x338.png" alt="" class="wp-image-3143" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-15-1024x338.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-15-300x99.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-15-768x253.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-15.png 1152w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">SignatureHash</mark></strong> is a crucial part of Bitcoin&#8217;s transaction model, responsible for generating a hash of a transaction input that includes the signature data. This <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">hash</mark></strong> is what is actually signed by the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">private key</mark></strong>, ensuring that the signature is uniquely associated with a specific transaction input state</li>
</ul>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="216" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-16-1024x216.png" alt="" class="wp-image-3144" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-16-1024x216.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-16-300x63.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-16-768x162.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-16.png 1205w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">IsMine</mark></strong> checks whether the provided public key script (scriptPubKey) belongs to the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">wallet </mark></strong>(i.e., whether the wallet holds the corresponding private key)</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="706" height="162" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-21.png" alt="" class="wp-image-3149" style="width:414px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-21.png 706w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-21-300x69.png 300w" sizes="(max-width: 706px) 100vw, 706px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">ExtractPubKey</mark></strong> extracts the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">public key</mark></strong> from the public key script (scriptPubKey). It optionally checks if the public key belongs to the wallet</li>
</ul>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="191" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-22-1024x191.png" alt="" class="wp-image-3150" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-22-1024x191.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-22-300x56.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-22-768x143.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-22.png 1198w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">ExtractHash160</mark></strong> is designed to extract the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">hash</mark></strong> of a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">public key</mark></strong> (specifically, the result of a RIPEMD-160 hashing operation on a SHA-256 hash of the public key) from a given script. This hash is used in Bitcoin transactions as a means of identifying addresses uniquely</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="877" height="569" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-17.png" alt="" class="wp-image-3145" style="width:500px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-17.png 877w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-17-300x195.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-17-768x498.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">SignSignature</mark></strong> generates a digital signature for a transaction input. It combines the transaction data with the relevant script and signs it using the private key associated with the corresponding public key</li>
</ul>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="532" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-19-1024x532.png" alt="" class="wp-image-3147" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-19-1024x532.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-19-300x156.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-19-768x399.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-19.png 1390w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">VerifySignature</mark></strong> checks if the input is valid. It confirms that the transaction hash <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">matches</mark></strong> the expected hash. Finally, it verifies the signature using the script evaluation process</li>
</ul>



<p>This function is important for maintaining the security and integrity of the Bitcoin network, ensuring that <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">funds</mark></strong> can only be spent by their rightful owners. If any of the checks fail, it ensures that the transaction cannot proceed</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="328" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-20-1024x328.png" alt="" class="wp-image-3148" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-20-1024x328.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-20-300x96.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-20-768x246.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-20.png 1272w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">serialize.h</mark></strong></p>



<p>This code implements <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">serialization</mark></strong> : <a href="https://en.wikipedia.org/wiki/Serialization">https://en.wikipedia.org/wiki/Serialization</a></p>



<p>The code converts objects of a particular class into a stream of <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">bytes</mark></strong>. It is used to store it in memory or transmit it over the network</p>



<p>Here is the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">serialize.h</mark></strong> : <a href="https://tinyurl.com/msmd2r3k">https://tinyurl.com/msmd2r3k</a></p>



<p>For example, the WriteCompactSize function is designed to serialize a size value (of <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">type uint64</mark></strong>) into a compact format for efficient storage and transmission. It uses a specific encoding scheme that optimizes for smaller sizes when possible, making it important for handling variable-length data</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="558" height="725" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-83.png" alt="" class="wp-image-3240" style="width:367px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-83.png 558w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-83-231x300.png 231w" sizes="(max-width: 558px) 100vw, 558px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">sha.cpp, sha.h</mark></strong></p>



<p>Here is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">sha.cpp</mark></strong> : <a href="https://tinyurl.com/mvhzu39d">https://tinyurl.com/mvhzu39d</a></p>



<p>The provided code implements the SHA1, SHA224, SHA256, SHA384, SHA512 <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">hashing </mark></strong>algorithm</p>



<p>It also includes an accelerated version of SHA52, written in <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">assembly</mark></strong> language, for compatible hardware</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="70" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-84-1024x70.png" alt="" class="wp-image-3241" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-84-1024x70.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-84-300x20.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-84-768x52.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-84.png 1159w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">ui.cpp, ui.h, ui.rc, uibase.cpp, uibase.h, uiproject.fbp</mark></strong></p>



<p>All these files are here to implement the user interface of the bitcoin application</p>



<p>It is based upon the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Qt framework</mark></strong> : <a href="https://www.qt.io/product/framework">https://www.qt.io/product/framework</a></p>



<p>It uses <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">wxFormbuilder</mark></strong> widgets, to hep create the user interface (example below)</p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" width="1024" height="620" src="https://www.forensicxs.com/wp-content/uploads/2024/08/image-85-1024x620.png" alt="" class="wp-image-3242" style="width:581px;height:auto" srcset="https://www.forensicxs.com/wp-content/uploads/2024/08/image-85-1024x620.png 1024w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-85-300x182.png 300w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-85-768x465.png 768w, https://www.forensicxs.com/wp-content/uploads/2024/08/image-85.png 1437w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>The volume of code is important : about 18 000 lines of code. We can imagine the time spent on this if bitcoin was developped by a single person !</p>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">uint256.h</mark></strong></p>



<p>This file defines two custom data types, <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">uint160</mark></strong> and <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">uint256</mark></strong>, for handling <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">160-bit</mark></strong> and <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">256-bit</mark></strong> unsigned integers, respectively. These types are commonly used in blockchain and cryptocurrency applications, to represent data like <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">hashes</mark></strong> (SHA-256 outputs) and <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">addresses</mark></strong></p>



<p>Here is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">uint256.h</mark></strong> : <a href="https://tinyurl.com/5bfnp858">https://tinyurl.com/5bfnp858</a></p>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">util.cpp, util.h</mark></strong></p>



<p>This code implements several utilities : random cryptographic <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">seed</mark></strong> generation, exceptions, <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">parser</mark></strong>, <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">time</mark></strong> management. They are quite standard but essential components, for the cryptography processes and the block <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">timestamp</mark></strong></p>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.forensicxs.com/bitcoin-core-v0-1-a-code-walkthrough/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Belarus and the Web</title>
		<link>https://www.forensicxs.com/belarus-and-the-web/</link>
					<comments>https://www.forensicxs.com/belarus-and-the-web/#respond</comments>
		
		<dc:creator><![CDATA[Forensicxs]]></dc:creator>
		<pubDate>Sun, 27 Nov 2022 22:01:44 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[beCloud]]></category>
		<category><![CDATA[Belarus]]></category>
		<category><![CDATA[Footprinting]]></category>
		<category><![CDATA[Operational and Analytical Center]]></category>
		<guid isPermaLink="false">https://www.forensicxs.com/?p=2968</guid>

					<description><![CDATA[In this article, I will scratch the surface of the Belarus web infrastructure, using some basic footprinting techniques Belarus is a country in Eastern Europe. It is bordered by Russia to the east and northeast, Ukraine to the south, Poland to the west, and Lithuania and Latvia to the northwest. It has a population of &#8230; <p class="link-more"><a href="https://www.forensicxs.com/belarus-and-the-web/" class="more-link">Continue reading<span class="screen-reader-text"> "Belarus and the Web"</span></a></p>]]></description>
										<content:encoded><![CDATA[
<p> </p>



<p>In this article, I will scratch the surface of the Belarus web infrastructure, using some basic <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">footprinting</mark></strong> techniques</p>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Belarus</mark></strong> is a country in Eastern Europe. It is bordered by Russia to the east and northeast, Ukraine to the south, Poland to the west, and Lithuania and Latvia to the northwest. It has a population of <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">9.5 million</mark></strong>. Minsk is the capital and largest city</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image.png" alt="" class="wp-image-2970" width="505" height="336" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image.png 683w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-300x199.png 300w" sizes="(max-width: 505px) 100vw, 505px" /></figure>



<p>Belarus had a complex history in the last century, changing hands at various times, to the  Grand Duchy of Lithuania, the Polish–Lithuanian Commonwealth, and the Russian Empire. In the aftermath of the Russian Revolution in 1917, the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Byelorussian SSR</mark></strong> (Soviet Socialist Republic) became a founding constituent republic of the Soviet Union in 1922</p>



<p>After the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Polish-Soviet War</mark></strong>, Belarus lost almost half of its territory to Poland. Much of the borders of Belarus took their modern shape in 1939, when some lands of the Second Polish Republic were reintegrated into it after the Soviet invasion of Poland</p>



<p>During <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">World War II</mark></strong>, military operations devastated Belarus, which lost about a quarter of its population and half of its economic resources</p>



<p>The parliament of the republic proclaimed the sovereignty of Belarus in July 1990, and during the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">dissolution of the Soviet Union</mark></strong>, Belarus declared independence in August 1991. However, Belarus kept strong ties with Russia</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-2.png" alt="" class="wp-image-2973" width="384" height="385" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-2.png 752w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-2-298x300.png 298w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-2-150x150.png 150w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-2-100x100.png 100w" sizes="(max-width: 384px) 100vw, 384px" /></figure>



<p>Following the adoption of a new constitution in 1994, <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Alexander Lukashenko</mark></strong> was elected Belarus&#8217;s first president in the country&#8217;s first and only free election post-independence, serving as president ever since. Lukashenko heads an authoritarian government with a poor human rights record due to widespread abuses</p>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">Internet infrastructure</mark></strong></p>



<p>Let&#8217;s start a quick review about <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Internet cables</mark></strong> providing the Internet to Belarus</p>



<p>The first one is the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Transit Europe Asia (TEA)</mark></strong> network, which is an international transit fiber-optic cable line passing trough Russia, and linking European countries with Asia. TEA has transmission routes on <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Rostelecom</mark></strong> (Russian National Telecommunication Company : <a rel="noreferrer noopener" href="https://bit.ly/3Vwy4Vy" target="_blank">https://bit.ly/3Vwy4Vy</a>) core networks, with extensions to Belarus</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-11.png" alt="" class="wp-image-2985" width="511" height="300" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-11.png 711w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-11-300x176.png 300w" sizes="(max-width: 511px) 100vw, 511px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/3fWHHME" target="_blank" rel="noreferrer noopener">https://bit.ly/3fWHHME</a></figcaption></figure>



<p>A second one is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">TransTeleCom (TTK)</mark></strong>, which is one of the leading Telecom operators in Russia. TTK has a partnership with the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Russian Railways</mark></strong> (<a rel="noreferrer noopener" href="https://bit.ly/3EHJv6I" target="_blank">https://bit.ly/3EHJv6I</a>)</p>



<p>TTK is operating a large fiber-optic backbone digital communication network, which is laid along the railways of Russia and has many access points in all densely populated regions of the country, connecting the eastern and western borders of the Russian Federation</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-12.png" alt="" class="wp-image-2987" width="505" height="259" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-12.png 1006w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-12-300x154.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-12-768x393.png 768w" sizes="(max-width: 505px) 100vw, 505px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/3fWHHME" target="_blank" rel="noreferrer noopener">https://bit.ly/3fWHHME</a></figcaption></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">TTK Eurasia Highway</mark></strong> has connections with communication networks of all neighboring countries with Russia, including Belarus, and is an optimal route between Europe and Asia</p>



<p>Belarus has its own local companies able to install underground cables and expand the Internet network. One of these is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Minskkabel</mark></strong> which is specialized in the manufacture of optical cables for an interconnected communication network between Belarus, Russia, and other neighbouring countries</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-13.png" alt="" class="wp-image-2988" width="386" height="129" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-13.png 948w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-13-300x101.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-13-768x259.png 768w" sizes="(max-width: 386px) 100vw, 386px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/3T9QadI" target="_blank" rel="noreferrer noopener">https://bit.ly/3T9QadI</a></figcaption></figure>



<p>Now, let&#8217;s look at the Belarus country code <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">ccTLD &#8211; Top Level Domain</mark></strong> and corresponding <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">DNS &#8211; Domain Name Server</mark></strong> <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">root zone</mark></strong></p>



<p>IANA is responsible to assign the operators of top-level domains, such as&nbsp;.com, and maintain their technical and administrative details</p>



<p>We can find the Belarus ccTLD on the IANA website with the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">.by country code</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-8.png" alt="" class="wp-image-2981" width="451" height="494" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-8.png 790w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-8-274x300.png 274w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-8-768x842.png 768w" sizes="(max-width: 451px) 100vw, 451px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/3ezLKOW" target="_blank" rel="noreferrer noopener">https://bit.ly/3ezLKOW</a></figcaption></figure>



<p>IANA is responsible for determining an appropriate <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">trustee</mark></strong> for each ccTLD. Administration and control are then delegated to that trustee, which is responsible for the policies and operation of the domain</p>



<p>In the case of Belarus, it is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Belarusian Cloud Technologies LLC</mark></strong> <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">(beCloud)</mark></strong>. According to their website, they describe themselves as the first infrastructure operator in Belarus. Here are some key services <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">operated</mark></strong> by beCloud :</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-21.png" alt="" class="wp-image-3007" width="573" height="124" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-21.png 963w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-21-300x65.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-21-768x167.png 768w" sizes="(max-width: 573px) 100vw, 573px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/3rZ8Scy" target="_blank" rel="noreferrer noopener">https://bit.ly/3rZ8Scy</a></figcaption></figure>



<p>In the last years, Belarus has been building a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">sovereign Cloud</mark></strong> ecosystem, mostly with the help of major European, US and Asian companies, such as the ones below. The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">international sanctions</mark></strong> on Belarus and Russia are mainly targeted to specific individuals, and do not block necessarily these partnerships and exchange of technology</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-22.png" alt="" class="wp-image-3008" width="372" height="458" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-22.png 664w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-22-244x300.png 244w" sizes="(max-width: 372px) 100vw, 372px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/3rWkb5h" target="_blank" rel="noreferrer noopener">https://bit.ly/3rWkb5h</a></figcaption></figure>



<p>Taking into account the capital cost of construction of a network and the limited population of Belarus, it was decided to create <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">one single infrastructure operator</mark></strong>. beCloud operates several <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">datacenters</mark></strong> and has a wide <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">network</mark></strong> inside Belarus, and sells the bandwidth to other operators</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-23.png" alt="" class="wp-image-3009" width="389" height="316" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-23.png 829w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-23-300x244.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-23-768x623.png 768w" sizes="(max-width: 389px) 100vw, 389px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/3S4ehK6" target="_blank" rel="noreferrer noopener">https://bit.ly/3S4ehK6</a></figcaption></figure>



<p>The chief inspector of the Belarus TLD is the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">OAC &#8211; Operational and Analytical Center</mark></strong></p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-9-1024x617.png" alt="" class="wp-image-2982" width="497" height="299" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-9-1024x617.png 1024w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-9-300x181.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-9-768x463.png 768w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-9.png 1109w" sizes="(max-width: 497px) 100vw, 497px" /><figcaption class="wp-element-caption"><a href="https://oac.gov.by/" target="_blank" rel="noreferrer noopener">https://oac.gov.by/</a></figcaption></figure>



<p>There is much <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">controversy</mark></strong> about this agency. A son of Lukashenko had been appointed director some years ago</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-24.png" alt="" class="wp-image-3011" width="364" height="187" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-24.png 812w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-24-300x154.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-24-768x395.png 768w" sizes="(max-width: 364px) 100vw, 364px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/3TrX9zc" target="_blank" rel="noreferrer noopener">https://bit.ly/3TrX9zc</a></figcaption></figure>



<p>Here are the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">main tasks</mark></strong> of the OAC</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-25.png" alt="" class="wp-image-3013" width="483" height="215" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-25.png 921w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-25-300x134.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-25-768x344.png 768w" sizes="(max-width: 483px) 100vw, 483px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/3yIqpd4" target="_blank" rel="noreferrer noopener">https://bit.ly/3yIqpd4</a></figcaption></figure>



<p>Several agencies are subordinated to the OAC, such as the important <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">National Traffic Exchange Center (NTEC)</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-28.png" alt="" class="wp-image-3026" width="361" height="180" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-28.png 816w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-28-300x150.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-28-768x383.png 768w" sizes="(max-width: 361px) 100vw, 361px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/3s1rEjK" target="_blank" rel="noreferrer noopener">https://bit.ly/3s1rEjK</a></figcaption></figure>



<p>The Ministry of Telecommunications <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">controls all telecommunications</mark></strong> originating within the country through its carrier unitary enterprise, <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Beltelecom</mark></strong></p>



<p>The statistics on <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Shodan</mark></strong> show us the importance of Beltelecom as the main operator of routers and switches accross Belarus</p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-15-1024x558.png" alt="" class="wp-image-2992" width="538" height="293" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-15-1024x558.png 1024w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-15-300x164.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-15-768x419.png 768w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-15.png 1223w" sizes="(max-width: 538px) 100vw, 538px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/3EqtMZG" target="_blank" rel="noreferrer noopener">https://bit.ly/3EqtMZG</a></figcaption></figure>



<p>Beltelecom owns all the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">backbone channels</mark></strong> that link to external networks such as the one from Rostelecom in Russia</p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-26-1024x761.png" alt="" class="wp-image-3014" width="536" height="397" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-26-1024x761.png 1024w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-26-300x223.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-26.png 1083w" sizes="(max-width: 536px) 100vw, 536px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/3eAt29S" target="_blank" rel="noreferrer noopener">https://bit.ly/3eAt29S</a></figcaption></figure>



<p>While Beltelecom is in charge of the infrastructure, <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">NTEC</mark></strong> is responsible for allowing the access to the international Internet, and grants this service for a fee that is paid by Telecom operators</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-30.png" alt="" class="wp-image-3028" width="507" height="84" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-30.png 798w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-30-300x50.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-30-768x128.png 768w" sizes="(max-width: 507px) 100vw, 507px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/3CWZ20b" target="_blank" rel="noreferrer noopener">https://bit.ly/3CWZ20b</a></figcaption></figure>



<p>The Belarus authorities can <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">block the internet</mark></strong> as they did in August 2020 during the elections turmoil, as you can see on the chart below</p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-19-1024x554.png" alt="" class="wp-image-2996" width="534" height="288" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-19-1024x554.png 1024w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-19-300x162.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-19-768x416.png 768w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-19.png 1461w" sizes="(max-width: 534px) 100vw, 534px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/3rVh0Lk" target="_blank" rel="noreferrer noopener">https://bit.ly/3rVh0Lk</a></figcaption></figure>



<p>In fact, the American IT company, <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Sandvine (Procera)</mark></strong>, had supplied filtering equipment for normal network operations (such as traffic optimization, congestion management, cost efficiency, anti malware&#8230;) using a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Deep Packet Inspection (DPI)</mark></strong> process, with the help of <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">resident engineers</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/Capture2.png" alt="" class="wp-image-2999" width="394" height="365" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/Capture2.png 582w, https://www.forensicxs.com/wp-content/uploads/2022/10/Capture2-300x278.png 300w" sizes="(max-width: 394px) 100vw, 394px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/3T5yiRo" target="_blank" rel="noreferrer noopener">https://bit.ly/3T5yiRo</a></figcaption></figure>



<p>The Sandvine equipement had been used by Belarus authorities to block legitimate traffic and <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">switch off</mark></strong> the Internet</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-27.png" alt="" class="wp-image-3015" width="477" height="148" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-27.png 771w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-27-300x93.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-27-768x239.png 768w" sizes="(max-width: 477px) 100vw, 477px" /></figure>



<p>Further to this, Sandvine decided to <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">terminate the contract</mark></strong> with Belarus : <a href="https://bit.ly/3VxIfcg" target="_blank" rel="noreferrer noopener">https://bit.ly/3VxIfcg</a></p>



<p>In Belarus, the state body <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">BelGIE</mark></strong> is responsible to manage the list of restricted IPs and traffic : <a href="https://belgie.by/en/home">https://belgie.by/en/home</a></p>



<p>Let&#8217;s check the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Name Servers</mark></strong> provided for the .by Belarus ccTLD (remind that a lot of domains in the world have multiple nameservers to increase reliability)</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>Name Server</th><th>IP</th><th>Identity</th><th>Location</th><th>Traceroute</th></tr></thead><tbody><tr><td>dns1.tld.becloudby.com</td><td>93.125.25.72</td><td>beCloud</td><td>Belarus</td><td>UTG<br>RETN<br>NTEC<br>beCloud</td></tr><tr><td>dns2.tld.becloudby.com</td><td>93.125.25.73</td><td>beCloud</td><td>Belarus</td><td>UTG<br>RETN<br>NTEC<br>beCloud</td></tr><tr><td>dns3.tld.becloudby.com</td><td>185.98.83.4</td><td>Dataline</td><td>Russia</td><td>UTG<br>RETN<br>Dataline</td></tr><tr><td>dns4.tld.becloudby.com</td><td>184.72.17.94</td><td>Amazon AWS</td><td>USA</td><td>AWS</td></tr><tr><td>dns5.tld.becloudby.com</td><td>54.180.35.203</td><td>Amazon Technologies</td><td>USA</td><td>AWS</td></tr></tbody></table><figcaption class="wp-element-caption"><a href="https://bit.ly/2wAB2B5" target="_blank" rel="noreferrer noopener">https://bit.ly/2wAB2B5</a></figcaption></figure>



<p>The main Name Servers n°1 and n°2 are hosted by <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">beCloud</mark></strong> in Belarus</p>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Ukrainian Telecommunications Group (UTG)</mark></strong> is a major Ukrainian operator, enabling some part of the traffic towards Belarus.  <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">RETN </mark></strong>is a major international network operator headquartered in UK and managing Eurasian cables going through Ukraine and Russia</p>



<p>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">National Traffic Exchange Center (NTEC)</mark></strong> has been seen above already, and we can confirm that the NTEC is at the center of the Internet communication from abroad Belarus</p>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Dataline</mark></strong> is an IT company located in Russia with cloud capabilities. It&#8217;s interesting to see that some backup Belarus Name Servers are hosted in <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Russia (Dataline)</mark></strong> and <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">USA (AWS)</mark></strong></p>



<p>Here below are the main <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">ISP</mark></strong> (Internet Service Providers) of Belarus :</p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-10-1024x606.png" alt="" class="wp-image-2984" width="486" height="286"/><figcaption class="wp-element-caption"><a href="https://bit.ly/3T5TNS3" target="_blank" rel="noreferrer noopener">https://bit.ly/3T5TNS3</a></figcaption></figure>



<p>Internet usage in Belarus is about <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">82%</mark></strong>, as we can find here : <a rel="noreferrer noopener" href="https://bit.ly/3CjOKqz" target="_blank">https://bit.ly/3CjOKqz</a>. It is similar as the one of France</p>



<p>The mobile networks <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">2G/3G/4G</mark></strong> are quite widespread, with a stronger concentration of these networks around major cities</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-6.png" alt="" class="wp-image-2978" width="446" height="320" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-6.png 878w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-6-300x216.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-6-768x553.png 768w" sizes="(max-width: 446px) 100vw, 446px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/3RFEQVO" target="_blank" rel="noreferrer noopener">https://bit.ly/3RFEQVO</a></figcaption></figure>



<p>The mobile network <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">5G</mark></strong> is not yet deployed, but activities are on-going to implement this latest standard</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-7.png" alt="" class="wp-image-2979" width="450" height="347" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-7.png 660w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-7-300x231.png 300w" sizes="(max-width: 450px) 100vw, 450px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/3Eq7APc" target="_blank" rel="noreferrer noopener">https://bit.ly/3Eq7APc</a></figcaption></figure>



<p>The overall <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">efficiency</mark></strong> of the Belarus network is not that great, probably due to a lower coverage in rural areas</p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-18-1024x568.png" alt="" class="wp-image-2995" width="455" height="251" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-18-1024x568.png 1024w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-18-300x166.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-18-768x426.png 768w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-18.png 1147w" sizes="(max-width: 455px) 100vw, 455px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/3CGAzNA" target="_blank" rel="noreferrer noopener">https://bit.ly/3CGAzNA</a></figcaption></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">Operational and Analytical Center</mark></strong></p>



<p>Let&#8217;s go deeper on the OAC &#8211; chief inspector of the Belarus TLD &#8211; that we have seen above : <a rel="noreferrer noopener" href="https://bit.ly/3gVNzGH" target="_blank">https://bit.ly/3gVNzGH</a></p>



<p>First of all, you shall know that the OAC is entitled by Law to restrict internet, in case of threats to National Security : <a href="https://bit.ly/3TrZaei" target="_blank" rel="noreferrer noopener">https://bit.ly/3TrZaei</a></p>



<p>We can use several <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">footprinting</mark></strong> and <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">recon</mark></strong> tools for that. Let&#8217;s go through the findings using some of these tools</p>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">urlscan.io</mark></strong> : <a href="https://bit.ly/3sG0S0m" target="_blank" rel="noreferrer noopener">https://bit.ly/3sG0S0m</a></p>



<p>The main IP is 195.50.4.123, located in Minsk, and belongs to BCTBY-AS, which is Belarusian Cloud Technologies, as seen above. The site takes advantage of the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Google web tracking</mark></strong> technologies, helping the webmaster to perform <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">analytics</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-31.png" alt="" class="wp-image-3033" width="397" height="238" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-31.png 536w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-31-300x180.png 300w" sizes="(max-width: 397px) 100vw, 397px" /></figure>



<p>Google Tag Manager (GTM) has been interesting for hackers, as JavaScript can be embedded inside GTM containers and is executed when a browser loads the link to a container : <a href="https://bit.ly/3Nihfd4" target="_blank" rel="noreferrer noopener">https://bit.ly/3Nihfd4</a></p>



<p>Doubleclick (<a rel="noreferrer noopener" href="https://bit.ly/3sGfQn9" target="_blank">https://bit.ly/3sGfQn9</a>) now belongs to Google and is part of the Google Marketing tools</p>



<p>With all these Google technology embedded inside their website, the admin have a good way to <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">track user</mark></strong> navigation on their website</p>



<p>We can read the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Javascript global variables</mark></strong>, here below</p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-33-1024x186.png" alt="" class="wp-image-3038" width="698" height="126" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-33-1024x186.png 1024w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-33-300x54.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-33-768x139.png 768w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-33.png 1131w" sizes="(max-width: 698px) 100vw, 698px" /></figure>



<p>Apart from usual Javascript events, we can confirm the Google analytics and tag manager, already mentioned above. In addition, we find the NS_CSM, which are <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Citrix</mark></strong> variables standing for <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Client Side Measurement</mark></strong></p>



<p>The CSM is the console included in the Citrix WAF (Web Application Firewall), allowing the Admin to monitor any security events. Here a sample screenshot of the interface</p>



<figure class="wp-block-image size-full"><img decoding="async" width="982" height="549" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-32.png" alt="" class="wp-image-3037" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-32.png 982w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-32-300x168.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-32-768x429.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/3NmBIgN" target="_blank" rel="noreferrer noopener">https://bit.ly/3NmBIgN</a></figcaption></figure>



<p>Basically, the Citrix WAF works as follows</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-37.png" alt="" class="wp-image-3042" width="372" height="452" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-37.png 670w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-37-247x300.png 247w" sizes="(max-width: 372px) 100vw, 372px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/3DHGjXP" target="_blank" rel="noreferrer noopener">https://bit.ly/3DHGjXP</a></figcaption></figure>



<p>The Citrix WAF is based upon a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">cookie</mark></strong> derived from the web client session : <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">citrix_ns_id</mark></strong></p>



<p>In fact, to maintain the state of the session, the Citrix Web App Firewall generates its own session cookie, and passes it only between the web browser and the Citrix Web Application Firewall, and <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">not to the web server</mark></strong></p>



<p>This will ensure that if any hacker tries to modify the session cookie, the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">WAF will drop</mark></strong> the current session, and the WAF will <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">keep the information</mark></strong> of the URLs and forms visited by the client</p>



<p>Here further details about how this Citrix WAF is working : <a href="https://bit.ly/3UeJ4p7" target="_blank" rel="noreferrer noopener">https://bit.ly/3UeJ4p7</a></p>



<p>Here below <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">all cookies</mark></strong> generated by the website :</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="759" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-34-1024x759.png" alt="" class="wp-image-3039" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-34-1024x759.png 1024w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-34-300x222.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-34-768x569.png 768w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-34.png 1069w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>Beyond the citrix_ns_id, we find the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">citrix_bot_id cookie</mark></strong>. This allows the Admin to implement <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Bot management policies</mark></strong>, to block malicious bots : <a href="https://bit.ly/3U62hd3" target="_blank" rel="noreferrer noopener">https://bit.ly/3U62hd3</a></p>



<p>We also see the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">XSRF token</mark></strong> (see here a definition : <a rel="noreferrer noopener" href="https://bit.ly/3DIOz9Y" target="_blank">https://bit.ly/3DIOz9Y</a>), which will help protect against <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">web sites forgeries</mark></strong></p>



<p>Beyond these cookies, we can see some basic <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">web hacking protections</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-35.png" alt="" class="wp-image-3040" width="534" height="77" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-35.png 852w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-35-300x44.png 300w" sizes="(max-width: 534px) 100vw, 534px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">nosniff</mark></strong> will help protect against MIME sniffing</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-38.png" alt="" class="wp-image-3043" width="433" height="165" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-38.png 626w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-38-300x114.png 300w" sizes="(max-width: 433px) 100vw, 433px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/3Ud9Wpc" target="_blank" rel="noreferrer noopener">https://bit.ly/3Ud9Wpc</a></figcaption></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">SAMEORIGIN</mark></strong> will block iframe inclusions that are not from the same web site origin</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-39.png" alt="" class="wp-image-3044" width="407" height="184" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-39.png 615w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-39-300x136.png 300w" sizes="(max-width: 407px) 100vw, 407px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/3U84Hav" target="_blank" rel="noreferrer noopener">https://bit.ly/3U84Hav</a></figcaption></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">1; mode=block</mark></strong> will prevent XSS attacks</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-40.png" alt="" class="wp-image-3045" width="438" height="243" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-40.png 768w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-40-300x167.png 300w" sizes="(max-width: 438px) 100vw, 438px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/2GWk0zR" target="_blank" rel="noreferrer noopener">https://bit.ly/2GWk0zR</a></figcaption></figure>



<p>Created for browsers equipped with XSS filters, this non-standard header was intended as a way to control the filtering functionality. Since modern browsers no longer use XSS filtering, this header is now <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">deprecated</mark></strong></p>



<p>We can see that the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">server is an nginx</mark></strong> dealing http requests on the port 443 (as expected)</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-41.png" alt="" class="wp-image-3046" width="316" height="285" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-41.png 615w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-41-300x270.png 300w" sizes="(max-width: 316px) 100vw, 316px" /></figure>



<p>The website is protected by <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">TLS1.3</mark></strong> and AES256</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-42.png" alt="" class="wp-image-3047" width="283" height="154" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-42.png 518w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-42-300x163.png 300w" sizes="(max-width: 283px) 100vw, 283px" /></figure>



<p>The website has an encryption certificate delivered by <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Let&#8217;s Encrypt</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/10/image-46.png" alt="" class="wp-image-3051" width="481" height="274" srcset="https://www.forensicxs.com/wp-content/uploads/2022/10/image-46.png 624w, https://www.forensicxs.com/wp-content/uploads/2022/10/image-46-300x171.png 300w" sizes="(max-width: 481px) 100vw, 481px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/3SOxYpK" target="_blank" rel="noreferrer noopener">https://bit.ly/3SOxYpK</a></figcaption></figure>



<p>Some people have <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">criticized</mark></strong> the fact that Let&#8217;s Encrypt provides CERT services to Belarus. But in fact, they validate only that the server has the proven control over the domain name you are visiting. And beyond that, blocking US CERT would probably push Belarus to implement <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Russian government Certificate of Authority</mark></strong>, with all potential risks for the end users : <a rel="noreferrer noopener" href="https://bit.ly/3U8wA2i" target="_blank">https://bit.ly/3U8wA2i</a></p>



<p>For the following analysis, check this reminder about <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">DNS</mark></strong> here : <a rel="noreferrer noopener" href="https://bit.ly/3E0FmtV" target="_blank">https://bit.ly/3E0FmtV</a>, and also here : <a rel="noreferrer noopener" href="https://bit.ly/3FOpETN" target="_blank">https://bit.ly/3FOpETN</a></p>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">BuiltWith Technology Profiler</mark></strong> : <a href="https://bit.ly/3hB2JBy" target="_blank" rel="noreferrer noopener">https://bit.ly/3hB2JBy</a></p>



<p>We can find more details about the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">front-end</mark></strong>, mainly the use of <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Javascript Framework</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/11/image-13.png" alt="" class="wp-image-3074" width="557" height="162" srcset="https://www.forensicxs.com/wp-content/uploads/2022/11/image-13.png 700w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-13-300x87.png 300w" sizes="(max-width: 557px) 100vw, 557px" /></figure>



<p>We can also find more details about the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">back-end</mark></strong> server</p>



<p>It seems that the server is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">probably</mark></strong> built using <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">PHP</mark></strong> version 7 or above (but this has not been detected since 2021 so it may have been replaced by another)</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/11/image-11.png" alt="" class="wp-image-3072" width="572" height="71" srcset="https://www.forensicxs.com/wp-content/uploads/2022/11/image-11.png 723w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-11-300x38.png 300w" sizes="(max-width: 572px) 100vw, 572px" /></figure>



<p>The server has a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Sender Policy Framework (SPF)</mark></strong>, which enables receiving mail servers to authenticate whether an email message was sent from an authorized mail server (spam and spoofing protection)</p>



<p>The server is based upon <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Nginx</mark></strong>. Previously, it was based upon<strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color"> Apache</mark></strong> (year 2019), and the OS was <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Debian</mark></strong> (year 2017)</p>



<p>We will see below that it&#8217;s now <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">probably</mark></strong> running <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">FreeBSD</mark></strong> (<a rel="noreferrer noopener" href="https://bit.ly/3AbZqaf" target="_blank">https://bit.ly/3AbZqaf</a>)</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/11/image-12.png" alt="" class="wp-image-3073" width="573" height="248" srcset="https://www.forensicxs.com/wp-content/uploads/2022/11/image-12.png 704w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-12-300x130.png 300w" sizes="(max-width: 573px) 100vw, 573px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">whois</mark></strong></p>



<p>Let&#8217;s run a whois against the IP address 195.50.4.123</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/11/image-7.png" alt="" class="wp-image-3066" width="524" height="563" srcset="https://www.forensicxs.com/wp-content/uploads/2022/11/image-7.png 744w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-7-279x300.png 279w" sizes="(max-width: 524px) 100vw, 524px" /></figure>



<p>We confirm that the IP is owned by Belarusian Cloud Technologies LLC, as seen above. There are two contact people, that we can cross check on social networks. We find the Linkedin profile of Andrey Chepikov, which states an experience at &#8220;protection of networks <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">against external influences</mark></strong>&#8220;</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/11/image-8.png" alt="" class="wp-image-3067" width="406" height="312" srcset="https://www.forensicxs.com/wp-content/uploads/2022/11/image-8.png 846w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-8-300x231.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-8-768x592.png 768w" sizes="(max-width: 406px) 100vw, 406px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">dnsrecon</mark></strong> : <a rel="noreferrer noopener" href="https://bit.ly/3sN1txp" target="_blank">https://bit.ly/3sN1txp</a></p>



<p>This tool does a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">DNS enumeration</mark></strong>. We find the basic informations about the domain oac.gov.by (MX : Mail Server, A : IP address, TXT : Text record). The Sender Policy Framework (SPF) is configured (v=spf1 -all) , so that only this server can send emails on behalf of the domain</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/11/image.png" alt="" class="wp-image-3055" width="615" height="135" srcset="https://www.forensicxs.com/wp-content/uploads/2022/11/image.png 782w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-300x66.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-768x169.png 768w" sizes="(max-width: 615px) 100vw, 615px" /></figure>



<p>To use Google Analytics, you need to prove that you own the domain. That&#8217;s why the Admin added a TXT record to prove this, with <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">google-site-verification</mark></strong>. Here is how you can confirm your domain ownership : <a rel="noreferrer noopener" href="https://bit.ly/3NE66DR" target="_blank">https://bit.ly/3NE66DR</a></p>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">dig</mark></strong> : <a href="https://bit.ly/3FTE3hT" target="_blank" rel="noreferrer noopener">https://bit.ly/3FTE3hT</a></p>



<p>We can check if the domain has <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">DNSSEC</mark></strong> implemented. In this case, it is <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">not enabled</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/11/image-9.png" alt="" class="wp-image-3068" width="496" height="290" srcset="https://www.forensicxs.com/wp-content/uploads/2022/11/image-9.png 636w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-9-300x175.png 300w" sizes="(max-width: 496px) 100vw, 496px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">dnshistory</mark></strong> : <a rel="noreferrer noopener" href="https://bit.ly/3SPbxkc" target="_blank">https://bit.ly/3SPbxkc</a></p>



<p>We can see that the domain has historical records dating from <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">December 2012</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/11/image-2.png" alt="" class="wp-image-3058" width="525" height="499" srcset="https://www.forensicxs.com/wp-content/uploads/2022/11/image-2.png 920w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-2-300x286.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-2-768x731.png 768w" sizes="(max-width: 525px) 100vw, 525px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">Linkedin</mark></strong></p>



<p>We can find some interesting informations on this social network, such as technologies that the OAC may be actively using :</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/11/image-10.png" alt="" class="wp-image-3071" width="519" height="419" srcset="https://www.forensicxs.com/wp-content/uploads/2022/11/image-10.png 814w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-10-300x243.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-10-768x622.png 768w" sizes="(max-width: 519px) 100vw, 519px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/3G6xrMW" target="_blank" rel="noreferrer noopener">https://bit.ly/3G6xrMW</a></figcaption></figure>



<p>We can therefore correlate some technical evidences we had found in the previous sections, which increases the probability that the OAC actually uses these technologies</p>



<p>We can therefore assume the following architecture :</p>



<ul class="wp-block-list">
<li>Javascript <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Vue.js</mark></strong> Frameworks for the Front-End</li>



<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">PHP Laravel</mark></strong>, Node.js, React.js Frameworks for the Back-End</li>



<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">PostgreSQL</mark></strong>, <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">MongoDB</mark></strong> for the database management</li>
</ul>



<p>The softwares and services are <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">probably</mark></strong> based upon a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Cloud Native</mark></strong>  architecture :</p>



<ul class="wp-block-list">
<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">VMware</mark></strong> (Virtual Machines)</li>



<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Kubernetes</mark></strong> k8s (to manage containerized applications across multiple hosts)</li>



<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Gitlab CI</mark></strong> (Continuous Integration) </li>



<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">CEPH</mark></strong> as a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">distributed storage system</mark></strong> (<a rel="noreferrer noopener" href="https://bit.ly/3Emillf" target="_blank">https://bit.ly/3Emillf</a>)</li>
</ul>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">p0f</mark></strong> : <a href="https://bit.ly/3AbaEMb" target="_blank" rel="noreferrer noopener">https://bit.ly/3AbaEMb</a></p>



<p>p0f &#8211; <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">passive operating system fingerprinting</mark></strong> &#8211; can be used to detect the server Operating System (OS). It will detect how the OS implements the TCP/IP stack</p>



<p>In our case, I find that the server machine is based upon <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Windows XP</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/11/image-14.png" alt="" class="wp-image-3077" width="432" height="205" srcset="https://www.forensicxs.com/wp-content/uploads/2022/11/image-14.png 588w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-14-300x142.png 300w" sizes="(max-width: 432px) 100vw, 432px" /></figure>



<p>Is it weird to find such an outdated version of Windows ? Not quite. Some organizations are still using XP nowadays. For example, the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Belarus railway system is using Windows XP</mark></strong>, as it was shown to the world during the invasion of Russia into Ukraine (<a rel="noreferrer noopener" href="https://bit.ly/3GbVrhG" target="_blank">https://bit.ly/3GbVrhG</a>)</p>



<p>In addition, Microsoft has decided to <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">block new Windows licence</mark></strong> to Belarus and Russia (<a rel="noreferrer noopener" href="https://bit.ly/3Trb5Ja" target="_blank">https://bit.ly/3Trb5Ja</a>), this will not help Belarus to move to more recent versions</p>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">Zenmap</mark></strong></p>



<p>We are going to find additional informations with Zenmap (in fact, it is a GUI version of <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">nmap</mark></strong> : <a rel="noreferrer noopener" href="https://bit.ly/2Hlfc7P" target="_blank">https://bit.ly/2Hlfc7P</a>)</p>



<p>The first one is the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">TCP Sequence Prediction </mark></strong>(difficulty = 251 in our case), which is a measure of the risk that a TCP connection can be hijacked by an attacker, predicting the sequence number and preparing a faked packet (you can learn more about sequence number here <a rel="noreferrer noopener" href="https://bit.ly/3G9JPMb" target="_blank">https://bit.ly/3G9JPMb</a> and also here <a rel="noreferrer noopener" href="https://bit.ly/3EsStUZ" target="_blank">https://bit.ly/3EsStUZ</a>)</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/11/image-19.png" alt="" class="wp-image-3084" width="400" height="28" srcset="https://www.forensicxs.com/wp-content/uploads/2022/11/image-19.png 458w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-19-300x21.png 300w" sizes="(max-width: 400px) 100vw, 400px" /></figure>



<p>We find the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">open Ports</mark></strong> and more technical informations about hardware used</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/11/image-17.png" alt="" class="wp-image-3082" width="651" height="80" srcset="https://www.forensicxs.com/wp-content/uploads/2022/11/image-17.png 816w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-17-300x37.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-17-768x95.png 768w" sizes="(max-width: 651px) 100vw, 651px" /></figure>



<p>The open Ports <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">80</mark></strong> (HTTP) and <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">443</mark></strong> (HTTPS) are typical for a Web Server</p>



<p>We find a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Citrix NetScaler, </mark></strong>which is an Application Delivery Controller (<strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">ADC</mark></strong>) created to optimize, manage, and secure network traffic : <a rel="noreferrer noopener" href="https://bit.ly/3X1Coww" target="_blank">https://bit.ly/3X1Coww</a>. This includes the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Citrix WAF</mark></strong> we have seen earlier</p>



<p>It is also <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">probable</mark></strong> that this ADC is acting as a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Citrix VPX Load Balancer</mark></strong>. A typical network topology would be as follows (VIP = virtual server IP), with internal machines hidden behind the Citrix ADC :</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/11/image-22.png" alt="" class="wp-image-3092" width="398" height="254" srcset="https://www.forensicxs.com/wp-content/uploads/2022/11/image-22.png 815w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-22-300x192.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-22-768x492.png 768w" sizes="(max-width: 398px) 100vw, 398px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/3Ac5n7n" target="_blank" rel="noreferrer noopener">https://bit.ly/3Ac5n7n</a></figcaption></figure>



<p>Zenmap provides <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">probable</mark></strong> <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">infrastructure</mark></strong> informations (with % of probability) :</p>



<ul class="wp-block-list">
<li>Citrix NetScaler VPX load balancer (89%) : as seen above</li>



<li>Linksys BEFSR41 EtherFast router (86%) : it&#8217;s a basic network <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">router</mark></strong></li>



<li>AVtech Room Alert 26W environmental monitor (86%)  : server room real time <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">monitoring</mark></strong> of temperature, humidity,&#8230;</li>



<li>FreeBSD 6.2-Release (85%) : it&#8217;s <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">probable</mark></strong> that the server is based upon <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">FreeBSD 6.2</mark></strong>. If true, this is quite an outdated version. We can check the version 6.3 release notes to get an overview of the bugs in 6.2 : <a href="https://bit.ly/3UQUhMH" target="_blank" rel="noreferrer noopener">https://bit.ly/3UQUhMH</a></li>
</ul>



<p>Let&#8217;s compare with a direct OS discover using <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">nmap</mark></strong></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/11/image-21.png" alt="" class="wp-image-3091" width="550" height="144" srcset="https://www.forensicxs.com/wp-content/uploads/2022/11/image-21.png 695w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-21-300x79.png 300w" sizes="(max-width: 550px) 100vw, 550px" /></figure>



<p>nmap provides us with a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">probable</mark></strong> guess, that FreeBSD 6.2 is based upon the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Virtual Machine Oracle Virtualbox</mark></strong></p>



<figure class="wp-block-image size-full"><img decoding="async" width="917" height="100" src="https://www.forensicxs.com/wp-content/uploads/2022/11/image-20.png" alt="" class="wp-image-3090" srcset="https://www.forensicxs.com/wp-content/uploads/2022/11/image-20.png 917w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-20-300x33.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-20-768x84.png 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">Web security</mark></strong></p>



<p>We can dig a bit deeper if the web site is well protected, using a vulnerability scanner, such as <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Wapiti</mark></strong> : <a rel="noreferrer noopener" href="https://bit.ly/3VxDZss" target="_blank">https://bit.ly/3VxDZss</a></p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="181" src="https://www.forensicxs.com/wp-content/uploads/2022/11/image-23-1024x181.png" alt="" class="wp-image-3097" srcset="https://www.forensicxs.com/wp-content/uploads/2022/11/image-23-1024x181.png 1024w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-23-300x53.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-23-768x135.png 768w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-23-1536x271.png 1536w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-23.png 1667w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></figure>



<p>We get the following report :</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/11/image-24.png" alt="" class="wp-image-3098" width="510" height="635" srcset="https://www.forensicxs.com/wp-content/uploads/2022/11/image-24.png 582w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-24-241x300.png 241w" sizes="(max-width: 510px) 100vw, 510px" /></figure>



<p>Let&#8217;s go through the results :</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/11/image-25.png" alt="" class="wp-image-3099" width="487" height="149" srcset="https://www.forensicxs.com/wp-content/uploads/2022/11/image-25.png 1024w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-25-300x92.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-25-768x236.png 768w" sizes="(max-width: 487px) 100vw, 487px" /></figure>



<p>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Content Security Policy header (CSP)</mark></strong> lets you precisely control permitted content sources and many other content parameters, and is a recommended way to protect your websites and applications against XSS attacks. A basic CSP header to allow only assets from the local origin is :</p>



<pre class="wp-block-code"><code>Content-Security-Policy: default-src 'self'</code></pre>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/11/image-29.png" alt="" class="wp-image-3105" width="497" height="153" srcset="https://www.forensicxs.com/wp-content/uploads/2022/11/image-29.png 755w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-29-300x93.png 300w" sizes="(max-width: 497px) 100vw, 497px" /><figcaption class="wp-element-caption"><a href="https://bit.ly/3XNY002" target="_blank" rel="noreferrer noopener">https://bit.ly/3XNY002</a></figcaption></figure>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/11/image-26.png" alt="" class="wp-image-3100" width="485" height="138" srcset="https://www.forensicxs.com/wp-content/uploads/2022/11/image-26.png 1024w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-26-300x86.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-26-768x220.png 768w" sizes="(max-width: 485px) 100vw, 485px" /></figure>



<p>When enabled on the server, the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">HTTP Strict Transport Security header (HSTS)</mark></strong> enforces the use of encrypted HTTPS connections instead of plain-text HTTP communication. A typical HSTS header might look like this:</p>



<pre class="wp-block-code"><code>Strict-Transport-Security: max-age=63072000; includeSubDomains; preload</code></pre>



<p>This informs any visiting web browser that the site and all its subdomains uses only SSL/TLS communication, and that the browser should default to accessing it over <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">HTTPS</mark></strong> for the next two years (the <code>max-age</code> value in seconds)</p>



<p>The <code>preload</code> directive indicates that the site is present on a global list of HTTPS-only sites. The purpose of preloading is to speed up page loads and eliminate the risk of <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">man-in-the-middle (MITM)</mark></strong> attacks when a site is visited for the first time</p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/11/image-27-1024x781.png" alt="" class="wp-image-3101" width="484" height="369" srcset="https://www.forensicxs.com/wp-content/uploads/2022/11/image-27-1024x781.png 1024w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-27-300x229.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-27-768x585.png 768w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-27.png 1039w" sizes="(max-width: 484px) 100vw, 484px" /></figure>



<p>An <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">HttpOnly Cookie</mark></strong> is a tag added to a browser cookie, that prevents client-side scripts from accessing data. Using the HttpOnly tag when generating a cookie helps mitigate the risk of client-side scripts accessing the protected cookie, thus making these cookies more secure.</p>



<p>The example below shows the syntax used within the HTTP response header :</p>



<p>Set-Cookie: <code>=“[; “=“]</code> <code>[; expires=“][; domain=“]</code> <code>[; path=“][; secure][; HttpOnly]</code></p>



<p>If the HttpOnly flag is included in the HTTP response header, the cookie cannot be accessed through the client-side script. As a result, even if a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">cross-site scripting (XSS) flaw</mark></strong> exists, and a user accidentally accesses a link that exploits the flaw, the browser will not reveal the cookie to the third-party</p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://www.forensicxs.com/wp-content/uploads/2022/11/image-28-1024x806.png" alt="" class="wp-image-3102" width="486" height="382" srcset="https://www.forensicxs.com/wp-content/uploads/2022/11/image-28-1024x806.png 1024w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-28-300x236.png 300w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-28-768x604.png 768w, https://www.forensicxs.com/wp-content/uploads/2022/11/image-28.png 1042w" sizes="(max-width: 486px) 100vw, 486px" /></figure>



<p>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Secure flag</mark></strong> is used to declare that the cookie may only be transmitted using a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">secure connection</mark></strong> (SSL/HTTPS). If this cookie is set, the browser will never send the cookie if the connection is HTTP. This flag prevents cookie theft via <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">man-in-the-middle attacks</mark></strong></p>



<p>It would be good practice to enable the above <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">security flags</mark></strong>, thus complying with the OWASP recommendations. However, I assume that the OAC is not so concerned, as the website does not include many rich content, and a powerfull <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">WAF</mark></strong> is already implemented</p>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">Belarus web infrastructure in summary</mark></strong></p>



<p>Let&#8217;s summarize the infrastructure that we have seen above</p>



<figure class="wp-block-table"><table><thead><tr><th>Entity</th><th>Key observation</th><th>Comment</th></tr></thead><tbody><tr><td>Belarus TLD</td><td>Name Servers are hosted in several countries</td><td>Belarus (beCloud), Russia (Dataline), USA (AWS)</td></tr><tr><td>beCloud</td><td>Sovereign Cloud and Internet infrastructure</td><td>Built with the support of many international corporations</td></tr><tr><td>oac.gov.by</td><td>IP owned by Belarusian Cloud Technologies</td><td>State owned Beltelecom has control over most of the Internet infrastructure</td></tr><tr><td>oac.gov.by</td><td>Chief inspector of the Belarus TLD</td><td>Entitled by Law to restrict internet, in case of threats to National Security</td></tr><tr><td>BelGIE</td><td>Responsible to optimize the traffic and filter IP addresses as per the need</td><td>DPI (Deep Packet Inspection) as per the need. Got support from Sandvine in the past for traffic optimization (including filtering)</td></tr><tr><td>oac.gov.by</td><td>Performs analytics using Google web tracking</td><td>Google Tag Manager, Doubleclick</td></tr><tr><td>oac.gov.by</td><td>WAF and Load Balancer implemented using Citrix</td><td>Citrix NetScaler<br>Citrix VPX Load Balancer</td></tr><tr><td>oac.gov.by</td><td>Encryption of the website using TLS1.3 and AES256</td><td>Certificate issued by Let&#8217;s Encrypt</td></tr><tr><td>oac.gov.by</td><td>Web server machine</td><td>The web server may use a Windows XP machine, with an nginx server</td></tr><tr><td><br>oac.gov.by</td><td>Web server OS</td><td>Managed by a FreeBSD controller, built upon an Oracle VM Virtual Box</td></tr><tr><td>oac.gov.by</td><td>Web security</td><td>Some usual basic security flags are missing, but the website is protected using a WAF</td></tr></tbody></table></figure>



<p><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">Conclusion</mark></strong></p>



<p>In this short preview of the Belarus web infrastructure, we have seen the following items, using <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">footprinting</mark></strong> methods :</p>



<ul class="wp-block-list">
<li>Belarus has built a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">sovereign cloud</mark></strong> to manage its web infrastructure, with the help of <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">international corporations</mark></strong> (US, Europe, Asia,..)</li>



<li>The Belarus Name Server is backed-up by <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">AWS</mark></strong> (USA) and <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Dataline</mark></strong> (Russia)</li>



<li>The Belarus authorities have a <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">strong degree of control</mark></strong> over access points and can block any IP traffic if necessary (such as during the August 2020 elections turmoil)</li>



<li>The Operational and Analytical Center (OAC) is the <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">chief inspector</mark></strong> of the Belarus Top Level Domain (TLD)</li>



<li>The OAC website performs analytics using <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Google web tracking</mark></strong> technology</li>



<li>The OAC website is protected with the use of <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Citrix</mark></strong> technology (WAF, Load Balancer), and its root certificate is issued by <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Let&#8217;s Encrypt</mark></strong></li>



<li>The OAC web server <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">may</mark></strong> be based upon an <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">obsolete version of Windows (XP)</mark></strong> and does not comply with all the basic <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">OWASP</mark></strong> recommendations</li>



<li>The <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">restrictions applied to Belarus</mark></strong> by some US corporations such as <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Microsoft</mark></strong> will limit their ability to implement security patches and updates</li>



<li><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">Linkedin profiles</mark></strong> are always a good way to learn more about the technologies used by a target</li>
</ul>



<p><br></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.forensicxs.com/belarus-and-the-web/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Database Caching 1/49 queries in 0.049 seconds using Disk

Served from: www.forensicxs.com @ 2026-01-01 06:02:18 by W3 Total Cache
-->