<?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:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[Kaladin]]></title><description><![CDATA[Cybersecurity Blog and Writeups]]></description><link>https://kaladin.dev/</link><image><url>https://kaladin.dev/favicon.png</url><title>Kaladin</title><link>https://kaladin.dev/</link></image><generator>Ghost 5.25</generator><lastBuildDate>Mon, 05 Jan 2026 04:10:46 GMT</lastBuildDate><atom:link href="https://kaladin.dev/blog/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Automating your VMware Homelab with Vagrant]]></title><description><![CDATA[Remember that old Catch-22:

How can I get the job without any experience?
How can I get any experience without the job?

A Homelab helps with that.]]></description><link>https://kaladin.dev/blog/vmware-homelab-automation-with-vagrant/</link><guid isPermaLink="false">626e9206ef5098063f8268a1</guid><dc:creator><![CDATA[Kaladin Brightlord]]></dc:creator><pubDate>Sun, 01 May 2022 15:15:04 GMT</pubDate><media:content url="https://images.unsplash.com/photo-1516110833967-0b5716ca1387?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=MnwxMTc3M3wwfDF8c2VhcmNofDh8fGF1dG9tYXRpb258ZW58MHx8fHwxNjUxNDIzMTEx&amp;ixlib=rb-1.2.1&amp;q=80&amp;w=2000" medium="image"/><content:encoded><![CDATA[<img src="https://images.unsplash.com/photo-1516110833967-0b5716ca1387?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=MnwxMTc3M3wwfDF8c2VhcmNofDh8fGF1dG9tYXRpb258ZW58MHx8fHwxNjUxNDIzMTEx&amp;ixlib=rb-1.2.1&amp;q=80&amp;w=2000" alt="Automating your VMware Homelab with Vagrant"><p></p><h2 id="introduction">Introduction</h2><!--kg-card-begin: markdown--><p>One of the best ways to learn and hone IT skills where you would otherwise need to have hands on experience, is by testing out or implementing cool technologies <a href="https://www.elastic.co/elasticsearch/#:~:text=What%20exactly%20can%20I%20use%20Elasticsearch%20for%3F">like these</a> in a homelab.</p>
<p>Remember that old <a href="https://en.wikipedia.org/wiki/Catch-22_(logic)">Catch-22</a>?</p>
<ul>
<li>How can I get the job without any experience?</li>
<li>How can I get any experience without the job?</li>
</ul>
<p>A Homelab helps with that.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: markdown--><h3 id="requirements">Requirements</h3>
<p>You will need to have at least one of the following Virtual Machine providers:<br>
<a href="https://www.vagrantup.com/docs/providers">Virtualbox</a>, <a href="https://www.vagrantup.com/docs/providers">Hyper-V</a>, <a href="https://github.com/josenk/vagrant-vmware-esxi">ESXI</a>, or <a href="https://www.vagrantup.com/docs/providers">VMWARE</a>.</p>
<p>For the purposes of this lab deployment I will be utilizing the Vagrant plugin for the VMWare provider, however the same or similar steps can still be followed if you use different providers. If you would like to do the same, but for ESXI I recommend you check out this awesome walk through by <a href="https://hunter2.gitbook.io/darthsidious/building-a-lab/building-a-lab-with-esxi-and-vagrant">Darthsidious</a> on building a lab.</p>
<p>If you&apos;re interested in having a Virtual Network Customization feature, creating VM clones, or creating snapshots among <a href="https://store-us.vmware.com/vmware-workstation-16-pro-5424176500.html#tab-section4">other awesome features</a> then a VMWare or ESXI provider should be the way to go.</p>
<p>Don&apos;t have the money for VMWare Workstation Pro?<br>
You can try evaluation version for 30 days for <a href="https://www.vmware.com/products/workstation-pro/workstation-pro-evaluation.html">VMWare Workstation Pro</a>.</p>
<!--kg-card-end: markdown--><h2 id="final-lab-mapsneak-preview">Final Lab Map - Sneak Preview</h2><figure class="kg-card kg-image-card"><img src="https://kaladin.dev/content/images/2022/05/image-2.png" class="kg-image" alt="Automating your VMware Homelab with Vagrant" loading="lazy" width="2000" height="1529" srcset="https://kaladin.dev/content/images/size/w600/2022/05/image-2.png 600w, https://kaladin.dev/content/images/size/w1000/2022/05/image-2.png 1000w, https://kaladin.dev/content/images/size/w1600/2022/05/image-2.png 1600w, https://kaladin.dev/content/images/2022/05/image-2.png 2312w" sizes="(min-width: 720px) 720px"></figure><p><sub><sub>I made this diagram with with the <a href="https://github.com/jgraph/drawio-desktop">Draw.io tool for Desktop</a></sub></sub></p><!--members-only--><h2 id="setup-steps">Setup Steps</h2><p>To get started we will need to prep an ISO to be ready for a deployment with Vagrant.</p><p>Packer helps us automate some of that tiresome process of preparing images into VMs ready for Vagrant installation.</p><!--kg-card-begin: markdown--><ol>
<li>Download <a href="https://chocolatey.org/install#individual">Chocolatey</a><pre><code class="language-powershell">Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString(&apos;https://community.chocolatey.org/install.ps1&apos;))```
</code></pre>
</li>
<li>Install Git via Chocolatey (if you don&apos;t already have it)<br>
<code>cinst git</code></li>
<li>Install Vagrant via Chocolatey<br>
<code>cinst vagrant</code></li>
<li>Install packer via Chocolatey<br>
<code>cinst packer -y</code></li>
<li>Create a directory for packer boxes<br>
<code>cmd /k &quot;mkdir C:\Packer &amp;&amp; cd C:\Packer&quot;</code></li>
</ol>
<!--kg-card-end: markdown--><figure class="kg-card kg-code-card"><pre><code class="language-batch">Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString(&apos;https://community.chocolatey.org/install.ps1&apos;))

cinst git -y

cinst vagrant -y

cinst packer -y

cmd /k &quot;mkdir C:\Packer &amp;&amp; cd C:\Packer&quot;</code></pre><figcaption>Installation Steps</figcaption></figure><p></p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://www.packer.io/plugins/builders/vmware"><div class="kg-bookmark-content"><div class="kg-bookmark-title">Packer by HashiCorp</div><div class="kg-bookmark-description">The VMware Packer builder is able to create VMware virtual machines for usewith any VMware product.</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://www.packer.io/packer/favicon.ico" alt="Automating your VMware Homelab with Vagrant"><span class="kg-bookmark-author">Packer by HashiCorp</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://www.packer.io/packer/img/og-image.png" alt="Automating your VMware Homelab with Vagrant"></div></a></figure><h3 id="the-vmware-packer-builder-by-hashicorp">The <a href="https://www.packer.io/plugins/builders/vmware">VMware Packer</a> builder by Hashicorp</h3><!--kg-card-begin: markdown--><blockquote>
<p>The VMware Packer builder is able to create VMware virtual machines for use with any VMware product.</p>
<p>Packer supports the following VMware builders:</p>
<ul>
<li>
<p><a href="https://www.packer.io/plugins/builders/vmware/iso">vmware-iso</a> - <strong>Starts from an ISO file</strong>, creates a brand new VMware VM, installs an OS, provisions software within the OS, then exports that machine to create an image. This is best for people who want to start from scratch.</p>
</li>
<li>
<p><a href="https://www.packer.io/docs/builders/vmware-vmx">vmware-vmx</a> - This builder <strong>imports an existing VMware machine (from a VMX file)</strong>, runs provisioners on top of that VM, and exports that machine to create an image. This is best if you have an existing VMware VM you want to use as the source. As an additional benefit, you can feed the artifact of this builder back into Packer to iterate on a machine.</p>
</li>
</ul>
</blockquote>
<!--kg-card-end: markdown--><figure class="kg-card kg-code-card"><pre><code class="language-batch">packer plugins install github.com/hashicorp/vmware</code></pre><figcaption>Add the plugin required by packer for VMware</figcaption></figure><p></p><h3 id="preparing-our-vmdks-for-packer-builder">Preparing our VMDKs for Packer Builder</h3><p>To prepare the VMDKs we will...</p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://kaladin.dev/content/images/2022/05/image.png" class="kg-image" alt="Automating your VMware Homelab with Vagrant" loading="lazy" width="500" height="202"><figcaption>Disk Utilities from VM Settings&#xA0;</figcaption></figure><p><sup>You can download a copy of the <em><em><strong><em><a href="https://kb.vmware.com/s/article/1023856">vmware-vdiskmanager</a></em></strong></em></em> for windows or linux to do this by command line. I also provide the required files (and the missing DLLs) on my <a href="https://drive.google.com/drive/folders/1XnEevr_5UN8xg7NUj0HTPAVwQwfuI6CX?usp=sharing">Google Drive</a>.</sup></p><!--kg-card-begin: markdown--><ol>
<li>Open the settings for the VM</li>
<li>Select Hard Disk</li>
<li>Click Defragment</li>
<li>Click Compact</li>
<li>Compress the VMDK directory with the command below</li>
</ol>
<!--kg-card-end: markdown--><figure class="kg-card kg-code-card"><pre><code class="language-bash">cd /path/to/my/vm.directory/
tar cvzf custom.box ./*</code></pre><figcaption>and finally - Compressing the VM directory</figcaption></figure><blockquote><sup>The files that are <strong>strictly required for a VMware machine to function</strong> are: nvram, vmsd, vmx, vmxf, and vmdk files.</sup></blockquote><p>More details on preparing VMDKs for .BOX format can be found below...</p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://www.vagrantup.com/docs/providers/vmware/boxes"><div class="kg-bookmark-content"><div class="kg-bookmark-title">Vagrant by HashiCorp</div><div class="kg-bookmark-description">As with every Vagrant provider, the Vagrant VMware providers have a custom boxformat.</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://www.vagrantup.com/vagrant/favicon.ico" alt="Automating your VMware Homelab with Vagrant"><span class="kg-bookmark-author">Vagrant by HashiCorp</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://www.vagrantup.com/vagrant/img/og-image.png" alt="Automating your VMware Homelab with Vagrant"></div></a></figure><p>Create a JSON in the packer directory for your VM</p><figure class="kg-card kg-code-card"><pre><code class="language-json">{
  &quot;builders&quot;: [
    {
	  &quot;type&quot;: &quot;vmware-vmx&quot;,
	  &quot;source_path&quot;: &quot;C:/Users/Administrator/Documents/vm_storage/FlareVM/FlareVM.vmx&quot;,
	  &quot;ssh_username&quot;: &quot;user&quot;,
	  &quot;ssh_password&quot;: &quot;password&quot;,
	  &quot;shutdown_command&quot;: &quot;shutdown -s -t 0&quot;
	}
  ]
}</code></pre><figcaption>build-flarevm.pkr.json</figcaption></figure><p>Convert the JSON to a .PKR.HCL with the following commands and build it</p><pre><code class="language-batch">packer hcl2_upgrade build_flarevm.pkr.json
packer build build_flarevm.pkr.json.pkr.hcl</code></pre>]]></content:encoded></item><item><title><![CDATA[Python Selfbots and Webhooks in Discord Pt. 1]]></title><description><![CDATA[Creating custom Discord selfbots when Discord's Webhooks aren't enough. With a dash of Python and a dab of Chrome Dev tools.]]></description><link>https://kaladin.dev/blog/discord-webhooks-and-selfbots-python-pt1/</link><guid isPermaLink="false">60ca021de99db8f33a39a43d</guid><category><![CDATA[Python]]></category><category><![CDATA[networking]]></category><dc:creator><![CDATA[Kaladin Brightlord]]></dc:creator><pubDate>Sat, 19 Jun 2021 23:24:33 GMT</pubDate><media:content url="https://kaladin.dev/content/images/2021/06/abstract-1.png" medium="image"/><content:encoded><![CDATA[<img src="https://kaladin.dev/content/images/2021/06/abstract-1.png" alt="Python Selfbots and Webhooks in Discord Pt. 1"><p></p><blockquote>Creating custom Discord selfbots when Discord&apos;s webhooks aren&apos;t enough.</blockquote><h2 id="my-inspiration"><u>My Inspiration</u></h2><p>Like most of the small projects I get ideas for, this one came to me when I was bored and wanted to know if I could send a friend a message on Discord or Slack using a simple device like a Raspberry Pi. </p><p>My friends often have tech troubles and since we usually communicate over Discord or Slack. I figured it would make my life a little bit easier if I can just have them run a script and it will automatically send the results back to me through our DMs to help troubleshoot their issues.</p><hr><h2 id="webhooks"><u>Webhooks</u></h2><p>This is generally the go to option if you are okay with performing smaller requests and tasks. Webhooks are quite easy to set up, but hamper the amount of control you have over your bot. Methods that use the API are favored and abide by the TOS, so if you like to live safely then this is the option for you.</p><p> See the <a href="#userbots">Userbots</a> section for more info on Discords TOS.</p><p>For instructions on creating Webhooks you can find the docs below:</p><!--kg-card-begin: markdown--><ul>
<li><a href="https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks">https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks</a></li>
</ul>
<!--kg-card-end: markdown--><h3 id="python">Python</h3><figure class="kg-card kg-code-card"><pre><code class="language-python">import requests
import json

if __name__ == &apos;__main__&apos;:

    wekbook_url = &apos;https://discordapp.com/api/webhooks/.../&apos;

    data = {
        &apos;text&apos;: &apos;A message sent with the power of Python in Discord.&apos;
    }

    response = requests.post(wekbook_url, data=json.dumps(
        data), headers={&apos;Content-Type&apos;: &apos;application/json&apos;})

    print(&apos;Response: &apos; + str(response.text))
    print(&apos;Response code: &apos; + str(response.status_code))</code></pre><figcaption>Sending messages in Discord with Webhook</figcaption></figure><figure class="kg-card kg-code-card"><pre><code class="language-python">import requests
import json

if __name__ == &apos;__main__&apos;:

    wekbook_url = &apos;https://hooks.slack.com/services/{API_GUID}&apos;

    data = {
    	&apos;icon_emoji&apos; = &apos;:ghost:&apos;,
        &apos;text&apos;: &apos;A message sent with the power of Python in Slack.&apos;,
        &apos;username&apos;: &apos;Python Bot&apos;,
        &apos;icon_emoji&apos;: &apos;:robot_face:&apos;
    }

    response = requests.post(wekbook_url, data=json.dumps(
        data), headers={&apos;Content-Type&apos;: &apos;application/json&apos;})

    print(&apos;Response: &apos; + str(response.text))
    print(&apos;Response code: &apos; + str(response.status_code))
</code></pre><figcaption>Sending messages in Slack with Webhooks</figcaption></figure><hr><h2 id="userbots"><u>Userbots</u></h2><p>This method is if you want more power over what your bot can do, for example with Slack you are unable to directly mention someone when using Webhooks. However a word of warning, you can be banned for using userbots as it is explicitly against the TOS (at least for Discord).</p><p></p><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://discord.com/terms"><div class="kg-bookmark-content"><div class="kg-bookmark-title">Terms of Service | Discord</div><div class="kg-bookmark-description">Read about Discord&#x2019;s Terms of Service.</div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://discord.com/assets/847541504914fd33810e70a0ea73177e.ico" alt="Python Selfbots and Webhooks in Discord Pt. 1"><span class="kg-bookmark-author">Discord</span></div></div><div class="kg-bookmark-thumbnail"><img src="https://discord.com/assets/652f40427e1f5186ad54836074898279.png" alt="Python Selfbots and Webhooks in Discord Pt. 1"></div></a></figure><figure class="kg-card kg-bookmark-card"><a class="kg-bookmark-container" href="https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.login"><div class="kg-bookmark-content"><div class="kg-bookmark-title">API Reference</div><div class="kg-bookmark-description"></div><div class="kg-bookmark-metadata"><img class="kg-bookmark-icon" src="https://discordpy.readthedocs.io/en/latest/_static/discord_py_logo.ico" alt="Python Selfbots and Webhooks in Discord Pt. 1"></div></div></a></figure><p></p><p>For Discord it is likely safer to strictly use the requests module, as Discord says you <a href="https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.login">will be banned</a> for logging in with your user account (through their module/api).</p><p>Which is why I will be using the <a href="https://github.com/Zenaker/Zenon">selfbot repo Zenon</a>.</p><hr><h3 id="finding-your-discord-auth-token">Finding your Discord Auth token:</h3><!--kg-card-begin: markdown--><ol>
<li>Open the Discord App</li>
<li>Press Ctrl+Shift+I (to open Chromium dev tools)</li>
<li>Navigate to the Application Tab -&gt; Storage -&gt; Local Storage -&gt; Discord.com</li>
<li>In the filter bar type: &quot;token&quot; without quotes</li>
<li>Press Ctrl+R (refresh Discord for the token to appear)</li>
<li>Finally highlight to copy and retrieve your token.</li>
</ol>
<!--kg-card-end: markdown--><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://kaladin.dev/content/images/2021/06/image-2.png" class="kg-image" alt="Python Selfbots and Webhooks in Discord Pt. 1" loading="lazy" width="1301" height="636" srcset="https://kaladin.dev/content/images/size/w600/2021/06/image-2.png 600w, https://kaladin.dev/content/images/size/w1000/2021/06/image-2.png 1000w, https://kaladin.dev/content/images/2021/06/image-2.png 1301w" sizes="(min-width: 720px) 720px"><figcaption>Copy only the value, without quotes</figcaption></figure><h3 id="install-dependencies">Install dependencies</h3><pre><code class="language-bat">pip3 install requests, unidecode</code></pre><p></p><!--kg-card-begin: markdown--><p>Here we define a few functions allowing our bot to wait for a command in your chat channel of choice and respond with a custom message, that can optionally include their username (unicode formatted).</p>
<!--kg-card-end: markdown--><figure class="kg-card kg-code-card"><pre><code class="language-python">import requests
import random
import time
from unidecode import unidecode


token = &quot;your-token-here&quot;
discord = &quot;https://discordapp.com/api/v6/&quot;
chatid = 795743570995839018

def send_message(chatid, content, proxy=None): # it can also be use as a private message
    return requests.post(discord + &quot;channels/&quot; + str(chatid) + &quot;/messages#&quot;, proxies=proxy, data={&quot;content&quot;:str(content), &quot;nonce&quot;:str(random.randint(10000000, 99999999))}, headers={&quot;Authorization&quot;:token}).text
	
def get_message(chatid, proxy=None):
    res = requests.get(discord + &quot;channels/&quot; + str(chatid) + &quot;/messages?limit=1&quot;, proxies=proxy, headers={&quot;Authorization&quot;:token}).text
    try:
        content = res.split(&apos;&quot;content&quot;: &quot;&apos;)[1].split(&apos;&quot;&apos;)[0]
    except IndexError as e:
        content = res.split(&apos;&quot;message&quot;: &quot;&apos;)[1].split(&apos;&quot;&apos;)[0],res.split(&apos;&quot;retry_after&quot;: &apos;)[-1].split(&quot;\n&quot;)[0]
    return content

def get_author_id(chatid, proxy=None):
    res = requests.get(discord + &quot;channels/&quot; + str(chatid) + &quot;/messages?limit=1&quot;, proxies=proxy, headers={&quot;Authorization&quot;:token}).text
    return res.split(&apos;&quot;author&quot;:&apos;)[1].split(&apos;&quot;id&quot;: &quot;&apos;)[1].split(&apos;&quot;&apos;)[0]

if __name__ == &quot;__main__&quot;:
    while True:
        time.sleep(0.05) # To not spam the server
        message = get_message(chatid)
        if message == &quot;!yobot&quot;:
            send_message(chatid, f&quot;How may I help you &lt;@{get_author_id(chatid)}&gt;?&quot;)
        elif message[0] == &quot;You are being rate limited.&quot;:
            print(f&quot;Waiting off the rate limit for {int(message[1])/1000}s&quot;)
            time.sleep(int(message[1])/1000)</code></pre><figcaption>Responding to chat messages with custom functions</figcaption></figure><figure class="kg-card kg-image-card"><img src="https://kaladin.dev/content/images/2021/06/image-4.png" class="kg-image" alt="Python Selfbots and Webhooks in Discord Pt. 1" loading="lazy" width="332" height="118"></figure><h3 id="prebuilt-request-functions">Prebuilt request functions</h3><!--kg-card-begin: markdown--><p>If you prefer to use a repo that already has prebuilt functions the <a href="https://github.com/Zenaker/Zenon/blob/master/zenon/messages/messages.py">Zenon repo</a> on GitHub has a decent amount of predefined function to get you started.</p>
<!--kg-card-end: markdown--><p></p><p>Please stay tuned for updates and part 2!</p>]]></content:encoded></item><item><title><![CDATA[Why Perl is better than Python for Exploit Development]]></title><description><![CDATA[<p>This is a bold claim considering how much Python is used for writing exploits, however as we compare the output of some shellcode produced from both Perl and Python, you will see why Perl can be the better choice in most scenarios, or at least more straightforward.</p><h2 id="two-potential-solutions-in-python3">Two potential solutions</h2>]]></description><link>https://kaladin.dev/blog/why-perl-is-better-than-python-for-exploit-development/</link><guid isPermaLink="false">60bfe8781115380a0897c078</guid><category><![CDATA[ExploitDevelopment]]></category><category><![CDATA[Python]]></category><dc:creator><![CDATA[Kaladin Brightlord]]></dc:creator><pubDate>Wed, 09 Jun 2021 00:10:41 GMT</pubDate><media:content url="https://kaladin.dev/content/images/2021/06/large-bytes.jpg" medium="image"/><content:encoded><![CDATA[<img src="https://kaladin.dev/content/images/2021/06/large-bytes.jpg" alt="Why Perl is better than Python for Exploit Development"><p>This is a bold claim considering how much Python is used for writing exploits, however as we compare the output of some shellcode produced from both Perl and Python, you will see why Perl can be the better choice in most scenarios, or at least more straightforward.</p><h2 id="two-potential-solutions-in-python3">Two potential solutions in Python3</h2><pre><code class="language-shell">$ uname -sp
Linux x86_64
</code></pre><figure class="kg-card kg-code-card"><pre><code class="language-python">#!/usr/bin/env python3

# Equivalent to running: execve /bin/sh
shellcode =  &quot;\x31\xc0\x50\x68\x2f\x2f\x73&quot;
shellcode += &quot;\x68\x68\x2f\x62\x69\x6e\x89&quot;
shellcode += &quot;\xe3\x89\xc1\x89\xc2\xb0\x0b&quot;
shellcode += &quot;\xcd\x80\x31\xc0\x40\xcd\x80&quot;

print(shellcode)</code></pre><figcaption>execve_binsh_shellcode1.py</figcaption></figure><p>Piping the Python shellcode output to a file works most of the time; however, when we attempt to write the shellcode straight to a file or binary, we run into some more issues (examples below).</p><figure class="kg-card kg-code-card"><pre><code class="language-python">#!/usr/bin/env python3

# Equivalent to running: execve /bin/sh
shellcode =  b&quot;\x31\xc0\x50\x68\x2f\x2f\x73&quot;
shellcode += b&quot;\x68\x68\x2f\x62\x69\x6e\x89&quot;
shellcode += b&quot;\xe3\x89\xc1\x89\xc2\xb0\x0b&quot;
shellcode += b&quot;\xcd\x80\x31\xc0\x40\xcd\x80&quot;

with open(&apos;python_shellcode2.bin&apos;, &apos;wb&apos;) as f:
	f.write(shellcode)</code></pre><figcaption>execve_binsh_shellcode2.py</figcaption></figure><hr><h2 id="lets-compare-the-two">Let&apos;s compare the two</h2><figure class="kg-card kg-code-card"><pre><code class="language-shell">$ python3 execve_binsh_shellcode.py &gt; python_shellcode1.bin
$ python3 execve_binsh_shellcode2.py
$ cat python_shellcode1.bin
1&#xC0;Ph//shh/bin&#x89;&#xE3;&#x89;&#xC1;&#x89;&#xC2;&#xB0;&#x2642;&#xCD;&#x80;1&#xC0;@&#xCD;&#x80;
$
$ cat python_shellcode2.bin
1&#x2514;Ph//shh/bin&#xEB;&#x3C0;&#xEB;&#x2534;&#xEB;&#x252C;&#x2591;&#x2642;&#x2550;&#xC7;1&#x2514;@&#x2550;&#xC7;</code></pre><figcaption>execve_binsh_shellcode.py terminal output</figcaption></figure><blockquote>Comparing the outputs, it&apos;s obvious that something is a little bit off...</blockquote><p></p><p>However, it isn&apos;t immediately clear what went wrong until we compare the differences between the two using xxd.</p><pre><code class="language-text">$ xxd python_shellcode1.bin
00000000: 31c3 8050 682f 2f73 6868 2f62 696e c289  1..Ph//shh/bin..
00000010: c3a3 c289 c381 c289 c382 c2b0 0bc3 8dc2  ................
00000020: 8031 c380 40c3 8dc2 800a                 .1..@.....

$ xxd python_shellcode2.bin
00000000: 31c0 5068 2f2f 7368 682f 6269 6e89 e389  1.Ph//shh/bin...
00000010: c189 c2b0 0bcd 8031 c040 cd80            .......1.@..
</code></pre><blockquote>It seems like Python is replacing \x80 and possibly some other bytes it doesn&apos;t like.</blockquote><p></p><pre><code class="language-text">\x31\xc0\x50\x68\x2f\x2f\x73
\x68\x68\x2f\x62\x69\x6e\x89
\xe3\x89\xc1\x89\xc2\xb0\x0b
\xcd\x80\x31\xc0\x40\xcd\x80</code></pre><p>Looking at the original shellcode we want, it is clear that we are getting some extra and undesired bytes in our output.</p><blockquote>Okay...Well, how does Perl perform then?</blockquote><p></p><hr><h2 id="a-safer-and-more-straightforward-approach">A safer and more straightforward approach</h2><pre><code class="language-shell">perl -e &apos;print(&quot;\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x89\xc1\x89\xc2\xb0\x0b\xcd\x80\x31\xc0\x40\xcd\x80&quot;)&apos; | xxd
</code></pre><figure class="kg-card kg-code-card"><pre><code class="language-text">00000000: 31c0 5068 2f2f 7368 682f 6269 6e89 e389  1.Ph//shh/bin...
00000010: c189 c2b0 0bcd 8031 c040 cd80            .......1.@..</code></pre><figcaption>Piping our output to xxd instead of a file</figcaption></figure><p>Awesome!!! Now we&apos;re ready to start writing some exploits. I will continue where we left off and demonstrate how we can drop some shells using Perl and a little bit of disassembly in a future post, subscribe to my blog so you don&apos;t miss it!</p><p><em>Happy hacking! -Kal</em></p>]]></content:encoded></item><item><title><![CDATA[Counting available host IP addresses - a classful approach]]></title><description><![CDATA[<p></p><h2 id="breaking-it-down">Breaking it down</h2><p>These two functions take two IP addresses from a string and splits them into four octets, then it converts the octets to a packed IP/integer (octet value * 256^octet) and sums the values to return how many host addresses are available between the two.</p><pre><code class="language-python">def ips_</code></pre>]]></description><link>https://kaladin.dev/blog/python-counting-addresses/</link><guid isPermaLink="false">60beea191115380a0897c018</guid><category><![CDATA[Python]]></category><category><![CDATA[networking]]></category><dc:creator><![CDATA[Kaladin Brightlord]]></dc:creator><pubDate>Tue, 08 Jun 2021 03:55:37 GMT</pubDate><media:content url="https://kaladin.dev/content/images/2021/06/no_place_like_home-1.jpg" medium="image"/><content:encoded><![CDATA[<img src="https://kaladin.dev/content/images/2021/06/no_place_like_home-1.jpg" alt="Counting available host IP addresses - a classful approach"><p></p><h2 id="breaking-it-down">Breaking it down</h2><p>These two functions take two IP addresses from a string and splits them into four octets, then it converts the octets to a packed IP/integer (octet value * 256^octet) and sums the values to return how many host addresses are available between the two.</p><pre><code class="language-python">def ips_between(start, end):
    end_octets = [ int(octet) for octet in end.split(&quot;.&quot;) ] # Making binary octets from the strings
    start_octets = [ int(octet) for octet in start.split(&quot;.&quot;) ]
    return ip_to_packed_int(end_octets) - ip_to_packed_int(start_octets)


def ip_to_packed_int(bin_octets: list)-&gt;int:
    packed_ip = []
    power = 3
    for i in bin_octets:
        packed_ip.append((int(i) * (256 ** power)))
        power -= 1
    return sum(packed_ip)</code></pre>]]></content:encoded></item><item><title><![CDATA[Convert IP addresses to integers]]></title><description><![CDATA[Addresses in their packed form are useful when you need to calculate the first host, last host, or subnet addresses. ]]></description><link>https://kaladin.dev/blog/ip-addresses-to-ints/</link><guid isPermaLink="false">60bee5c41115380a0897bfb1</guid><category><![CDATA[Python]]></category><category><![CDATA[networking]]></category><dc:creator><![CDATA[Kaladin Brightlord]]></dc:creator><pubDate>Tue, 08 Jun 2021 03:53:03 GMT</pubDate><media:content url="https://kaladin.dev/content/images/2021/06/python_bg-1.jpg" medium="image"/><content:encoded><![CDATA[<img src="https://kaladin.dev/content/images/2021/06/python_bg-1.jpg" alt="Convert IP addresses to integers"><p>Here is an example of some Python code to convert IP addresses to their Packed (integer) form. Addresses in their packed form are useful when you need to calculate the first host, last host, or subnet addresses. </p><figure class="kg-card kg-code-card"><pre><code class="language-text">192.168.1.0
255.0.0.0
255.255.255.255
0.0.0.1
0.0.0.255</code></pre><figcaption>addresses.txt</figcaption></figure><pre><code class="language-python">#!/usr/bin/env python3


with open(&quot;addresses.txt&quot;, &quot;r&quot;) as f:
        addresses = filter(None, f.read().split(&quot;\n&quot;))


def ip_to_int32(ip):
        packed_int = [int(ip.split(&quot;.&quot;)[0]) &lt;&lt; 24, int(ip.split(&quot;.&quot;)[1]) \
        &lt;&lt; 16, int(ip.split(&quot;.&quot;)[2]) &lt;&lt; 8, int(ip.split(&quot;.&quot;)[3])]
        return sum(packed_int)


for address in addresses:
        packed_ip = ip_to_int32(ip=address)
        print(packed_ip)</code></pre><pre><code class="language-bash">chmod +x ip_to_int.py
python3 ip_to_int.py
</code></pre><p></p><p></p><hr><p><em>This was done through Prism.js</em></p>]]></content:encoded></item></channel></rss>