<?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 Mostafa Abd-Ellatif on Medium]]></title>
        <description><![CDATA[Stories by Mostafa Abd-Ellatif on Medium]]></description>
        <link>https://medium.com/@mostafaabdellatif?source=rss-8b1ca98e499c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*TbSNn2qNha1KIuqgfW1BUA.jpeg</url>
            <title>Stories by Mostafa Abd-Ellatif on Medium</title>
            <link>https://medium.com/@mostafaabdellatif?source=rss-8b1ca98e499c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 17:28:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mostafaabdellatif/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 Blockchain to learn]]></title>
            <link>https://medium.com/@mostafaabdellatif/building-a-blockchain-to-learn-41ba1a2bebc3?source=rss-8b1ca98e499c------2</link>
            <guid isPermaLink="false">https://medium.com/p/41ba1a2bebc3</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[blockchain-technology]]></category>
            <dc:creator><![CDATA[Mostafa Abd-Ellatif]]></dc:creator>
            <pubDate>Sun, 02 Mar 2025 11:21:46 GMT</pubDate>
            <atom:updated>2025-03-02T11:21:46.896Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building a Blockchain to learn</h3><p>undoubtedly blockchain is a hot topic in the tech scene specially when it comes to cryptocurrencies like : bitcoin , ethereum..etc</p><p>so , here i will try to explain the foundational technology behind cryptocurrencies and decentralized apps which is blockchain technology , by building a simple blockchain <a href="https://github.com/Mos7mos7/blockat"><strong><em>here</em></strong></a>.</p><h3><strong><em>Brief History :</em></strong></h3><p>On October 31, 2008 satoshi nakamuto proposed a solution for some problems that causes the iconic 2008 financial crisis and it laid the foundation of what later became known as Blockchain. In the original Bitcoin white paper, Satoshi described how to build a peer-to-peer electronic cash system that allows online payments to be sent directly from one party to another without going through a centralized institution.</p><h3><strong>Introduction :</strong></h3><p>so what is blockchain , A BlockChain is a distributed database with growing lists of records (blocks) that are securely linked together via cryptographic hashes. Each block contains a cryptographic hash of the previous block.<br>the first block of the chain called (Gensis Block) ,<br>The gensis block of the bitcoin contains an article from Times in which satoshi express his concern about The financial crisis in 2008 for which bitcoin was made</p><figure><img alt="gensis Block of bitcoin" src="https://cdn-images-1.medium.com/max/1024/1*DSNgNMvPGPraqW23noA7fQ.png" /></figure><h3><strong>Key characteristics</strong> :</h3><p><strong>Immutable</strong> : As with existing databases, Blockchain retains data via<br>transactions The difference is blockchain can be changed in append only mode. In other words, transactions can only be added to the blockchain but cannot be deleted or modified</p><p><strong>Decentralized (Distributed)</strong> : Rather than the centralized model of network, Blockchain is a decentralized peer to peer network. Where each NODE has a copy of the data</p><p><strong>Cryptographic</strong> : Cryptography is used to make sure that the sender owns the bitcoin that she’s trying to send, and to decide how the transactions are added to the blockchain.</p><p><strong>Consensus Algorithm</strong> : Consensus algorithms are a set of rules or protocols that allow distributed nodes to reach an agreement on a value or a<br>decision, based on their local information and messages from<br>other nodes , each network uses different alogrithm like :<br>bitcoin uses proof of work (PoW) , etherum uses proof of stake (PoS)<br>in case of bitcoin A special type of participants in the network called miners compete on searching for the solution to a cryptographic puzzle that will allow them to add a block of transactions to Bitcoin’s blockchain.</p><h3><strong>Publishing a Transaction :</strong></h3><p>In the context of Bitcoin, the ECDSA (Elliptic Curve Digital Signature Algorithm) is employed to create Bitcoin wallets for simplicity let’s assume that each Bitcoin wallet has one pair of private/public keys and that a Bitcoin address is the wallet’s public key , To send or receive Bitcoin (BTC), a user first generates a wallet containing a private and public key pair. For example, if Alice wishes to send Bob some BTC, she initiates a transaction by specifying both her and Bob’s public keys, along with the amount of BTC to be sent. Alice then signs the transaction using her private key. A node on the blockchain network uses Alice’s public key to verify the transaction’s authenticity before adding it to a block, which is subsequently appended to the blockchain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*SHLUNFvph79f6_-g959Uxw.png" /></figure><h3><strong>Mining</strong> :</h3><p>All Bitcoin transactions are organized into let’s call it files for simplicity known as blocks. The Bitcoin network generates a new block of transactions approximately every 10 minutes. Once a block is added to the blockchain, it becomes permanent and cannot be altered or removed. A specific group of network participants, referred to as miners (which are computers linked to the blockchain), are tasked with creating these new blocks. Miners must verify each transaction by using the sender’s public key, ensure the sender has sufficient funds for the transaction, and then include the transaction in the block. Miners have the freedom to select which transactions to include in the blocks, so senders typically attach a transaction fee to encourage miners to prioritize their transactions.</p><p>For a block to be accepted by the blockchain, it needs to be “mined”, To mine a block, miners need to find an extremely rare solution to a cryptographic puzzle. If a mined block is accepted by the blockchain, the miner receive a reward in bitcoins which is an additional incentive to transaction fees. The mining process is also referred to as Proof of Work (PoW).</p><h3><strong>Mining deep dive</strong> :</h3><p>Bitcoin employs a cryptographic hash function known as SHA-256. This function is applied to a combination of the block’s data (which includes Bitcoin transactions) and a number referred to as a nonce. Altering either the block’s data or the nonce results in entirely different hash outputs. For a block to be deemed valid or “mined,” the hash value generated from the block data and nonce must satisfy a specific condition. For instance, the hash might need to begin with “0000” in its first four digits. The difficulty of mining can be increased by making the condition more stringent, such as requiring the hash to start with a greater number of leading zeros , The cryptograhic puzzle that miners need to solve is to find a nonce value that makes the hash value satisfies the mining condition.</p><h3><strong>Chain of Blocks</strong> :</h3><p>As discussed , transactions are grouped in blocks and blocks are appended to the blockchain. In order to create a chain of blocks, each new block uses the previous block’s hash as part of its data. To create a new block, a miner selects a set of transactions, adds the previous block’s hash and mines the block in a similar fashion described above.</p><p>Any changes to the data in any block will affect all the hash values of the blocks that come after it and they will become invalid. This give the blockchain its immutability characteristic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*l3Cvxwhm5TlL5PqxT7au3Q.png" /></figure><p>In the Bitcoin network, all miners compete against each other to discover a valid block that will be added to the blockchain, earning them a reward from the network. Discovering a nonce that validates a block is a rare event, but due to the large number of miners participating, the likelihood of someone successfully validating a block is very high. The first miner to submit a valid block sees their block added to the blockchain and receives a Bitcoin reward. However, what occurs if two or more miners submit valid blocks simultaneously?</p><h3>Handling Conflicts :</h3><p>When two miners solve a block at nearly the same time, the network temporarily splits into two competing blockchains. To resolve this conflict, the network waits for the next block to be mined. Some miners will continue building on the first blockchain (Blockchain 1), while others will build on the second (Blockchain 2). The conflict is resolved when a new block is successfully mined on one of these chains. For example, if the new block is added to Blockchain 1, then Blockchain 2 becomes invalid. The miner who validated the block on Blockchain 1 receives the reward, and any transactions from Blockchain 2 that were not included in Blockchain 1 are returned to the transaction pool to be included in future blocks. In essence, the rule for resolving such conflicts is simple: the longest chain prevails, and the shorter chain is discarded. This ensures the network maintains a single, consistent version of the truth.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41ba1a2bebc3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your First BlockChain CTF challenge]]></title>
            <link>https://medium.com/@mostafaabdellatif/your-first-blockchain-ctf-challenge-59b12d04ac11?source=rss-8b1ca98e499c------2</link>
            <guid isPermaLink="false">https://medium.com/p/59b12d04ac11</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Mostafa Abd-Ellatif]]></dc:creator>
            <pubDate>Sat, 13 Apr 2024 00:04:32 GMT</pubDate>
            <atom:updated>2024-04-13T00:04:32.584Z</atom:updated>
            <content:encoded><![CDATA[<p>Here , i will try to explain and demonstrate the RussianRoullete challenge from hack the box hacker royale CTF 2024 and to explain some blockchain concepts along the way.</p><p>So the first thing you will be provided with a ZIP file to download and by unzip it you will have two solidity (which is a programming language for implementing smart contracts on various blockchain platforms, most notably, Ethereum) files which is Setup.sol and RussianRoulette.sol</p><pre>// Setup.sol<br>pragma solidity 0.8.23;<br><br>import {RussianRoulette} from &quot;./RussianRoulette.sol&quot;;<br><br>contract Setup {<br>    RussianRoulette public immutable TARGET;<br><br>    constructor() payable {<br>        TARGET = new RussianRoulette{value: 10 ether}();<br>    }<br><br>    function isSolved() public view returns (bool) {<br>        return address(TARGET).balance == 0;<br>    }<br>}</pre><pre>// RussianRoulette.sol<br>pragma solidity 0.8.23;<br><br>contract RussianRoulette {<br><br>    constructor() payable {<br>        // i need more bullets<br>    }<br><br>    function pullTrigger() public returns (string memory) {<br>        if (uint256(blockhash(block.number - 1)) % 10 == 7) {<br>            selfdestruct(payable(msg.sender)); // ?<br>        } else {<br>        return &quot;im SAFU ... for now&quot;;<br>        }<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*BwOjDBvGzREwYyWMUNwMfA.png" /></figure><p>so the code in setup.sol is trying to do is to deploy and interact with an instance of the RussianRoulette contract, sending 10 Ether to it upon deployment, and providing a function to check if it has been &quot;solved&quot; by checking its balance which we are interested in and seek to provoke.</p><p>while code in the RussianRoulette.sol contract implements a basic version of the Russian Roulette game, where players can repeatedly call the pullTrigger function to try their luck. If they&#39;re unlucky and hit the &quot;bullet&quot;, the contract self-destructs, ending the game.</p><p>the challenge also provide you with two servers one to get some information about your address , the russian roulette contract address , setupt contract address all within the blockchain network and also will provide you with your private key that you will sign every transaction you do with that key upon connecting to first server with netcat you will get the following :</p><pre><br>$ nc server IP PORT<br>1 - Connection information<br>2 - Restart Instance<br>3 - Get flag<br>action? 1<br><br>    Private key     :  0xbf72ec411f03738614ea4ff8ca1bedcf5879ca3ce0ed3fa1be876e82ba365e0b<br>    Address         :  0x23C88A40d138f6eB43C1ae1E439fB37813D13709<br>    Target contract :  0x8b40383E4793e3C9d4e44db36E878f9D279f0522<br>    Setup contract  :  0xE7bA09fB42a91B2EbBc893d99dbD8D7C109eaf05</pre><p>meanwhile the second server is considered the ETH network which we will interact via RPC (<strong>Remote procedure call which is a way for developers and users to communicate with an Ethereum node and interact with the Ethereum blockchain network</strong>) via default http so you can consider that you are interacting with the ETH node with RPC via http.</p><p>so how we would interact with the node in a blockchain network?</p><p>here comes a famous toolkit named <a href="https://book.getfoundry.sh/"><strong><em>foundry</em></strong></a> which contains a 4 major tools :</p><p><strong>forge</strong> : Ethereum testing framework.</p><p><strong>cast</strong> : Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.</p><p><strong>anvil</strong> : Local Ethereum node, akin to Ganache, Hardhat Network.</p><p><strong>chisel</strong> : Fast, utilitarian, and verbose solidity REPL.</p><p>we are only interested in <strong>cast</strong> tool to interact with the contracts and invoke procedures.</p><h3>SOLUTION :</h3><p>we want this line of code in RussianRoulette.sol to be implemented</p><pre>selfdestruct(payable(msg.sender));</pre><p>so the contract will be destroyed and send us the flag so the way to do that is to satisfy the if condition :</p><pre>if (uint256(blockhash(block.number - 1)) % 10 == 7)</pre><p>and what this line is doing is to check for the block number (after casting it to integer) which is used to mine our transaction which in this case is the rpc call if the reminder of division to 10 is equal to 7.</p><p>so the solution is to call function or procedure pullTrigger() 17 time so that every call to the function will be mined to a block until we hit 17th block , now we have satisfied the if condition (17%10 = 7)</p><p>To call pullTrigger() 17 time we can do that with <strong>cast</strong> tool and a simple bash script :</p><pre>for i in $(seq 1 17)<br>do<br> cast send --rpc-url $RPC_url --private-key $Private_Key $TARGET_ADDRESS &quot;pullTrigger()&quot;<br>done</pre><p>Of course replace variables with $ sign with one provided to you via the first server and the TARGET_ADDRESS will be RussianRoulette address</p><p>after execution of the bash file you have satisfied the conditions.</p><p>Go grab your flag from the server 3rd choice , Voilà</p><p>your flag is : HTB{99%_0f_g4mbl3rs_quit_b4_bigwin}.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59b12d04ac11" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Here , i Will try to write a different summary for the “Linux Basics for Hackers” by Occupy the…]]></title>
            <link>https://medium.com/@mostafaabdellatif/here-i-will-try-to-write-a-different-summary-for-the-linux-basics-for-hackers-by-occupy-the-3096e403abac?source=rss-8b1ca98e499c------2</link>
            <guid isPermaLink="false">https://medium.com/p/3096e403abac</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[linux-tutorial]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Mostafa Abd-Ellatif]]></dc:creator>
            <pubDate>Mon, 14 Aug 2023 18:10:06 GMT</pubDate>
            <atom:updated>2023-08-14T18:10:06.293Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*DmfCc4YixEToW0lgWzaaig.jpeg" /></figure><p>Here , i Will try to write a different summary for the “<strong>Linux Basics for Hackers</strong>” by Occupy the web , the book explains kali linux which is a debian based disruption like ubuntu and parrot.</p><p>In my opinion , the book focuses heavily on Linux not security but with a bit of flavor of hacking .</p><p>i will explain every chapter and expose it’s commands in a brief way , enough talking.</p><p><strong>CH1-Getting started with basics</strong>: talks about some computer science basics like :binaries , terminal , root (which is a very important term in linux that refers to an administrative user account with powerful privileages) and linux filesystem (also important and it explains who files and directories are related and structured ).</p><p><strong>Commands used</strong>: pwd — whoami — cd — ls — man — locate — whereis — which — find — grep — cat — touch — mkdir — cp — mv — rm — rmdir — redirect operators (&gt;&gt;-&gt;).</p><p><strong>CH2-TEXT MANIPULATION: </strong>talks about files how to view them from the top or bottom and how to search certain file for a keyword and even replace them , as files is very important in linux (“<em>everything in Linux is a file</em>”)</p><p><strong>Commands Used: </strong>head — tail — nl — operator “ | “ or pipe — sed — more — less.</p><p><strong>CH3-ANALYZING AND MANAGING NETWORKS</strong>: this chapter contain some basic networking terms like : ip address , network interface , MAC address and mentions some protocols in brief such as : DHCP , DNS , also it’s worth mention two important files : /etc/hosts which contains some hostnames and their translations into IPs</p><p>/etc/resolv.conf : which contains your dns nameserver and ip.</p><p><strong>Commands Used </strong>: ifconfig — iwconfig — dhclient — dig.</p><p><strong>CH4-ADDING AND REMOVING SOFTWARE</strong> : the chapter discuss installing and removing programs or softwares , because this process is different from windows as in windows you need to search the internet for the software and install it , however in linux there is a different approach to installing programs or packages or software which is packaging tools in kali linux the packaging tool name is apt (advanced packaging tool) it’s like a repository for <strong>prgrams.</strong></p><p><strong>Commands Used</strong> : apt with its derivatives such as : apt-get , apt-cache</p><p><strong>CH5-CONTROLLING FILE AND DIRECTORY PERMISSIONS</strong> <strong>V.important</strong> : the chapter discuss different users levels and their privileges and concept of permissions on files and group of users and changing ownership of files and SUID , GUID .</p><p><strong>Commands Used</strong> : chown — chgrp — chmod</p><p><strong>CH6-PROCESS MANAGEMENT</strong> : talks about process identifying and viewing them and resources dediacted to them and their ID also killing processes and changing priority of process , moving them to background and bringing them back to foreground.</p><p><strong>Commands Used</strong> : ps — msfconsole — top — htop — nice — renice — kill — killall</p><p><strong>CH7-MANAGING USER ENVIRONMENT VARIABLES</strong> : discuss how environment variables affects your system and your experience with the system , also mention some important environment variables and their affect and how to change them both temporary and permanent ,one of them is <strong>PATH </strong>which guide your system where to look for binaries.</p><p><strong>Commands Used</strong> : env — set — echo — export — unset</p><p><strong>CH8-BASH SCRIPTING</strong> : the chapter explains in brief bash scripting and creates a small script to scan open ports important thing to keep in mind that <strong>bash</strong> is an application to utilize shell , you can communicate with kernel through shell , bash is the popular one but there is also : zsh , csh , ksh.</p><p><strong>No commands used in the chapter</strong>.</p><p><strong>CH9-COMPRESSING AND ARCHIVING</strong> : talks about difference between archiving or (tar ball) which means putting files together and compressing them into one single file less size , also expose some different compressing algorithms and their compressing ratio and complexity.</p><p><strong>Commands Used</strong> : tar — gzip — gunzip — bzip2 — bunzip2 — compress — uncompress — dd (important utility to copy bit by bit file in physical mean)</p><p><strong>CH10-FILESYSTEM AND STORAGE DEVICE MANAGEMENT</strong> : talks about how Linux deal with hard drives , naming them , Partition them , read and write to drives either block devices or block devices , the chapter also mentions mounting which means attaching particular partition to a directory in filesystem.</p><p><strong>Commands Used</strong> : fdisk — lsblk — mount — unmount — df — fsck</p><p><strong>CH11-THE LOGGING SYSTEM</strong> : introduce logging concept and brief overview of daemons , how to monitor system logs , rotate them , logging rules and finally how to destroy a file make it unreadable not deleting it.</p><p><strong>Commands Used</strong> : locate — rsyslog — shred — service</p><p><strong>CH12-USING AND ABUSING SERVICES</strong> : talks about what a service is , how it works in background , and how to start , stop , restart a service and deep dive into some examples like : openSSH — apache web server — mysql server .</p><p><strong>Commands Used</strong> : service — raspistill — mysql — msfconsole — msfdb</p><p><strong>CH13-BECOMING SECURE AND ANONYMOUS</strong> : explains in brief how the internet works and some routing terms and discuss how authority sniffing and spying on us , expose the onion routing system and obviously TOR network and how it works also discuss other ways to help stay anonymous like : VPN — proxy servers — Private encrypted email .</p><p><strong>Commands Used</strong> : proxychains</p><p><strong>CH14-UNDERSTANDING AND INSPECTING WIRELESS NETWORKS</strong> : the chapter explains in details wi-fi terms like ESSID , BSSID , SSID and talks about NIC (network interface card) different modes also how to Recon in both wi-fi , Bluetooth also how to sniff and extract data in Bluetooth .</p><p><strong>Commands Used</strong> : ifconfig — iwconfig — iwlist — nmcli — airmon­-ng — airodump-ng — aireplay-ng — hciconfig — hcitool — sdptool — l2ping</p><p><strong>CH15-MANAGING THE LINUX KERNEL AND LOADABLE KERNEL MODULES :</strong> this is an important chapter that introduce the kernel and its modules how to add or remove modules and how to modify them and how list all modules in your system.</p><p><strong>Commands Used</strong> : uname — sysctl — lsmod — modinfo — modprobe — dmesg.</p><p><strong>CH16-AUTOMATING TASKS WITH JOB SCHEDULING</strong> : the chapter discuss idea of scheduling and explains cron and how to automate things and write scripts to run at specific time on a daily or weekly or annual basis depends on your needs also teaches how to add scripts to run at startup.</p><p><strong>Commands Used</strong> : crontab — update-rc.d — rcconf</p><p><strong>CH17-PYTHON SCRIPTING BASICS FOR HACKERS</strong> : nothing related to linux in the chapter just basic python programming like : using pip to install packages , loops , conditions , functions and some basic OOP concepts.</p><p>SN : there is some commands that are a software or an application such as msfconsole , you figure them yourself.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3096e403abac" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>