vagd


Namevagd JSON
Version 1.3.3 PyPI version JSON
download
home_pageNone
SummaryVirtuAlization GDb integrations in pwntools
upload_time2024-05-13 10:26:35
maintainerNone
docs_urlNone
author0x6fe1be2
requires_python>=3.7
licenseNone
keywords vagd pwn pwntools exploit ctf capture the flag binary vagrant qemu docker
VCS
bugtrack_url
requirements pwntools docker typer
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![PyPI](https://img.shields.io/pypi/v/vagd?style=flat)](https://pypi.org/project/vagd/) [![docs](https://img.shields.io/badge/docs-passing-success)](https://vagd.gfelber.dev)

# VAGD

VirtuAlization GDb integrations in pwntools



## Installation

```bash
pip install vagd
```
or from repo with
```bash
git clone https://github.com/gfelber/vagd
pip install ./vagd/
```



## Usage

+ `vagd template [OPTIONS] [BINARY] [IP] [PORT]` to generate a template, list OPTIONS with help `-h`

```python
#!/usr/bin/env python
from pwn import *

IP = ''         # remote IP
PORT = 0        # remote PORT
BINARY = ''     # PATH to local binary e.g. ./chal
ARGS = []       # ARGS supplied to binary 
ENV = {}        # ENVs supplied to binary
# GDB SCRIPT, executed at start of GDB session (set breakpoint here)
GDB = f"""

c"""

context.binary = exe = ELF(BINARY, checksec=False)
# enable disable ASLR (works for GDB)
context.aslr = False

vm = None
def get_target(**kw):
    global vm

    if args.REMOTE:
        context.log_level = 'debug'
        return remote(IP, PORT)

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


t = get_target()

t.interactive()
```

+ `vagd info BINARY` to print info about binary

```bash
# run as process in VM
./exploit.py
# run as gdb server in VM requires tmux
./exploit.py GDB
# run on remote IP:PORT
./exploit.py REMOTE
```

I recommend using [pwndbg](https://github.com/pwndbg/pwndbg).

 

## Files

All created files ares stored in the local `./.vagd/` directory. Additional large files (e.g. cloudimages) are stored in the home directory `~/.vagd/` or handled by tools themselfs (e.g. Docker).



## CLI

```bash
alias vagd="python -m vagd" # or install with pip / pipx
# help message
vagd -h
# analyses the binary, prints checksec and .comment (often includes Distro and Compiler info)
vagd info BINARY
# creates template, for more info use: vagd template -h
vagd template [OPTIONS] [BINARY] [IP] [PORT]
# ssh to current vagd instance, for more info use: vagd ssh -h
vagd ssh [OPTIONS]
# scp file to/from vagd instance, for more info use: vagd scp -h
# e.g. vagd scp ./test_file vagd:./ # vagd:./ is default target
vagd scp [OPTIONS] SOURCE [TARGET]
# stop and remove current vagd instance, for more info use: vagd clean -h
vagd clean [OPTIONS]
```



## [Documentation](https://vagd.gfelber.dev)



## Boxes

A listed of known working Boxes can be found in the [Documentation](http://vagd.gfelber.dev/autoapi/vagd/box/index.html#module-vagd.box).
Other images might also work but currently only distributions that use `apt` and alpine for Docker are supported.
This limitation may be circumvented by creating a target yourself (with the dependencies gdbserver, python, openssh) and creating a ssh connection via Shgd.



## Troubleshooting

### background processes

all instances continue to run in the background (after a vagd object has been started), this improves the runtime greatly after the first execution of the exploit. But this means that instances must be killed manually e.g.: `vagd clean`

### gdb & gdbserver

Because gdbserver is used to run binaries on the instances I recommend using [pwndbg](https://github.com/pwndbg/pwndbg). Other well known gdb plugins like [peda](https://github.com/longld/peda) aren't compatible with gdbserver and therefore won't work.

### files

files on the virtual instance are never overwritten this has performance reason (so files aren't always copied if the exploit is run). If you need to updated files on the remote either use `vagd scp` or create use temporary directories `Dogd(..., tmp=True)`

### gdb performance

Using gdbserver and gdb to index libraries can be very slow. Therefore an experimental feature is available that mounts libraries locally: `Dogd(..., ex=True, fast=True)` 



## Future plans

### pre configured QEMU Images / Docker Image

created pre configured environments with preinstalled lib debug symbols and gdbserver to lower init runtime.

### Better Docker integration

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.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "vagd",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "vagd, pwn, pwntools, exploit, ctf, capture, the, flag, binary, vagrant, qemu, docker",
    "author": "0x6fe1be2",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/e1/bc/6e7a28005ebf6c19e902a19338ea7d6d332ae9d6bf2ef00bf01de96ec47a/vagd-1.3.3.tar.gz",
    "platform": null,
    "description": "[![PyPI](https://img.shields.io/pypi/v/vagd?style=flat)](https://pypi.org/project/vagd/) [![docs](https://img.shields.io/badge/docs-passing-success)](https://vagd.gfelber.dev)\n\n# VAGD\n\nVirtuAlization GDb integrations in pwntools\n\n\n\n## Installation\n\n```bash\npip install vagd\n```\nor from repo with\n```bash\ngit clone https://github.com/gfelber/vagd\npip install ./vagd/\n```\n\n\n\n## Usage\n\n+ `vagd template [OPTIONS] [BINARY] [IP] [PORT]` to generate a template, list OPTIONS with help `-h`\n\n```python\n#!/usr/bin/env python\nfrom pwn import *\n\nIP = ''         # remote IP\nPORT = 0        # remote PORT\nBINARY = ''     # PATH to local binary e.g. ./chal\nARGS = []       # ARGS supplied to binary \nENV = {}        # ENVs supplied to binary\n# GDB SCRIPT, executed at start of GDB session (set breakpoint here)\nGDB = f\"\"\"\n\nc\"\"\"\n\ncontext.binary = exe = ELF(BINARY, checksec=False)\n# enable disable ASLR (works for GDB)\ncontext.aslr = False\n\nvm = None\ndef get_target(**kw):\n    global vm\n\n    if args.REMOTE:\n        context.log_level = 'debug'\n        return remote(IP, PORT)\n\n    from vagd import Dogd, Qegd, Shgd\n    if not vm:\n        # Docker \n        vm = Dogd(exe.path, image=\"ubuntu:jammy\", ex=True, fast=True)\n        # or Qemu\n        vm = Qegd(exe.path, img=\"https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img\", ex=True, fast=True)\n        # or SSH\n        vm = Shgd(exe.path, user='user', host='localhost', port=22, ex=True, fast=True)\n    return vm.start(argv=ARGS, env=ENV, gdbscript=GDB, **kw) # returns a pwn.process (similar to pwn.process())\n\n\nt = get_target()\n\nt.interactive()\n```\n\n+ `vagd info BINARY` to print info about binary\n\n```bash\n# run as process in VM\n./exploit.py\n# run as gdb server in VM requires tmux\n./exploit.py GDB\n# run on remote IP:PORT\n./exploit.py REMOTE\n```\n\nI recommend using [pwndbg](https://github.com/pwndbg/pwndbg).\n\n \n\n## Files\n\nAll created files ares stored in the local `./.vagd/` directory. Additional large files (e.g. cloudimages) are stored in the home directory `~/.vagd/` or handled by tools themselfs (e.g. Docker).\n\n\n\n## CLI\n\n```bash\nalias vagd=\"python -m vagd\" # or install with pip / pipx\n# help message\nvagd -h\n# analyses the binary, prints checksec and .comment (often includes Distro and Compiler info)\nvagd info BINARY\n# creates template, for more info use: vagd template -h\nvagd template [OPTIONS] [BINARY] [IP] [PORT]\n# ssh to current vagd instance, for more info use: vagd ssh -h\nvagd ssh [OPTIONS]\n# scp file to/from vagd instance, for more info use: vagd scp -h\n# e.g. vagd scp ./test_file vagd:./ # vagd:./ is default target\nvagd scp [OPTIONS] SOURCE [TARGET]\n# stop and remove current vagd instance, for more info use: vagd clean -h\nvagd clean [OPTIONS]\n```\n\n\n\n## [Documentation](https://vagd.gfelber.dev)\n\n\n\n## Boxes\n\nA listed of known working Boxes can be found in the [Documentation](http://vagd.gfelber.dev/autoapi/vagd/box/index.html#module-vagd.box).\nOther images might also work but currently only distributions that use `apt` and alpine for Docker are supported.\nThis limitation may be circumvented by creating a target yourself (with the dependencies gdbserver, python, openssh) and creating a ssh connection via Shgd.\n\n\n\n## Troubleshooting\n\n### background processes\n\nall instances continue to run in the background (after a vagd object has been started), this improves the runtime greatly after the first execution of the exploit. But this means that instances must be killed manually e.g.: `vagd clean`\n\n### gdb & gdbserver\n\nBecause gdbserver is used to run binaries on the instances I recommend using [pwndbg](https://github.com/pwndbg/pwndbg). Other well known gdb plugins like [peda](https://github.com/longld/peda) aren't compatible with gdbserver and therefore won't work.\n\n### files\n\nfiles on the virtual instance are never overwritten this has performance reason (so files aren't always copied if the exploit is run). If you need to updated files on the remote either use `vagd scp` or create use temporary directories `Dogd(..., tmp=True)`\n\n### gdb performance\n\nUsing gdbserver and gdb to index libraries can be very slow. Therefore an experimental feature is available that mounts libraries locally: `Dogd(..., ex=True, fast=True)` \n\n\n\n## Future plans\n\n### pre configured QEMU Images / Docker Image\n\ncreated pre configured environments with preinstalled lib debug symbols and gdbserver to lower init runtime.\n\n### Better Docker integration\n\ncreated 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.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "VirtuAlization GDb integrations in pwntools",
    "version": "1.3.3",
    "project_urls": {
        "Bug Tracker": "https://github.com/gfelber/vagd/issues",
        "Documentation": "https://gfelber.github.io/vagd/",
        "Homepage": "https://github.com/gfelber/vagd"
    },
    "split_keywords": [
        "vagd",
        " pwn",
        " pwntools",
        " exploit",
        " ctf",
        " capture",
        " the",
        " flag",
        " binary",
        " vagrant",
        " qemu",
        " docker"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d06b7f834ea58ecab56126bf306be67ec71c0bd96b5aea261f9057a209a84dd9",
                "md5": "e2ecee52497e73c3069b220c387a0b87",
                "sha256": "8be0c6abb1690e4cecbe7c68f8be1743e89c37cfa155aa7bbe63508d4201c9b9"
            },
            "downloads": -1,
            "filename": "vagd-1.3.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e2ecee52497e73c3069b220c387a0b87",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 49329,
            "upload_time": "2024-05-13T10:26:31",
            "upload_time_iso_8601": "2024-05-13T10:26:31.423752Z",
            "url": "https://files.pythonhosted.org/packages/d0/6b/7f834ea58ecab56126bf306be67ec71c0bd96b5aea261f9057a209a84dd9/vagd-1.3.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e1bc6e7a28005ebf6c19e902a19338ea7d6d332ae9d6bf2ef00bf01de96ec47a",
                "md5": "641894abdcb533083f2cd87617b1114b",
                "sha256": "92fda9bae584cce22c4bd0e022543d0333f4b8a35fcc410e29d55a297ff4c3fb"
            },
            "downloads": -1,
            "filename": "vagd-1.3.3.tar.gz",
            "has_sig": false,
            "md5_digest": "641894abdcb533083f2cd87617b1114b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 45385,
            "upload_time": "2024-05-13T10:26:35",
            "upload_time_iso_8601": "2024-05-13T10:26:35.842929Z",
            "url": "https://files.pythonhosted.org/packages/e1/bc/6e7a28005ebf6c19e902a19338ea7d6d332ae9d6bf2ef00bf01de96ec47a/vagd-1.3.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-13 10:26:35",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "gfelber",
    "github_project": "vagd",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "pwntools",
            "specs": []
        },
        {
            "name": "docker",
            "specs": []
        },
        {
            "name": "typer",
            "specs": []
        }
    ],
    "lcname": "vagd"
}
        
Elapsed time: 0.25930s