Skip to content

<Not exactly a problem> Running binaries + debugger inside docker #218

@sivaplaysmC

Description

@sivaplaysmC

NOTE: Since discussions were disabled, raising an issue to discuss about this.

Instead of the current setup which uses glibc_run.sh (which compiles glibc from scratch and then compiles the binary and then links to it), what if we just use a dockerfile that provides the needed glibc version?

Like so:

# for glibc 2.39
FROM docker.io/library/ubuntu:24.04

RUN apt-mark hold libc6 && apt update && apt install -y gdb wget curl xz-utils binutils gcc
RUN curl -qsL 'https://install.pwndbg.re' | sh -s -- -t pwndbg-gdb

RUN mkdir -p /how2heap
WORKDIR /how2heap

COPY compile-all.sh .

COPY *.c .

RUN sh compile-all.sh

# disables ASLR
ENTRYPOINT ["setarch", "-R", "/usr/bin/bash"]

compile-all.sh

#!/usr/bin/env sh

set -eu

CFILES=$(ls *.c)

for cfile in $CFILES
do
    # set -x
    # put each C file into it's own dir.
    dirname=$(echo $cfile | sed s/.c\$//)
    mkdir "$dirname"
    mv $cfile "$dirname/"

    cmd="gcc -no-pie -g $dirname/$cfile -o $dirname/$dirname"
    echo $cmd
    $cmd
done

This scripts creates a neat setup like so:

Image

This allows for a pre-made environment similar to ret2system's web ui, but in the terminal with pwndbg.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions