I found the times when USBs were plugged in with this:
# cat /var/log/messages | grep -A 20 "usb 1-1: new high-speed USB device"
May 17 16:54:28 trogdor kernel: usb 1-1: new high-speed USB device number 8 using xhci_hcd
# cat /var/log/messages | grep "Unmounted" | grep sdf
May 17 16:56:36 trogdor journal: Unmounted /dev/sdf1 on behalf of uid 1000
Then checked what files were modified in that time range with this:
# find / -executable -type f -newermt "2018-05-17 16:54:00" ! -newermt "2018-05-17 16:57:00" -ls
I agree it's not a great solution, and far too manual. As far as I can tell there is no elegant way to see in the logs if files were moved to or from a device.
Bit of explanation:
By default CentOS7 holds logs for 4 weeks after their cycled out, so the logs should be there to sift through in /var/log/messages-${date_in_some_format}.
$ cat /etc/logrotate.conf
# see "man logrotate" for details
# rotate log files weekly
weekly
# keep 4 weeks worth of backlogs
rotate 4
....
....
And anything of level info or higher is logged to /var/log/messages according to the rsyslog configuration file, including USB attach/detach in a barely-helpful format.
$ cat /etc/rsyslog.conf
# rsyslog configuration file
# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none /var/log/messages
I plugged in my USB and copied malicious.sh from it into /tmp/ and /home/trogdor/
-rwxr-xr-x. 1 trogdor trogdor 44 May 17 16:55 /tmp/malicious.sh
-rwxr-xr-x. 1 trogdor trogdor 44 May 17 16:56 /home/trogdormalicious.sh
In the logs I searched for when USBs were attached, and then when they were detached. I used -A to output 20 lines after the matching line, to find where the device was mounted so I was sure that this was actually the device that was being unmounted (/dev/sdf in this case). Older logs are by default stored in /var/log with messages-${date in some format}
# cat /var/log/messages | grep -A 20 "usb 1-1: new high-speed USB device"
--
May 17 16:54:28 trogdor kernel: usb 1-1: new high-speed USB device number 8 using xhci_hcd
---
May 17 16:54:29 trogdor kernel: sd 11:0:0:0: [sdf] 31258624 512-byte logical blocks: (16.0 GB/14.9 GiB)
--
Then because the last line shows it was mounted on sdf :
# cat /var/log/messages | grep "Unmounted" | grep sdf
---
May 17 16:56:36 trogdor journal: Unmounted /dev/sdf1 on behalf of uid 1000
I ripped off this for the find time range. The times are recent, but the same applies to times in the more distant past. The output has to be sifted, but it's not as bad as it could be, assuming that the malicious files are uploaded quickly.
I also checked only for executable files.
# find / -executable -type f -newermt "2018-05-17 16:54:00" ! -newermt "2018-05-17 16:57:00" -ls