Skip to content

Commit

Permalink
add: Blog - pwn env setup on win11 using wsl
Browse files Browse the repository at this point in the history
  • Loading branch information
h3athen committed Dec 11, 2024
1 parent a66dc85 commit aabfcc8
Show file tree
Hide file tree
Showing 59 changed files with 3,044 additions and 63 deletions.
4 changes: 2 additions & 2 deletions config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ disableTextInHeader = false
showDateUpdated = false
showAuthor = true
# showAuthorBottom = false
showHero = true
heroStyle = "basic" # valid options: basic, big, background, thumbAndBackground
showHero = false
heroStyle = "big" # valid options: basic, big, background, thumbAndBackground
# layoutBackgroundBlur = true # only used when heroStyle equals background or thumbAndBackground
layoutBackgroundHeaderSpace = true # only used when heroStyle equals background
showBreadcrumbs = true
Expand Down
Binary file added content/posts/win11-pwn-env/featured.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
147 changes: 147 additions & 0 deletions content/posts/win11-pwn-env/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
---
title: "PWN environment setup on Win11 using WSL2"
date: 2024-12-11
draft: false
summary: "Setting up a binary exploitation environment on Windows 11 using WSL2"
tags: ["pwn", "blog", "tutorial"]
---

Having a good environment is a must when you want to do binary exploitaton. Here I will show you how to set up a simple environment using Ubuntu and WSL2
so you can straight up jump into finding and writing your exploits.

## Agenda

Things we will be setting up:
- Ubuntu inside our Windows WSL2
- Pwntools library for writing exploits
- PwnDbg for debugging and finding vulnerability on programms

## Setting up Ubuntu on WSL2

Change WSL version to 2
```bash
wsl --set-default-version 2
```
<img src="img/Pasted image 20241209090017.png">
<hr>

Searching for our distribution in the online marketplace
```bash
wsl --list --online
```
<img src="img/Pasted image 20241209090045.png">
<hr>

Installing our distribution with a suitable version. Here I will be instaling Ubuntu 24.04 which comes under their LTS
```bash
wsl --install -d Ubuntu-24.04
```
<img src="img/Pasted image 20241209090109.png">
<hr>

After the installation, it will prompt you to set up a user with a password. After which it will drop you to your user shell
and you should be able to see something like this.
<img src="img/Pasted image 20241209091105.png">

### Configuring 32-bit environment
Since the distribution we installed is of 64-bit, we must set it up to run 32-bit programs as well. Its very common in CTFs that we receive 32-bit binaries.

Installing all the necessary packages and libraries.
```bash
sudo dpkg --add-architecture i386
sudo apt-get update
```
<img src="img/Pasted image 20241209091403.png">
<hr>

```bash
sudo apt install build-essential
```
<img src="img/Pasted image 20241209091547.png">
<hr>

```bash
sudo apt install gcc-multilib
```
<img src="img/Pasted image 20241209091733.png">

## Setting up PwnTools library
Pwntools is a CTF framework and exploit development library. Written in Python, it is designed for rapid prototyping and development, and intended to make exploit writing as simple as possible.
```bash
sudo apt-get update
sudo apt-get install python3 python3-pip python3-dev git libssl-dev libffi-dev build-essential
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade pwntools
```
<img src="img/Pasted image 20241209092006.png">

### Working around the PIP upgrade error
<img src="img/Pasted image 20241209092036.png">

There are many solutions to it. The best and the recommended one is to set up a virtual environment.
The second would be to use the `--break-system-packages` tag with our pip command and
the third is to set up a config so that we dont have to pass the tag everytime we use pip.

{{< alert iconColor="#FADFA1" >}}
**NOTE!** I would still recommend to set up an virtual environment!
{{< /alert >}}

Lets set up a config for our pip
```bash
mkdir .config
mkdir .config/pip
touch .config/pip/pip.conf
```

edit `pip.conf`
```ini
[global]
break-system-packages = true
```

Now we should be able to continue our installing without any errors.
<img src="img/Pasted image 20241209092615.png">
<img src="img/Pasted image 20241209092706.png">
<hr>

We can confirm our installation by loading the library into Python
<img src="img/Pasted image 20241209093218.png">

## Setting up PwnDbg
PwnDbg is a GDB plug-in that makes debugging with GDB suck less, with a focus on features needed by low-level software developers, hardware hackers, reverse-engineers and exploit developers.

First lets start by installing gdb
```bash
sudo apt install gdb
```
<img src="img/Pasted image 20241209115301.png">
<hr>

Installing and setting up PwnDbg
```bash
git clone https://github.com/pwndbg/pwndbg
cd pwndbg
./setup.sh
```
<img src="img/Pasted image 20241209115504.png">
<img src="img/Pasted image 20241209115611.png">

## Resources

- PwnTools - <http://pwntools.com/>
- PwnDbg - <https://pwndbg.re/>
- [How to install Linux on Windows with WSL](https://learn.microsoft.com/en-us/windows/wsl/install)
- [Windows Subsystem for Linux](https://learn.microsoft.com/en-us/windows/wsl/)

## FAQ
### What to do after this?

Well, I would suggest installing a code exitor such as [VSCode](https://code.visualstudio.com/) on your host machine for you to write exploits or you can be a chad and install neovim on your linux.

After that you can set up a disassembler and decompiler of your choice. There are many to choose from but these are some of my picks:
- [Ghidra by NSA (yes the NSA)](https://ghidra-sre.org/)
- [IDA by Hex Rays](https://hex-rays.com/)
- [Binary Ninja by Vector 35](https://binary.ninja/)
- [Cutter by Rizin](https://cutter.re/)

Now that you are all set, the only thing left is to start hacking and writing exploits
141 changes: 141 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,147 @@ <h2 class="mt-8 text-2xl font-extrabold mb-10">Recent</h2>








<a class="flex flex-wrap article " href="/posts/win11-pwn-env/">


<div class="w-full md:w-auto h-full thumbnail nozoom thumbnailshadow md:mr-7" style="background-image:url(/posts/win11-pwn-env/featured_hu12059272893085827353.png);"></div>

<div class=" mt-3 md:mt-0">
<div class="items-center text-left text-xl font-semibold">

<div class="font-bold text-xl text-neutral-800 decoration-primary-500 hover:underline hover:underline-offset-2 dark:text-neutral"
href="/posts/win11-pwn-env/">PWN environment setup on Win11 using WSL2</div>



</div>
<div class="text-sm text-neutral-500 dark:text-neutral-400">


































<div class="flex flex-row flex-wrap items-center">


<time datetime="2024-12-11T00:00:00&#43;00:00">11 December 2024</time><span class="px-2 text-primary-500">&middot;</span><span title="Reading time">3 mins</span>




</div>





<div class="flex flex-row flex-wrap items-center">












<span style="margin-top:0.5rem" class="mr-2" onclick="window.open(&#34;/tags/pwn/&#34;,'_self');">
<span class="flex" style="cursor: pointer;">
<span class="rounded-md border border-primary-400 px-1 py-[1px] text-xs font-normal text-primary-700 dark:border-primary-600 dark:text-primary-400">
Pwn
</span>
</span>
</span>

<span style="margin-top:0.5rem" class="mr-2" onclick="window.open(&#34;/tags/blog/&#34;,'_self');">
<span class="flex" style="cursor: pointer;">
<span class="rounded-md border border-primary-400 px-1 py-[1px] text-xs font-normal text-primary-700 dark:border-primary-600 dark:text-primary-400">
Blog
</span>
</span>
</span>

<span style="margin-top:0.5rem" class="mr-2" onclick="window.open(&#34;/tags/tutorial/&#34;,'_self');">
<span class="flex" style="cursor: pointer;">
<span class="rounded-md border border-primary-400 px-1 py-[1px] text-xs font-normal text-primary-700 dark:border-primary-600 dark:text-primary-400">
Tutorial
</span>
</span>
</span>




</div>




</div>

<div class="py-1 max-w-fit prose dark:prose-invert">
Setting up a binary exploitation environment on Windows 11 using WSL2
</div>

</div>
</a>























Expand Down
2 changes: 1 addition & 1 deletion public/index.json

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion public/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,17 @@
<managingEditor>[email protected] (Aryan Gurung)</managingEditor>
<webMaster>[email protected] (Aryan Gurung)</webMaster>
<copyright>© 2024 Aryan Gurung</copyright>
<lastBuildDate>Fri, 08 Nov 2024 00:00:00 +0000</lastBuildDate><atom:link href="http://localhost:1313/index.xml" rel="self" type="application/rss+xml" />
<lastBuildDate>Wed, 11 Dec 2024 00:00:00 +0000</lastBuildDate><atom:link href="http://localhost:1313/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>PWN environment setup on Win11 using WSL2</title>
<link>http://localhost:1313/posts/win11-pwn-env/</link>
<pubDate>Wed, 11 Dec 2024 00:00:00 +0000</pubDate>
<author>[email protected] (Aryan Gurung)</author>
<guid>http://localhost:1313/posts/win11-pwn-env/</guid>
<description>Setting up a binary exploitation environment on Windows 11 using WSL2</description>
<media:content xmlns:media="http://search.yahoo.com/mrss/" url="http://localhost:1313/posts/win11-pwn-env/featured.png" />
</item>

<item>
<title>Dear Diary, My Flare-On 11</title>
<link>http://localhost:1313/posts/flare-on-11-diary/</link>
Expand Down
11 changes: 0 additions & 11 deletions public/posts/a-plunge-into-lower-level/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -596,17 +596,6 @@

<article>







<div class="w-full h-36 md:h-56 lg:h-72 single_hero_basic nozoom" style="background-image:url(/posts/a-plunge-into-lower-level/featured_hu17003037379706996293.jpg);"></div>





<header id="single_header" class="mt-5 max-w-prose">

Expand Down
11 changes: 0 additions & 11 deletions public/posts/flare-on-11-diary/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -600,17 +600,6 @@

<article>







<div class="w-full h-36 md:h-56 lg:h-72 single_hero_basic nozoom" style="background-image:url(/posts/flare-on-11-diary/featured_hu10908335592546151875.png);"></div>





<header id="single_header" class="mt-5 max-w-prose">

Expand Down
Loading

0 comments on commit aabfcc8

Please sign in to comment.