Skip to content

Commit

Permalink
Remove Lua bindings (#24)
Browse files Browse the repository at this point in the history
* deleted lua backdoor

* fixed missing `switch-break` in disassembly instruction formatting
  • Loading branch information
hugsy authored Nov 8, 2023
1 parent 94c4d86 commit 12b773d
Show file tree
Hide file tree
Showing 16 changed files with 116 additions and 976 deletions.
76 changes: 38 additions & 38 deletions .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
name: "Code Analysis"

on:
push:
branches: [main, dev]

pull_request:
branches: [main, dev]

workflow_dispatch:

jobs:
codeql:
runs-on: windows-latest

permissions:
security-events: write
actions: read
contents: read

steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true

- name: Initialize
uses: github/codeql-action/init@v2

- name: Build
run: |
Import-Module .\.github\Invoke-VisualStudio.ps1
Invoke-VisualStudio2022x64
cmake -S . -B ./build -A x64 -DPWN_BUILD_TOOLKIT=OFF -DPWN_INCLUDE_DISASSEMBLER=OFF -DPWN_ENABLE_LUA_BACKDOOR=OFF -DPWN_BUILD_DOCS=OFF -DPWN_BUILD_TESTING=OFF -DPWN_LOG_USE_COLOR=OFF
cmake --build ./build --verbose --config Debug
- name: Analyze
uses: github/codeql-action/analyze@v2
name: "Code Analysis"

on:
push:
branches: [main, dev]

pull_request:
branches: [main, dev]

workflow_dispatch:

jobs:
codeql:
runs-on: windows-latest

permissions:
security-events: write
actions: read
contents: read

steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true

- name: Initialize
uses: github/codeql-action/init@v2

- name: Build
run: |
Import-Module .\.github\Invoke-VisualStudio.ps1
Invoke-VisualStudio2022x64
cmake -S . -B ./build -A x64 -DPWN_BUILD_TOOLKIT=OFF -DPWN_INCLUDE_DISASSEMBLER=OFF -DPWN_BUILD_DOCS=OFF -DPWN_BUILD_TESTING=OFF -DPWN_LOG_USE_COLOR=OFF
cmake --build ./build --verbose --config Debug
- name: Analyze
uses: github/codeql-action/analyze@v2
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
build:
name: "${{ matrix.variants.os }}/${{ matrix.variants.arch }}/${{ matrix.variants.config }}"
env:
CMAKE_FLAGS: '-DPWN_BUILD_DOCS=OFF -DPWN_DISASSEMBLE_X86=ON -DPWN_DISASSEMBLE_ARM64=ON -DPWN_BUILD_TOOLKIT=ON -DPWN_BUILD_TESTING=ON -DPWN_ENABLE_LUA_BACKDOOR=OFF'
CMAKE_FLAGS: '-DPWN_BUILD_DOCS=OFF -DPWN_DISASSEMBLE_X86=ON -DPWN_DISASSEMBLE_ARM64=ON -DPWN_BUILD_TOOLKIT=ON -DPWN_BUILD_TESTING=ON'
NB_CPU: 1

strategy:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ concurrency:
cancel-in-progress: true

env:
CMAKE_FLAGS: "-DPWN_BUILD_DOCS=ON -DPWN_ENABLE_LUA_BACKDOOR=OFF -DPWN_INCLUDE_DISASSEMBLER=OFF -DPWN_BUILD_TOOLKIT=OFF -DPWN_BUILD_TESTING=OFF"
CMAKE_FLAGS: "-DPWN_BUILD_DOCS=ON -DPWN_INCLUDE_DISASSEMBLER=OFF -DPWN_BUILD_TOOLKIT=OFF -DPWN_BUILD_TESTING=OFF"

jobs:
deploy:
Expand Down
12 changes: 0 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ option(PWN_DISASSEMBLE_X86 "Compile with Zydis disassembler support (X86/64 only
option(PWN_DISASSEMBLE_ARM64 "Compile with BinaryNinja disassembler support (ARM64)" ON)

option(PWN_BUILD_SHARED_LIBS "Build as a shared library" OFF)
option(PWN_ENABLE_LUA_BACKDOOR "Enable Lua scripting for backdoor" OFF) # Deprecated, will be deleted soon

if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
# pwn++ is NOT a top dir (i.e. build as dependency)
Expand All @@ -40,7 +39,6 @@ endif()

set(PWNLIB_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR})

# set(PWNLIB_DEPS_DIR ${PWNLIB_ROOT_DIR}/Deps)
set(PWN_INCLUDE_DISASSEMBLER FALSE)
set(CMAKE_INSTALL_LIBDIR Library)
set(CMAKE_INSTALL_BINDIR Binary)
Expand Down Expand Up @@ -113,16 +111,6 @@ if(WIN32)
install(DIRECTORY $<TARGET_PROPERTY:Deps_PhNt,INTERFACE_DIRECTORIES> DESTINATION ${PROJECT_NAME}/Dependencies/Include)
endif(WIN32)

# if(PWN_ENABLE_LUA_BACKDOOR)
# option(BUILD_SHARED_LIBS "" OFF)
# add_subdirectory(${PWNLIB_DEPS_DIR}/lua)
# add_library(PWN::Deps::Lua ALIAS lua)

# install(TARGETS lua DESTINATION ${PROJECT_NAME}/Dependencies/Library)
# install(TARGETS lua-header DESTINATION ${PROJECT_NAME}/Dependencies/Include)

# list(APPEND PWN_MODULES Backdoor)
# endif()
if(PWN_INCLUDE_DISASSEMBLER)
list(APPEND PWN_MODULES Assembly)
endif(PWN_INCLUDE_DISASSEMBLER)
Expand Down
34 changes: 0 additions & 34 deletions Docs/examples/common/utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,37 +127,3 @@ void wmain()
}
```


### Lua VM backdoor

Namespace: `pwn::backdoor`

The lib embeds a Lua VM (if compiled with the flag `PWN_ENABLE_LUA_BACKDOOR`) which allows to script your way into a remote process where the pwn++.dll is injected. On Windows it will use a Named Pipe (see tools/win32/Backdoor for a standalone example)

```powershell
> .\Backdoor.exe
[DEBUG] {c:\temp\backdoor.cpp:645:wmain()} Starting as PID=15004
[...]
[DEBUG] {Z:\pwn++\src\pwn++\win32\backdoor.cpp:548:start()} Listening for connection on '\\.\pipe\WindowsBackupService_202004L_1932'
[DEBUG] {Z:\pwn++\src\pwn++\win32\backdoor.cpp:253:WaitNextConnectionAsync()} Waiting for connection
```

Now you can use any client to connect and interact with the Named Pipe

```lua
> .\NamedPipe.exe '\\.\pipe\WindowsBackupService_202004L_1932'
>>> return pwn.version()
>> Sent 20 bytes
<< Received 6 bytes
---
0.1.3
---
>>> return pwn.process.pid()
>> Sent 24 bytes
<< Received 6 bytes
---
15004
---
>>>
```

4 changes: 4 additions & 0 deletions Modules/Assembly/Source/Disassembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ Disassembler::Format(Instruction& insn, uptr Address)
{
return Err(ErrorCode::ExternalApiCallFailed);
}

break;
}
#endif // PWN_DISASSEMBLE_X86

Expand All @@ -239,6 +241,8 @@ Disassembler::Format(Instruction& insn, uptr Address)
{
return Err(ErrorCode::ExternalApiCallFailed);
}

break;
}
#endif // PWN_DISASSEMBLE_ARM64

Expand Down
33 changes: 0 additions & 33 deletions Modules/Backdoor/CMakeLists.txt

This file was deleted.

156 changes: 0 additions & 156 deletions Modules/Backdoor/Include/Backdoor.hpp

This file was deleted.

Loading

0 comments on commit 12b773d

Please sign in to comment.