<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Zakaryteo on Medium]]></title>
        <description><![CDATA[Stories by Zakaryteo on Medium]]></description>
        <link>https://medium.com/@zakaryteo?source=rss-d92c29bdd2a6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ZZ5grL3wMy9_umMS</url>
            <title>Stories by Zakaryteo on Medium</title>
            <link>https://medium.com/@zakaryteo?source=rss-d92c29bdd2a6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 08:54:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@zakaryteo/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building a Real-Time SIEM for Ethereum Smart Contract Attacks]]></title>
            <link>https://medium.com/@zakaryteo/building-a-real-time-siem-for-ethereum-smart-contract-attacks-97732205b0ef?source=rss-d92c29bdd2a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/97732205b0ef</guid>
            <category><![CDATA[blockchain-security]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[web3-security]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Zakaryteo]]></dc:creator>
            <pubDate>Mon, 18 May 2026 16:40:30 GMT</pubDate>
            <atom:updated>2026-05-18T16:40:30.885Z</atom:updated>
            <content:encoded><![CDATA[<h3>How I built a detection system that catches reentrancy, integer overflow, and access control exploits as they happen — with Discord alerts and a Kibana dashboard</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iiDXQvipkv3ket_-r5YFIg.png" /><figcaption>Kibana dashboard</figcaption></figure><h3>The problem with smart contract security</h3><p>Most smart contract security tools work in one of two ways: static analysis before deployment, or post-mortem investigation after an exploit. Neither tells you what’s happening <em>right now</em>.</p><p>The 2016 DAO hack drained $60 million before anyone could react. The 2022 Ronin bridge exploit went undetected for six days. In both cases, the attack pattern was visible on-chain the entire time — nobody was watching.</p><p>This project asks a simple question: <em>what if you were watching?</em></p><p>I built a lightweight SIEM (Security Information and Event Management) system for Ethereum smart contracts. It monitors a local blockchain in real time, detects three classic attack patterns as they execute, and fires alerts to Discord and Elasticsearch within seconds of the malicious transaction being mined.</p><h3>The attack lab</h3><p>The lab runs on a local Hardhat network and contains three deliberately vulnerable contracts:</p><p><strong>Vulnerable.sol</strong> — the classic reentrancy target. The withdraw() function sends ETH to the caller before updating the internal balance. This violates the Checks-Effects-Interactions pattern, allowing a malicious contract to re-enter withdraw() repeatedly inside a single transaction.</p><p><strong>VulnerableBank.sol</strong> — an integer overflow target. The transfer() function uses Solidity&#39;s unchecked block, disabling the overflow protection added in 0.8.0. Subtracting 2 from a balance of 1 silently wraps around to uint256.max, giving the attacker a near-infinite balance to drain the vault.</p><p><strong>VulnerableVault.sol</strong> — an access control target. The drainVault() function has no onlyOwner modifier. Any address — not just the owner — can call it and sweep the entire contract balance.</p><p>Each contract has a corresponding attacker contract and deploy/attack script, so every exploit can be triggered with a single command.</p><h3>How detection works</h3><p>The core insight is that <strong>every attack leaves an on-chain trace in the transaction logs</strong> — you just have to know what pattern to look for.</p><p>The detection bot (bot/agent.js) subscribes to new blocks and inspects every transaction receipt. Rather than filtering by tx.to (which would miss attacks routed through an intermediary contract), it scans every log in the receipt and checks whether the <em>emitting address</em> matches a monitored contract.</p><pre>const hasTrackedLog = receipt.logs.some(<br>    log =&gt; contractMap.has(log.address.toLowerCase())<br>);</pre><p>This is the critical difference from naive monitoring. In a reentrancy attack, the transaction goes <em>to</em> the attacker contract — not the vulnerable one. The vulnerable contract’s events only appear as internal logs. Filtering by tx.to would miss them entirely.</p><p>Once a relevant transaction is found, bot/detection.js routes each log to the appropriate detection logic based on the contract type.</p><h3>Detection signatures</h3><p><strong>Reentrancy</strong> is the simplest to detect. Each re-entrant call to withdraw() eventually emits a Withdraw event. Count how many times the same address appears as the withdrawer in a single transaction — two or more is a reentrancy.</p><pre>if (topic === TOPICS.Withdraw) {<br>    const user = decodeAddress(log.topics[1]);<br>    withdrawCounts.set(user, (withdrawCounts.get(user) || 0) + 1);<br>}<br>// later...<br>if (count &gt;= 2) → REENTRANCY ALERT</pre><p><strong>Integer overflow</strong> is trickier because the corrupted state is internal to the contract. The detection signal is the Transfer event. The bot tracks each address&#39;s running deposit balance. When a Transfer event shows an outgoing amount that exceeds the tracked balance, an underflow has occurred.</p><pre>if (amount &gt; knownBalance) → OVERFLOW ALERT</pre><p>This works even when the vault has been previously drained, because the underflow is visible in the Transfer arguments regardless of how much ETH is available.</p><p><strong>Access control</strong> is the most straightforward. The VaultDrained event records who called drainVault(). The owner address is saved to config at deploy time. Any mismatch is a violation.</p><pre>if (caller.toLowerCase() !== contractInfo.owner.toLowerCase()) → ACCESS CONTROL ALERT</pre><h3>The alerting pipeline</h3><p>When an attack is detected, three things happen simultaneously:</p><ol><li><strong>Console output</strong> — full JSON alert with transaction hash, attacker address, and attack details printed to the terminal</li><li><strong>Discord embed</strong> — a formatted message sent to a webhook, colour-coded by severity (dark red for CRITICAL, red for HIGH)</li><li><strong>Elasticsearch index</strong> — a document written to the siem-alerts index with an @timestamp field, making it queryable in Kibana</li></ol><p>The Discord alert varies by attack type — the title, description, and colour all reflect the specific vulnerability detected, not just a generic “something went wrong” message.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*qbD43OHZzfzzEtznBQSIbw.png" /><figcaption>Discord notifcation</figcaption></figure><h3>The stack</h3><ul><li><strong>Hardhat 3</strong> — local Ethereum node and contract deployment</li><li><strong>ethers.js v6</strong> — blockchain interaction and log decoding</li><li><strong>Node.js ESM</strong> — the detection bot runs as a standalone process</li><li><strong>@elastic/elasticsearch v8</strong> — indexing alerts</li><li><strong>Elasticsearch 8 + Kibana 8</strong> — running in Docker via docker compose up -d</li><li><strong>axios + dotenv</strong> — Discord webhook delivery with secrets kept out of source control</li></ul><h3>Running it yourself</h3><p>The full workflow across five terminals:</p><pre># Terminal 1 — local chain<br>npx hardhat node</pre><pre># Terminal 2 — observability stack<br>docker compose up -d</pre><pre># Terminal 3 — deploy the vulnerable contracts (once per session)<br>npx hardhat run scripts/deploy.js --network localhost<br>npx hardhat run scripts/deployBank.js --network localhost<br>npx hardhat run scripts/deployVault.js --network localhost</pre><pre># Terminal 4 — start the detection bot<br>node bot/agent.js</pre><pre># Terminal 5 — trigger attacks and watch alerts fire<br>npx hardhat run scripts/attack.js --network localhost<br>npx hardhat run scripts/attackOverflow.js --network localhost<br>npx hardhat run scripts/attackAccessControl.js --network localhost</pre><p>Each attack produces a Discord embed and a Kibana document within a second or two of the transaction being mined.</p><h3>What I learned</h3><p><strong>Log-based detection beats transaction-based detection.</strong> Filtering by tx.to is the obvious approach, but it fails for any attack that flows through an intermediary contract — which is most of them. Scanning receipt logs and checking log.address is far more robust.</p><p><strong>On-chain events are honest.</strong> Smart contracts can lie in their return values, but events are part of the blockchain’s permanent record. An attacker can’t suppress a Withdraw event or forge a VaultDrained with a different caller. The event log is a tamper-evident audit trail.</p><p><strong>The detection gap is solvable.</strong> Reentrancy, overflow, and access control all have clear, unique on-chain signatures. Real-time detection isn’t a research problem — it’s an engineering one.</p><p><strong>Secrets are easy to leak.</strong> Discord webhook URLs, RPC endpoints, and private keys all need to stay out of version control. A .env file with .env in .gitignore is the minimum viable solution.</p><h3>What’s next</h3><p>A few directions this could go:</p><ul><li><strong>Mainnet / testnet monitoring</strong> — swap the local Hardhat RPC for an Alchemy or Infura endpoint and the same bot works against real contracts</li><li><strong>Flash loan detection</strong> — flash loans have a distinct pattern: borrow and repay in the same transaction, often combined with price oracle manipulation</li><li><strong>Automated incident response</strong> — beyond alerting, the bot could submit a transaction to pause a contract or drain a honeypot before the attacker can</li></ul><p>The full source is on GitHub. Contributions welcome.</p><p><em>Built with Hardhat 3, ethers.js v6, Elasticsearch, and a healthy distrust of unchecked arithmetic.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97732205b0ef" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ethernaut #17: Recovery]]></title>
            <link>https://medium.com/@zakaryteo/ethernaut-17-recovery-80ce07535a4f?source=rss-d92c29bdd2a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/80ce07535a4f</guid>
            <category><![CDATA[blockchain-security]]></category>
            <category><![CDATA[ethernaut]]></category>
            <dc:creator><![CDATA[Zakaryteo]]></dc:creator>
            <pubDate>Sat, 10 Jan 2026 07:19:58 GMT</pubDate>
            <atom:updated>2026-01-10T07:19:58.710Z</atom:updated>
            <content:encoded><![CDATA[<p>This level was a little complex to comprehend but after completing it, it was not as bad as how I envisioned it to be. So this level first starts off with me finding the lost address and how I did that was using the instance address. From this, I went to etherscan and search it up to see if there is the 0<strong>.</strong>001 ETH at an address. Next, I simply interacted with the contract via Remix.</p><pre> function destroy(address payable _to) public {<br>        selfdestruct(_to);<br>    }</pre><p>Since the function within the contract destroy is public, and it basically self destructs. I simply called this function with my own address which allowed me to pass the level.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80ce07535a4f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ethernaut #16: Preservation]]></title>
            <link>https://medium.com/@zakaryteo/ethernaut-16-preservation-f84c8d339852?source=rss-d92c29bdd2a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/f84c8d339852</guid>
            <category><![CDATA[ethernaut]]></category>
            <category><![CDATA[blockchain-security]]></category>
            <dc:creator><![CDATA[Zakaryteo]]></dc:creator>
            <pubDate>Mon, 05 Jan 2026 17:33:23 GMT</pubDate>
            <atom:updated>2026-01-05T17:33:23.236Z</atom:updated>
            <content:encoded><![CDATA[<p>This level demonstrates a classic delegatecall vulnerability. The vulnerable contract uses delegatecall to execute a library’s setTime function, but delegatecall runs the external code in the context of the caller’s storage. Because the library assumes its own storage layout, writing to storage slot 0 actually overwrites the caller’s state variable timeZone1Library.</p><pre>contract Attack {<br>    address public timeZone1Library;<br>    address public timeZone2Library;<br>    address public owner;<br><br>    function setTime(uint) public  {<br>        owner = msg.sender;<br>    }<br>}</pre><p>So I created an Attack contract for this level, where I need the for the contract address to be changed to my own exploit contract. So the first call uses delegatecall to overwrite the library address via a storage collision. Because the contract always delegatecalls whatever address is stored in timeZone1Library, the second call executes my attacker contract’s setTime function in the context of the vulnerable contract, allowing me to overwrite the owner variable with my own address. However, with the level needing 32bytes for the parameter, I had to change the contract address to it using padLeft(address, 64), with 64 being the number of characters.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f84c8d339852" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ethernaut #15: Naught Coin]]></title>
            <link>https://medium.com/@zakaryteo/ethernaut-15-naught-coin-05617b302fab?source=rss-d92c29bdd2a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/05617b302fab</guid>
            <category><![CDATA[blockchain-security]]></category>
            <category><![CDATA[ethernaut]]></category>
            <dc:creator><![CDATA[Zakaryteo]]></dc:creator>
            <pubDate>Sat, 03 Jan 2026 07:03:34 GMT</pubDate>
            <atom:updated>2026-01-03T07:03:34.379Z</atom:updated>
            <content:encoded><![CDATA[<p>With the completion of two gatekeepers, I now moved on to this level which gives a good insight of how tokens and DEX trade works. This level is also different in a sense where I did not need to come up with an attack function for it. All I had to do was interact with what was given via remix. Now for this level, I had to get rid of my tokens I am holding but the problem is that there is a 10 year lock period to the tokens. This is done by lockTokens is overriding the transfer function.</p><p>Although it seems like nothing can be transfered out, there are more functions than just this which is not overrided. Hence, I use the function transferFrom. This way the tokens are not locked and I can get rid of it as instructed for this level. So at the instance address that was given to me, and importing the code over to remix, I could interact with the code by first approving the tokens to be transferred from.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/323/1*dOnkxT2m9KWcuBvWxlsvrg.png" /><figcaption>functions that I interracted with</figcaption></figure><p>With these function, I approved the number of Naught coin tokens I had first. Then I double checked with allowance to see if every single token can be sent. Finally I used transferFrom which then I sent tokens from my own address to another address. From there, I checked the balance which resulted in 0 and completed this level.</p><p>This level taught me that even though on the surface level it might look like the tokens are locked, using ERC20 has its default functions that it comes with which were not locked. Making it a little loophole which could potentially be exploited.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=05617b302fab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ethernaut #14: Gatekeeper Two]]></title>
            <link>https://medium.com/@zakaryteo/ethernaut-14-gatekeeper-two-5c5afdb4bc67?source=rss-d92c29bdd2a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c5afdb4bc67</guid>
            <category><![CDATA[blockchain-security]]></category>
            <category><![CDATA[ethernaut]]></category>
            <dc:creator><![CDATA[Zakaryteo]]></dc:creator>
            <pubDate>Mon, 29 Dec 2025 17:51:24 GMT</pubDate>
            <atom:updated>2025-12-29T17:51:24.532Z</atom:updated>
            <content:encoded><![CDATA[<p>This level is similar to the previous one in terms of having 3 gates and the first gate being the same.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*L1DpdMYkNg6E3CwIXmN5QQ.png" /><figcaption>Contract for the current level</figcaption></figure><p>As mentioned the first gate is passed by contract exploting it which was what I have been doing since the start. Next was the problem as I tried doing the same exact way as how I had been doing. However that gives a problem which cannot pass the second gate. The second gate condition which I had to solve was making code.length = 0. How did I bypass it? I used a constructor. How using a constructor works is because my contract’s code is not saved yet by using a constructor, which allows the code.length to equal 0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*Uk2WgO_BLXz3EndRLnTWlA.png" /><figcaption>My attack function</figcaption></figure><p>As shown, the first two gates are satisfied by adding the contract address as the parameter. Next for the final gate, it is related to the equation where I reverse and rearrange the formula. Instead of type(uint64).max being the subject, I made uint64 the subject instead. From there, this will give me the gateKey which I can use to enter the final gate without truly know what it exactly is.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c5afdb4bc67" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ethernaut #13: Gatekeeper One]]></title>
            <link>https://medium.com/@zakaryteo/ethernaut-13-gatekeeper-one-9ddf1ed216a5?source=rss-d92c29bdd2a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ddf1ed216a5</guid>
            <category><![CDATA[ethernaut]]></category>
            <category><![CDATA[blockchain-security]]></category>
            <dc:creator><![CDATA[Zakaryteo]]></dc:creator>
            <pubDate>Mon, 22 Dec 2025 17:31:13 GMT</pubDate>
            <atom:updated>2025-12-22T17:31:13.447Z</atom:updated>
            <content:encoded><![CDATA[<p>It has been a while since I have done one of this as this particular level got me stuck for a really long time. It is the hardest one I have done to date and this level had many conditions to be met. So this level has 3 conditions to be met, the first condition is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*ZRbb4TygunwjxB5LxJGNjw.png" /><figcaption>First gate condition</figcaption></figure><p>From this, it is rather simple and something we have really been doing, expoiting the contract, which did not take much time. The next part of the contract was where the difficulty began.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/309/1*UvnxxxVtZ28VRX-7dwK6OQ.png" /><figcaption>Second gate condition</figcaption></figure><p>This condition required me to have my gas left at that point of gateTwo to be divisible exactly by 8191 with no remainder. So for this, I wrote the following code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*oU7xg8Xc9-bvOar_iz2nzQ.png" /><figcaption>Whole attack function that satisfies all three gates</figcaption></figure><p>What this does for gateTwo is that I take the totalGas which is the gas I started with, before any functions was run on this level. In which I put it in an equation, making it i + (8191 * 3). This is where i will be the gasSpent until gateTwo() and why I used 3 was just a safe number which is not too big, even though it can increase to 4 or even 5. So i cannot be predetermined as it is always random which is why i increases each loop, making this a brute force method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*pmuTLIE06M66wFqZcUOI5w.png" /><figcaption>Third gate condition</figcaption></figure><p>Now for the final gate, gateThree. This is determined from the uint values of the gateKey. From the first line, uint32 should equal uint16 which means the last 4 bytes of the gateKey should equal the last 2 bytes of the gateKey. So if in terms of the key, the 3rd and 4th last bytes are 0. Next, uint32 should not equal uint64 of the gateKey, meaning that accross all 8 bytes, the last 4 should be the same, making the first 4 bytes not all 0. Lastly, uint160 is the whole address on ethereum of 20 bytes. This means that uint16 of uint160 is the last 2 bytes of the tx.origin, should be equal. So for visualisation in terms of 0x B1 B2 B3 B4 B5 B6 B7 B8, B5 and B6 must be zeroes, B1 B2 B3 B4 must not all be zero and B7 B8 must equal to the last 2 bytes of tx.origin. Hence I used, 0xFFFFFFFF0000FFFF which forces the relavant bytes to 0 and satisfies all conditions.</p><p>This level is by far the hardest yet which took me a long time to understand what I was doing as I had to search up thoroughly even had to really resort to guides to help my through this. But reading through and understanding the thought process really helped and I am expecting tougher levels from now on.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ddf1ed216a5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ethernaut #12: Privacy]]></title>
            <link>https://medium.com/@zakaryteo/ethernaut-12-privacy-92b8c88ac6c2?source=rss-d92c29bdd2a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/92b8c88ac6c2</guid>
            <category><![CDATA[ethernaut]]></category>
            <category><![CDATA[blockchain-security]]></category>
            <dc:creator><![CDATA[Zakaryteo]]></dc:creator>
            <pubDate>Sun, 09 Nov 2025 17:00:40 GMT</pubDate>
            <atom:updated>2025-11-09T17:00:40.314Z</atom:updated>
            <content:encoded><![CDATA[<p>In this level, it showed me a contract which uses private variables which is required to unlock the contract. As it is private, it normal coding, private would be inaccessible. However, in web3 there is something that can used to help with this and it is storage. So how would it work, each storage slot can hold up to 256 bits or 32 bytes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/377/1*H2bNyx272e4jHtho-_2KSw.png" /><figcaption>variables used in the level</figcaption></figure><p>So for boolean, it will take the first slot of slot 0 even though it is a boolean which is way lesser than 256 bits. Since the next line is uint256, it takes the next slot of 1. The next 3 variables could all fit into one slot of 2, as they total up to 32 bits which can fit. Lastly, the array of 3 takes the next 3 slots each consisting of 32 bytes. With this, I got the storage of slot 5, which consisted of data[2] using getStorageAt(). This gave me a 32 byte data but to unlock the contract I would need a 16 byte data instead. So I changed the length of it to 16 bytes using slice() and resulted in me using the 16 byte data to unlock the contract.</p><p>From this level, I learnt that nothing is truly private in the ethereum blockchain and to never storage anything important on the blockchain.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92b8c88ac6c2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ethernaut #11: Elevator]]></title>
            <link>https://medium.com/@zakaryteo/ethernaut-11-elevator-ea5e8d041f67?source=rss-d92c29bdd2a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea5e8d041f67</guid>
            <category><![CDATA[blockchain-security]]></category>
            <category><![CDATA[ethernaut]]></category>
            <dc:creator><![CDATA[Zakaryteo]]></dc:creator>
            <pubDate>Thu, 06 Nov 2025 17:39:56 GMT</pubDate>
            <atom:updated>2025-11-06T17:39:56.184Z</atom:updated>
            <content:encoded><![CDATA[<p>This level is about abusing a flaw in the main code to trick the contract into thinking that the top level is what was inputed. So the first thing was to head over to Remix to come up with an Attack. Next, since there was only one function that is in this level, it was the only one which I had to target. Within that one function, goTo(), there was one particular function that was called twice, isLastFloor.</p><p>Firstly, how this contract works is that no matter what level I put, I would never reach the top floor as it was never defined. This means that it was an endless loop without tempering with it.</p><pre>contract Attack {<br>    bool isSecondTime = false;<br><br>    function isLastFloor(uint) external returns (bool) {<br>        if (isSecondTime) {<br>            return true;<br>        }<br><br>        isSecondTime = true;<br>        return false;<br>    }<br><br>    function attack(address _target) external {<br>        IElevator elevator = IElevator(_target);<br><br>        elevator.goTo(1);<br>    }<br>}</pre><p>With this attack contract, I used an interface of Elevator which uses goTo. So the main part of this is isLastFloor where I basically return false first. As I return false, I set isSecondTime as true. Then, when its called a second time, like how I mentioned it is called twice, I return true. What does this mean? So in the original contract:</p><pre>if (!building.isLastFloor(_floor)) {<br>            floor = _floor;<br>            top = building.isLastFloor(floor);<br>        }</pre><p>When I enter a number (1), isLastFloor is called for the first time, setting isSecondTime as true and returning false. Next, floor is set as 1. The following line makes top as true since true is being returned.</p><p>So how should we prevent such vulnerabilities from happening? We use view, it prevents any state change. In a simpler way to understanding it, it is like access priviledges for google sheets or excel. If someone has only view access, they can see the content(the contract or function) but they cannot edit or make changes (causing the attack to give a true for secondTime).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea5e8d041f67" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ethernaut #10: Re-entrancy]]></title>
            <link>https://medium.com/@zakaryteo/ethernaut-10-re-entrancy-1062ad8dd457?source=rss-d92c29bdd2a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/1062ad8dd457</guid>
            <category><![CDATA[blockchain-security]]></category>
            <category><![CDATA[ethernaut]]></category>
            <dc:creator><![CDATA[Zakaryteo]]></dc:creator>
            <pubDate>Sun, 26 Oct 2025 17:19:52 GMT</pubDate>
            <atom:updated>2025-10-26T17:19:52.259Z</atom:updated>
            <content:encoded><![CDATA[<p>This level teaches about reentrancy and this was one of the more well known exploits, I even heard about it before starting on blockchain security. Now with this level, I already roughly knew how it happens and for this, I decided to go to Remix and create another contract to attack. Using the donate and withdraw function by creating an Interface, I allowed myself to withdraw from the contract by donate a small amount of Eth. And with that I use withdraw, with a fallback function keep withdrawing before any value can be updated.</p><pre>receive() external payable { <br>        uint targetBalance = address(reentrance).balance;<br><br>        if (targetBalance &gt;= 0.001 ether) {<br>            reentrance.withdraw(0.001 ether);<br>        }<br>    }</pre><p>I used did this upon receiving and as it is shown, it will keep removing ether as long it is more than 0.001 ether. This will keep removing and transfering to me until it reaches 0.</p><p>Although I had read about this vulnerability before, it does intrigues me that this could be prevented just by changing the original function arrangement. All that was to be done is to update the person’s balance before withdrawing can be done instead of withdrawing first then updating the balance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1062ad8dd457" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ethernaut #9: King]]></title>
            <link>https://medium.com/@zakaryteo/ethernaut-9-king-f56062bab521?source=rss-d92c29bdd2a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/f56062bab521</guid>
            <category><![CDATA[blockchain-security]]></category>
            <category><![CDATA[ethernaut]]></category>
            <dc:creator><![CDATA[Zakaryteo]]></dc:creator>
            <pubDate>Sat, 25 Oct 2025 17:50:01 GMT</pubDate>
            <atom:updated>2025-10-25T17:50:01.688Z</atom:updated>
            <content:encoded><![CDATA[<p>This level called King is a game or some sort and the requirements this time is to break the game. Since whoever sends it an amount of ether that is larger than the current prize becomes the new king. Hence, the overthrown king gets paid the new prize, making a bit of ether in the process. So to break it could mean either no ether being sent to the old King, taking over without sending any ether or simply just crashing the game and preventing any follow up after being King.</p><p>That was what I decided to do, provent any follow up after being King, in other words DOS. This was done with my attack function:</p><pre>contract Attack {<br><br>    constructor(address payable _kingContract) payable {<br>        _kingContract.call{value: msg.value}(&quot;&quot;);<br>    }<br>    <br>}</pre><p>What this does: I do continue sending Eth to the contract and become the new king. However, without any receive()/fallback(), it makes it impossible for the king contract to send ETH back during the crown transfer. What this means is, I become king by sending ETH and without any receive()/fallback() function, the next player that tries to become king will not be able to sent. As the attack has no receive(), the transfer faius and the transaction reverts. Causing the game to stop as no one can be king anymore.</p><p>Now with this level, I actually overthinked quite a bit on how to stop the game where I could simply DOS the game. While unsure on how to do that, I did some research and found the importance of receive()/feedback(). As without these, it shows it can stop the game just like that.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f56062bab521" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>