Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/metasploit/framework/obfuscation/crandomizer/utility.rb
19758 views
1
require 'metasm'
2
require 'securerandom'
3
4
module Metasploit
5
module Framework
6
module Obfuscation
7
module CRandomizer
8
9
class Utility
10
11
# Returns a random number.
12
#
13
# @return [Integer]
14
def self.rand_int
15
SecureRandom.random_number(100000000)
16
end
17
18
# Returns a random string.
19
#
20
# @return [String]
21
def self.rand_string
22
SecureRandom.hex
23
end
24
25
# Returns a Metasm parser.
26
#
27
# @param code [String] The C code to parse.
28
# @return [Metasm::C::Parser]
29
def self.parse(code)
30
parser = Metasm::C::Parser.new
31
parser.allow_bad_c = true
32
parser.parse(code)
33
parser
34
end
35
end
36
37
end
38
end
39
end
40
end
41