diff --git a/.github/workflows/Publish-Python3-Bindings.yml b/.github/workflows/Publish-Python3-Bindings.yml new file mode 100644 index 0000000..e69de29 diff --git a/.github/workflows/Testing.yml b/.github/workflows/Testing.yml new file mode 100644 index 0000000..cbce684 --- /dev/null +++ b/.github/workflows/Testing.yml @@ -0,0 +1,46 @@ +name: Testing + +on: + push: + branches: + - '*' + tags-ignore: + - '*' + pull_request: + +jobs: + windows-testing: + + runs-on: windows-latest + + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-python@v4 + with: + python-version: '3.8' + + - name: Install dependencies + run: | + choco install --yes swig + - name: Build + run: | + make all PYENV=C:\hostedtoolcache\windows\Python\3.8.10\x64 + - name: Run Tests + run: | + make all PYENV=C:\hostedtoolcache\windows\Python\3.8.10\x64 + python -c "from pwnlib.tubes import process; process.send()" + - name: Clean + run: make clean + + ubuntu-testing: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Install swig + run: | + sudo apt install --yes swig + - name: Build + run: echo "hello world" \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b12ab1e --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +CC=clang +CFLAGS=-W -Wall -ansi -pedantic -std=c99 -g +PYENV?=C:\Python38 + +all: + $(MAKE) -C pwnlib + +clean: + $(MAKE) -C pwnlib clean \ No newline at end of file diff --git a/Readme.md b/Readme.md index 381c273..94ea038 100644 --- a/Readme.md +++ b/Readme.md @@ -7,8 +7,52 @@ Pwnto-driver is a reimplementation of pwntools in C instead of python. The goal As the dev have some experience with the old pwntools, the new tool aims to fix some known issues: - windows program and drivers support. More than pwntools. - Linux driver support (more than pwn++ that is written in C++ instead of C). + +# I Build + +# I.1 Install building dependencies + +``` +choco install --yes python --version 3.8.0 +choco install --yes swig +``` + +# I.2 Build/Clean project + +In order to build pwnto-driver including swig bindings, you must specify your python path. For example, if you installed python 3 with the command `choco install --yes python --version 3.8.0`, the you could build with: + +```shell +make all PYENV=C:\Python38 +``` +clean with + +```shell +make clean +``` + +# II Contributing + +# Install dev dependencies + +```shell +choco install --yes doxygen.install +choco install --yes doxygen.portable +choco install --yes swig +``` + +# II.1 Bindings with swig + +Each set of .h/.c of file you create MUST be followed by another .i file with the same name containing swig binding definition. + +It will then autogenerate binding so that our c program with c perf and c syntax will be available by importation in most of the languages including python. + +Watch the swig doc for more informations. + +# II.2 Documentating with doxygen + +# II.3 Testing with integrated doxygen doctest -## alternatives: +# alternatives: - [pwntools](https://github.com/Gallopsled/pwntools) : Works only on Linux. Not windows. No ability to upload in drivers. - [pwn++](https://github.com/hugsy/pwn--) : Does not provide native C support. Then no ability to upload in drivers. \ No newline at end of file diff --git a/pwnlib/Makefile b/pwnlib/Makefile new file mode 100644 index 0000000..d4b9ad2 --- /dev/null +++ b/pwnlib/Makefile @@ -0,0 +1,8 @@ +CC=clang +CFLAGS=-W -Wall -ansi -pedantic -std=c99 -g + +all: + $(MAKE) -C tubes + +clean: + $(MAKE) -C tubes clean \ No newline at end of file diff --git a/pwnlib/tubes/Makefile b/pwnlib/tubes/Makefile new file mode 100644 index 0000000..8663053 --- /dev/null +++ b/pwnlib/tubes/Makefile @@ -0,0 +1,17 @@ +CC=clang +CFLAGS=-W -Wall -ansi -pedantic -std=c99 -g +INC=-I include/ + +all: swig-all + +swig-all: + swig -python process.i + gcc -O2 -fPIC -c process.c + gcc -O2 -fPIC -c process_wrap.c -I"$(PYENV)\include" + gcc -shared process.o process_wrap.o -o _process.pyd -L "$(PYENV)\libs" -l python3 + +clean: + @rm process.o + @rm process_wrap.o + @rm process.py + @rm _process.pyd \ No newline at end of file diff --git a/pwnlib/tubes/process.c b/pwnlib/tubes/process.c new file mode 100644 index 0000000..c4738d5 --- /dev/null +++ b/pwnlib/tubes/process.c @@ -0,0 +1,42 @@ +#include +#include +#include "process.h" + +Process proc; + +void process (char *command) { + /** + * @brief open a file. + * + * @param file , the file to execute. + * @return Nothing. + * + * @test + * File * fdesc = process("python"); + * //CHECK(p.recv(5) == "Hello"); + */ + + + printf("hello\n"); +} + +void recv(int size) { + char *buff; + fgets(buff, sizeof(size), proc.process_PID); +} + +void send () { + printf("hey!"); +} + +void libs() { + +} + +void libc() { + +} + +void bin() { + +} \ No newline at end of file diff --git a/pwnlib/tubes/process.h b/pwnlib/tubes/process.h new file mode 100644 index 0000000..cc61080 --- /dev/null +++ b/pwnlib/tubes/process.h @@ -0,0 +1,10 @@ +typedef struct { + FILE *process_PID; +} Process; + +void process (char *command); +void recv(int size); +void send(); +void libs(); +void libc(); +void bin(); \ No newline at end of file diff --git a/pwnlib/tubes/process.i b/pwnlib/tubes/process.i new file mode 100644 index 0000000..5cebee8 --- /dev/null +++ b/pwnlib/tubes/process.i @@ -0,0 +1,6 @@ +%module process +%{ +#include "process.h" +%} + +%include "process.h" \ No newline at end of file diff --git a/pwnlib/tubes/tubes.c b/pwnlib/tubes/tubes.c new file mode 100644 index 0000000..d309bb9 --- /dev/null +++ b/pwnlib/tubes/tubes.c @@ -0,0 +1,5 @@ +#include "process.h" + +void function init_all() { + +} \ No newline at end of file diff --git a/pwnlib/tubes/tubes.h b/pwnlib/tubes/tubes.h new file mode 100644 index 0000000..dc80296 --- /dev/null +++ b/pwnlib/tubes/tubes.h @@ -0,0 +1 @@ +void function init_all();