rapid7 / metasploit-payloads

Unified repository for different Metasploit Framework payloads
Other
1.75k stars 673 forks source link

Pull in changes from ReflectiveDLLInjection to support direct syscalls #688

Closed cdelafuente-r7 closed 10 months ago

cdelafuente-r7 commented 11 months ago

This PR adds the necessary changes to support the direct syscalls version of ReflectiveDLLInjection. At this time, the related PR is still under review but it is possible to test by updating the ReflectiveDLLInjection submodule reference:

cd c/meterpreter/source/ReflectiveDLLInjection
git remote add rdi_direct_syscalls git@github.com:cdelafuente-r7/ReflectiveDLLInjection.git
git fetch rdi_direct_syscalls
git checkout rdi_direct_syscalls/direct_syscalls

Don't forget to git fetch/git checkout again if the ReflectiveDLLInjection branch is updated.

Follow the standard documentation to build Meterpreter on Windows and with MinGW.

Note that CI is failing because the ReflectiveDLLInjection submodule needs to be updated to point to the direct syscalls implementation.

Testing with MSF

Once the DLL's are built, you need to copy output/ directory content into the Metasploit Framework's data/meterpreter/ directory.

Then in MSF console, test Meterpreter payloads (staged and single). For example:

adfoster-r7 commented 11 months ago

Looks like a CI failure on mingw

Digest: sha256:a733f4ab29ed04a0e29e39e9e602efcbfc40512b3800f69078643ac13bd0ac77
Status: Downloaded newer image for rapid7/msf-ubuntu-x64-meterpreter:latest
^@-- The C compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc
-- Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Build Type not specified, defaulting to 'Release'.
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/x86_64-w64-mingw32-as
-- Configuring done
CMake Error at ReflectiveDLLInjection/CMakeLists.txt:19 (add_library):
  Cannot find source file:

    ../../source/ReflectiveDLLInjection/dll/src/GateTrampoline64.s

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx

CMake Error at ReflectiveDLLInjection/CMakeLists.txt:19 (add_library):
  No SOURCES given to target: ReflectiveDLLInjection

CMake Generate step failed.  Build files cannot be regenerated correctly.
make: *** [Makefile:24: meterpreter-x86-gen] Error 1
make: *** [Makefile:296: docker] Error 2
cdelafuente-r7 commented 11 months ago

It is expected since the ReflectiveDLLInjection submodule needs to point to the new direct syscalls implementation.

adfoster-r7 commented 11 months ago

Ah; Is it worth temporarily updating the submodule config file to point to your branch so we can verify CI passes here? šŸ‘€

cdelafuente-r7 commented 11 months ago

Thanks @adfoster-r7 for the suggestion, I've updated the submodule config in the last commit. CI passes now.

adfoster-r7 commented 11 months ago

Cool! šŸŽ‰

For visibility, I've created a PR to run the Windows compilation on VS2019 over here now too - https://github.com/rapid7/metasploit-payloads/pull/689

cdelafuente-r7 commented 10 months ago

Closing it since a new updated PR exists.