Skip to content

Add RSpec coverage for Msf::Util::EXE.to_winaarch64pe - #9

Merged
bwatters-r7 merged 1 commit into
bwatters-r7:feature/add-aarch64-psexecfrom
vinicius-batistella:feature/aarch64-exe-spec
Aug 17, 2026
Merged

Add RSpec coverage for Msf::Util::EXE.to_winaarch64pe#9
bwatters-r7 merged 1 commit into
bwatters-r7:feature/add-aarch64-psexecfrom
vinicius-batistella:feature/aarch64-exe-spec

Conversation

@vinicius-batistella

Copy link
Copy Markdown

Follow-up to rapid7#21779, addressing the empty Included RSpec tests checkbox and the Copilot review note about missing coverage for the new AArch64 EXE generator paths.

Summary

Add spec/lib/msf/util/exe/windows/aarch64_spec.rb covering the two behaviours callers rely on now that psexec / generate_payload_exe_service / to_executable_fmt route AArch64 payloads through Msf::Util::EXE.to_winaarch64pe:

  • a small payload is written at the PAYLOAD: tag offset in data/templates/template_aarch64_windows.exe, the returned bytes are still an MZ/PE the same size as the template, and the surrounding template bytes are unchanged;
  • a payload larger than WINAARCH64_PAYLOAD_SPACE raises the documented RuntimeError instead of silently overflowing the fixed-size buffer.

The oversize test derives its input from Msf::Util::EXE::Windows::Aarch64::ClassMethods::WINAARCH64_PAYLOAD_SPACE so widening the template buffer will surface here.

Mirrors the existing structure of spec/lib/msf/util/exe/windows/common_spec.rb, which covers to_win32pe_service / to_win64pe_service.

Verification

Run against this branch:

$ SPEC_HELPER_LOAD_METASPLOIT=false \
  bundle exec rspec spec/lib/msf/util/exe/windows/aarch64_spec.rb

Msf::Util::EXE::Windows::Aarch64
  .to_winaarch64pe
    returns a Windows PE the same size as the template
    injects the shellcode at the PAYLOAD: tag offset
    leaves bytes before and after the payload buffer unchanged
    raises when the payload exceeds the template payload buffer

Finished in 0.09608 seconds
4 examples, 0 failures
  • bundle exec rubocop spec/lib/msf/util/exe/windows/aarch64_spec.rb clean.

Made with Cursor

The AArch64 Windows PE generator was added in this branch without a
matching spec, unlike its x86/x64 counterparts in
spec/lib/msf/util/exe/windows/common_spec.rb. Cover the two behaviours
that matter for callers that now route AArch64 payloads through it
(psexec, msfvenom, RPC):

  - a small payload is written at the "PAYLOAD:" tag offset in the
    template, the returned bytes are still an MZ/PE the same size as
    the template, and the surrounding template bytes are untouched;
  - a payload larger than WINAARCH64_PAYLOAD_SPACE raises the
    documented RuntimeError instead of silently overflowing the
    fixed-size buffer.

The oversize test computes its input from
Msf::Util::EXE::Windows::Aarch64::ClassMethods::WINAARCH64_PAYLOAD_SPACE
so widening the template buffer will surface the change here.

Co-authored-by: Cursor <cursoragent@cursor.com>
@bwatters-r7
bwatters-r7 merged commit 3d8d268 into bwatters-r7:feature/add-aarch64-psexec Aug 17, 2026
25 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants