Một attacker sau khi xâm nhập và lấy được thông tin cần thiết từ victim thì việc quan trọng nhất là xóa dấu vết trước khi rời đi, đây là việc quan trọng để xóa mọi dấu vết liên quan tránh sự phát hiện của đội ngũ pháp y của victim, đảm bảo an toàn cho kẻ tấn công.
Đây cũng là bước thường bị bỏ qua nhất đối với một bộ phận người xâm nhập kiểm tra nghiệp dư, thậm chí vì một số lí do nào đó mà cả những người chuyên nghiệp cũng đôi khi quên đi, gây ảnh hưởng tới sự an toàn của người kiểm tra thâm nhập tốt hay xấu.
Xóa dấu vết đồng nghĩa với việc xóa mọi hoạt động của kẻ tấn công để tránh bị phát hiện, và đương nhiên là xóa dấu viết không phải lúc nào cũng xóa được 100% nhưng cũng một phần đảm bảo rằng đội ngũ pháp y sẽ khó khăn hơn trong việc dò ấu vết.
Xóa dấu vết trên Linux sau khi thực hiện kiểm tra thâm nhập
Hầu hết, các bản ghi nhật kí trên hệ thống linux thường được lưu trữ tại địa chỉ /var/log/ và các dấu vết quan trọng mà attacker sẽ xóa đó là :
1. Xóa các bản ghi nhật kí
2. Sửa đổi hoặc xóa các registry
3. Xóa các file mà attacker đa tạo ra trên hệ thống của nạn nhân
Và việc này sẽ rất rắc rối nếu như thực hiện thủ công, vậy ta cần có một công cụ riêng được thiết kế cho công việc này, công cụ thì nhiều nhưng trong bài viết này ta sẽ sử dụng công cụ mang tên Shred với công cụ này ta có thể xóa tập tin hoặc dữ liệu vĩnh viễn và ngăn chặn sự phục hồi dữ liệu, bởi vì nó ghi đè lên tập tin nhiều lần với các giá trị 1 và 0 (khi thực hiện xóa một tập tin trên máy tính, nó thực sự không bị xóa, nó được đánh dấu đơn giản là không gian nơi dữ liệu có thể được ghi vào)
pi@raspberry:~ $ shred --help
Usage: shred [OPTION]... FILE...
Overwrite the specified FILE(s) repeatedly, in order to make it harder
for even very expensive hardware probing to recover the data.
If FILE is -, shred standard output.
Mandatory arguments to long options are mandatory for short options too.
-f, --force change permissions to allow writing if necessary
-n, --iterations=N overwrite N times instead of the default (3)
--random-source=FILE get random bytes from FILE
-s, --size=N shred this many bytes (suffixes like K, M, G accepted)
-u truncate and remove file after overwriting
--remove[=HOW] like -u but give control on HOW to delete; See below
-v, --verbose show progress
-x, --exact do not round file sizes up to the next full block;
this is the default for non-regular files
-z, --zero add a final overwrite with zeros to hide shredding
--help display this help and exit
--version output version information and exit
Delete FILE(s) if --remove (-u) is specified. The default is not to remove
the files because it is common to operate on device files like /dev/hda,
and those files usually should not be removed.
The optional HOW parameter indicates how to remove a directory entry:
'unlink' => use a standard unlink call.
'wipe' => also first obfuscate bytes in the name.
'wipesync' => also sync each obfuscated byte to disk.
The default mode is 'wipesync', but note it can be expensive.
CAUTION: Note that shred relies on a very important assumption:
that the file system overwrites data in place. This is the traditional
way to do things, but many modern file system designs do not satisfy this
assumption. The following are examples of file systems on which shred is
not effective, or is not guaranteed to be effective in all file system modes:
* log-structured or journaled file systems, such as those supplied with
AIX and Solaris (and JFS, ReiserFS, XFS, Ext3, etc.)
* file systems that write redundant data and carry on even if some writes
fail, such as RAID-based file systems
* file systems that make snapshots, such as Network Appliance's NFS server
* file systems that cache in temporary locations, such as NFS
version 3 clients
* compressed file systems
In the case of ext3 file systems, the above disclaimer applies
(and shred is thus of limited effectiveness) only in data=journal mode,
which journals file data in addition to just metadata. In both the
data=ordered (default) and data=writeback modes, shred works as usual.
Ext3 journaling modes can be changed by adding the data=something option
to the mount options for a particular file system in the /etc/fstab file,
as documented in the mount man page (man mount).
In addition, file system backups and remote mirrors may contain copies
of the file that cannot be removed, and that will allow a shredded file
to be recovered later.
GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Full documentation at: <http://www.gnu.org/software/coreutils/shred>
or available locally via: info '(coreutils) shred invocation'
Shred có sẵn trên các hệ thống linux và trên kho lưu trữ gói, các cậu có thể apt nó về. Đây là các tùy chọn phổ biến có sẵn trong shred.
-f thay đổi quyền để cho phép viết nếu cần
-n (iterations = N) ghi đè N lần thay vì mặc định. (Mặc định là ghi đè 3 lần)
-s (size = N) chỉ định số lượng byte cần cắt nhỏ
-u cắt ngắn và xóa các tập tin sau khi ghi đè
-v hiển thị thông tin về tiến trình
-z thêm một ghi đè cuối cùng với số không để ẩn shredding
-u xóa tệp sau khi ghi đè
Còn các tùy chọn nâng cao hoặc khác thì các cậu xem nơi phần giới thiệu công cụ ở phía trên.
Dưới đây là các tệp nhật kí thường gặp và công dụng của chúng :
/var/log/auth.log: Nhật ký xác thực
/var/log/kern.log: Nhật ký hạt nhân
/var/log/cron.log: Nhật ký Crond (công việc định kỳ)
/var/log/maillog: Nhật ký máy chủ thư
/var/log/httpd/: Thư mục nhật ký truy cập và lỗi của Apache
/var/log/boot.log: Nhật ký khởi động hệ thống
Và cách dùng chung để xóa các nhật kí đó :
shred -vfzu [Nhật-kí-cần-xóa]
Cũng tùy theo đặc quyền mà các cậu có được trên hệ thống mới đảm bảo rằng các cậu có hay không có thể xóa được các file log này.
Còn một file khá quan trọng nữa đó là nhật kí dòng lệnh, là nơi lưu trữ các lệnh mà người dùng đã thực hiện, đối với người dùng thì nó lưu tại :
/home/<user>/.bash_history
Còn với root :
/root/.bash_history
Để xóa các cậu chỉ cần :
> [<đường-dẫn-nhật-kí-dòng-lệnh>]
Ví dụ :
> /root/.bash_history
Tham khảo : hsploit.com
OK ! DONE
[ " Căn bệnh lớn nhất của thời đại này đó là khi người ta cảm thấy mình không hề được yêu thương " ]