<?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 Precious Jacob on Medium]]></title>
        <description><![CDATA[Stories by Precious Jacob on Medium]]></description>
        <link>https://medium.com/@peejayhack?source=rss-f7bbf3b57762------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*6nMo22Ou7VoSaNJvE0RgaQ.jpeg</url>
            <title>Stories by Precious Jacob on Medium</title>
            <link>https://medium.com/@peejayhack?source=rss-f7bbf3b57762------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 13:58:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@peejayhack/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[Portfolio Project Blog Post: TasKeeper]]></title>
            <link>https://medium.com/@peejayhack/portfolio-project-blog-post-taskeeper-85b1c27677ee?source=rss-f7bbf3b57762------2</link>
            <guid isPermaLink="false">https://medium.com/p/85b1c27677ee</guid>
            <dc:creator><![CDATA[Precious Jacob]]></dc:creator>
            <pubDate>Tue, 07 Mar 2023 16:11:58 GMT</pubDate>
            <atom:updated>2023-03-07T17:02:40.102Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1ojbYnWCraCmjMT1X-q0SA.png" /></figure><p>Hi Internet, unlike my previous articles, this article is in line with the <a href="https://www.alxafrica.com/software-engineering/">alx_africa</a> curriculum. It is an article illustrating the trials and learnings encountered while building a portfolio project. For this project, I am my teammates agreed to work on a task-keeper — an app that helps you schedule your day and keep your tasks in check.</p><p><strong>The </strong>project was built for people who either live a routined life or struggle with scheduling their tasks and remembering close ones birthdays. My team members include Olatomiwa Atoro-Tywo, Franca Uvere and Precious Jacob. As an engineering problem, we wanted to focus on 2 things: optimizing user-experience by creating a smooth mobile and web compatible UI, and also sourcing a reliable and sophisticated API. Olatomiwa worked on the webstatic of the project, Franca and I worked on the documentation, console application and database of the project.</p><p>Each member on my team is a fulltime undergraduate of a University and they are also enrolled in the alx Software Engineering program. Thus, we often had a lot on our plates and scheduling each task had proven to be a good way to handle stress and get tasks accomplished; so it was an easy project for us to agree upon.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/0*8BGuzUZM5vuI1jJN" /><figcaption>Architecture of the project.</figcaption></figure><p>We used HTML, CSS and JavaScript for the front-end of the project. We opted for HTML, CSS and JavaScript because we wanted to solidify our understanding of using JavaScript to manipulate web elements. We used Python for the console and SQLAlchemy Database Management System (DBMS) for the database. We opted to use Python and SQLAlchemy because the Python <a href="https://docs.python.org/3/library/cmd.html">cmd</a> module eases the process of building a console and SQLAlchemy seemed like a very good DBMS that works well with Python. Features we have completed include an interactive console, a landing page that’s interactive with both PC and mobile screen sizes(ongoing) and the feature that prompts for the task, saves it and marks it as done when completed.</p><p>Over the course of building this project, we sharpened our skills on the frameworks used and learnt to incoporate different tech tools to work as one. And actually, Python is a beautiful programming language.</p><p>Precious Jacob is a Software Engineering Student at alx and also a Biomedical Engineering Undergraduate at the University of Lagos. He is passionate about technologies ranging from Software Engineering including Machine Learning and Data Science to Medically inclined technologies.</p><p>Project Github Link: <a href="https://github.com/SwitteeFranca2-0/TasKeeper">https://github.com/SwitteeFranca2-0/TasKeeper</a><br>LinkedIn Profile: <a href="https://www.linkedin.com/in/chiemezie-jacob/">https://www.linkedin.com/in/chiemezie-jacob/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85b1c27677ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What happens when you type a URL in your browser?]]></title>
            <link>https://medium.com/@peejayhack/what-happens-when-you-type-a-url-in-your-browser-fafcc71cc7aa?source=rss-f7bbf3b57762------2</link>
            <guid isPermaLink="false">https://medium.com/p/fafcc71cc7aa</guid>
            <category><![CDATA[google-search]]></category>
            <category><![CDATA[search-engines]]></category>
            <category><![CDATA[tcp]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[ip-address]]></category>
            <dc:creator><![CDATA[Precious Jacob]]></dc:creator>
            <pubDate>Wed, 04 Jan 2023 12:04:57 GMT</pubDate>
            <atom:updated>2023-01-04T14:55:21.740Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello Internet in <a href="https://youtu.be/qmWCT_OgrKQ">Derek Banas’s</a> accent, a Youtuber you should definitely be aware of, welcome to part four of my Software Engineering articles; you get the vibes. Welpp, it’s the 4th of January so I might just seize this opportunity to wish you a “Happyyy Newww Yearrrrr!!! 🎉”, hoping this year brings out the best in us all.</p><p>Anyways, back to why you clicked that link, you ever wonder about what goes on behind the scene when you click a link or type a link into your browser’s search bar? How the information gets to you? How your direct messages remain secured over the world wide internet? ……⏰(<em>tick tock</em>), I did too. In this post, we will take a look at a grand overview of what goes on behind the scene.</p><p>The process involves the browser, the Operating System, the Server where you host the site, services running on that site and the internet Service Provider being used. In order to completely understand the process, it’s important we go over some terminologies:</p><p><strong>Internet Protocol Address(IP address)</strong>: The IP address is a unique identifier assigned to every computer accessing the internet or a local network. You can read more on IP addresses <a href="https://medium.com/@peejayhack/introduction-to-internet-protocols-tcp-and-udp-167d32fdc43">here</a>. An IP address contains four parts separated by dots (IPV4) or 8 parts separated by colons (IPV6).</p><p><strong>Domain Name: </strong>A Domain Name is an easy to remember name that’s associated with a physical IP address on the internet. The whole idea behind behind domain names came in because texts are way easier to remember than numbers. helloworld.com is way easier to remember than 205.24.143.123. Oh, you could memorize that, try memorizing 10 separate versions of that. You get the idea?</p><p><strong>Domain Name System(DNS)</strong>: In simple words, the domain name system is a technology that translates human-adapted text-based domain names to machine-adapted, numerical-based IP addresses. The Domain Name System is like your phonebook with names attached to each number, it helps the browser find the IP address of servers on the internet. Basically, the DNS resolves a Domain name into its specific IP address.</p><p><strong>Websites: </strong>Websites are collections of related domain pages under a single name, often HTML, CSS and JavaScript pages that tell the browser how to render your website.</p><p><strong>Server: </strong>A server is basically a computer on steroids that provides data and services to other computers via a network. A server has a specific operating system that contains services.</p><blockquote>NB: It’s important you note that a Server and a Web Server are two separate entities.</blockquote><p><strong>Resolver: </strong>A set of dynamic library routines used by applications that need to know machine names.</p><p><strong>Client: </strong>The <em>user-agent</em>; any tool that acts on behalf of the user. This role is primarily performed by the Web browser, but it may also be performed by programs used by Engineers and Web Developers to debug their applications.</p><p><strong>Web Server: </strong>A web server is software and hardware that uses HTTP (Hypertext Transfer Protocol) and other protocols to respond to Client (see previous terminology) requests made over the World Wide Web. The main job of a web server is to display website content through storing, processing and delivering webpages to users.</p><p>Now that you know of the various parts involved, let’s look at each step, how they relate to each other and how the browser communicates with the server when you type in a URL.</p><p><em>Ahah!</em>, it’s finally time to go over what actually goes on behind the scene.</p><h3><strong>The Process</strong></h3><p>I will be using the URL <em>https://isitchristmas.com</em> to show how these steps work together.</p><h4><strong>1. You type a URL into the browser and press Enter.</strong></h4><p>Let’s break down the parts of this URL</p><blockquote>https://isitchristmas.com/</blockquote><p><strong>Scheme/Protocol</strong></p><p>The <em>https:// </em>is the scheme of the URL. It identifies the protocol to be used to access the resource on the Internet. It could be HTTPS which stands for Hypertext Transfer Protocol Secure. This scheme tells the browser to make a connection to the server using Transport Layer Security, or TLS. TLS is an encryption protocol that encrypts data sent over the internet to ensure eavedroppers and and hackers are unable to see what’s being transmitted. With HTTPS, the data exchanged between your browser and the server, like passwords or credit card info, is encrypted. You could often also come across the HTTP scheme which is basically HTTPS without encryption. Other Schemes include <em>gopher://</em>,<em> malito://</em>,<em> ftp://</em>,<em> file:// e.t.c.</em></p><p><strong>Domain</strong></p><p>isitchristmas.com is the domain of the URL. It is the memorizable address that points to a speciic server’s IP address. You can see the DNS A address 104.236.86.11 pointing to the website <em>isitchristmas.com </em>which represents the IP address of the website in the image below. It’s important to note that the domain could also contain subdomains that precedes the actual domain name with a dot. e.g hey.isitchristmas.com would be a subdomain of isitchristmas.com</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*ROvfbgl3WNLpQe7lqtCyJg.png" /><figcaption>IP address of isitchristmas.com</figcaption></figure><p><strong>Path</strong></p><p>The path is the string that comes after the top level domain name. isitchristmas.com doesn’t have a path but we can easily cook one up. Take <em>isitchristmas.com/the-path-to/yes</em> as an example. the-path-to is the path on the server to the requested resource, /<em>yes. </em>You can think about it like the structure of directories stored on your computer. It’s a way to organize resources on a site, be it HTML, CSS, JavaScript files or dynamically generated content.</p><p><strong>Resource</strong></p><p><em>/yes </em>is the name of the resource on the website whose nature isn’t defined any further; it could be document, file, photo or anything else. Sometimes it might across as a file with an extension <em>.html </em>which indicates it is a static file on the server with HTML content. Often times it would come across without an extension which indicates it is a dynamically server generated content.</p><h4>2. Your Browser searches for the IP address to the Domain.</h4><p>After you have typed the URL into your browser and clicked enter, the browser needs to figure out the IP address and hence the server of the domain name to connect to. This is a fairly complex and lengthy process that you can look through <a href="https://howdns.works/">here</a>. The DNS system involves it looking through the cache of the browser and then the cache of the Operating System, a local network cache at your router, and a DNS server cache on your corporate network or at your internet service provider (ISP). If it doesn’t find it in any of this cache layers, it then reaches out to the resolver which makes a recursive lookup contacting the root server and so on till the DNS record is found. All these happen within milliseconds. Once the browser matches the DNS record with the IP address, it’s then time for it to find the server on the Internet and establish a connection.</p><h4>3. <strong>Browser initiates a TCP connection with the server.</strong></h4><p>Packets from a client browser request gets routed through the ISP router via an internet exchange to switch ISPs or networks all using the <a href="https://medium.com/p/167d32fdc43">Transmission Control Protocol (TCP)</a> to find the server with the IP address to connect to at port 443. A <a href="https://www.khanacademy.org/computing/computers-and-internet/xcae6f4a7ff015e7d:online-data-security/xcae6f4a7ff015e7d:secure-internet-protocols/a/transport-layer-security-protocol-tls">TLS</a> handshake takes place once the browser and server have established a connection to signify that the domain is secured. Once the browser has established a connection with the server, the next step is to send the HTTP request to get the resource, or the page.</p><h4>4. Browser sends the HTTP request to the server</h4><p>The browser follows the rules of the HTTP(S) protocol at this point. It starts with the browser sending an HTTP request to the server to request the contents of the page. The request typically contains information that the server could use to determine what the clients wants it to do. The information could be broken down into a request line, a header, and a body. The request line usually contains the request method which is one of PUT, GET, POST, PATCH, DELETE. The request line tells the server you want to GET resource at <em>/yes </em>and to communicate with https/1.1. Once the server has received the request from the client, the server processes it and sends back a response. You can read more on what exactly goes on <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Session">here</a>.</p><h3>5. Server processes request and sends back a response</h3><p>The server takes the request and based on the info in the request line, headers, and body, decides how to process the request. For the request, GET /hello-world/ HTTP/1.1, the server gets the content at this path, constructs the response and sends it back to the client. The response contains the following:</p><ul><li>a status line, telling the client the status of the request</li><li>response headers, telling the browser how to handle the response</li><li>the requested resource at that path, either content like HTML, CSS, Javascript, or image files, or data</li></ul><p>Resources can be static files, either text (HTML files) or non-text data (images). Browsers aren’t always requesting static files, though. Often, these are dynamic resources generated at the time of the request and there is no file associated with the resource. The browser renders the content afterwards.</p><h3>6. How the browser renders the content</h3><p>After receiving a response from the server, the browser inspects the response headers for information on how to render the resource. The Content-Type header could either tell us it’s a static HTML resource in the response body or something else. The browsers DOM handles what it does with that particular resource. For HTML resource, it subsequently makes request to get the JavaScript and CSS files that can be found in the script and link tags respectively. The Javascript resource helps with the functionalities of the page while the CSS resource helps with the styling of the page. It also makes requests other types of data like images and so on and renders them accordingly.</p><p>And that’s about it for what happens when you type a URL in a browser’s search bar!</p><p>At times, things don’t go as smoothly as this. There could be a lot of traffic clients requests to servers. A Load Balancer comes into play in scenarios like this in order to improve the efficiency of servers and reduce loading time.</p><h4>LOAD BALANCER</h4><p>At a high level, load balancers distribute the work-load of your system to multiple individual systems, or group systems to reduce the amount of load on an individual system which in turn increases the efficiency, reliability and availability of your enterprise application or website. There are different types of algorithms load balancers use. A few of them include the Weighted Scheduling Algorithm, Round Robin Scheduling, the Least Connection Scheduling Algorithm and so on. Talking about Load Balancers would most likely take an entire article of its own so i might just do that in another article.</p><h4>FIREWALL</h4><p>A firewall is a division between a private network and an outer network, often the internet that manages traffic passing between the two networks. Firewalls allow, limit, and block network traffic based on preconfigured rules in the hardware or software, analyzing data packets that request entry to the network. In addition to limiting access to computers and networks, a firewall is also useful for allowing remote access to a private network through secure authentication certificates and logins.</p><p>The image below is a summary of the whole process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qzHNneCUh7VAhGN2V3glWQ.png" /><figcaption>Summary of what happens.</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fafcc71cc7aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Internet Protocols: TCP and UDP]]></title>
            <link>https://medium.com/@peejayhack/introduction-to-internet-protocols-tcp-and-udp-167d32fdc43?source=rss-f7bbf3b57762------2</link>
            <guid isPermaLink="false">https://medium.com/p/167d32fdc43</guid>
            <category><![CDATA[ip]]></category>
            <category><![CDATA[tcp]]></category>
            <category><![CDATA[internet-protocol]]></category>
            <category><![CDATA[udp]]></category>
            <category><![CDATA[ipv4]]></category>
            <dc:creator><![CDATA[Precious Jacob]]></dc:creator>
            <pubDate>Thu, 15 Sep 2022 07:42:55 GMT</pubDate>
            <atom:updated>2022-09-15T07:42:55.472Z</atom:updated>
            <content:encoded><![CDATA[<p>Internet protocol (IP) is a protocol, or collection of guidelines for routing and addressing packets of data so they can travel across networks and arrive at the correct destination. They define the set of rules for which information would be transferred over networks. How a computer sends and receives information can be thought of as a postal system. A postal system is a medium that makes it possible for anyone to send a letter, packet or parcel to any address in the same country or abroad. IP addresses function in a similar manner and makes it possible for packets of information to be sent and received by an individual and like a postal system, things can go wrong. Let’s get into the details of how things work.</p><p>The internet divides data into tiny units called packets for transmission. These packets include IP information, which enables routers to transmit the packets to the appropriate address. Just like the postal system each packet contain the IP address of the recipient and the domain sending the packet. You probably learnt how computers connect to each other and form networks. Data is sent to the appropriate destination by being directed to the IP address associated with each device or domain that connects to the internet.</p><p>Once data arrives at the destination, information contained is handled differently based on which transport protocol is used in combination with the IP. Before getting into the types of transport protocol, I would take a brief moment to shed a little light on the versions of IP addresses available.</p><h3><strong>IPV4 vs. IPV6</strong></h3><p>Version 4 and Version 6 are currently the two most widely used standards of internet protocols. IPV4 was introduced in 1983. In protocol version 4, an IP address contains four octet. It is separated by dots. For example: <strong>127.0.1.145</strong>. This is a 32bit format which means it allows for only 2 ^32, or 4.3million unique addresses. However, just as there are just six permutations of the letters “abc”, the supply of the domain quickly ran out. In protocol version 6, an IP address contains eight groups of hexadecimal digits separated by a colon. For example: <strong>3485:0a0f:2b3c:0212:8a4c:0042:2342</strong>. This a 128bit format that can support up to 2¹²⁸ unique addresses. IPV6 is not yet completely adopted and the majority of domains still use IPV4 addresses. IPV6 provides some additional updates to IPV4 including security speed and privacy improvements. Despite their differences, both IPv4 and IPv6 have co-existed concurrently on the web for over a decade. The two versions can run in parallel, but special measures had to be implemented to facilitate communications between IPv4 and IPv6 devices.</p><h3><strong>IP Packets</strong></h3><p>When you send data across a network, you send them across a series of packages called a packet also known as a data gram. At a high level, IP packets contain a IP header and a payload or the data attached to them. Just like the postal system from earlier, you not only send the recipient’s address, you also include your own address incase a return location is needed. The IP header is a series of zeros and ones and it contains information about source IP address, the destination IP address, Time To Live(TTL) alongside some other information&#39;s to help deliver the packet. The payload contains the data of the packet and some other protocols. You can think of them as a message inside the payload of the IP packet. The two most common protocols are the Transmission Control Protocols referred to as TCP and the User Datagram Protocol, known as the UDP.</p><h3>Transmission Control Protocol (<strong>TCP)</strong></h3><p>Earlier, I mentioned how things could go wrong with a postal address. When sending letters to a friend or acquaintance, it’s possible a letter gets damaged or lost during transits. The same applies to Internet protocols packets too, they can arrive out of order, become damaged, corrupted or dropped during transit. To solve these problems, Transport protocols were introduced. Transport layer protocols dictates how data is sent and received. The Transmission Control Protocol (TCP) is a transport layer protocol that can solve all of the problems listed above but at the cost of a small delay when sending the data. Via TCP, recipients will acknowledge receiving data packets when it arrives. In the event that the reception is not acknowledged, missing packets will be transmitted again. TCP is designed for reliability and not speed. Data loading via TCP may take longer if some packets are missing since TCP must ensure that all packets arrive in sequence.. The TCP is used to send data that must arrive in order. For example: text messages, e-mails, file transfer, HyperText Transfer Protocol Secure (HTTPS).</p><h3><strong>User Datagram Protocol (UDP)</strong></h3><p>The User Datagram Protocol on the other hand also solves the corrupt data issue but it’s less reliable. The data can arrive out of order or not arrive at all. The UDP is much faster, simpler and more efficient than the TCP. It doesn’t have to worry about data loss or the package arriving in order and it in fact doesn’t establish a connection before transmitting data. It is widely used in real-time services like videogame, voice, or video communication since any amount of delay cannot be tolerated in these services. UDP doesn’t delay or retransmit any data.</p><p>These protocols help make sure that data arrives in order and do not become corrupted, lost or dropped during transit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U5S4z4Zei6q6px8wRlJqzQ.png" /></figure><p>Meme Credit: <a href="https://www.reddit.com/r/networkingmemes/comments/anws9o/virgin_tcp_chad_udp/">https://www.reddit.com/user/wisperino345/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=167d32fdc43" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bitwise Operators: The How’s and the Why’s.]]></title>
            <link>https://medium.com/@peejayhack/bitwise-operators-the-hows-and-the-whys-5ccea3abafa3?source=rss-f7bbf3b57762------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ccea3abafa3</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[alx-blog]]></category>
            <category><![CDATA[binary]]></category>
            <category><![CDATA[bitwise-operations]]></category>
            <category><![CDATA[bitwise-operator]]></category>
            <dc:creator><![CDATA[Precious Jacob]]></dc:creator>
            <pubDate>Mon, 22 Aug 2022 01:13:10 GMT</pubDate>
            <atom:updated>2022-09-15T13:27:10.321Z</atom:updated>
            <content:encoded><![CDATA[<p>Bitwise Manipulation is one concept that irked me for a while. Although straightforward, laying my hands on resources was the difficult part.</p><p>Competitive programmers commonly utilize bitwise operators because they improve memory and speed performance. Most bitwise operations can only be visualized when numbers are represented in binary, that is, zeros and ones. I will be providing the binary conversion of the decimal numbers used in this article but I won’t be going into detail on converting decimals to binary.</p><p>Without further ado, let’s dive right into it. We would be looking at the following bitwise operators: AND(&amp;), OR(|), NOT(~), right-shift(&gt;&gt;), left-shift(&lt;&lt;) and XOR(^). The first few might seem familiar but stick with me to the end.</p><p><strong>The AND Operator</strong></p><p>The AND(&amp;) bitwise operator is somewhat synonymous to the logical and(&amp;&amp;) operator. It only returns True if both bits are 1’s. Like I stated earlier, bitwise operators deal with the binary form of decimals. For example,</p><pre>1 &amp; 0 =&gt; 0<br>0 &amp; 0 =&gt; 0<br>0 &amp; 1 =&gt; 0<br>1 &amp; 1 =&gt; 1</pre><p>As shown in the snippet above, the AND(&amp;) operator only returns true when both bits are 1’s. Let’s look at an application of the and operator.</p><p><strong>APPLICATION OF THE AND(&amp;) OPERATOR</strong></p><p>One application of the AND(&amp;) operator is checking if a number is odd or even. Binary representations of even decimal numbers will always end with a zero and representations of odd numbers will always end with a 1. We are going to leverage this fact. For example:</p><pre>10 =&gt; Even =&gt; 1010 =&gt; ends with a Zero<br>16 =&gt; Even =&gt; 1000 =&gt; ends with a Zero<br>15 =&gt; Odd  =&gt; 1111 =&gt; ends with a One</pre><p>To test if a number(n) is odd or even using the AND operator we simply run</p><pre>n &amp; 1<br>n &amp; 1 =&gt; 1 ? Odd : Even</pre><p>If the operation above returns a 1, it’s odd. It’s however even if it returns a 0.</p><p>Proof:</p><p>5(odd) &amp; 1 = 1</p><p>Behind the hood 👇</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YhDRBUZ090cyGX-PSmcxdQ.png" /><figcaption>5 &amp; 1 =&gt; 1</figcaption></figure><p>From the image above, we can see 5 &amp; 1 gives us 1.</p><p>6 &amp; 1 on the other hand will yield 0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-aolAmNlkKo3aSuznNWdhA.png" /></figure><p>6(even) &amp; 1 =&gt; 0</p><pre>Checking if a number is even or not<br>if (6 &amp; 1 == 0) {<br>     printf(&quot;It&#39;s even&quot;);<br>}</pre><p>And you might be soliloquizing “Why not just use the modulus operator?”. The bitwise operator is significantly faster than the modulus operator which serves as a huge benefit to competitive programmers and efficient code.</p><p><strong>The OR(|) operator</strong></p><p>The OR(|) operator is synonymous to the logical or(||) operator. The OR bitwise operator returns true if any one of the bits being compared is 1. For example:</p><pre>1 | 0 =&gt; 1<br>0 | 1 =&gt; 1<br>1 | 1 =&gt; 1<br>0 | 0 =&gt; 0</pre><p>As shown in the snippet above, the OR operator returns True if either of the bits is 1 and a fallacy only if both is 0.</p><p>An example:</p><p>5 | 4 = 5</p><pre>101 =&gt; 5<br>100 =&gt; 4<br>101 =&gt; 5</pre><p><strong>Application of the OR operator</strong></p><p>Writing an implementation of the OR operator is rather laborious but it can be applied to robot sensors. How? Supposed we have four zero bits representing directions 0(forward) 0(backward) 0(left) 0(forward). And we have four other zero digits representing a keypad sensor. All we have to do is set one of the sensor digits to one whenever a key is clicked and the machine runs the OR operator to determine which is being clicked. Let’s look at a snippet to illustrate this.</p><pre>                  Forward Backward Right Left <br>Bits           =&gt;    0       0       0     0<br>Sensor         =&gt;    0       1       0     0<br>             <em>RUNS THE OR OPERATOR ON BOTH<br></em>Result         =&gt;    0       1       0     0          </pre><p>As shown in the snippet above, After running the OR operator between the keypad control and sensor, the robot is able to know which way to move.</p><p><strong>The Right Shift(&gt;&gt;) operator</strong></p><p>The right shift operator does exactly what it says. It shifts the bits to the right by the number of times specified. For example:</p><p>15 &gt;&gt; 2</p><p>The operation above will shift the bits of 15 two times to the right. Let’s look at the binary representation.</p><pre>15 =&gt; 1111<br>Shifting this two bits to the right will yield 11. Shifting simply means pushing numbers off the edge.<br>1111 <br>after first shift becomes =&gt; 111<br>Second shift =&gt; 11<br>The decimal representation of the binary 11 is 3</pre><p>There is also a straight-forward formula to computing the right-shift operation.</p><pre>Right shift = ( n &gt;&gt; i ) =&gt; n / 2^i</pre><p>The right shift operator can be used to get the value of a bit at a particular position. Consider the following code:</p><pre>int get_bit(unsigned long int n, unsigned int index){<br>   int bit;<br>   bit = (n &gt;&gt; index);<br>   if (index &gt; 32)<br>      return (-1);<br>   return (bit &amp; 1);<br>}</pre><p>The code above right shifts the bits by the number of indexes and then runs the bitwise AND operator on the most recent last digit to determine if it’s a 1 or a 0.</p><p><strong>The Left-shift(&lt;&lt;) Operator</strong></p><p>The left shift operator is the inverse of the right-shift operator. It shifts the bits to the left appending zeros behind. Consider the snippet below:</p><pre>1000101 &lt;&lt;  3</pre><pre>To be left shifted three times </pre><pre>Becomes</pre><pre>1000101000</pre><p>As you probably noticed above, three zeros were appended to the binary number above changing the overall value of the binary number. The direct formula for the left shift operator is <strong>(n * 2^i)</strong></p><p>The left shift operator can be used to compute powers of 2 by simply left-shifting the power against 1. For example:</p><pre>1 &lt;&lt; 5 =&gt; 32 </pre><pre>32 is equivalent to 2⁵</pre><pre>1 &lt;&lt; 6 =&gt; 64 </pre><pre>64 is equivalent to 2⁶</pre><p>What’s going on under the hood?</p><p>From example 1, binary number 1 becomes 100000 after being left shifted five times.</p><p>Binary number 10000 is equal to 32 in decimal</p><p>With a few tweaks and a for loop, the binary left-shift operator can be used to convert a number from binary to decimal.</p><p><strong>The XOR(^) operator</strong></p><p>The XOR also known as the Exclusive OR operator is by far the most commonly used bitwise operator. The XOR returns true only if a bit is a 1 and the other is a zero. It returns false if both are zero’s and also false if both bits are 1’s. Consider the snippet below :</p><pre>1 ^ 0 =&gt; 1</pre><pre>0 ^ 1 =&gt; 1</pre><pre>0 ^ 0 =&gt; 0</pre><pre>1 ^ 1 =&gt; 0</pre><p>So basically, the XOR operator returns a 0 when a number is being XOR’ed(pun intended) with itself and returns the number when it’s being XOR’ed with 0.</p><p>An attribute of the XOR operator is that it has the commutative property. That is the order in which the operation is carried out doesn’t change the result in any way.</p><p>i.e both 5 ^ 5 ^ 6 and 5 ^ 6 ^ 5 will yield the same result.</p><p>One application of the XOR operator is finding a number that occurs only once in an array where all other numbers occur twice.</p><pre>array = [5, 6, 7, 5, 7, 8, 9, 6, 9]</pre><p>From the array above, we can see that only the number 8 occurs once in the array. How can we obtain this though?</p><p>My approach is to take each number from the array run the XOR operation on them. This gives us</p><pre>5 ^ 6 ^ 7 ^ 5 ^ 7 ^ 8 ^ 9 ^ 6 ^ 9</pre><p>But how does this even help us?</p><p>Recall I said earlier that “the XOR operator returns a 0 when a number is being XOR’ed with itself and returns the number when it’s being XOR’ed with 0” and I also said the XOR operator is commutative. Keeping both of this in mind, let’s re-arrange the digits above.</p><pre>5 ^ 5 ^ 7 ^ 7 ^ 8 ^ 8 ^ 9 ^ 9 ^ 6</pre><pre>&quot;The XOR operator returns zero when a number is being XOR&#39;ed with it self&quot;. Applying this:</pre><pre>5 ^ 5 = 0<br>7 ^ 7 = 0<br>8 ^ 8 = 0<br>9 ^ 9 = 0</pre><pre>Giving us:<br>(0) ^ (0) ^ (0) ^ (0) ^ 6</pre><pre>And also recall I said XOR returns the number when it&#39;s being XOR&#39;ed with 0. Applying this concept gives us:</pre><pre>0 ^ 6 = 6</pre><pre>Therefore giving us the number that occurs only once in the array.</pre><p><strong>The NOT(~) operator</strong></p><p>The NOT operator flips bits. All bits are flipped, 1’s turn to 0 and 0’s turn to 1.</p><p>For example, the binary number 10010101 becomes 01101010.</p><p>The direct formula for computing the NOT operator in decimal is x = -(x + 1)</p><p>That is, ~17 becomes -(17 + 1) =&gt; -18</p><p><strong>Conclusion</strong></p><p>Although, bitwise operators are efficient, it’s best to avoid them for code readability sake except when absolutely necessary!</p><p>Thanks for coming this far. Keep striving!</p><p><strong>Adiós👋</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ccea3abafa3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reverse Engineering: Cracking crackme3 with GDB]]></title>
            <link>https://medium.com/@peejayhack/reverse-engineering-cracking-crackme3-with-gdb-789ac01b12ae?source=rss-f7bbf3b57762------2</link>
            <guid isPermaLink="false">https://medium.com/p/789ac01b12ae</guid>
            <category><![CDATA[c-programming]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[alx-blog]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[gdb]]></category>
            <dc:creator><![CDATA[Precious Jacob]]></dc:creator>
            <pubDate>Fri, 12 Aug 2022 11:27:16 GMT</pubDate>
            <atom:updated>2023-01-05T12:07:30.209Z</atom:updated>
            <content:encoded><![CDATA[<p>At <a href="https://www.alxafrica.com/programme_post/full-stack-software-engineer/">alx_africa</a>, we take a project-based learning and peer learning approach towards learning. To wit, there are no formal instructors or formal courses. Instead, it is 100% project centered. Students are occasionally provided links to documentations and increasingly difficult tasks to complete with limited aid. We are sometimes assigned advanced assignments that are optional. Decoding the crackme3 Linux file was one of them.</p><p>Upon getting started I ran the <em>file</em> command to validate the type of the file I was dealing with.</p><blockquote><em>file ./crackme3</em></blockquote><figure><img alt="Pictorial representation of the file command being run" src="https://cdn-images-1.medium.com/max/1024/1*LZQRSIWqfBmgOfEQoTQPMg.jpeg" /></figure><p>It’s not stripped, meaning our file still contains symbols. I then proceeded to run Ltrace on the file to see if the password will appear.</p><blockquote>Ltrace Is A Program That Simply Runs The Specified Command Until It Exits. It Intercepts And Records The Dynamic Library Calls Which Are Called By The Executed Process And The Signals Which Are Received By That Process. It Can Also Intercept And Print The System Calls Executed By The Program.</blockquote><blockquote>— Linux manual page</blockquote><blockquote><strong><em>$</em></strong><em> ltrace ./crackme3 password</em></blockquote><blockquote><em>__libc_start_main(0x40068c, 2, 0x7ffcdd754bd8, 0x400710 &lt;unfinished …&gt;</em></blockquote><blockquote>“Usage: %s password\n”, “./crackme3 “Usage: ./crackme3 password”</blockquote><blockquote><em>strlen(“password”) = 8</em></blockquote><blockquote><em>puts(“ko”ko</em></blockquote><blockquote><em>) = 27</em></blockquote><blockquote><em>+++ exited (status 1) +++</em></blockquote><p>Running the Ltrace command shows it’s checking for the length of the password. I had thoughts about using objdump but decided to go for the GNU debugger: gdb.</p><p><strong>Using the GNU project debugger</strong></p><p>GDB is a tool used to view the binary assembly code of a program helping software engineers identify and squash bugs in their code.</p><pre>GDB, the GNU Project debugger, allows you to see what is going on `inside’ another program while it executes — or what another program was doing at the moment it crashed.</pre><p>Getting started, I ran the <em>gdb</em> command on the <em>crackme3</em> file followed by the <em>disassemble main</em> command. The <em>disassemble</em> command disassembles the <em>main</em> function into binary assembler code. It outputted a list of assembly functions in AT&amp;T syntax which seemed difficult to read so I ran the <em>set disassembly-flavor intel </em>to make it more friendly to the human eye setting it to the intel syntax and ran the <em>disassemble main command </em>again.</p><pre>gdb ./crackme3</pre><pre>disassemble main</pre><pre>set disassembly-flavor intel</pre><pre>disassemble main</pre><figure><img alt="AT&amp;T Syntax" src="https://cdn-images-1.medium.com/max/1024/1*xnFdnItbDEsIkl-68FYPZw.png" /><figcaption>AT&amp;T Syntax</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7EzsrrEruB_zAvNcnrb62g.png" /><figcaption>Intel Syntax</figcaption></figure><p>It looks complicated but you can ignore most of it. The idea is to look for breakpoints where there is a possible data leakage. That is, functions that either prints data or compares data. For example, the yellow &lt;fprintf@plt&gt; and &lt;puts@plt&gt; breakpoints are familiar C commands that probably writes something to stdout. The &lt;check_password&gt; command on the other hand is not a familiar function and it probably does something interesting. I ran the disassemble command on the <em>check_password</em> to analyze the process happening in that function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EE8-p9s0wbOHFXpWYB3VWg.jpeg" /><figcaption>disass check_password</figcaption></figure><p>Check_password shows that the length of the password to be entered is of length 4. Breakpoint 0x400653 compares two registers, rax and rdx. This seeems to be a nice spot to investigate.</p><pre><strong>(gdb) </strong>break *0x400653</pre><pre><strong>(gdb) </strong>run test</pre><pre><strong>(gdb) </strong>info registers</pre><p>I set up a breakpoint to analyze the process at this address. . A breakpoint is point where the program execution process is interrupted. Breakpoint is set, now use <em>run test </em>to start the program. The four-character password I used to get past the length test and into the password comparison is represented by the value ‘test’. At this point, I entered info registers to look at the registers of the program at the point it was interrupted. That is, the point where it compares data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c4vdHfwOsi5O7Rw-cF5Wcg.png" /><figcaption>Info registers</figcaption></figure><p>From the information provided by the register, I find two integers are stored in the register being compared. First is the 0x74 stored in the rax which represents ‘t’ and the second is the 0x48 stored in the rdx register which represents ‘H’.</p><pre>Registers data on each loop</pre><pre>1 RDX - 0x48 =&gt; H</pre><pre>2 RDX - 0x6f =&gt; 0</pre><pre>3 RDX - 0X6C =&gt; l</pre><pre>4 RDX - 0x4 =&gt; ^D or End of file</pre><p>The hexadecimal to text conversion of the letter 0x48 is ‘H’. The RCX is a hexadecimal value of 0x46c6f8. If read in reverse, it is 48, 6f, 6C and 4. Converting it to character values gives H, o, l and ^D or EOF. The task required we input the password into a file named ‘101-password’ then redirect it into crackme3 using `cat 101-password`. Inputting the EOF command was the tricky part. I used an <a href="https://www.rapidtables.com/convert/number/hex-to-ascii.html"><em>hexadecimal to text converter</em></a> to save me the stress of typing in the EOF.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*GrJHP7dR-DydcuYVl4mm2A.png" /><figcaption>Conversion from hexadecimal to text.</figcaption></figure><p>I inputted it into the file using the VI editor.</p><pre>vi 101-password</pre><pre>:set noendofline binary</pre><pre>:wq or :x</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iUpWFQ_AL7G9p68KV2qeuw.png" /><figcaption>Password in vi editor</figcaption></figure><p>I copied and pasted the text from the text converter and simply cleared out the Hol from behind the EOF and inputted it before the EOF. Another tricky part about the VI editor is that it inputs a trailing newline character behind every file you save. To maneuver this obstacle, I ran ‘<em>:set noendofline binary</em>’ command in vim which gets rid of the trailing newline character. Then ran the ‘:x’ (you can also use :wq) command to save and exit the editor. I then went on to redirect it using ./crackme3 `cat 101-password` and voila. <em>Congratulations!</em>. I successfully by cracked the file.</p><pre>./crackme3 `cat 101-passsword`</pre><pre>Congratulations!</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Taz_Wr2Iqi1fvfQuEG4stw.png" /><figcaption>Cracked⚡</figcaption></figure><p>I am quite certain there are other viable approach towards solving this. Let me know if you had a better approach towards cracking this in the comment section. See ya.</p><p>References</p><p>¹ Rick Harris. (May 19, 2016). Reverse Engineering: Using Linux GDB:</p><p><a href="https://medium.com/@rickharris_dev/reverse-engineering-using-linux-gdb-a99611ab2d32">Reverse-engineering: Using Linux GDB</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=789ac01b12ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>