Skip to content

Commit

Permalink
Merge: requirements -> development
Browse files Browse the repository at this point in the history
Add requirements
  • Loading branch information
Sarapulov-Vas authored Aug 1, 2024
2 parents 4a72b2f + 810d8a6 commit 0c81425
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 49 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,4 @@ res/out

.vscode/
.idea/
.venv/
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# recompilation_postprocessor
![Pylint](https://github.com/VyacheslavIurevich/recompilation_postprocessor/actions/workflows/pylint.yml/badge.svg)

This script provides ability to postprocess code, which is decompiled via Ghidra, to make it buildable.
This script provides ability to postprocess code, which is decompiled via Ghidra, to make it recompilable.
# Technologies used
* [Python 3.12](https://www.python.org/)
* [pyhidra](https://github.com/dod-cyber-crime-center/pyhidra)
Expand All @@ -22,18 +22,31 @@ or SSH:
```shell
git clone [email protected]:VyacheslavIurevich/recompilation_postprocessor.git
```
# Usage
Set the GHIDRA_INSTALL_DIR environment variable to point to the directory where Ghidra is installed.
```shell
export GHIDRA_INSTALL_DIR={path to Ghidra}
```
Go to main folder of repository
```shell
cd recompilation-postprocessor
```
Create a virtual environment:
```shell
python3 -m venv .venv
source .venv/bin/activate
```
Install requirements:
```shell
pip install -r requirements.txt
```
# Usage
Run the script with input and output command line arguments.
```shell
python run.py {path to input binary} {output .c file path}
python3 run.py {path to input binary} {output .c file path}
```
For example:
```shell
python run.py res/in/hello_world res/out/hello_world.c
python3 run.py res/in/hello_world res/out/hello_world.c
```
After this, you can try to compile output code. Example with GCC:
```shell
Expand Down
8 changes: 0 additions & 8 deletions ci/pylint.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
#!/bin/bash
echo "Running pylint"
git ls-files '*.py' | xargs pylint
pylint_check_status=$?
if [[ $pylint_check_status -ne 0 ]]; then
echo "pylint fail"
exit 1
else
echo "pylint OK"
exit 0
fi
8 changes: 0 additions & 8 deletions ci/shellcheck.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
#!/bin/bash
echo "Running shellcheck"
git ls-files '*.sh' | xargs shellcheck
shellcheck_check_status=$?
if [[ $shellcheck_check_status -ne 0 ]]; then
echo "shellcheck fail"
exit 1
else
echo "shellcheck OK"
exit 0
fi
10 changes: 1 addition & 9 deletions ci/test.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
#!/bin/bash
echo "Run tests"
mkdir res/out
mkdir -p res/out
pytest src/tests/user_tests.py
pytest_check_status=$?
if [[ $pytest_check_status -ne 0 ]]; then
echo "Tests fail"
exit 1
else
echo "Tests OK"
exit 0
fi
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pyhidra==1.2.0
pytest==8.3.2
pylint==3.2.6
4 changes: 2 additions & 2 deletions src/scripts/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def put_program_data_types(program, file_writer, monitor, library_list):
libc = {}
typedefs = []
with open(Application.getApplicationRootDirectory().getAbsolutePath()\
+ "/Features/Base/data/parserprofiles/clib.prf", 'r', encoding="utf-8") as f:
for line in f:
+ "/Features/Base/data/parserprofiles/clib.prf", 'r', encoding="utf-8") as file:
for line in file:
if line == '\n':
break
header = line.replace("\n", "")
Expand Down
33 changes: 15 additions & 18 deletions src/tests/user_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,22 @@ def compile_binary(binary):
return os.system(f"{COMPILER} {OUTPUT_PATH}")


class TestUser:
"""User scenario tests"""
def test_hello_world(clean):
"""Recompiles hello world binary"""
assert compile_binary("hello_world") == 0

def test_hello_world(self, clean):
"""Recompiles hello world binary"""
assert compile_binary("hello_world") == 0
def test_bmp(clean):
"""Recompiles BMP header reader binary"""
assert compile_binary("bmp1") == 0

def test_bmp(self, clean):
"""Recompiles BMP header reader binary"""
assert compile_binary("bmp1") == 0
def test_bst(clean):
"""Recompiles binary search tree binary"""
assert compile_binary("bst") == 0

def test_bst(self, clean):
"""Recompiles binary search tree binary"""
assert compile_binary("bst") == 0
def test_avl(clean):
"""Recompiles AVL tree binary"""
assert compile_binary("avl") == 0

def test_avl(self, clean):
"""Recompiles AVL tree binary"""
assert compile_binary("avl") == 0

def test_linpack(self, clean):
"""Recompiles AVL tree binary"""
assert compile_binary("linpack") == 0
def test_linpack(clean):
"""Recompiles AVL tree binary"""
assert compile_binary("linpack") == 0

0 comments on commit 0c81425

Please sign in to comment.