Skip to content

Commit

Permalink
set template
Browse files Browse the repository at this point in the history
  • Loading branch information
gogo2464 committed Sep 14, 2024
1 parent 2cbb17b commit b3776d0
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 107 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/Publish-Python3-Bindings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Publish

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.12'

- name: Install dependencies
run: |
choco install nuget.commandline --yes
nuget install Bison -Version 3.7.4 -OutputDirectory C:\Tools\bison
nuget install PCRE2 -Version 10.39 -OutputDirectory C:\Tools\pcre2
git clone https://github.com/swig/swig/
cd swig
mkdir C:\install\swig
$env:PATH="C:\Tools\CMake\CMake-win64.3.15.5\bin;C:\Tools\bison\Bison.3.7.4\bin;" + $env:PATH
$PCRE_ROOT="C:\Tools\pcre2\PCRE2.10.39.0"
$PCRE_PLATFORM="x64"
$WORKING_DIR=(Get-Location).ToString() -replace "\\","/"
cmake -G "Visual Studio 17 2022" -A "x64" `
-DCMAKE_INSTALL_PREFIX="C:\install\swig" `
-DCMAKE_C_FLAGS="/DPCRE2_STATIC" `
-DCMAKE_CXX_FLAGS="/DPCRE2_STATIC" `
-DPCRE2_INCLUDE_DIR="$PCRE_ROOT/include" `
-DPCRE2_LIBRARY="$PCRE_ROOT/lib/pcre2-8-static.lib" `
-S . -B build
cmake --build build --config Release
cmake --install build --config Release
$env:Path += "C:\install\swig"
cd ..
choco install --yes doxygen.install
choco install --yes doxygen.portable
choco install --yes visualstudio2022community --package-parameters "--add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended --includeOptional" #choco install --yes visualstudio2022community --package-parameters "--allWorkloads --includeRecommended --includeOptional"
choco install --yes windows-sdk-10.0 windowsdriverkit10
- name: Install catch2
run: |
git clone https://github.com/catchorg/Catch2
cd Catch2 ; mkdir build ; cd build
cmake -G "Visual Studio 17 2022" ..
cmake --build . --target install
cd ..
- name: Build
run: |
make all PYENV=C:\hostedtoolcache\windows\Python\3.12.1\x64
- name: Generate doxygen documentation
run: |
doxygen .\Doxyfile -w html
- name: run C catch2 doctests
run: |
cd testing
mkdir build && cd build
cmake ..
cmake --build .
.\Debug\custom-main-tests.exe
- name: Run Binding Tests
run: |
make all PYENV=C:\hostedtoolcache\windows\Python\3.12.1\x64
python -c "from pwnlib.tubes.process import Process; p = Process('C:\hostedtoolcache\windows\Python\3.12.1\x64\python.exe'); p.recv(123)"
- name: Clean
run: make clean

ubuntu-testing:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Build
run: echo "hello world"
46 changes: 0 additions & 46 deletions .github/workflows/Testing.yml

This file was deleted.

7 changes: 4 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ As the dev have some experience with the old pwntools, the new tool aims to fix
# I.1 Install building dependencies

```
choco install --yes python --version 3.8.0
choco install --yes python --version 3.13.0-rc2
choco install --yes swig
choco install --yes llvm
```

# 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:
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.13.0-rc2`, the you could build with:

```shell
make all PYENV=C:\Python38
make all PYENV=C:\Python313
```
clean with

Expand Down
8 changes: 4 additions & 4 deletions pwnlib/tubes/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ 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
swig -c++ -python process.i
clang++ -O2 -shared -c process.cpp
clang++ -O2 -shared -c process_wrap.cxx -I"$(PYENV)\include"
clang++ -shared process.o process_wrap.o -o _process.pyd -L "$(PYENV)\libs" -l python3

clean:
@rm process.o
Expand Down
42 changes: 0 additions & 42 deletions pwnlib/tubes/process.c

This file was deleted.

53 changes: 53 additions & 0 deletions pwnlib/tubes/process.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include <stdio.h>
#include <stdlib.h>
#include <iostream>

#include "process.hpp"


Process::Process() {
/**
* @brief open a file.
*
* @param file , the file to execute.
* @return Nothing.
*
* @test
* File * fdesc = process("python");
* //CHECK(p.recv(5) == "Hello");
*/

printf("executing...\n");
}

Process::~Process() {
std::cout << " destroying process." << std::endl;
}

void Process::recv(int size) {

}

void Process::send() {

}

void Process::libs() {

}

void Process::libc() {

}

void Process::bin() {

}

/*
void recv(int size) {
char *buff;
fgets(buff, sizeof(size), proc.process_PID);
}
*/
10 changes: 0 additions & 10 deletions pwnlib/tubes/process.h

This file was deleted.

16 changes: 16 additions & 0 deletions pwnlib/tubes/process.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <stdio.h>
#include <stdlib.h>
#include <iostream>

class Process {
public:
Process();
~Process();
void recv(int size);
void send();
void libs();
void libc();
void bin();
private:
int processPid;
};
4 changes: 2 additions & 2 deletions pwnlib/tubes/process.i
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%module process
%{
#include "process.h"
#include "process.hpp"
%}

%include "process.h"
%include "process.hpp"

0 comments on commit b3776d0

Please sign in to comment.