From 11d15426a8821aef4c826a5e237a6e9c514613d4 Mon Sep 17 00:00:00 2001 From: devseed Date: Wed, 16 Oct 2024 16:07:23 +0900 Subject: [PATCH] make project structure simple --- .github/workflows/{build_wintools.yml => build.yml} | 4 ++-- .gitignore | 2 +- .gitmodules | 6 +++--- project/winexe_winmemdll/Makefile => Makefile | 8 +++----- README.md | 5 ++--- depend/reversetool | 1 - depend/winreverse | 1 + project/winexe_winmemdll/release_msvc.bat | 2 -- script/build_winmemdll.bat | 2 ++ {project/winexe_winmemdll/src => src}/winmemdll.c | 0 .../winexe_winmemdll/src => src}/winmemdll_shellcode.h | 0 .../winexe_winmemdll/src => src}/winmemdll_shellcode.py | 2 +- {project/winexe_winmemdll/src => src}/winmemdll_test.c | 0 project/winexe_winmemdll/winmemdll.sln => winmemdll.sln | 0 .../winmemdll.vcxproj => winmemdll.vcxproj | 8 ++++---- .../winmemdll_test.vcxproj => winmemdll_test.vcxproj | 8 ++++---- 16 files changed, 23 insertions(+), 26 deletions(-) rename .github/workflows/{build_wintools.yml => build.yml} (75%) rename project/winexe_winmemdll/Makefile => Makefile (86%) delete mode 160000 depend/reversetool create mode 160000 depend/winreverse delete mode 100644 project/winexe_winmemdll/release_msvc.bat create mode 100644 script/build_winmemdll.bat rename {project/winexe_winmemdll/src => src}/winmemdll.c (100%) rename {project/winexe_winmemdll/src => src}/winmemdll_shellcode.h (100%) rename {project/winexe_winmemdll/src => src}/winmemdll_shellcode.py (99%) rename {project/winexe_winmemdll/src => src}/winmemdll_test.c (100%) rename project/winexe_winmemdll/winmemdll.sln => winmemdll.sln (100%) rename project/winexe_winmemdll/winmemdll.vcxproj => winmemdll.vcxproj (92%) rename project/winexe_winmemdll/winmemdll_test.vcxproj => winmemdll_test.vcxproj (92%) diff --git a/.github/workflows/build_wintools.yml b/.github/workflows/build.yml similarity index 75% rename from .github/workflows/build_wintools.yml rename to .github/workflows/build.yml index 69d4559..f7bc8da 100644 --- a/.github/workflows/build_wintools.yml +++ b/.github/workflows/build.yml @@ -18,12 +18,12 @@ jobs: uses: microsoft/setup-msbuild@v1.1 - name: build target - run: .\project\winexe_winmemdll\release_msvc.bat + run: script/build_winmemdll.bat - name: upload release uses: ncipollo/release-action@v1 if: github.event_name == 'push' with: - artifacts: "./project/winexe_winmemdll/build/winmemdll32.exe,./project/winexe_winmemdll/build/winmemdll64.exe" + artifacts: "build/winmemdll32.exe,build/winmemdll64.exe" allowUpdates: "true" token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index c6dc84a..187988a 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,4 @@ .vscode __pycache__ -project/**/build/* \ No newline at end of file +build/* \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 6939b2a..ea68255 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "depend/reversetool"] - path = depend/reversetool - url = https://github.com/YuriSizuku/ReverseTool.git +[submodule "depend/winreverse"] + path = depend/winreverse + url = https://github.com/YuriSizuku/toolkit-WinReverse.git diff --git a/project/winexe_winmemdll/Makefile b/Makefile similarity index 86% rename from project/winexe_winmemdll/Makefile rename to Makefile index f7260aa..2e03b7a 100644 --- a/project/winexe_winmemdll/Makefile +++ b/Makefile @@ -1,7 +1,5 @@ # build example, tested in linux 10.0.0-3, gcc 12, wine-9.0 -# make winmemdll_shellcode CC=x86_64-w64-mingw32-gcc BUILD_TYPE=32 -# make winmemdll_shellcode CC=i686-w64-mingw32-clang BUILD_TYPE=32 -# make winmemdll_shellcode CC=x86_64-w64-mingw32-clang BUILD_TYPE=64 +# make winmemdll_shellcode CC=x86_64-w64-mingw32-clang # make winmemdll winmemdll_test CC=i686-w64-mingw32-gcc BUILD_TYPE=32d # make winmemdll winmemdll_test CC=x86_64-w64-mingw32-gcc BUILD_TYPE=64d @@ -9,7 +7,7 @@ CC:=gcc # clang (llvm-mingw), gcc (mingw-w64), tcc (x86 stdcall name has problem) BUILD_TYPE:=32# 32, 32d, 64, 64d BUILD_DIR:=build -INCS:=-I../../depend/reversetool/src +INCS:=-Idepend/winreverse/src LIBS:=-luser32 -lgdi32 -lpsapi CFLAGS:=-fPIC -std=c99 \ -fvisibility=hidden \ @@ -58,7 +56,7 @@ winmemdll_test: src/winmemdll_test.c # only support llvm-mingw (tested 18.1), for building coff format # sometimes nested force inline function might cause problems -winmemdll_shellcode: ../../depend/reversetool/project/windll_winpe/src/libwinpe.c +winmemdll_shellcode: depend/winreverse/project/windll_winpe/src/libwinpe.c @echo "## $@" # use -mno-sse for not making string as constant, sse makes array assign with ds: $(CC) -c -O3 -m32 -mno-sse $< -o $(BUILD_DIR)/$@32.o \ diff --git a/README.md b/README.md index d304ba1..cf714b9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MemoryModule -![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/yurisizuku/memorymodule?color=green&label=MemoryModule)![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/YuriSizuku/MemoryModule/build_wintools.yml?label=build_wintools) +![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/yurisizuku/win-MemoryModule?color=green&label=MemoryModule)![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/YuriSizuku/win-MemoryModule/build.yml?label=build) ☘️ A flexible PE loader, loading module in memory. Most of the functions can be inline, compatible for shellcode. @@ -22,8 +22,7 @@ Here's a example for using `llvm-mingw` ```shell git clone https://github.com/YuriSizuku/MemoryModule.git --recursive -cd MemoryModule/project/win_memdll -make winmemdll_shellcode # only if you want to generate shellcode +make winmemdll_shellcode CC=x86_64-w64-mingw32-clang # only if you want to generate shellcode make winmemdll CC=i686-w64-mingw32-gcc BUILD_TYPE=32d # x86 debug ``` diff --git a/depend/reversetool b/depend/reversetool deleted file mode 160000 index 517fb6b..0000000 --- a/depend/reversetool +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 517fb6b5b4930d027f401a6eb7dcd61e2966d715 diff --git a/depend/winreverse b/depend/winreverse new file mode 160000 index 0000000..8f0a175 --- /dev/null +++ b/depend/winreverse @@ -0,0 +1 @@ +Subproject commit 8f0a1755e84a5d1a8414fe05cc3c31cb31bdf828 diff --git a/project/winexe_winmemdll/release_msvc.bat b/project/winexe_winmemdll/release_msvc.bat deleted file mode 100644 index a81f3f3..0000000 --- a/project/winexe_winmemdll/release_msvc.bat +++ /dev/null @@ -1,2 +0,0 @@ -msbuild %~dp0\winmemdll.sln -t:winmemdll:rebuild -p:configuration=release -p:Platform=x86 -msbuild %~dp0\winmemdll.sln -t:winmemdll:rebuild -p:configuration=release -p:Platform=x64 \ No newline at end of file diff --git a/script/build_winmemdll.bat b/script/build_winmemdll.bat new file mode 100644 index 0000000..296e248 --- /dev/null +++ b/script/build_winmemdll.bat @@ -0,0 +1,2 @@ +msbuild winmemdll.sln -t:winmemdll:rebuild -p:configuration=release -p:Platform=x86 +msbuild winmemdll.sln -t:winmemdll:rebuild -p:configuration=release -p:Platform=x64 \ No newline at end of file diff --git a/project/winexe_winmemdll/src/winmemdll.c b/src/winmemdll.c similarity index 100% rename from project/winexe_winmemdll/src/winmemdll.c rename to src/winmemdll.c diff --git a/project/winexe_winmemdll/src/winmemdll_shellcode.h b/src/winmemdll_shellcode.h similarity index 100% rename from project/winexe_winmemdll/src/winmemdll_shellcode.h rename to src/winmemdll_shellcode.h diff --git a/project/winexe_winmemdll/src/winmemdll_shellcode.py b/src/winmemdll_shellcode.py similarity index 99% rename from project/winexe_winmemdll/src/winmemdll_shellcode.py rename to src/winmemdll_shellcode.py index 638df83..b3485e1 100644 --- a/project/winexe_winmemdll/src/winmemdll_shellcode.py +++ b/src/winmemdll_shellcode.py @@ -1,7 +1,7 @@ import sys from keystone import * -sys.path.append("../../depend/reversetool/src") +sys.path.append("depend/winreverse/src") import wincoff as shellcode def gen_oepinit_code32(): diff --git a/project/winexe_winmemdll/src/winmemdll_test.c b/src/winmemdll_test.c similarity index 100% rename from project/winexe_winmemdll/src/winmemdll_test.c rename to src/winmemdll_test.c diff --git a/project/winexe_winmemdll/winmemdll.sln b/winmemdll.sln similarity index 100% rename from project/winexe_winmemdll/winmemdll.sln rename to winmemdll.sln diff --git a/project/winexe_winmemdll/winmemdll.vcxproj b/winmemdll.vcxproj similarity index 92% rename from project/winexe_winmemdll/winmemdll.vcxproj rename to winmemdll.vcxproj index b562d7a..6e358db 100644 --- a/project/winexe_winmemdll/winmemdll.vcxproj +++ b/winmemdll.vcxproj @@ -105,7 +105,7 @@ _CRT_SECURE_NO_DEPRECATE;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true MultiThreadedDebug - ../../depend/reversetool/src/;%(AdditionalIncludeDirectories) + depend/winreverse/src/;%(AdditionalIncludeDirectories) Console @@ -122,7 +122,7 @@ _CRT_SECURE_NO_DEPRECATE;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true MultiThreaded - ../../depend/reversetool/src/;%(AdditionalIncludeDirectories) + depend/winreverse/src/;%(AdditionalIncludeDirectories) Console @@ -139,7 +139,7 @@ _CRT_SECURE_NO_DEPRECATE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true MultiThreadedDebug - ../../depend/reversetool/src/;%(AdditionalIncludeDirectories) + depend/winreverse/src/;%(AdditionalIncludeDirectories) Console @@ -156,7 +156,7 @@ _CRT_SECURE_NO_DEPRECATE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true MultiThreaded - ../../depend/reversetool/src/;%(AdditionalIncludeDirectories) + depend/winreverse/src/;%(AdditionalIncludeDirectories) Console diff --git a/project/winexe_winmemdll/winmemdll_test.vcxproj b/winmemdll_test.vcxproj similarity index 92% rename from project/winexe_winmemdll/winmemdll_test.vcxproj rename to winmemdll_test.vcxproj index 5c1012f..cd7daee 100644 --- a/project/winexe_winmemdll/winmemdll_test.vcxproj +++ b/winmemdll_test.vcxproj @@ -105,7 +105,7 @@ _CRT_SECURE_NO_DEPRECATE;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true MultiThreadedDebug - ../../depend/reversetool/src;%(AdditionalIncludeDirectories) + depend/winreverse/src;%(AdditionalIncludeDirectories) Console @@ -122,7 +122,7 @@ _CRT_SECURE_NO_DEPRECATE;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true MultiThreaded - ../../depend/reversetool/src;%(AdditionalIncludeDirectories) + depend/winreverse/src;%(AdditionalIncludeDirectories) Console @@ -139,7 +139,7 @@ _CRT_SECURE_NO_DEPRECATE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true MultiThreadedDebug - ../../depend/reversetool/src;%(AdditionalIncludeDirectories) + depend/winreverse/src;%(AdditionalIncludeDirectories) Console @@ -156,7 +156,7 @@ _CRT_SECURE_NO_DEPRECATE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true MultiThreaded - ../../depend/reversetool/src;%(AdditionalIncludeDirectories) + depend/winreverse/src;%(AdditionalIncludeDirectories) Console