All Projects → matrix1001 → Welpwn

matrix1001 / Welpwn

Licence: mit
💖CTF pwn framework.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Welpwn

hackergame-challenge-docker
nc 类题目的 Docker 容器资源限制、动态 flag、网页终端
Stars: ✭ 62 (-78.17%)
Mutual labels:  pwn, ctf
winpwn
CTF windows pwntools
Stars: ✭ 137 (-51.76%)
Mutual labels:  pwn, ctf
libc-db
libc database (file in packages, hash, package files, symbols). Raw binary libc available on https://github.com/BestPig/libc-bin)
Stars: ✭ 21 (-92.61%)
Mutual labels:  pwn, ctf
nadbg
👀Dynamic memory watcher/tracer/analyzer for CTF pwn
Stars: ✭ 51 (-82.04%)
Mutual labels:  pwn, ctf
CTF
My CTF tools & some other stuff
Stars: ✭ 17 (-94.01%)
Mutual labels:  pwn, ctf
heapinfo
An interactive memory info for pwning / exploiting
Stars: ✭ 96 (-66.2%)
Mutual labels:  pwn, ctf
Linux-Kernel-Exploitation
Linux kernel development & exploitation lab.
Stars: ✭ 130 (-54.23%)
Mutual labels:  pwn, ctf
NTU-Computer-Security
台大 計算機安全 - Pwn 簡報、影片、作業題目與解法 - Computer Security Fall 2019 @ CSIE NTU Taiwan
Stars: ✭ 293 (+3.17%)
Mutual labels:  pwn, ctf
pwnscripts
Very simple script(s) to hasten binary exploit creation
Stars: ✭ 66 (-76.76%)
Mutual labels:  pwn, ctf
BinV
👓 Yet another binary vulnerbilities checker. An automated vulnerability scanner for ELF based on symbolic execution.
Stars: ✭ 25 (-91.2%)
Mutual labels:  pwn, ctf
ctf
ctf wp 2019-2020
Stars: ✭ 23 (-91.9%)
Mutual labels:  pwn, ctf
how-to-exploit-a-double-free
How to exploit a double free vulnerability in 2021. Use After Free for Dummies
Stars: ✭ 1,165 (+310.21%)
Mutual labels:  pwn, ctf
heaptrace
helps visualize heap operations for pwn and debugging
Stars: ✭ 252 (-11.27%)
Mutual labels:  pwn, ctf
exploiting
Exploiting challenges in Linux and Windows
Stars: ✭ 122 (-57.04%)
Mutual labels:  pwn, ctf
ctf-writeups
📚 Yet another CTF writeups repository. PWN and RE tasks
Stars: ✭ 29 (-89.79%)
Mutual labels:  pwn, ctf
My-PWN-Life
This is a PWN challenges repo.###### 1f y0u l1ke, g1v3 m3 a star~
Stars: ✭ 23 (-91.9%)
Mutual labels:  pwn, ctf
ghidra2dwarf
🐉 Export ghidra decompiled code to dwarf sections inside ELF binary
Stars: ✭ 135 (-52.46%)
Mutual labels:  pwn, ctf
kar98k public
pwn & ctf tools for windows
Stars: ✭ 24 (-91.55%)
Mutual labels:  pwn, ctf
FastPwn
CTF中Pwn的快速利用模板(包含awd pwn)
Stars: ✭ 18 (-93.66%)
Mutual labels:  pwn, ctf
ctf-writeups
Writeups of CTF challenges
Stars: ✭ 19 (-93.31%)
Mutual labels:  pwn, ctf

Introduction

Pwnning is an art.

welpwn is designed to make pwnning an art, freeing you from dozens of meaningless jobs.

Features

  • Automatically get those magic values for you.
    • libc address
    • heap address
    • stack address
    • program address (with PIE)
    • canary
  • Support multi glibc debugging.
    • 2.19, 2.23-2.29
    • both 32bit and 64bit
  • Debug enhancement (support PIE).
    • symbols
    • breakpoints
  • Misc
    • libc-database
    • one_gadget
  • Heap ? Well, no support for heap analysis. But I have a gif for you. HeapInspect

Tutorial

Detailed Documention

Install

There are two ways for you to use welpwn.

Via Install

setup.py has been added since version 0.9.3. If you do not frequently update welpwn, and have no need for teamwork with this tool, this is the recommended way.

git clone https://github.com/matrix1001/welpwn && cd welpwn && python setup.py install

Via Path

This is recommended for developers and those who need to share their exploit for teamwork.

git clone https://github.com/matrix1001/welpwn && cd welpwn && python start.py

Then you probably get something like this.

# paste these codes into your exp.py
# https://github.com/matrix1001/welpwn # reserve this link :)
import sys
sys.path.insert(0,'/tmp/welpwn')
from PwnContext.core import *

Template

My personal template for pwn challenge.

python start.py --template
#https://github.com/matrix1001/welpwn
from PwnContext import *

try:
    from IPython import embed as ipy
except ImportError:
    print ('IPython not installed.')

if __name__ == '__main__':        
    # context.terminal = ['tmux', 'splitw', '-h'] # uncomment this if you use tmux
    context.log_level = 'debug'
    # functions for quick script
    s       = lambda data               :ctx.send(str(data))        #in case that data is an int
    sa      = lambda delim,data         :ctx.sendafter(str(delim), str(data)) 
    sl      = lambda data               :ctx.sendline(str(data)) 
    sla     = lambda delim,data         :ctx.sendlineafter(str(delim), str(data)) 
    r       = lambda numb=4096          :ctx.recv(numb)
    ru      = lambda delims, drop=True  :ctx.recvuntil(delims, drop)
    irt     = lambda                    :ctx.interactive()
    rs      = lambda *args, **kwargs    :ctx.start(*args, **kwargs)
    dbg     = lambda gs='', **kwargs    :ctx.debug(gdbscript=gs, **kwargs)
    # misc functions
    uu32    = lambda data   :u32(data.ljust(4, '\0'))
    uu64    = lambda data   :u64(data.ljust(8, '\0'))
    leak    = lambda name,addr :log.success('{} = {:#x}'.format(name, addr))

    ctx.binary = './pwn'
    ctx.remote_libc = './libc.so'
    ctx.remote = ('1.1.1.1', 1111)
    ctx.debug_remote_libc = False # True for debugging remote libc, false for local.

    rs()
    # rs('remote') # uncomment this for exploiting remote target

    libc = ctx.libc # ELF object of the corresponding libc.

    # ipy() # if you have ipython, you can use this to check variables.

Core API

welpwn is a super wrapper of pwntools, using a ctx to manage binary, libc, gdb and other stuff.

ctx.start

ctx.start support process, remote and gdb.

process and remote have the same usage as those of pwntools.

>>> from PwnContext.core import *
>>> ctx.binary = '/bin/sh'
[*] '/bin/sh'
...
>>> ctx.start()
...
[+] Starting local process '/bin/sh': pid 27377
>>> ctx.sendline('whoami')
root
>>> print(ctx.recv())
>>> print('let\'s try remote')
let's try remote
>>> ctx.remote = ('localhost', 1234)
>>> ctx.start('remote')
...
[+] Opening connection to localhost on port 1234: Done
>>> ctx.sendline('whoami')
>>> print(ctx.recv())
root

gdb is similar to gdb.debug. It's convenient to debug at the process entry.

>>> ctx.start('gdb', gdbscript='b *0x602010\nc')
...

ctx.remote_libc

ctx.remote_libc is designed to handle the libc of challenges, which may be different from your system's.

Just assign the path of libc to it, then set ctx.debug_remote_libc to True.

from PwnContext.core import *
ctx.binary = './pwn'
ctx.remote_libc = './libc.so.6'
ctx.debug_remote_libc = True
ctx.start()
print(ctx.libc.path)
# result: /path/to/current/dir/libc.so.6

Note

No 100% guarantee for successfully loading the libc. Segfault may happen due to different versions of libc.so and ld.so.

ctx.custom_lib_dir

ctx.custome_lib_dir is also designed to handle different libc, especially useful when challenges need other libraries like libpthread.so.

from PwnContext.core import *
ctx.binary = './pwn'
ctx.custom_libc_dir = './lib/'
ctx.debug_remote_libc = True
ctx.start()
print(ctx.libc.path)
# result: /path/to/current/dir/lib/libc.so.6

Note

If you want to debug with symbols, main_arena for example, use glibc-all-in-one to download libc.

If you want to debug with source code, just compile glibc and enjoy it.

ctx.bases and ctx.canary

ctx.bases gives you start addresses of prog, heap, libc, stack.

ctx.canary is an integer.

Note that ctx.bases.heap is available only after the process called malloc.

You can use it to prove your concept and even pre brute-force.

from PwnContext.core import *

ctx.binary = '/bin/sh'
while True:
    ctx.start()
    libc_base = ctx.bases.libc
    if (libc_base & 0xf000) == 0x2000: break
print 'now we got libc base:', hex(ctx.bases.libc)
# result: now we got libc base: 0x7f680e782000

ctx.symbols and ctx.breakpoints

ctx.symbols and ctx.breakpoints are designed for gdb. They both generate gdbscript when you call ctx.debug(). Both support PIE and ASLR.

Check this example.

from PwnContext.core import *

ctx.binary = '/bin/cat'
ctx.symbols = {'sym1':0x1234, 'sym2':0x5678}
ctx.breakpoints = [0x1234, 0x5678]
ctx.start()
ctx.debug()

Then the following script is passed to gdb.

set $sym2=0x5647464d8678
set $sym1=0x5647464d4234
b *0x5647464d4234
b *0x5647464d8678

Use p/x $sym1 to check it.

Now support heap and libc symbols. Just use a name starts with libc_ or heap_.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].