Skip to content

Block Api ROR13 IV randomization#21306

Merged
smcintyre-r7 merged 19 commits intorapid7:masterfrom
dledda-r7:feat/block-api-randomization
Apr 21, 2026
Merged

Block Api ROR13 IV randomization#21306
smcintyre-r7 merged 19 commits intorapid7:masterfrom
dledda-r7:feat/block-api-randomization

Conversation

@dledda-r7
Copy link
Copy Markdown
Contributor

This PR updates the usage of Rex::Text.block_api_hash to take in account IV randomization.

The way it works is simple, the BlockApi and BlockApi_x64 will generate, per-run, a random IV (32 bit value) and will patch on-the-fly the asm_block_api output and will pass the iv to the Rex::Text.block_api_hash to have the updated hash

There also some other fix here and there and slight edge-cases covered, like handling how the migration stub generation works and also the exitfunk handling using a helper

Comment thread lib/msf/core/payload/windows.rb
@dledda-r7 dledda-r7 marked this pull request as draft April 15, 2026 13:04
@dledda-r7
Copy link
Copy Markdown
Contributor Author

I will put it in draft for now, there is more stuff to do on this

@dledda-r7 dledda-r7 force-pushed the feat/block-api-randomization branch from 942db86 to 340a724 Compare April 16, 2026 08:25
@dledda-r7
Copy link
Copy Markdown
Contributor Author

i'm unsure in what is the problem with CI, updating the cache size i am getting this that looks wrong:

[*] Single Updated: windows/x64/pingback_reverse_tcp CacheSize on disk at /home/kali/Documents/github/metasploit-framework/modules/payloads/singles/windows/x64/pingback_reverse_tcp.rb from 425 to :dynamic...
[*] Stager Updated: windows/x64/custom/bind_ipv6_tcp_uuid CacheSize on disk at /home/kali/Documents/github/metasploit-framework/modules/payloads/stagers/windows/x64/bind_ipv6_tcp_uuid.rb from 526 to :dynamic...
[*] Stager Updated: windows/x64/custom/bind_tcp_uuid CacheSize on disk at /home/kali/Documents/github/metasploit-framework/modules/payloads/stagers/windows/x64/bind_tcp_uuid.rb from 524 to :dynamic...
[*] Stager Updated: windows/x64/custom/reverse_http CacheSize on disk at /home/kali/Documents/github/metasploit-framework/modules/payloads/stagers/windows/x64/reverse_http.rb from 607 to :dynamic...
[*] Stager Updated: windows/x64/custom/reverse_https CacheSize on disk at /home/kali/Documents/github/metasploit-framework/modules/payloads/stagers/windows/x64/reverse_https.rb from 638 to :dynamic...
[*] Stager Updated: windows/x64/custom/reverse_tcp_uuid CacheSize on disk at /home/kali/Documents/github/metasploit-framework/modules/payloads/stagers/windows/x64/reverse_tcp_uuid.rb from 491 to :dynamic...
[*] Stager Updated: windows/x64/custom/reverse_winhttp CacheSize on disk at /home/kali/Documents/github/metasploit-framework/modules/payloads/stagers/windows/x64/reverse_winhttp.rb from 751 to :dynamic...
[*] Stager Updated: windows/x64/custom/reverse_winhttps CacheSize on disk at /home/kali/Documents/github/metasploit-framework/modules/payloads/stagers/windows/x64/reverse_winhttps.rb from 787 to :dynamic...

@dledda-r7 dledda-r7 marked this pull request as ready for review April 16, 2026 12:52
@dledda-r7 dledda-r7 added payload rn-payload-enhancement release notes for enhanced payloads labels Apr 16, 2026
Copy link
Copy Markdown
Contributor

@smcintyre-r7 smcintyre-r7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to remove all the instances where you initialize the value by calling #block_api_iv.

Comment thread lib/msf/core/payload/windows/x64/block_api_x64.rb
Comment thread lib/msf/core/payload/windows/x64/block_api_x64.rb Outdated
Comment thread lib/msf/core/payload/windows/x64/block_api_x64.rb Outdated
Comment thread lib/msf/core/payload/windows/x64/block_api_x64.rb Outdated
Comment thread lib/msf/core/payload/windows/x64/addr_loader.rb Outdated
Comment thread lib/msf/core/payload/windows/x64/block_api_x64.rb Outdated
Comment thread lib/msf/core/payload/windows/x64/reverse_tcp_x64.rb Outdated
Comment thread lib/msf/core/payload/windows/block_api.rb
@github-project-automation github-project-automation Bot moved this from Todo to Waiting on Contributor in Metasploit Kanban Apr 16, 2026
dledda-r7 and others added 5 commits April 17, 2026 11:23
Co-authored-by: Spencer McIntyre <58950994+smcintyre-r7@users.noreply.github.com>
Co-authored-by: Spencer McIntyre <58950994+smcintyre-r7@users.noreply.github.com>
Co-authored-by: Spencer McIntyre <58950994+smcintyre-r7@users.noreply.github.com>
Comment thread lib/msf/core/payload/windows/x64/block_api_x64.rb
Comment thread lib/msf/core/payload/windows/x64/block_api_x64.rb
Comment thread lib/msf/core/payload/windows/x64/block_api_x64.rb Outdated
Co-authored-by: Spencer McIntyre <58950994+smcintyre-r7@users.noreply.github.com>
dledda-r7 and others added 2 commits April 20, 2026 15:19
Co-authored-by: Spencer McIntyre <58950994+smcintyre-r7@users.noreply.github.com>
Co-authored-by: Spencer McIntyre <58950994+smcintyre-r7@users.noreply.github.com>
@dledda-r7
Copy link
Copy Markdown
Contributor Author

With Rex::Text.block_api_hash being pretty well consolidated in framework now, we could update the return type to natively be an integer. It never really made sense to have it return the hexadecimal string.

The only missing is this one, will do asap

Comment thread lib/msf/core/payload/windows/block_api.rb
Copy link
Copy Markdown
Contributor

@smcintyre-r7 smcintyre-r7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested 32-bit and 64-bit stagers both with and without PrependMigrate. Code all looks good, and the API with how opts is handled is optimized for the most common use case where the IV is entirely handled by the library, but allows the caller to control it if necessary.

I think we're ready to land this now.

@github-project-automation github-project-automation Bot moved this from Waiting on Contributor to In Progress in Metasploit Kanban Apr 21, 2026
@smcintyre-r7 smcintyre-r7 merged commit 6a00ea3 into rapid7:master Apr 21, 2026
48 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Metasploit Kanban Apr 21, 2026
@smcintyre-r7
Copy link
Copy Markdown
Contributor

Release Notes

This updates the Block API shellcode to use a random IV when calculating the ROR13 hash of methods which it calls. The result is the removal of a static piece of data that could have been previously signatured.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

payload rn-payload-enhancement release notes for enhanced payloads

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants