Skip to content

Commit

Permalink
Merge pull request #1 from gogo2464/unit-testing
Browse files Browse the repository at this point in the history
add testing and minimal example
  • Loading branch information
gogo2464 authored Dec 13, 2023
2 parents 85bd27f + 48d16f6 commit 2cbb17b
Show file tree
Hide file tree
Showing 11 changed files with 189 additions and 1 deletion.
Empty file.
46 changes: 46 additions & 0 deletions .github/workflows/Testing.yml
Original file line number Diff line number Diff line change
@@ -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"
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
46 changes: 45 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
8 changes: 8 additions & 0 deletions pwnlib/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CC=clang
CFLAGS=-W -Wall -ansi -pedantic -std=c99 -g

all:
$(MAKE) -C tubes

clean:
$(MAKE) -C tubes clean
17 changes: 17 additions & 0 deletions pwnlib/tubes/Makefile
Original file line number Diff line number Diff line change
@@ -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
42 changes: 42 additions & 0 deletions pwnlib/tubes/process.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include <stdio.h>
#include <stdlib.h>
#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() {

}
10 changes: 10 additions & 0 deletions pwnlib/tubes/process.h
Original file line number Diff line number Diff line change
@@ -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();
6 changes: 6 additions & 0 deletions pwnlib/tubes/process.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
%module process
%{
#include "process.h"
%}

%include "process.h"
5 changes: 5 additions & 0 deletions pwnlib/tubes/tubes.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "process.h"

void function init_all() {

}
1 change: 1 addition & 0 deletions pwnlib/tubes/tubes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
void function init_all();

0 comments on commit 2cbb17b

Please sign in to comment.