* random states
* random hostnames git-svn-id: file:///home/svn/incoming/trunk@3605 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
f678425f07
commit
71fc4bd219
|
@ -23,6 +23,11 @@ module Text
|
|||
#
|
||||
##
|
||||
|
||||
States = ["AK", "AL", "AR", "AZ", "CA", "CO", "CT", "DE", "FL", "GA", "HI",
|
||||
"IA", "ID", "IL", "IN", "KS", "KY", "LA", "MA", "MD", "ME", "MI", "MN",
|
||||
"MO", "MS", "MT", "NC", "ND", "NE", "NH", "NJ", "NM", "NV", "NY", "OH",
|
||||
"OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VA", "VT", "WA",
|
||||
"WI", "WV", "WY"]
|
||||
UpperAlpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
LowerAlpha = "abcdefghijklmnopqrstuvwxyz"
|
||||
Numerals = "0123456789"
|
||||
|
@ -608,6 +613,22 @@ module Text
|
|||
return arr
|
||||
end
|
||||
|
||||
# Generate a random hostname
|
||||
def self.rand_hostname
|
||||
host = []
|
||||
(rand(5) + 1).times {
|
||||
host.push(Rex::Text.rand_text_alphanumeric(rand(10) + 1))
|
||||
}
|
||||
d = ['com', 'net', 'org', 'gov']
|
||||
host.push(d[rand(d.size)])
|
||||
host.join('.').downcase
|
||||
end
|
||||
|
||||
# Generate a state
|
||||
def self.rand_state()
|
||||
States[rand(States.size)]
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def self.converge_sets(sets, idx, offsets, length) # :nodoc:
|
||||
|
|
|
@ -27,6 +27,8 @@ class Rex::Text::UnitTest < Test::Unit::TestCase
|
|||
assert_equal("\025\362$WF\330X\214:\301", Rex::Text.rand_text(10), 'rand text 2')
|
||||
assert_equal("\346'W\256XQ\245\031MH", Rex::Text.rand_text(10), 'rand text 3')
|
||||
assert_equal('bababbabba', Rex::Text.rand_text(10, nil, 'ab'), 'rand text with specified "good"')
|
||||
assert_equal('MA', Rex::Text.rand_state(), 'rand state')
|
||||
assert_equal('xzdttongb.5gfk0xjly3.aak.fmo0rp.com', Rex::Text.rand_hostname(), 'rand hostname')
|
||||
end
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue