CVE-2019-19781 - Imaging a physical FreeBSD device
In response to exploitation of CVE-2019-19781, incident responders may find themselves needing to grab an image of vulnerable Citrix ADC and/or Gateway appliances. It’s likely that the majority of these devices are virtual appliances within networks, however there’s bound to be some physical boxes sitting out in datacentres somewhere.
Thus, here are a couple of ways to grab an image of these devices.
Note!
Copy partitions to an external drive attached to the device.
The Netscalers have a single USB port on the front or back, making copying data off to an external drive easy enough once mounted.
- Run
df -hand identify partitions of interest. These are likely/dev/md0, /dev/ad0s1a, /dev/ad0s1b - Mount a drive with an ext2/3 filesystem.
- To identify your drive, use
geom.geom disk listto view disks andgeom part listto break them out into partitions. - Use the
mountutility to specify the block device and your mountpoint, if you’re having issues then try mounting as a CDROM.
- To identify your drive, use
- Use
ddto copy the partitions identified withdf -hto output files on the mounted drive.- You may be able to direct the output from
ddstraight to the partitions block device in/devwithout mounting. I didn’t have any success with it though.
- You may be able to direct the output from
Copy partitions to a host of your choice over SSH.
- Run
df -hand identify partitions of interest. These are likely/dev/md0, /dev/ad0s1a, /dev/ad0s1b - Choose a host to either: push the image to, pull the image to (recommended).
- Push method (taken from https://github.com/x1sec/CVE-2019-19781/blob/master/CVE-2019-19781-DFIR.md)
dd if=/dev/md0 | gzip -1 - | ssh user@[IP address] dd of=/[fullpath]/md0.gzdd if=/dev/ad0s1a | gzip -1 - | ssh user@[IP address] dd of=/[fullpath]/ad0s1a.gzdd if=/dev/ad0s1b | gzip -1 - | ssh user@[IP address] dd of=/[fullpath]/ad0s1b.gz
- Pull method (also taken from the above link, but it was my pull request)
ssh user@[IP address] "shell dd if=/dev/md0 | gzip -1 - " | dd of=/[fullpath]/md0.gz status=progressssh user@[IP address] "shell dd if=/dev/ad0s1a | gzip -1 - " | dd of=/[fullpath]/ad0s1a.gz status=progressssh user@[IP address] "shell dd if=/dev/ad0s1b | gzip -1 - " | dd of=/[fullpath]/ad0s1b.gz status=progress- The shell keyword in the above commands are required to pass dd through to the execution context of sh.
- Remove gzip if you’re concerned about performance of the Netscalers, you’ll take a full cut of the disk including all unallocated space though.
Happy imaging!