Skip to content

Commit 0385914

Browse files
author
HD Moore
committed
YARD docs for the Msf::Util::PayloadCachedSize class
1 parent 02509d0 commit 0385914

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

lib/msf/util/payload_cached_size.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ module Util
1414

1515
class PayloadCachedSize
1616

17+
# Insert a new CachedSize value into the text of a payload module
18+
#
19+
# @param data [String] The source code of a payload module
20+
# @param cached_size [String] The new value for cached_size, which
21+
# which should be either numeric or the string :dynamic
22+
# @return [String]
1723
def self.update_cache_constant(data, cached_size)
1824
data.
1925
gsub(/^\s*CachedSize\s*=\s*(\d+|:dynamic).*/, '').
@@ -22,6 +28,12 @@ def self.update_cache_constant(data, cached_size)
2228
end
2329
end
2430

31+
# Insert a new CachedSize value into a payload module file
32+
#
33+
# @param mod [Msf::Payload] The class of the payload module to update
34+
# @param cached_size [String] The new value for cached_size, which
35+
# which should be either numeric or the string :dynamic
36+
# @return [void]
2537
def self.update_cached_size(mod, cached_size)
2638
mod_data = ""
2739

@@ -34,19 +46,37 @@ def self.update_cached_size(mod, cached_size)
3446
end
3547
end
3648

49+
# Updates the payload module specified with the current CachedSize
50+
#
51+
# @param mod [Msf::Payload] The class of the payload module to update
52+
# @return [void]
3753
def self.update_module_cached_size(mod)
3854
update_cached_size(mod, compute_cached_size(mod))
3955
end
4056

57+
# Calculates the CachedSize value for a payload module
58+
#
59+
# @param mod [Msf::Payload] The class of the payload module to update
60+
# @return [Fixnum]
4161
def self.compute_cached_size(mod)
4262
return :dynamic if is_dynamic?(mod)
4363
return mod.new.size
4464
end
4565

66+
# Determines whether a payload generates a static sized output
67+
#
68+
# @param mod [Msf::Payload] The class of the payload module to update
69+
# @param generation_count [Fixnum] The number of iterations to use to
70+
# verify that the size is static.
71+
# @return [Fixnum]
4672
def self.is_dynamic?(mod,generation_count=5)
4773
[*(1..generation_count)].map{|x| mod.new.size}.uniq.length != 1
4874
end
4975

76+
# Determines whether a payload's CachedSize is up to date
77+
#
78+
# @param mod [Msf::Payload] The class of the payload module to update
79+
# @return [Boolean]
5080
def self.is_cached_size_accurate?(mod)
5181
return true if mod.dynamic_size?
5282
return false if mod.cached_size.nil?

0 commit comments

Comments
 (0)