1
2
Fork 0
mirror of https://github.com/carlospolop/hacktricks.git synced 2023-12-14 19:12:55 +01:00
hacktricks/exploiting/tools/pwntools.md

173 lines
2.6 KiB
Markdown
Raw Normal View History

# PwnTools
```
pip3 install pwntools
```
2021-11-30 17:46:07 +01:00
## Pwn asm 
2021-11-30 17:46:07 +01:00
Get opcodes from line or file. 
```
pwn asm "jmp esp"
pwn asm -i <filepath>
```
2021-11-30 17:46:07 +01:00
**Can select:**&#x20;
* output type (raw,hex,string,elf)
* output file context (16,32,64,linux,windows...)
2021-11-30 17:46:07 +01:00
* avoid bytes (new lines, null, a list)&#x20;
* select encoder debug shellcode using gdb run the output
2021-11-30 17:46:07 +01:00
## &#x20; **Pwn checksec**
2021-11-30 17:46:07 +01:00
Checksec script&#x20;
```
pwn checksec <executable>
```
## Pwn constgrep
2021-11-30 17:46:07 +01:00
## Pwn cyclic&#x20;
Get a pattern
```
pwn cyclic 3000
pwn cyclic -l faad
```
2021-11-30 17:46:07 +01:00
**Can select:** &#x20;
* The used alphabet (lowercase chars by default)
* Length of uniq pattern (default 4)
* context (16,32,64,linux,windows...)
* Take the offset (-l)
## Pwn debug
Attach GDB to a process
```
pwn debug --exec /bin/bash
pwn debug --pid 1234
pwn debug --process bash
```
2021-11-30 17:46:07 +01:00
**Can select:**&#x20;
2021-11-30 17:46:07 +01:00
* By executable, by name or by pid context (16,32,64,linux,windows...)&#x20;
* gdbscript to execute&#x20;
* sysrootpath
2021-11-30 17:46:07 +01:00
## Pwn disablenx&#x20;
2021-11-30 17:46:07 +01:00
Disable nx of a binary &#x20;
```
pwn disablenx <filepath>
```
2021-11-30 17:46:07 +01:00
## Pwn disasm&#x20;
Disas hex opcodes
```
pwn disasm ffe4
```
2021-11-30 17:46:07 +01:00
**Can select:**&#x20;
2021-11-30 17:46:07 +01:00
* context (16,32,64,linux,windows...)&#x20;
* base addres&#x20;
* color(default)/no color
2021-11-30 17:46:07 +01:00
## Pwn elfdiff&#x20;
Print differences between 2 fiels
```
pwn elfdiff <file1> <file2>
```
2021-11-30 17:46:07 +01:00
## Pwn hex&#x20;
Get hexadecimal representation
```bash
pwn hex hola #Get hex of "hola" ascii
```
2021-11-30 17:46:07 +01:00
## Pwn phd&#x20;
2021-11-30 17:46:07 +01:00
Get hexdump&#x20;
```
pwn phd <file>
```
2021-11-30 17:46:07 +01:00
&#x20;**Can select:**&#x20;
2021-11-30 17:46:07 +01:00
* Number of bytes to show&#x20;
* Number of bytes per line highlight byte&#x20;
* Skip bytes at beginning
2021-11-30 17:46:07 +01:00
## Pwn pwnstrip&#x20;
## Pwn scrable
2021-11-30 17:46:07 +01:00
## Pwn shellcraft&#x20;
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)
2021-11-30 17:46:07 +01:00
* before (debug trap before code)&#x20;
* after
* avoid using opcodes (default: not null and new line)
* Run the shellcode
* Color/no color
2021-11-30 17:46:07 +01:00
* list syscalls&#x20;
* list possible shellcodes&#x20;
* Generate ELF as a shared library
2021-11-30 17:46:07 +01:00
## Pwn template&#x20;
2021-11-30 17:46:07 +01:00
Get a python template&#x20;
```
pwn template
```
**Can select:** host, port, user, pass, path and quiet
2021-11-30 17:46:07 +01:00
## Pwn unhex&#x20;
2021-11-30 17:46:07 +01:00
From hex to string&#x20;
```
pwn unhex 686f6c61
```
2021-11-30 17:46:07 +01:00
## Pwn update&#x20;
To update pwntools
```
pwn update
```