hacktricks/exploiting/tools/pwntools.md

207 lines
4.5 KiB
Markdown
Raw Normal View History

2022-05-01 16:32:23 +00:00
2022-04-28 16:01:33 +00:00
2024-07-18 16:21:56 +00:00
{% hint style="success" %}
Learn & practice AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
Learn & practice GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
2022-04-28 16:01:33 +00:00
2024-07-18 16:21:56 +00:00
<details>
2022-04-28 16:01:33 +00:00
2024-07-18 16:21:56 +00:00
<summary>Support HackTricks</summary>
2022-04-28 16:01:33 +00:00
2024-07-18 16:21:56 +00:00
* Check the [**subscription plans**](https://github.com/sponsors/carlospolop)!
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2022-04-28 16:01:33 +00:00
</details>
2024-07-18 16:21:56 +00:00
{% endhint %}
2022-04-28 16:01:33 +00:00
2022-05-01 16:32:23 +00:00
```
pip3 install pwntools
```
2022-05-01 16:32:23 +00:00
# Pwn asm
2022-04-05 22:24:52 +00:00
Get opcodes from line or file.
```
pwn asm "jmp esp"
pwn asm -i <filepath>
```
2022-04-05 22:24:52 +00:00
**Can select:**
* output type (raw,hex,string,elf)
* output file context (16,32,64,linux,windows...)
2022-04-05 22:24:52 +00:00
* avoid bytes (new lines, null, a list)
* select encoder debug shellcode using gdb run the output
2022-05-01 16:32:23 +00:00
# **Pwn checksec**
2022-04-05 22:24:52 +00:00
Checksec script
```
pwn checksec <executable>
```
2022-05-01 16:32:23 +00:00
# Pwn constgrep
2022-05-01 16:32:23 +00:00
# Pwn cyclic
Get a pattern
```
pwn cyclic 3000
pwn cyclic -l faad
```
2022-05-01 16:32:23 +00:00
**Can select:**
* The used alphabet (lowercase chars by default)
* Length of uniq pattern (default 4)
* context (16,32,64,linux,windows...)
* Take the offset (-l)
2022-05-01 16:32:23 +00:00
# Pwn debug
Attach GDB to a process
```
pwn debug --exec /bin/bash
pwn debug --pid 1234
pwn debug --process bash
```
2022-04-05 22:24:52 +00:00
**Can select:**
2022-04-05 22:24:52 +00:00
* By executable, by name or by pid context (16,32,64,linux,windows...)
* gdbscript to execute
* sysrootpath
2022-05-01 16:32:23 +00:00
# Pwn disablenx
2022-05-01 16:32:23 +00:00
Disable nx of a binary
```
pwn disablenx <filepath>
```
2022-05-01 16:32:23 +00:00
# Pwn disasm
Disas hex opcodes
```
pwn disasm ffe4
```
2022-04-05 22:24:52 +00:00
**Can select:**
2022-04-05 22:24:52 +00:00
* context (16,32,64,linux,windows...)
* base addres
* color(default)/no color
2022-05-01 16:32:23 +00:00
# Pwn elfdiff
Print differences between 2 fiels
```
pwn elfdiff <file1> <file2>
```
2022-05-01 16:32:23 +00:00
# Pwn hex
Get hexadecimal representation
```bash
pwn hex hola #Get hex of "hola" ascii
```
2022-05-01 16:32:23 +00:00
# Pwn phd
2022-04-05 22:24:52 +00:00
Get hexdump
```
pwn phd <file>
```
2022-04-05 22:24:52 +00:00
**Can select:**
2022-04-05 22:24:52 +00:00
* Number of bytes to show
* Number of bytes per line highlight byte
* Skip bytes at beginning
2022-05-01 16:32:23 +00:00
# Pwn pwnstrip
2022-05-01 16:32:23 +00:00
# Pwn scrable
2022-05-01 16:32:23 +00:00
# Pwn shellcraft
Get shellcodes
```
pwn shellcraft -l #List shellcodes
pwn shellcraft -l amd #Shellcode with amd in the name
pwn shellcraft -f hex amd64.linux.sh #Create in C and run
pwn shellcraft -r amd64.linux.sh #Run to test. Get shell
pwn shellcraft .r amd64.linux.bindsh 9095 #Bind SH to port
```
**Can select:**
* shellcode and arguments for the shellcode
* Out file
* output format
* debug (attach dbg to shellcode)
2022-04-05 22:24:52 +00:00
* before (debug trap before code)
* after
* avoid using opcodes (default: not null and new line)
* Run the shellcode
* Color/no color
2022-04-05 22:24:52 +00:00
* list syscalls
* list possible shellcodes
* Generate ELF as a shared library
2022-05-01 16:32:23 +00:00
# Pwn template
2022-04-05 22:24:52 +00:00
Get a python template
```
pwn template
```
**Can select:** host, port, user, pass, path and quiet
2022-05-01 16:32:23 +00:00
# Pwn unhex
2022-04-05 22:24:52 +00:00
From hex to string
```
pwn unhex 686f6c61
```
2022-05-01 16:32:23 +00:00
# Pwn update
To update pwntools
```
pwn update
```
2022-04-28 16:01:33 +00:00
2022-05-01 16:32:23 +00:00
2024-07-18 16:21:56 +00:00
{% hint style="success" %}
Learn & practice AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
Learn & practice GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
2022-04-28 16:01:33 +00:00
2024-07-18 16:21:56 +00:00
<details>
2022-04-28 16:01:33 +00:00
2024-07-18 16:21:56 +00:00
<summary>Support HackTricks</summary>
2022-04-28 16:01:33 +00:00
2024-07-18 16:21:56 +00:00
* Check the [**subscription plans**](https://github.com/sponsors/carlospolop)!
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2022-04-28 16:01:33 +00:00
</details>
2024-07-18 16:21:56 +00:00
{% endhint %}
2022-05-01 16:32:23 +00:00