Skip to content

Commit bb3f4dd

Browse files
committed
1.5.1 better templates
+ improved alias formatting (max column size) + added new comments in template + integrated vagd info in template + added fail safe vagd info (no .comment section)
1 parent 918fab2 commit bb3f4dd

File tree

6 files changed

+195
-134
lines changed

6 files changed

+195
-134
lines changed

README.md

+58-30
Original file line numberDiff line numberDiff line change
@@ -22,45 +22,70 @@ pip install ./vagd/
2222
- `vagd template [OPTIONS] [BINARY] [IP] [PORT]` to generate a template, list OPTIONS with help `-h`
2323

2424
```python
25-
#!/usr/bin/env python
2625
from pwn import *
2726

28-
IP = '' # remote IP
29-
PORT = 0 # remote PORT
30-
BINARY = '' # PATH to local binary e.g. ./chal
31-
ARGS = [] # ARGS supplied to binary
32-
ENV = {} # ENVs supplied to binary
33-
# GDB SCRIPT, executed at start of GDB session (set breakpoint here)
34-
GDB = f"""
27+
GOFF = 0x555555554000 # GDB default base address
28+
IP = '' # remote IP
29+
PORT = 0 # remote PORT
30+
BINARY = '' # PATH to local binary
31+
ARGS = [] # ARGS supplied to binary
32+
ENV = {} # ENV supplied to binary
33+
34+
# GDB SCRIPT, executed at start of GDB session (e.g. set breakpoints here)
35+
GDB = f"""
36+
set follow-fork-mode parent
3537
3638
c"""
3739

38-
context.binary = exe = ELF(BINARY, checksec=False)
39-
# enable disable ASLR (works for GDB)
40-
context.aslr = False
40+
context.binary = exe = ELF(BINARY, checksec=False) # binary
41+
context.aslr = False # ASLR enabled (only GDB)
4142

4243
vm = None
43-
def get_target(**kw):
44-
global vm
44+
# setup vagd vm
45+
def setup():
46+
global vm
47+
if args.REMOTE or args.LOCAL:
48+
return
49+
50+
try:
51+
# only load vagd if needed
52+
from vagd import Dogd, Qegd, Box
53+
except:
54+
log.error('Failed to import vagd, either run locally using LOCAL or install it')
55+
if not vm:
56+
vm = Dogd(BINARY, image=Box.DOCKER_UBUNTU, ex=True, fast=True) # Docker
57+
# vm = Qegd(BINARY, img=Box.QEMU_UBUNTU, ex=True, fast=True) # Qemu
58+
if vm.is_new:
59+
# additional setup here
60+
log.info('new vagd instance')
61+
62+
63+
# get target (pwnlib.tubes.tube)
64+
def get_target(**kw) -> tubes.tube:
65+
if args.REMOTE:
66+
# context.log_level = 'debug'
67+
return remote(IP, PORT)
68+
69+
if args.LOCAL:
70+
if args.GDB:
71+
return gdb.debug([BINARY] + ARGS, env=ENV, gdbscript=GDB, **kw)
72+
return process([BINARY] + ARGS, env=ENV, **kw)
4573

46-
if args.REMOTE:
47-
context.log_level = 'debug'
48-
return remote(IP, PORT)
74+
return vm.start(argv=ARGS, env=ENV, gdbscript=GDB, **kw)
4975

50-
from vagd import Dogd, Qegd, Shgd
51-
if not vm:
52-
# Docker
53-
vm = Dogd(exe.path, image="ubuntu:jammy", ex=True, fast=True)
54-
# or Qemu
55-
vm = Qegd(exe.path, img="https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img", ex=True, fast=True)
56-
# or SSH
57-
vm = Shgd(exe.path, user='user', host='localhost', port=22, ex=True, fast=True)
58-
return vm.start(argv=ARGS, env=ENV, gdbscript=GDB, **kw) # returns a pwn.process (similar to pwn.process())
5976

77+
setup()
78+
79+
#===========================================================
80+
# EXPLOIT STARTS HERE
81+
#===========================================================
82+
83+
# libc = ELF('', checksec=False)
6084

6185
t = get_target()
6286

63-
t.interactive()
87+
t.interactive() # or it()
88+
6489
```
6590

6691
- `vagd info BINARY` to print info about binary
@@ -72,6 +97,8 @@ t.interactive()
7297
./exploit.py GDB
7398
# run on remote IP:PORT
7499
./exploit.py REMOTE
100+
# run process locally
101+
./exploit.py LOCAL [GDB]
75102
```
76103

77104
I recommend using [pwndbg](https://github.com/pwndbg/pwndbg).
@@ -127,10 +154,11 @@ Using gdbserver and gdb to index libraries can be very slow. Therefore an experi
127154

128155
## Future plans
129156

130-
### pre configured QEMU Images / Docker Image
157+
### Better Docker integration
131158

132-
created pre configured environments with preinstalled lib debug symbols and gdbserver to lower init runtime.
159+
- migrate away from ssh (attach from host) to get lower latency
160+
- additionally virtualize containers (Qemu) in order to change the used kernel.
133161

134-
### Better Docker integration
162+
### Qemu user
135163

136-
created a Docker integration that allows loading existing Dockerfiles (maybe docker-compose), also add a feature that additionally visualizes (Qemu) them to change the used kernel.
164+
- add templates that make use of pwntools qemu-user integration

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "vagd"
3-
version = "1.5.0"
3+
version = "1.5.1"
44
authors = [{ name = "0x6fe1be2" }]
55
description = "VirtuAlization GDb integrations in pwntools"
66
readme = "README.md"

src/vagd/box.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
class Box:
22
"""constants class for recommended images and boxes"""
33

4-
VAGRANT_JAMMY64 = "ubuntu/jammy64"
5-
VAGRANT_FOCAL64 = "ubuntu/focal64"
6-
VAGRANT_BIONIC64 = "ubuntu/bionic64"
7-
VAGRANT_XENIAL64 = "ubuntu/xenial64"
8-
94
QEMU_NOBLE = "https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img"
105
QEMU_JAMMY = "https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img"
116
QEMU_FOCAL = "https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img"
127
QEMU_BIONIC = "https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img"
13-
QEMU_XENIAL = "https://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img"
148
QEMU_UBUNTU = QEMU_NOBLE
9+
10+
QEMU_NOBLE_ARM = "https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-arm64.img"
1511
QEMU_JAMMY_ARM = "https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-arm64.img"
1612

1713
DOCKER_NOBLE = "ubuntu:noble"
@@ -27,3 +23,9 @@ class Box:
2723

2824
DOCKER_ALPINE_320 = "alpine:3.20"
2925
DOCKER_ALPINE = DOCKER_ALPINE_320
26+
27+
# DEPRECATED
28+
VAGRANT_JAMMY64 = "ubuntu/jammy64"
29+
VAGRANT_FOCAL64 = "ubuntu/focal64"
30+
VAGRANT_BIONIC64 = "ubuntu/bionic64"
31+
VAGRANT_XENIAL64 = "ubuntu/xenial64"

0 commit comments

Comments
 (0)