Fixes the script for updating cached payload sizes#20911
Fixes the script for updating cached payload sizes#20911msutovsky-r7 wants to merge 9 commits intorapid7:masterfrom
Conversation
lib/msf/util/payload_cached_size.rb
Outdated
| # @return [Boolean] | ||
| def self.is_cached_size_accurate?(mod) | ||
| return true if mod.dynamic_size? && is_dynamic?(mod) | ||
| return true if mod.dynamic_size? || is_dynamic?(mod) |
There was a problem hiding this comment.
Can you remind me the reason to this logic switch?
There was a problem hiding this comment.
Right, because this was effectively turning some :dynamic payloads into fixed length payload. That's because is_dynamic? returns true, if payload generates x times output with different length using same datastore options. This function fails to detect two types of dynamic payloads: if payload is unique each time but with fixed size or if the payload should be dynamic due to other datastore option. This fix tries to address it by basically declaring that :dynamic payload should stay :dynamic.
There was a problem hiding this comment.
Alternative method is to change is_dynamic? - some payloads are and should be marked as dynamic, due to changing output. So another option is to change the logic to use hash instead of size length.
| # Initialize the simplified framework instance. | ||
| framework = Msf::Simple::Framework.create('DisableDatabase' => true) | ||
| exceptions = [] | ||
| framework = Msf::Simple::Framework.create({'DeferModuleLoads' => true}) |
There was a problem hiding this comment.
Is this one the change we discussed to avoid having DATASTORE saved with save being fetched by the script?
lib/msf/util/payload_cached_size.rb
Outdated
| #return true if mod.dynamic_size? | ||
| #return true if mod.dynamic_size? || is_dynamic?(mod) |
There was a problem hiding this comment.
| #return true if mod.dynamic_size? | |
| #return true if mod.dynamic_size? || is_dynamic?(mod) |
lib/msf/util/payload_cached_size.rb
Outdated
| # @return [Boolean] | ||
| def self.is_cached_size_accurate?(mod) | ||
| return true if mod.dynamic_size? && is_dynamic?(mod) | ||
| return true if mod.dynamic_size? || is_dynamic?(mod) |
There was a problem hiding this comment.
Alternative method is to change is_dynamic? - some payloads are and should be marked as dynamic, due to changing output. So another option is to change the logic to use hash instead of size length.
|
So I know this is drafted right now but I gave it a quick test. After running it on the main branch, I see that it's flipped some modules from dynamic to sized and the top one seems to still have the problem from the original issues where the |
|
On testing this, it still seems like it's updating the sizes for payloads that shouldn't have their sizes updated |
Fixes #20864
This PR addresses issue with
update_payload_cached_sizesscript. There has been some issues and inconsistencies with the script, leading to behavior when developers had to manually update cached sizes of payload, when CI failed. This PR tries to address the issue by unifying the way framework instance is created in CI and in the script. Furthermore, it takes into account thedynamiccached sizes and tries to forbid overwriting cached sizes by multiple payloads (i.e. staggers). As a bonus, it fixes a bug in PHP exec payload.This is work in progress, the initial fix seems to be working, further tests are necessary.
cached_sizesaccordingly