Skip to main content

A wrapper around pwntools but also with a few of the functions that I use on a daily basis.

Project description

flashlib

A wrapper around pwntools but also with a few of the functions that I use on a daily basis.


To install, run:

pip3 install pwn-flashlib

Basic usage:

from flashlib import *

# This will setup everything for you, elf, libc
init("./test")

# => io is in the global namespace
# <do your exploitation part here>

io.interactive()

Calculating offsets by recvafter

#!/usr/bin/env python3

from flashlib import *

# Just init and io, libc and elf will be in the global space
init("./test")

main = hexleak(io.recvafter(b": "))
elf.address = main - elf.sym.main
logleak(elf.address)

io.interactive()

Attaching GDB:

When running the exploit, run it as: python3 exploit.py GDB and use the attach method to attach a gdb to the current process.

The context.terminal is set to tmux, you can override to your liking.

#!/usr/bin/env python3

from flashlib import *

gdbscript = """
	b *main+40
"""

init("./test")
attach(gdbscript) # this will attach the gdb session

io.interactive()

REMOTE:

Let's consider a scenario where you have setup a remote gdb session, you need to just pass REMOTE and GDB and in attach, just pass remote=("127.0.0.1", GDBPORT) and you'll be prompted to attach gdb? i.e. attach the gdbserver to the process.

#!/usr/bin/env python3

from flashlib import *

gdbscript = """
	b *main+40
"""

init("./test")
attach(gdbscript, remote=("127.0.0.1", 1234))

CUSTOM IO:

Another scenario where you have both a local and a remote connection, you can pass custom pwnlib.tubes process to attach the gdb session to.

#!/usr/bin/env python3

from flashlib import *

gdbscript = """
	b *main+40
"""

local, elf, libc = init("./test")
io = remote("127.0.0.1", 31337)

# This will now 
attach(gdbscript, _io=local)

Proof-of-Work

Since my pwn-chal container now supports proof-of-work which is quite similar to pwn.red/jail, I just had a function lying around to solve the proof-of-work:

#!/usr/bin/env python3

init("./test")

# just invoke the function and it will solve pow
# no need to pass anything else.
# Handles pow for:
# 1. pwn-chal
# 2. pwn.red/jail
pow_solve()

There's a lot more stuff which I'll keep updating as well.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pwn_flashlib-0.3.1.tar.gz (4.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pwn_flashlib-0.3.1-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file pwn_flashlib-0.3.1.tar.gz.

File metadata

  • Download URL: pwn_flashlib-0.3.1.tar.gz
  • Upload date:
  • Size: 4.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for pwn_flashlib-0.3.1.tar.gz
Algorithm Hash digest
SHA256 51d4d225f88b41a06540f15b0b32b77bf35d0ada6363ac13e6bc69ddbad602d8
MD5 0b0f94433f2e21bf06cf5eaebb38ccf1
BLAKE2b-256 5059176ce8351fd84bf8a8c65990a9c8b645895e7acfd45217d9d4f3fbbcb5b8

See more details on using hashes here.

File details

Details for the file pwn_flashlib-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: pwn_flashlib-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for pwn_flashlib-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1e35d6bc05002d12a4229f35b2aa7874117f6155ab03eacaf9e5dad42bb106bb
MD5 b847b518157d1dcfe0a61d9b0823084e
BLAKE2b-256 f059d00876a45ea8d7caf3892d9491e8f0ff3ea601db25b33649f19ff5303929

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page