浅谈Linux取证
Linux取证 查询内核版本对应镜像号 Deep Security 12.0 Supported Linux Kernels (trendmicro.com) Ubuntu:Deep Security 12.0 Supported Linux Kernels (trendmicro.com) Debian:Deep Security 12.0 Supported Linux Kernels (tr
Linux取证
查询内核版本对应镜像号
Deep Security 12.0 Supported Linux Kernels (trendmicro.com)
Ubuntu:Deep Security 12.0 Supported Linux Kernels (trendmicro.com)
Debian:Deep Security 12.0 Supported Linux Kernels (trendmicro.com)
linux取证vol命令
linux_apihooks - Checks for userland apihooks
linux_arp - Print the ARP table
linux_aslr_shift - Automatically detect the Linux ASLR shift
linux_banner - Prints the Linux banner information
linux_bash - Recover bash history from bash process memory
linux_bash_env - Recover a process dynamic environment variables
linux_bash_hash - Recover bash hash table from bash process memory
linux_check_afinfo - Verifies the operation function pointers of network protocols
linux_check_creds - Checks if any processes are sharing credential structures
linux_check_evt_arm - Checks the Exception Vector Table to look for syscall table hooking
linux_check_fop - Check file operation structures for rootkit modifications
linux_check_idt - Checks if the IDT has been altered
linux_check_inline_kernel - Check for inline kernel hooks
linux_check_modules - Compares module list to sysfs info, if available
linux_check_syscall - Checks if the system call table has been altered
linux_check_syscall_arm - Checks if the system call table has been altered
linux_check_tty - Checks tty devices for hooks
linux_cpuinfo - Prints info about each active processor
linux_dentry_cache - Gather files from the dentry cache
linux_dmesg - Gather dmesg buffer
linux_dump_map - Writes selected memory mappings to disk
linux_dynamic_env - Recover a process dynamic environment variables
linux_elfs - Find ELF binaries in process mappings
linux_enumerate_files - Lists files referenced by the filesystem cache
linux_find_file - Lists and recovers files from memory
linux_getcwd - Lists current working directory of each process
linux_hidden_modules - Carves memory to find hidden kernel modules
linux_ifconfig - Gathers active interfaces
linux_info_regs - It's like 'info registers' in GDB. It prints out all the
linux_iomem - Provides output similar to /proc/iomem
linux_kernel_opened_files - Lists files that are opened from within the kernel
linux_keyboard_notifiers - Parses the keyboard notifier call chain
linux_ldrmodules - Compares the output of proc maps with the list of libraries from libdl
linux_library_list - Lists libraries loaded into a process
linux_librarydump - Dumps shared libraries in process memory to disk
linux_list_raw - List applications with promiscuous sockets
linux_lsmod - Gather loaded kernel modules
linux_lsof - Lists file descriptors and their path
linux_malfind - Looks for suspicious process mappings
linux_memmap - Dumps the memory map for linux tasks
linux_moddump - Extract loaded kernel modules
linux_mount - Gather mounted fs/devices
linux_mount_cache - Gather mounted fs/devices from kmem_cache
linux_netfilter - Lists Netfilter hooks
linux_netscan - Carves for network connection structures
linux_netstat - Lists open sockets
linux_pidhashtable - Enumerates processes through the PID hash table
linux_pkt_queues - Writes per-process packet queues out to disk
linux_plthook - Scan ELF binaries' PLT for hooks to non-NEEDED images
linux_proc_maps - Gathers process memory maps
linux_proc_maps_rb - Gathers process maps for linux through the mappings red-black tree
linux_procdump - Dumps a process's executable image to disk
linux_process_hollow - Checks for signs of process hollowing
linux_psaux - Gathers processes along with full command line and start time
linux_psenv - Gathers processes along with their static environment variables
linux_pslist - Gather active tasks by walking the task_struct->task list
linux_pslist_cache - Gather tasks from the kmem_cache
linux_psscan - Scan physical memory for processes
linux_pstree - Shows the parent/child relationship between processes
linux_psxview - Find hidden processes with various process listings
linux_recover_filesystem - Recovers the entire cached file system from memory
linux_route_cache - Recovers the routing cache from memory
linux_sk_buff_cache - Recovers packets from the sk_buff kmem_cache
linux_slabinfo - Mimics /proc/slabinfo on a running machine
linux_strings - Match physical offsets to virtual addresses (may take a while, VERY verbose)
linux_threads - Prints threads of processes
linux_tmpfs - Recovers tmpfs filesystems from memory
linux_truecrypt_passphrase - Recovers cached Truecrypt passphrases
linux_vma_cache - Gather VMAs from the vm_area_struct cache
linux_volshell - Shell in the memory image
linux_yarascan - A shell in the Linux memory image
以一道题目进行技术分析
2023强网杯-找到PNG了吗
下载附件,是一个mem文件,尝试正常的volatility取证,发现无果,考虑linux取证
先看一下版本号(利用vol3)
python vol.py -f flag.mem banner

可以看到是Ubuntu20.04的版本,那么我们就要利用Ubuntu20.04的镜像进行一系列的linux取证前置操作
虚拟机内核更换版本
首先下载正常的镜像,启动虚拟机,之后查看一下内核版本
uname -r

发现直接下载的和题目给出的内核版本不一样,尝试换源
先查看当前系统已安装的内核镜像
dpkg --get-selections |grep linux-image
发现没有目的的内核版本,下载一下
linux-image-5.15.0-67-generic install
linux-image-5.15.0-91-generic install
查询指定版本的linux镜像包
apt-cache search linux| grep 5.4.0-100
安装指定版本内核的linux系统头文件及镜像
apt-get install linux-headers-5.4.0-100-generic linux-image-5.4.0-100-generic
查看当前系统中内核的启动顺序
grep menuentry /boot/grub/grub.cfg

修改内核启动顺序
如果你升级的版本比当前内核版本高的话,默认新安装的内核就是第一顺序启动的,只需重启系统就行了,否则,则需要修改配置文件,具体如下:
vim /etc/default/grub

Advanced options for Ubuntu>Ubuntu, with Linux 5.4.0-100-generic
将GRUB_DEFAULT=0修改为GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux 4.15.0-76-generic",保存退出。
生效grub配置
update-grub
之后重启即可
创建vtypes
先在Ubuntu20.04下载一个volatility2,进行dwarf的编译
先在/volatility/tools/linux目录下,将module.c的最后末尾加上
MODULE_LICENSE("GPL");

之后安装gcc
sudo apt install gcc
再安装dwarfdump
sudo apt-get install dwarfdump
sudo apt-get install build-essential
之后再make编译
cd /volatility/tools/linux
sudo make
发现成功得到dwarf文件

获取符号表
一般我们可以在/boot目录下找到该System.map文件。该文件包含系统的符号信息。
cd /boot

这个就是我们需要的符号表
制作用户配置文件
将moudle.dwarf以及system.map文件打包成一个zip文件
sudo zip /home/qwb/Desktop/Ubuntu20.5-4-0-100.zip /home/qwb/Desktop/volatility/tools/linux/module.dwarf /boot/System.map-`uname -r`
这样我们一个可以调试的内核就制作好了
开始做题
然后我们回到自己的kali虚拟机,使用vol2,将Ubuntu.zip放到自己的/volatility-master/volatility/plugins/linux/目录下

第一个就是,我们选用这个作为我们的profiles
python2 vol.py -f '/home/evil/Desktop/vol images/找到PNG了吗.mem' --profile=LinuxUbuntu20_5-4-0-100x64 linux_enumerate_files
这里发现桌面有一个比较奇怪的东西,dump一下

python2 vol.py -f '/home/evil/Desktop/vol images/找到PNG了吗.mem' --profile=LinuxUbuntu20_5-4-0-100x64 linux_find_file -i 0xffff9ce28fe300e8 -O 1.jocker
之后导出发现是空的,尝试在内存中搜索jocker

发现源码
int main()
{
int clientSocket = socket(AF_INET, SOCK_STREAM, 0);
if (clientSocket == -1) {
printf("socket failed!\n");
return 1;
}
struct sockaddr_in serverAddr;
serverAddr.sin_family = AF_INET;
serverAddr.sin_port = htons(SERVER_PORT);
serverAddr.sin_addr.s_addr = inet_addr(SERVER_IP);
connect(clientSocket, (struct sockaddr*)&serverAddr, sizeof(serverAddr));
int result = recv(clientSocket, buff, sizeof(buff), 0);
int a=0;
char q[10];
unsigned char key[]="do_not_care";
unsigned char key2[] = "where_is_the_key";
FILE* file = fopen("have_your_fun.jocker", "wb");
if (file == NULL) {
printf("open file failed!\n");
return 1;
}
unsigned char *str;
str = (char *) malloc(20000);
memcpy(str, buff, 20000);
rc4_encrypt_decrypt(key2, str, 20000);
printf("please give me the key of fun:");
scanf("%s",q);
rc4_encrypt_decrypt(key, str, 20000);
fwrite(buff, 1, 20000, file);
printf("maybe you go wrong");
fclose(file);
close(clientSocket);
return 0;
}
其实就是利用RC4加密,Cyber操作一下

winhex搜索一下,整段复制出来解密

之后继续RC4解密即可

2023 0xGame on my linux
首先看一下版本号

Linux version 5.10.0-21-amd64 (debian-kernel@lists.debian.org) (gcc-10 (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2) #1 SMP Debian 5.10.162-1 (2023-01-21)
Vol3做法
利用网站查询一下kernel版本,Deep Security 12.0 Supported Linux Kernels (trendmicro.com)

发现是debian11的,下一下deb包,Index of /debian-security/pool/main/l/linux (sipwise.com)

之后解压,得到data.tar,拖入linux分析解压
之后利用vol3进行操作,vol3的貌似便捷一点(这里vol3需要结合wsl)
tar -xvf data.tar ./usr/lib/debug/boot/

之后开始制作符号表文件
dwarf2json linux --system-map /mnt/h/linux-image-5.10.0-21-amd64-dbg_5.10.162-1_amd64/usr/lib/debug/boot/System.map-5.10.0-21-amd64 --elf /mnt/h/linux-image-5.10.0-21-amd64-dbg_5.10.162-1_amd64/usr/lib/debug/boot/vmlinux-5.10.0-21-amd64
> linux-image-5.10.0-21-amd64-dbg_5.10.162-1_amd64.json
sudo mv linux-image-5.10.0-21-amd64-dbg_5.10.162-1_amd64.json /mnt/d/CTF/Misc/volatility3用这个/volatility3/framework/symbols/linux
之后成功将我们的符号表文件导入vol3中,直接分析即可
python3 vol.py -f oh-my-linux.mem linux.pslist

之后查看一下历史命令
python3 vol.py -f oh-my-linux.mem linux.bash

提示我们要查看zsh里的命令之后还得看vol2,vol2的做法还是得下镜像之后按照qwb的题目来做
Vol2做法
就是和qwb一样,得下iso镜像,debian11的,之后创建vtypes和符号表,用vol2做
参考
0xGame2023 oh-my-linux 技术分析 | Randark_JMT - 陈橘墨
Ubuntu Linux内核版本升级或降级到指定版本(基于ubuntu 18.04示例)_ubuntu降版本20降到18-CSDN博客