Skip to content

Commit ec7bb6d

Browse files
author
Tod Beardsley
committed
Land rapid7#2969, random name generator for phishing
2 parents 3676525 + a4809ef commit ec7bb6d

File tree

2 files changed

+135
-2
lines changed

2 files changed

+135
-2
lines changed

lib/rex/text.rb

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ module Text
3232
#
3333
##
3434

35+
TLDs = ['com', 'net', 'org', 'gov', 'biz', 'edu']
3536
States = ["AK", "AL", "AR", "AZ", "CA", "CO", "CT", "DE", "FL", "GA", "HI",
3637
"IA", "ID", "IL", "IN", "KS", "KY", "LA", "MA", "MD", "ME", "MI", "MN",
3738
"MO", "MS", "MT", "NC", "ND", "NE", "NH", "NJ", "NM", "NV", "NY", "OH",
@@ -102,6 +103,62 @@ module Text
102103
nil, nil, nil, nil, nil, nil, nil, nil, nil
103104
]
104105

106+
#
107+
# Most 100 common surnames, male/female names in the U.S. (http://names.mongabay.com/)
108+
#
109+
110+
Surnames = [
111+
"adams", "alexander", "allen", "anderson", "bailey", "baker", "barnes",
112+
"bell", "bennett", "brooks", "brown", "bryant", "butler", "campbell",
113+
"carter", "clark", "coleman", "collins", "cook", "cooper", "cox",
114+
"davis", "diaz", "edwards", "evans", "flores", "foster", "garcia",
115+
"gonzales", "gonzalez", "gray", "green", "griffin", "hall", "harris",
116+
"hayes", "henderson", "hernandez", "hill", "howard", "hughes", "jackson",
117+
"james", "jenkins", "johnson", "jones", "kelly", "king", "lee", "lewis",
118+
"long", "lopez", "martin", "martinez", "miller", "mitchell", "moore",
119+
"morgan", "morris", "murphy", "nelson", "parker", "patterson", "perez",
120+
"perry", "peterson", "phillips", "powell", "price", "ramirez", "reed",
121+
"richardson", "rivera", "roberts", "robinson", "rodriguez", "rogers",
122+
"ross", "russell", "sanchez", "sanders", "scott", "simmons", "smith",
123+
"stewart", "taylor", "thomas", "thompson", "torres", "turner", "walker",
124+
"ward", "washington", "watson", "white", "williams", "wilson", "wood",
125+
"wright", "young"
126+
]
127+
128+
Names_Male = [
129+
"aaron", "adam", "alan", "albert", "andrew", "anthony", "antonio",
130+
"arthur", "benjamin", "billy", "bobby", "brandon", "brian", "bruce",
131+
"carl", "carlos", "charles", "chris", "christopher", "clarence", "craig",
132+
"daniel", "david", "dennis", "donald", "douglas", "earl", "edward",
133+
"eric", "ernest", "eugene", "frank", "fred", "gary", "george", "gerald",
134+
"gregory", "harold", "harry", "henry", "howard", "jack", "james", "jason",
135+
"jeffrey", "jeremy", "jerry", "jesse", "jimmy", "joe", "john", "johnny",
136+
"jonathan", "jose", "joseph", "joshua", "juan", "justin", "keith",
137+
"kenneth", "kevin", "larry", "lawrence", "louis", "mark", "martin",
138+
"matthew", "michael", "nicholas", "patrick", "paul", "peter", "philip",
139+
"phillip", "ralph", "randy", "raymond", "richard", "robert", "roger",
140+
"ronald", "roy", "russell", "ryan", "samuel", "scott", "sean", "shawn",
141+
"stephen", "steve", "steven", "terry", "thomas", "timothy", "todd",
142+
"victor", "walter", "wayne", "william", "willie"
143+
]
144+
145+
Names_Female = [
146+
"alice", "amanda", "amy", "andrea", "angela", "ann", "anna", "anne",
147+
"annie", "ashley", "barbara", "betty", "beverly", "bonnie", "brenda",
148+
"carol", "carolyn", "catherine", "cheryl", "christina", "christine",
149+
"cynthia", "deborah", "debra", "denise", "diana", "diane", "donna",
150+
"doris", "dorothy", "elizabeth", "emily", "evelyn", "frances", "gloria",
151+
"heather", "helen", "irene", "jacqueline", "jane", "janet", "janice",
152+
"jean", "jennifer", "jessica", "joan", "joyce", "judith", "judy", "julia",
153+
"julie", "karen", "katherine", "kathleen", "kathryn", "kathy", "kelly",
154+
"kimberly", "laura", "lillian", "linda", "lisa", "lois", "lori", "louise",
155+
"margaret", "maria", "marie", "marilyn", "martha", "mary", "melissa",
156+
"michelle", "mildred", "nancy", "nicole", "norma", "pamela", "patricia",
157+
"paula", "phyllis", "rachel", "rebecca", "robin", "rose", "ruby", "ruth",
158+
"sandra", "sara", "sarah", "sharon", "shirley", "stephanie", "susan",
159+
"tammy", "teresa", "theresa", "tina", "virginia", "wanda"
160+
]
161+
105162
##
106163
#
107164
# Serialization
@@ -1525,8 +1582,7 @@ def self.rand_hostname
15251582
(rand(5) + 1).times {
15261583
host.push(Rex::Text.rand_text_alphanumeric(rand(10) + 1))
15271584
}
1528-
d = ['com', 'net', 'org', 'gov']
1529-
host.push(d[rand(d.size)])
1585+
host.push(TLDs[rand(TLDs.size)])
15301586
host.join('.').downcase
15311587
end
15321588

@@ -1535,6 +1591,40 @@ def self.rand_state()
15351591
States[rand(States.size)]
15361592
end
15371593

1594+
# Generate a surname
1595+
def self.rand_surname
1596+
Surnames[rand(Surnames.size)]
1597+
end
1598+
1599+
# Generate a name
1600+
def self.rand_name
1601+
if rand(10) % 2 == 0
1602+
Names_Male[rand(Names_Male.size)]
1603+
else
1604+
Names_Female[rand(Names_Female.size)]
1605+
end
1606+
end
1607+
1608+
# Generate a male name
1609+
def self.rand_name_male
1610+
Names_Male[rand(Names_Male.size)]
1611+
end
1612+
1613+
# Generate a female name
1614+
def self.rand_name_female
1615+
Names_Female[rand(Names_Female.size)]
1616+
end
1617+
1618+
# Generate a random mail address
1619+
def self.rand_mail_address
1620+
mail_address = ''
1621+
mail_address << Rex::Text.rand_name
1622+
mail_address << '.'
1623+
mail_address << Rex::Text.rand_surname
1624+
mail_address << '@'
1625+
mail_address << Rex::Text.rand_hostname
1626+
end
1627+
15381628

15391629
#
15401630
# Calculate the ROR13 hash of a given string

spec/lib/rex/text_spec.rb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,49 @@
7171
end
7272
end
7373

74+
context ".rand_surname" do
75+
it "should return a random surname" do
76+
described_class::Surnames.should include(described_class.rand_surname)
77+
end
78+
end
79+
80+
context ".rand_name" do
81+
it "should return a random name" do
82+
names = described_class::Names_Female + described_class::Names_Male
83+
names.should include(described_class.rand_name)
84+
end
85+
end
86+
87+
context ".rand_name_female" do
88+
it "should return a random female name" do
89+
described_class::Names_Female.should include(described_class.rand_name_female)
90+
end
91+
end
92+
93+
context ".rand_name_male" do
94+
it "should return a random male name" do
95+
described_class::Names_Male.should include(described_class.rand_name_male)
96+
end
97+
end
98+
99+
context ".rand_mail_address" do
100+
it "should return a random mail address" do
101+
names = described_class::Names_Female + described_class::Names_Male
102+
surnames = described_class::Surnames
103+
tlds = described_class::TLDs
104+
105+
# XXX: This is kinda dirty
106+
mail_address = described_class.rand_mail_address.split("@").map { |x| x.split(".") }
107+
name, surname = mail_address.first.first, mail_address.first.last
108+
domain, tld = "example", mail_address.last.last # Poor man's stubbing to preserve TLD
109+
110+
names.should include(name)
111+
surnames.should include(surname)
112+
domain.should eq("example")
113+
tlds.should include(tld)
114+
end
115+
end
116+
74117
end
75118
end
76119

0 commit comments

Comments
 (0)