Re-implemented #generate_id in Core::Main::Crypto.

This is a better home for it since that is where other OpenSSL
crypto/token generator methods reside.
This commit is contained in:
soh_cah_toa
2014-04-23 11:41:11 -04:00
parent 861d66207d
commit 007f6302df
2 changed files with 18 additions and 8 deletions

View File

@@ -39,6 +39,23 @@ module Core
config.set('beef.api_token', token)
token
end
# Generates a unique identifier for DNS rules.
#
# @return [String] 8-character hex identifier
def self.dns_rule_id
id = nil
length = 4
begin
id = OpenSSL::Random.random_bytes(length).unpack('H*')[0]
BeEF::Core::Models::Dns::Rule.each { |rule| throw StandardError if id == rule.id }
rescue StandardError
retry
end
id.to_s
end
end
end