<?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 Josh Schiavone on Medium]]></title>
        <description><![CDATA[Stories by Josh Schiavone on Medium]]></description>
        <link>https://medium.com/@jshschiavone?source=rss-a170f0349c24------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*lN-idkHuQfQJ7Fm7qFUBSg.jpeg</url>
            <title>Stories by Josh Schiavone on Medium</title>
            <link>https://medium.com/@jshschiavone?source=rss-a170f0349c24------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 11:20:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jshschiavone/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[An Introduction to i386 Boot Loader Programming]]></title>
            <link>https://medium.com/@jshschiavone/an-introduction-to-i386-boot-loader-programming-823354b80846?source=rss-a170f0349c24------2</link>
            <guid isPermaLink="false">https://medium.com/p/823354b80846</guid>
            <category><![CDATA[josh-schiavone]]></category>
            <category><![CDATA[how-to-make-a-bootloader]]></category>
            <category><![CDATA[assembly]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[bootloader]]></category>
            <dc:creator><![CDATA[Josh Schiavone]]></dc:creator>
            <pubDate>Fri, 17 Jul 2020 08:16:49 GMT</pubDate>
            <atom:updated>2020-07-31T02:02:52.940Z</atom:updated>
            <content:encoded><![CDATA[<p>It seems like right when you turn on your PC, magic happens. It’s almost like regular users believe anything below high-level software programs is almost impossible to comprehend. However, that’s not the case and I believe it’s crucial for a programmer to understand the levels of computing from the hardware all the way up to everyday programs.</p><p>Below is a comprehensive diagram on the computer architecture hierarchy:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/1*29iFfr25vFAWpbdILPGoZg.png" /><figcaption><a href="https://media.cheggcdn.com/media%2F387%2F387382a8-1961-4d3d-9d3c-3c73d85537e0%2Fphp4pvBdk.png">https://media.cheggcdn.com/media%2F387%2F387382a8-1961-4d3d-9d3c-3c73d85537e0%2Fphp4pvBdk.png</a></figcaption></figure><p>Let’s break it down.</p><p>Level 0: Bare-metal. circuit boards, memory buses, etc.</p><p>Level 1 &amp; 2: Micro-architecture. CPU instruction sets, memory communication.</p><p>Level 3: The Operating System (i.e. Windows, Linux, etc). Found right above the firmware and the BIOS (Basic Input Output System).</p><p>Level 4: Assembly. A human readable language that translates to machine code that the CPU can execute.</p><p>Level 5. High-level Programming (C/C++, Java, Python). Trivial for humans to grasp that translates down to assembly language, that translates all the way down to machine code.</p><p>In this write up, we will be working in the level 3–4 hierarchy space.</p><h3>Requirements</h3><p>A) Nasm: The net wide assembler is the most popular assembler and disassembler for the Intel x86 CPU architecture. It is used to write 16-bit, 32-bit and 64-bit programs.</p><p>B) QEMU: A simplistic virtualization program for Linux to run operating systems as virtual machines, without boot-able media.</p><p><strong>Installation</strong>:</p><p>Ubuntu &amp; Debian:</p><pre>sudo apt install nasm qemu</pre><p>Arch Linux:</p><pre>sudo pacman -S nasm qemu</pre><p>OSX:</p><pre>sudo brew install nasm qemu </pre><h3><strong>Core Concepts</strong></h3><p><strong>Absolute Addresses:</strong></p><p>An absolute address can be defined with the assembly “org” instruction which allows us to to set our location counter address to execute our code at link time. Let’s take a look at the MBR’s process from a memory standpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*rzhHmJQduxaP2wv-xVJ81g.png" /></figure><p>The master boot record has a maximum fixed size of 512 bytes. In all cases, the boot sector is loaded at address 0x7c00. We will declare our MBR entry point at this address in the code.</p><h4><strong>Magic Numbers:</strong></h4><p>Magic numbers are the final two bytes of the Master Boot Record (511–512) which must be written as a hexadecimal value to initialize the boot sector process. This section of the MBR must contain ‘AA’ an ‘55’. These two bytes classifies it as a valid MBR.</p><h3><strong>x86 Assembly Concepts</strong></h3><p>Basic command breakdown:</p><p>Below I will demonstrate the basic assembly commands that we will use to write a simple boot loader.</p><pre>mov register, value ; simply stores a value into the given register</pre><pre>jmp label:          ; jump to a specified point (i.e, function or back to a loop)</pre><pre>call function:      ; executes a defined function</pre><pre>cmp dest, src:      ; will compare two operands</pre><pre>jle label:          ; will jump back somewhere if previous compare is less or equal. (l = less, e = equal)</pre><pre>int value:          ; calls a kernel interrupt</pre><h4><strong>Registers</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/0*58khMfk1NI2Jv3N2.jpg" /><figcaption><a href="https://www.tutorialspoint.com/assembly_programming/images/register1.jpg">https://www.tutorialspoint.com/assembly_programming/images/register1.jpg</a></figcaption></figure><p>These are our general purpose assembly registers for our CPU to store data. We will be programming the boot sector in 16-bit mode so we will stick with, AH, AL (8-bit), BH, BL (8-bit). We won’t be touching the counter and data registers but we certainly can if we wanted to. To view all the other CPU registers, they can be found here: <a href="https://wiki.osdev.org/CPU_Registers_x86">https://wiki.osdev.org/CPU_Registers_x86</a>.</p><h3>Programming The Boot loader</h3><p>Firstly, we will create a boot.asm file where we will write our boot loader code.</p><p>To start off, we will write an assembly program to print a character to QEMU.</p><pre>[org 0x7c00] ; MBR start address</pre><pre>mov ah, 0x0E ; BIOS command to move our cursor forward<br>mov al, &#39;X&#39;  ; Store the character to print in the al register<br>int 0x10     ; BIOS interrupt - equivalent to print function</pre><pre>jmp $</pre><pre>times 510-($-$$) db 0 ; byte padding<br>dw 0xAA55             ; magic MBR number</pre><p>Assemble the program:</p><pre>nasm boot.asm -f bin -o boot.bin</pre><p>Run the boot sector with QEMU:</p><pre>qemu-system-x86_64 -fda boot.bin</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*qMEx4mLaOZpPhT78074VTA.png" /></figure><p>Awesome. We now printed the character ‘X’ from the OS layer. Although, it’s not very smart storing single characters in separate memory addresses and combining them as strings. Let’s write a function to print each character in a string, using loops.</p><pre>[org 0x7c00] ; MBR start address <br> <br>mov si, STR  ; store our first string in the si register<br>call printf  <br> <br>mov si, STR_B ; store our second string in the si register<br>call printf <br> <br>jmp $         ; infinite loop<br> <br>printf: <br> pusha        ; push everything onto the stack, only 16-bit mode<br> str_loop:    ; loop function<br> mov al, [si] ; move first char of STR to a-low <br> cmp al, 0 ; look for null terminator <br> jne print_char ; continue to print each char in STR <br> popa ; pop all stack values <br> ret <br> <br> print_char: <br> mov ah, 0x0E ; call our BIOS code for cursor shift <br> int 0x10 <br> add si, 1 ; move forward memory location by one <br> jmp str_loop <br> <br>STR: db ‘Bootsector loaded successfully’, 0x0A, 0x0D, 0 <br>STR_B: db “Dummy OS — Power off the machine to load a real OS”, 0x0A, 0x0D, 0 <br> <br>; padding &amp; magic number <br>times 510-($-$$) db 0 <br>dw 0xAA55 ; initiliaze boot sector</pre><p>Above will produce the following output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*E1cAkLaHXinTiHdqxy20Vw.png" /></figure><p>We now booted into a BIOS that does absolutely nothing but displays strings. From this point, the opportunities are endless. You can now start developing an operating system from the ground up that actually serves a purpose.</p><h3>Conclusion</h3><p>In this write up, we covered the computer architecture hierarchy, absolute addresses, magic numbers, basic assembly instructions, CPU registers, and actually developing a minimalist boot loader.</p><p>If you’re interested to see some of my other projects, feel free to visit my GitHub: <a href="https://github.com/josh0xA/">https://github.com/josh0xA/</a>.</p><p>2020 © Josh Schiavone</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=823354b80846" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Intercepting Network Traffic With The Espionage Packet Sniffer]]></title>
            <link>https://medium.com/@jshschiavone/intercepting-network-traffic-with-the-espionage-packet-sniffer-9af8aa86e45e?source=rss-a170f0349c24------2</link>
            <guid isPermaLink="false">https://medium.com/p/9af8aa86e45e</guid>
            <category><![CDATA[packet-sniffing]]></category>
            <category><![CDATA[espionage]]></category>
            <category><![CDATA[josh]]></category>
            <category><![CDATA[schiavone]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Josh Schiavone]]></dc:creator>
            <pubDate>Mon, 13 Jul 2020 05:36:20 GMT</pubDate>
            <atom:updated>2020-07-13T06:02:42.169Z</atom:updated>
            <content:encoded><![CDATA[<p>The practice of packet sniffing has been around since the late 1980s. It has been used widely throughout the cybersecurity community and it serves many purposes. First, I think we should cover what it really is. According to paessler.com, it is defined as the practice of gathering, collecting, and logging some or all <strong>packets</strong> that pass through a computer network, regardless of how the <strong>packet</strong> is addressed.</p><p>This writeup will cover the following:</p><ol><li>Prologue: Performing/executing this type of attack.</li><li>Tools used (Espionage &amp; sslstrip2).</li><li>Understanding what is going on behind the scenes (Raw sockets, ethernet frames, protocols, etc.)</li><li>How to defend against network interceptions.</li><li>Epilogue: Legal use and unethical use.</li></ol><p>Let’s go through a demonstration on a basic packet sniffing attack. I will be using Espionage. If you don’t have it installed, you can clone it from the GitHub repository found here: <a href="https://github.com/josh0xA/Espionage">https://github.com/josh0xA/Espionage</a></p><p>A) The following command will execute a verbose interception and store the output to the argument -f.</p><ul><li>sudo python3 espionage.py --verbose --iface wlan0 -f capture_output.pcap</li></ul><figure><img alt="Espionage will run until opted out by the user (Ctrl+C)/" src="https://cdn-images-1.medium.com/max/922/1*wNQi9Y2j26NahUWYzJ52Kg.png" /></figure><p>We can see the source and the destination and also the flags of the TCP segment of the packets flowing through our machine to a third-party host. This extra information helps us analyze and break down the packets.</p><p>Okay, so what? This probably isn’t the most effective method of attack if you’re looking to gather information and as you can see we can only sniff on our localhost (127.0.0.1). To solve this, we can use a very popular and very old tactic called ARP Spoofing. ARP Spoofing or ARP Cache Poisoning tricks the default gateway of our router into thinking we are another computer on the network. It does this by sending ARP packets from the MAC address of our machine to the router and from the target allowing all traffic to be rerouted through the attacker.</p><p>Let’s perform an ARP Spoofing attack.</p><p>B) sudo python3 espionage.py — target 192.168.0.64 — iface wlan0</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RZtqbBWUgk5Z5gc-" /><figcaption>Let this run in the background as a separate instance.</figcaption></figure><p>Now we can use a built-in espionage command to sniff URLs visited from 192.168.0.64.</p><p>C) sudo python3 espionage.py — iface wlan0 — urlonly</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*y7NM7wbelw-0xtRG" /><figcaption>URL Sniff</figcaption></figure><p>As you can see it sniffed the URLs visited by the target machine. It also logs raw HTTP data that has been inputted to insecure websites (shown on the bottom: usr=admin, pwd=12345). For this to be most effective, run sslstrip2 in the background to remove the secure socket layer (SSL) protocol encryption that is used when any client communicates with modern web servers.</p><h3><strong>Behind The Scenes</strong></h3><p>Yes, simply running a program to sniff passing data is very amusing and easy. I get it. Although, I would like to cover what is actually going on behind the scenes. Every packet sniffer and packet sniffing library uses raw sockets. Let’s cover them.</p><p>Using a raw socket means you can determine every section of the packet, either header or payload. Please note that the raw socket is a general word. I categorize raw socket into Network Socket and Data-Link Socket (or alternatively L3 Socket and L2 Socket). A non-raw socket means that you can only determine the transport layer payload so the operating system handles all the packet headers, flags, etc.</p><p><strong>Creating a raw socket using Python and struct:</strong></p><p>Before we pack a raw socket, let&#39;s go over the IP header structure and TCP header structure.</p><p>The IP Header Structure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*7JJj_-_dpqqfEWQ3.gif" /><figcaption>32-Bits Wide</figcaption></figure><p>The TCP Header Structure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/0*8e3DTsHBzQ8BiFYM" /><figcaption>32-Bits Wide</figcaption></figure><p><strong>Creating TCP/IP Packets With Python</strong></p><ol><li>First, let’s create the raw socket</li></ol><pre>try:<br>	s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW)<br>except socket.error , msg:<br>	print &#39;Socket could not be created. Error Code : &#39; + str(msg[0]) + &#39; Message &#39; + msg[1]<br>	sys.exit()</pre><p>2. Now, we can pack the IP header:</p><pre>source_ip = &#39;192.168.1.101&#39;<br>dest_ip = &#39;192.168.1.1&#39;<br><br># ip header fields<br>ip_ihl = 5<br>ip_ver = 4<br>ip_tos = 0<br>ip_tot_len = 0	# kernel will fill the correct total length<br>ip_id = 54321	#Id of this packet<br>ip_frag_off = 0<br>ip_ttl = 255<br>ip_proto = socket.IPPROTO_TCP<br>ip_check = 0	# kernel will fill the correct checksum<br>ip_saddr = socket.inet_aton ( source_ip )	<br>ip_daddr = socket.inet_aton ( dest_ip )<br><br>ip_ihl_ver = (version &amp;lt;&amp;lt; 4) + ihl<br><br># the ! in the pack format string means network order<br>ip_header = pack(&#39;!BBHHHBBH4s4s&#39; , ip_ihl_ver, ip_tos, ip_tot_len, ip_id, ip_frag_off, ip_ttl, ip_proto, ip_check, ip_saddr, ip_daddr)</pre><p>3. Then the TCP header:</p><pre># tcp header fields<br>tcp_source = 1234 # source port<br>tcp_dest = 80	# destination port<br>tcp_seq = 454<br>tcp_ack_seq = 0<br>tcp_doff = 5	# 4 bit field, size of tcp header, 5 * 4 = 20 bytes<br>#tcp flags<br>tcp_fin = 0<br>tcp_syn = 1<br>tcp_rst = 0<br>tcp_psh = 0<br>tcp_ack = 0<br>tcp_urg = 0<br>tcp_window = socket.htons (5840) # maximum allowed window size<br>tcp_check = 0<br>tcp_urg_ptr = 0<br><br>tcp_offset_res = (tcp_doff &amp;lt;&amp;lt; 4) + 0<br>tcp_flags = tcp_fin + (tcp_syn &amp;lt;&amp;lt; 1) + (tcp_rst &amp;lt;&amp;lt; 2) + (tcp_psh &amp;lt;&amp;lt;3) + (tcp_ack &amp;lt;&amp;lt; 4) + (tcp_urg &amp;lt;&amp;lt; 5)<br><br># the ! in the pack format string means network order<br>tcp_header = pack(&#39;!HHLLBBHHH&#39; , tcp_source, tcp_dest, tcp_seq, tcp_ack_seq, tcp_offset_res, tcp_flags,  tcp_window, tcp_check, tcp_urg_ptr)</pre><p>4. We can pack it all together and send the packet (Note: A checksum should be properly generated but I will not cover how to generate one here in this writeup)</p><pre># final full packet - syn packets dont have any data<br>packet = ip_header + tcp_header + user_data<br><br># send the packet finally - the port specified has no effect<br>s.sendto(packet, (dest_ip , 0 )) </pre><p>Great! We just created a TCP/IP packet and sent it to a destination. Now that you have a better understanding of raw socket programming you can gain further knowledge on intercepting more obscure packets (ie. Wireless IEEE 802.11 packets).</p><h3><strong>Packet Interception Defense Technique(s)</strong></h3><p>I’ve demonstrated how easy it is to do reconnaissance on a local network. However, companies wouldn’t want anybody with just a computer to spy on their employees. Packet sniffing has been a major player within cybersecurity mainly because there is not an actual good defence against it. Although, that doesn’t mean you can’t secure the data sent through your network.</p><p>The most popular practice people use is to simply connect to a Virtual Private Network (VPN) service. This reroutes all your traffic through a third-party server in which the sniffer cannot intercept data from the VPN to your destination.</p><p>Note: This is why they tell you to connect to a VPN when on public a WiFi network.</p><h3><strong>The Ethics of Network Interception</strong></h3><p>The fact of the matter is, developing and owning a packet sniffer is completely legal (in most countries). Issues arise when you snoop traffic on networks where you are NOT authorized to do so. Other than that, you’re pretty much fine. So if you decide to use Espionage to spy on other people&#39;s traffic, please make sure you have been given explicit permission from an administrator to do so.</p><h3>Conclusion</h3><p>This writeup sums up the following:</p><ol><li>An introduction to the packet sniffing concept.</li><li>A basic tutorial on how to use the Espionage sniffer to sniff raw packets and URLs.</li><li>Behind the scenes action (raw sockets).</li><li>How to defend yourself against malicious network snoopers.</li><li>Legalities of this attack. When and Where it is allowed to be carried out.</li></ol><p>2020 © Josh Schiavone</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9af8aa86e45e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>