Method: Rex::Poly::LogicalBlock#generate
- Defined in:
- lib/rex/poly/block.rb
#generate(save_registers = nil, state = nil, badchars = nil) ⇒ Object
Generates the polymorphic buffer that results from this block and any of the blocks that it either directly or indirectly depends on. A list of register numbers to be saved can be passed in as an argument.
This method is not thread safe. To call this method on a single block instance from within multiple threads, be sure to encapsulate the calls inside a locked context.
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
# File 'lib/rex/poly/block.rb', line 240 def generate(save_registers = nil, state = nil, badchars = nil) # Create a localized state instance if one was not supplied. state = Rex::Poly::State.new if (state == nil) buf = nil cnt = 0 # This is a lame way of doing this. We just try to generate at most 128 # times until we don't have badchars. The reason we have to do it this # way is because of the fact that badchars can be introduced through # block offsetting and register number selection which can't be readily # predicted or detected during the generation phase. In the future we # can make this better, but for now this will have to do. begin buf = do_generate(save_registers, state, badchars) if (buf and (badchars.nil? or Rex::Text.badchar_index(buf, badchars).nil?)) break end end while ((cnt += 1) < 128) # If we passed 128 tries, then we can't succeed. buf = nil if (cnt >= 128) buf end |