电子取证常用工具

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/etc/sysconfig/network-scripts/ifcfg-ens33
BOOTPROTO=static
IPADDR=192.168.1.174
NETMASK=255.255.255.0
systemctl restart network
netstat -ntln
systemctl stop firewalld
cd /www/server/panel && python tools.pyc panel newpassword # baota
cat /www/server/panel/data/userInfo.json
#load default.db into sqllite, read user password from users table, logs table
#data/admin_path.pl
mysqldump -uroot -p [tablename] --all-databases > /backup.sql
skip-grant-tables #/etc/my.cnf
show variables like '%log%'
show master status; #show master logs;
mysql/bin/mysqlbinlog mysql-bin.0001 > ./1.log;
mysql/bin/mysqlbinlog --start-position=120 --stop-postion=2222 mysql-bin.0001 | mysql -uroot -p123456#实际是将读出的binlog日志内容,通过管道符传递给myslq命令。
mysqld --console --skip-grant-tables --shared-memory #无密码启动服务
mysql -u root -p
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'd4fd620fed2205ec' WITH GRANT OPTION;
FLUSH PRIVILEGES;
# Load large sql file
max_allowed_packet = 1024M #my.cnf
>source D:/dataFile/back.sql;
%USERPROFILE%\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt #powershell history
Add-Type -Path .\DBManager.dll
[DBManager.Encryption]::AESDecrypt()
docker ps -a
docker start 
docker exec -it mysql57 /bin/bash #go into docker
docker inspect f5a
lsblk
docker-compose build
docker-compose up #docker-compose.yml
dumpe2fs /dev/sdb1 #search last mounted on
mount /dev/sdb1 /data
nginx -t #check nginx configuration file

数据取证

内存取证

Volatility常用指令制作profile

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
volatility -f <input> --profile=<profile_type> plugin #imageinfo/kdbgscan可用于猜测profile
volatility --info #查所有支持的profile,如果不指定–profile这个选项的话,默认这个选项为WinXPSP2x86.
volatility -f mem.data --profile=Win7SP1x64 cmdscan #cmd历史运行命令
#常用pluin:cmdscan editbox psscan filescan netscan iehistory clipboard notepad screenshot truecryptsummary,如果clipboard显示不全,可以使用strings mem | grep 显示
volatility -f mem.data --profile=Win7SP1x64 filescan | grep -E 'jpg' #查文件列表
$ volatility -f Target.vmem --profile=Win7SP1x64 mimikatz #需要先下载https://github.com/ruokeqx/tool-for-CTF到/usr/lib/python2.7/dist-packages/volatility/plugins
volatility -f mem.data --profile=Win7SP1x64 hivelist #列举缓存在内存的注册表 
Virtual    Physical   Name
0xe16aab60 0x082a6b60 \Device\HarddiskVolume1\WINDOWS\system32\config\SAM
0xe1035b60 0x02b08b60 \Device\HarddiskVolume1\WINDOWS\system32\config\system
volatility -f mem.data -profile=Win7SP1x64 hashdump #输出内存中的LM/NTLM hash用户密码
volatility -f mem.data -profile=Win7SP1x64 hashdump -y 0xe1035b60 -s 0xe16aab60 #获取内存中的系统密码填hivelist返回的虚拟地址[-y system_virtual -s SAM_virtual]
Administrator:500:0182bd0bd4444bf867cd839bf040d93b:c22b315c040ae6e0efee3518d830362b::: #https://blog.csdn.net/endeav_or/article/details/50196325 0182bd0bd4444bf867cd839bf040d93b是LM-Hash,通过变换作为DES加密key为魔术字符串KGS!@#$%进行加密;c22b315c040ae6e0efee3518d830362b是NTLM-Hash,转16进制后进行MD4加密。可直接通过cmd5网站或者https://www.objectif-securite.ch/en/ophcrack.php破解
volatility -f mem.data --profile=Win7SP1x64 printkey -K "SAM\Domains\Account\Users\Names" #获取SAM表用户
volatility -f mem.data --profile=Win7SP1x64 printkey -K "SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon" #获取最后登录系统用户

pslist #列出运行的进程。如果Exit所在的一列显示了日期时间,则表明该进程已经结束了。
volatility -f mem.data --profile=Win7SP1x64 dumpfiles -Q 0x251b56e0 -D ./ #提取内存缓存的文件
volatility -f mem.data --profile=Win7SP1x64 pstree #查进程列表,与pslist基本相同,采用树方式,将进程间父子关系表达出来
volatility -f mem.data --profile=Win7SP1x64 memdump -p 2768 --dump-dir=dump #将内存中的某个进程数据以dmp的格式保存出来 
#mspaint.exe进程内容修改后缀为.data,用gimp打开(Image Type:RGB Alpha,上下键盘调整宽度和高度)
#TrueCrypy.exe进程内容需要借助Elcomsoft Forensic Disk Decryptor(Elcomsoft硬盘取证解密器,简称为EFDD)软件来获取key

利用mimikatz提取虚拟机内存密码

1
2
3
4
5
6
7
8
9
D:\ctf\tools\forensics\Bin2Dmp\Release\x64\Bin2Dmp.exe Target.vmem Target.dmp #转dmp
windbg->File->Open Crash Dump
.symfix
.reload
.load D:\ctf\tools\intranet\mimikatz_trunk\x64\mimilib.dll
!process 0 0 lsass.exe #查找lsass进程
PROCESS fffffa800dba26d0
.process /r /p fffffa800dba26d0 #将镜像lsass环境转换到本机
!mimikatz #载入mimikatz

KeePass密码数据库管理

1
2
keepass2john PassBook.kdbx > keepass.txt #keepass2john is a tool comes with john
john keepass.txt

从sam/security/system文件提取密码

使用reg命令将sam、system和security文件导出

1
2
3
reg save HKLM\SYSTEM system.hiv
reg save HKLM\SAM sam.hiv
reg save HKLM\SECURITY security.hiv
1
2
python2 D:\ctf\software\Python27\Scripts\secretsdump.py -sam sam -security security -system sys LOCAL
python2 D:\ctf\software\Python27\Scripts\secretsdump.py -ntds ntds.dit -security security -system system LOCAL -history
1
mimikatz # lsadump::sam /system:system.hiv /sam:sam.hiv /security:security.hiv

Firefox密码取证

根据C:\Users\x\AppData\Roaming\Mozilla\Firefox\Profiles\xx.default-release目录下的key4.dblogins.json文件,利用firepwd

1
python firepwd.py -d ..\Profiles

磁盘取证

FTK-Imager,加载磁盘文件vmdk、e01,File->Image Mounting

BitLocker/TrueCrypt加密磁盘

Elcomsoft Forensic Disk Decryptor,Extract keys从内存中导出key文件,再Decrypt or mount disk->Image file of disk。

Windows删除文件恢复

Winhex恢复

Tools->Open Disk

右键$MFT->Open,ctrl+F查找文件名(编码选Unicode)

c0941800  46 49 4C 45 30 00 03 00    09 0C 27 BA 0D 00 00 00
c0941810  10 00 00 00 38 00 01 <-偏移0x16,01表示正常文件,00表示文件已删除
...
c0941940                             80 00 00 00 48 00 00 00 <-80数据属性标识
c0941950  01 <-偏移0x8,01表示后面保存真实数据存储位置,00表示直接保存真实数据
...
c0941970                             00 0A 00 00 00 00 00 00 <-偏移0x30文件大小,0xA00
c0941980                             31 01 A9 A2 46 00 00 00 <-偏移0x40,值31,低位1表示后面1位是簇数(01),高位3,表示后面3位是簇号开始位置0x46A2A9

ctrl+G,cluster=4629161(0x46A2A9的十进制),转到目标位置,右键选择Beginning of block;alt+G,New position填A00(文件大小),relative to选current position,转到目标位置,右键选择End of block

右键->Edit->Copy Block->Into New File,导出到文件

经测试,被删除文件的文件记录会很快被别的新建文件覆盖。如果在MFT中无法找到文件记录,需要通过文件内容中的特征字段直接查找。

手机备份文件恢复

Huawei备份文件解密

将备份文件夹下所有文件还原出来,再解密。(sample:内存分析-longjiancup-2021)

1
python3 D:\ctf\tools\forensics\kobackupdec\kobackupdec.py -vvv password inputdir outputdir

邮件文件恢复

pst文件恢复

SysTools Outlook PST Viewer(sample:丢失的邮件,gdqwb-2021),打开文件时勾选:Advance scan选项。

RAID重组

Rstudio重组

Drive->Open Image(选定所有镜像文件)->Create Virtual RAID->Create Virtual Block RAID,出现多个顺序时,依次试验,找一个大于4条带大小的文件打开,能打开就说明重组成功。右键Virtual RAID 1,选择创建镜像。