Created
December 26, 2024 19:33
-
-
Save beucismis/2250f48f53463c82bb07550644170d5a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| USER=beucismis | |
| LOG_FILENAME=usbsniffer.log | |
| LOG_FILE_PATH=/home/$USER/usbsniffer/$LOG_FILENAME | |
| TARGET_DIR_PATH=/home/$USER/usbsniffer/files/ | |
| function usage() { | |
| echo "Usage: $0 {device_name} (e.g. sda1)" | |
| exit 1 | |
| } | |
| if [[ $# -ne 1 ]]; then | |
| usage | |
| fi | |
| if [ "$EUID" -ne 0 ]; then | |
| echo "Please run as root!" | |
| exit 1 | |
| fi | |
| function info() { | |
| echo "$(date) - $1" >> $LOG_FILE_PATH | |
| } | |
| DEVICE_NAME=$1 | |
| DEVICE=/dev/$DEVICE_NAME | |
| MOUNT_POINT=/media/usb/$DEVICE_NAME | |
| mkdir -p $MOUNT_POINT | |
| mount $DEVICE $MOUNT_POINT | |
| info "Mounted $DEVICE at $MOUNT_POINT" | |
| cp -r $MOUNT_POINT/* $TARGET_DIR_PATH | |
| info "All files copied to $TARGET_DIR_PATH" | |
| umount $MOUNT_POINT | |
| info "Unmounted $DEVICE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment