CTF Forensic » 履歴 » バージョン 4
kanata, 2025/05/10 09:25
1 | 4 | kanata | {{>toc}} |
---|---|---|---|
2 | |||
3 | 1 | kanata | # CTF Forensic |
4 | 3 | kanata | |
5 | 1 | kanata | {{last_updated_at}} |
6 | |||
7 | # Command gadgets |
||
8 | |||
9 | - ハッシュ値生成 |
||
10 | |||
11 | md5sum sha1sum sha224sum sha256sum |
||
12 | |||
13 | ## find |
||
14 | |||
15 | 通常のファイル検索 |
||
16 | |||
17 | ``` |
||
18 | find `pwd` -name "${1}" -print 2>/dev/null |
||
19 | ``` |
||
20 | |||
21 | どんな種類のファイルがあるか検索 |
||
22 | |||
23 | ``` |
||
24 | find ./ | xargs file |
||
25 | ``` |
||
26 | |||
27 | ## xz |
||
28 | |||
29 | 圧縮 |
||
30 | |||
31 | ``` |
||
32 | xz -zk ファイル |
||
33 | ``` |
||
34 | |||
35 | 展開 |
||
36 | |||
37 | ``` |
||
38 | unxz -dk ファイル |
||
39 | ``` |
||
40 | |||
41 | ## ディスクイメージからzipファイルを抜き出す(python) |
||
42 | |||
43 | dは1個目、yは二個目 |
||
44 | |||
45 | ``` |
||
46 | $python |
||
47 | >>> d = open("入力ファイル名","rb").read() |
||
48 | >>> z = d[d.find("PK\x03\x04"):d.find("PK\x05\x06")+22] |
||
49 | >>> len(z) |
||
50 | >>> open("出力ファイル名","wb").write(d[d.find("PK\x03\x04"):d.find("PK\x05\x06")+22]) |
||
51 | >>> y = d[d.find("PK\x05\x06")+22:] |
||
52 | >>> open("出力ファイル名","wb").write(y[y.find("PK\x03\x04"):y.find("PK\x05\x06")+22]) |
||
53 | ``` |
||
54 | |||
55 | ## gzipファイルに付けられたコメントを表示する |
||
56 | |||
57 | 標準的なコマンドがない。ただ、 |
||
58 | |||
59 | - ファイル名 |
||
60 | - NULL(0x00) |
||
61 | - コメント |
||
62 | |||
63 | というフォーマットになっているので、がんばれは読めると思われる。 |
||
64 | |||
65 | 参考:http://www.gzip.org/zlib/rfc-gzip.html |
||
66 | |||
67 | ちなみにコメントの有無は、fileコマンドで |
||
68 | |||
69 | ``` |
||
70 | comment, |
||
71 | ``` |
||
72 | |||
73 | が出てきたらコメント在り。 |
||
74 | |||
75 | ## zipファイルに付けられたコメントを表示する |
||
76 | |||
77 | zipの中のファイル毎にコメントを付けられる仕様。あんまり使われてないけど。 |
||
78 | |||
79 | ``` |
||
80 | unzip -lz a.zip |
||
81 | ``` |
||
82 | |||
83 | ## Exif情報を取得する |
||
84 | |||
85 | ImageMagickでExif情報を取得するには、identifyコマンドを使う。 |
||
86 | |||
87 | ``` |
||
88 | identify -verbose a.jpg |
||
89 | ``` |
||
90 | |||
91 | ## ddコマンドで保存したイメージファイルをマウントする |
||
92 | |||
93 | ``` |
||
94 | % sudo fdisk -u -l disk_20130530-1400.img |
||
95 | |||
96 | ディスク acid_20130530-1400.img: 4012 MB, 4012900352 バイト |
||
97 | ヘッド 255, セクタ 63, シリンダ 487, 合計 7837696 セクタ |
||
98 | Units = セクタ数 of 1 * 512 = 512 バイト |
||
99 | セクタサイズ (論理 / 物理): 512 バイト / 512 バイト |
||
100 | I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト |
||
101 | ディスク識別子: 0x00014d34 |
||
102 | |||
103 | デバイス ブート 始点 終点 ブロック Id システム |
||
104 | disk_20130530-1400.img1 8192 122879 57344 c W95 FAT32 (LBA) |
||
105 | disk_20130530-1400.img2 122880 7774207 3825664 83 Linux |
||
106 | |||
107 | % sudo mount -o loop,offset=$((512*122880)) disk_20130530-1400.img /mnt |
||
108 | ``` |
||
109 | |||
110 | ## 時刻指定でgrepする |
||
111 | |||
112 | find_by_date.sh |
||
113 | |||
114 | ``` |
||
115 | #!/bin/sh |
||
116 | |||
117 | DATE_FROM="201504250000.00" |
||
118 | DATE_TO="201504262359.59" |
||
119 | |||
120 | touch -t $DATE_FROM /tmp/tmp_date_from.$$ |
||
121 | touch -t $DATE_TO /tmp/tmp_date_to.$$ |
||
122 | |||
123 | find $SEARCH_PATH -type f -newer /tmp/tmp_date_from.$$ ! -newer /tmp/tmp_date_to.$$ -ls; |
||
124 | |||
125 | exit 0 |
||
126 | ``` |
||
127 | |||
128 | grep_by_date.sh |
||
129 | |||
130 | ``` |
||
131 | #!/bin/sh |
||
132 | |||
133 | LIST=`/usr/local/bin/find_by_date.sh $1 $2 $3|awk '{print $NF'}` |
||
134 | |||
135 | for WORD in ${LIST} |
||
136 | do |
||
137 | grep $4 ${WORD} 2>/dev/null |
||
138 | if [ $? = "0" ] |
||
139 | then |
||
140 | echo "########## ${WORD} is founded ##########" |
||
141 | fi |
||
142 | done |
||
143 | |||
144 | exit 0 |
||
145 | ``` |
||
146 | |||
147 | ## 画像ファイルのEXIF情報を取得する |
||
148 | |||
149 | ```bash |
||
150 | $ identify -verbose ファイルPATH |
||
151 | ``` |
||
152 | |||
153 | [俺的備忘録 〜なんかいろいろ〜 - コンソール上でImageMagickを使って画像ファイルのEXIF情報を取得する](https://orebibou.com/2017/08/%e3%82%b3%e3%83%b3%e3%82%bd%e3%83%bc%e3%83%ab%e4%b8%8a%e3%81%a7imagemagick%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e7%94%bb%e5%83%8f%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%81%aeexif%e6%83%85%e5%a0%b1/) |
||
154 | |||
155 | |||
156 | |||
157 | |||
158 | |||
159 | |||
160 | |||
161 | |||
162 | |||
163 | |||
164 | |||
165 | # WebService / Application |
||
166 | |||
167 | ## Online TrID File Identifier |
||
168 | |||
169 | http://mark0.net/onlinetrid.aspx |
||
170 | |||
171 | ## binvis.io - バイナリビューア |
||
172 | |||
173 | http://binvis.io/#/ |
||
174 | |||
175 | |||
176 | |||
177 | |||
178 | # Setup |
||
179 | |||
180 | ## hachoir-subfile のインストール |
||
181 | |||
182 | CentOSへの[hachoir-subfile](https://bitbucket.org/haypo/hachoir/wiki/hachoir-subfile)のインストール |
||
183 | |||
184 | ``` |
||
185 | $ cd /home/user/PythonSandBox |
||
186 | $ source bin/activate # virtualenvによる仮想環境に移行 |
||
187 | |||
188 | (PythonSandBox)$ cd tmp |
||
189 | (PythonSandBox)$ mkdir hachoir |
||
190 | (PythonSandBox)$ hachoir |
||
191 | (PythonSandBox)$ wget http://cheeseshop.python.org/packages/source/h/hachoir-core/hachoir-core-1.3.3.tar.gz |
||
192 | (PythonSandBox)$ wget http://cheeseshop.python.org/packages/source/h/hachoir-parser/hachoir-parser-1.3.4.tar.gz |
||
193 | (PythonSandBox)$ wget http://cheeseshop.python.org/packages/source/h/hachoir-metadata/hachoir-metadata-1.3.3.tar.gz |
||
194 | (PythonSandBox)$ wget http://cheeseshop.python.org/packages/source/h/hachoir-urwid/hachoir-urwid-1.1.tar.gz |
||
195 | (PythonSandBox)$ wget http://cheeseshop.python.org/packages/source/h/hachoir-wx/hachoir-wx-0.3.tar.gz |
||
196 | (PythonSandBox)$ wget http://cheeseshop.python.org/packages/source/h/hachoir-subfile/hachoir-subfile-0.5.3.tar.gz |
||
197 | (PythonSandBox)$ wget http://cheeseshop.python.org/packages/source/h/hachoir-regex/hachoir-regex-1.0.5.tar.gz |
||
198 | ``` |
||
199 | |||
200 | 次に、ダウンロードした全てのファイルをtar xvfzで展開。その中に入っているsetup.py全てについて |
||
201 | |||
202 | ``` |
||
203 | (PythonSandBox)$./setup.py build |
||
204 | (PythonSandBox)$./setup.py install |
||
205 | ``` |
||
206 | |||
207 | を実施する。順番はあんまり関係ないみたい |
||
208 | |||
209 | ## zpipeのインストール |
||
210 | |||
211 | zlib部分の圧縮・伸張ができるプログラム |
||
212 | |||
213 | 使い方 |
||
214 | |||
215 | ``` |
||
216 | $ zpipe < src.bin > dest.bin #圧縮 |
||
217 | $ zpipe -d < src.bin > dest.bin #伸張 |
||
218 | ``` |
||
219 | |||
220 | 注: deflateInitで圧縮されたzlib圧縮データのことである。deflateInit2でGZIP圧縮されたデータではない。 |
||
221 | |||
222 | ビルド方法 |
||
223 | |||
224 | ``` |
||
225 | $ cd /tmp |
||
226 | $ git clone https://github.com/madler/zlib |
||
227 | $ cd zlib |
||
228 | $ ./configure |
||
229 | $ make |
||
230 | $ cd examples |
||
231 | $ gcc zpipe.c -lz -o zpipe |
||
232 | ``` |
||
233 | |||
234 | |||
235 | |||
236 | |||
237 | # フォレンジック調査で使用するマウント関連のコマンド |
||
238 | |||
239 | http://sec-v6.blogspot.jp/2013/03/blog-post.html |
||
240 | |||
241 | ## ディスクイメージをそのままマウントする |
||
242 | |||
243 | ``` |
||
244 | mount [image_file] [mount_point] |
||
245 | ``` |
||
246 | |||
247 | ## 特定のパーティションをマウントする |
||
248 | |||
249 | ディスクイメージの中の特定パーティションのみマウントするにはまずオフセットを調べる。 |
||
250 | オフセットを調べるには fdisk または mmls を使用する。 |
||
251 | |||
252 | ``` |
||
253 | fdisk -lu [image_file] |
||
254 | mmls [image_file] |
||
255 | ``` |
||
256 | |||
257 | mmls は sleuthkit.org で開発されている sleuthkit に入っているコマンド。SIFT ではデフォルトで使用可能。 |
||
258 | マウントしたいパーティションの start となっている数値にセクタサイズ(通常512)をかけた数が offset となり、この値を mount コマンドで指定する。 |
||
259 | |||
260 | ``` |
||
261 | mount -o loop,offset=[start*512] [image_file] [mount_point] |
||
262 | ``` |
||
263 | |||
264 | フォレンジック調査なら読み取り専用のオプション -o ro loop、ファイルタイプとして -t ntfs とか nls=utf8 とか付け加える。 |
||
265 | |||
266 | ## E01 イメージの取り扱い |
||
267 | |||
268 | EnCase image file format で保全されたディスクイメージを扱いたい場合にいは SIFT に入っている ewfmount を使う。 |
||
269 | ewfmount により E01 イメージを dd イメージで操作できる。 |
||
270 | |||
271 | ``` |
||
272 | ewfmount [e01_image_file] [mount_point] |
||
273 | ``` |
||
274 | |||
275 | E01 イメージが一つではなく複数に分割されている場合は末尾がE01のファイルを指定するだけ。 |
||
276 | この状態で [mount_point] 配下に ewf1 という dd イメージファイルができ、それをマウントすることができる。 アンマウントは通常通り umount コマンドでできる。 |
||
277 | |||
278 | ## イメージディスクの作成 |
||
279 | イメージディスクの作成は下記コマンドで実行。 |
||
280 | |||
281 | ``` |
||
282 | dd if=[input_disk] of=[output_file] bs=512 obs=1024k count=[number] conv=sync,noerror |
||
283 | ``` |
||
284 | |||
285 | # メモリフォレンジック |
||
286 | |||
287 | ## volatility |
||
288 | |||
289 | [volatility](http://www.volatilityfoundation.org/)一択 |
||
290 | |||
291 | >ちなみにこの分野は日本語書籍がほぼ無い |
||
292 | |||
293 | 1. imageinfoオプションで、OS判別してvolatilityのプロファイルを特定 |
||
294 | 2. その上で、各種コマンドを叩いて調べる |
||
295 | 3. [SANSのチートシート](https://digital-forensics.sans.org/media/poster_2014_find_evil.pdf)から怪しいプロセスを発見するのがまず一歩か |
||
296 | |||
297 | > 1個しかないプロセスが複数あるとか、親プロセスがおかしいとか |
||
298 | |||
299 | |||
300 | * dllの読み込みは、false false false だったら怪しい、true false true は正常な可能性が高い |
||
301 | |||
302 | >> DLLの隠蔽、DLLのリンクは三種類の双方向リストで管理されており、これを細工して隠蔽できる |
||
303 | |||
304 | * 後述のstringsコマンドで抽出した文字列を、volatilityを使ってメモリイメージと紐付けられる。それをgrepでいろいろ見る。 |
||
305 | |||
306 | |||
307 | ``` |
||
308 | # Help |
||
309 | volatility -h |
||
310 | volatility pslist --help |
||
311 | |||
312 | # Info これでOSを特定する |
||
313 | volatility -f [image] imageinfo |
||
314 | |||
315 | $ volatility -f win7_trial_64bit.raw imageinfo |
||
316 | Volatility Foundation Volatility Framework 2.4 |
||
317 | Determining profile based on KDBG search... |
||
318 | |||
319 | Suggested Profile(s) : Win7SP0x64, Win7SP1x64, Win2008R2SP0x64, Win2008R2SP1x64 |
||
320 | AS Layer1 : AMD64PagedMemory (Kernel AS) |
||
321 | AS Layer2 : FileAddressSpace (/Users/Michael/Desktop/win7_trial_64bit.raw) |
||
322 | PAE type : PAE |
||
323 | DTB : 0x187000L |
||
324 | KDBG : 0xf80002803070 |
||
325 | Number of Processors : 1 |
||
326 | Image Type (Service Pack) : 0 |
||
327 | KPCR for CPU 0 : 0xfffff80002804d00L |
||
328 | KUSER_SHARED_DATA : 0xfffff78000000000L |
||
329 | Image date and time : 2012-02-22 11:29:02 UTC+0000 |
||
330 | Image local date and time : 2012-02-22 03:29:02 -0800 |
||
331 | ``` |
||
332 | |||
333 | >この場合、プロファイルは Win7SP0x64 か Win2008R2SP0x64 (Image Type (Service Pack) : 0 から絞り込める) |
||
334 | |||
335 | |||
336 | ``` |
||
337 | # Process |
||
338 | volatility -f [image] --profile=[OS Profile] pslist |
||
339 | volatility -f [image] --profile=[OS Profile] psscan |
||
340 | volatility -f [image] --profile=[OS Profile] pstree |
||
341 | volatility -f [image] --profile=[OS Profile] psxview |
||
342 | volatility -f [image] --profile=[OS Profile] psxview --apply-rules |
||
343 | |||
344 | # Network |
||
345 | volatility -f [image] --profile=[OS Profile] netscan #Vista以降 |
||
346 | volatility -f [image] --profile=[OS Profile] connections # |
||
347 | volatility -f [image] --profile=[OS Profile] connscan # |
||
348 | volatility -f [image] --profile=[OS Profile] sockscan # |
||
349 | |||
350 | # Registry |
||
351 | volatility -f [image] --profile=[OS Profile] hivelist |
||
352 | volatility -f [image] --profile=[OS Profile] printkey -K "[registry key]" |
||
353 | volatility -f [image] --profile=[OS Profile] userassist |
||
354 | volatility -f [image] --profile=[OS Profile] shellbags |
||
355 | volatility -f [image] --profile=[OS Profile] shellbags --output-file=[shellbags.body] --output=body |
||
356 | volatility -f [image] --profile=[OS Profile] shimcache |
||
357 | volatility -f [image] --profile=[OS Profile] getsids --offset [address] |
||
358 | volatility -f [image] --profile=[OS Profile] privs --offset [address] |
||
359 | volatility -f [image] --profile=[OS Profile] hashdump |
||
360 | volatility -f [image] --profile=[OS Profile] lsadump |
||
361 | |||
362 | # Command history |
||
363 | volatility -f [image] --profile=[OS Profile] cmdscan |
||
364 | volatility -f [image] --profile=[OS Profile] consoles |
||
365 | |||
366 | # DLL |
||
367 | volatility -f [image] --profile=[OS Profile] dlllist |
||
368 | volatility -f [image] --profile=[OS Profile] handles -p [pid] -t File |
||
369 | volatility -f [image] --profile=[OS Profile] handles -p [pid] -t Key |
||
370 | volatility -f [image] --profile=[OS Profile] handles -p [pid] -t Directory |
||
371 | volatility -f [image] --profile=[OS Profile] handles -p [pid] -t Port |
||
372 | volatility -f [image] --profile=[OS Profile] handles -p [pid] -t Mutant |
||
373 | volatility -f [image] --profile=[OS Profile] handles --offset [address] |
||
374 | |||
375 | # evtlog |
||
376 | volatility -f [image] --profile=[OS Profile] evtlogs -D [Directory] |
||
377 | volatility -f [image] --profile=[OS Profile] evtlogs --save-evt -D [Directory] |
||
378 | |||
379 | # Service |
||
380 | volatility -f [image] --profile=[OS Profile] svcscan |
||
381 | |||
382 | # FileSystem |
||
383 | volatility -f [image] --profile=[OS Profile] mftparser --output-file=[outfile.txt] |
||
384 | volatility -f [image] --profile=[OS Profile] mftparser --output-file=[outfile.txt] --output=body # body形式は別のソフトで読める |
||
385 | |||
386 | # Dump |
||
387 | volatility -f [image] --profile=[OS Profile] dlldump -p [pid] -D [Directory] |
||
388 | volatility -f [image] --profile=[OS Profile] procdump -p [pid] -D [Directory] |
||
389 | volatility -f [image] --profile=[OS Profile] dumpfiles -r .evtx$ --ignore-case -D [Directory] |
||
390 | procdump -p [pid] --dump-dir=/tmp |
||
391 | photorec /d [Directory] [image] |
||
392 | |||
393 | # Timeline |
||
394 | volatility -f [image] --profile=[OS Profile] timeliner --output-file=timeliner.body --output=body |
||
395 | |||
396 | # bodyファイルは結合できる |
||
397 | cat [BodyFile.1] [BodyFile.2] [BodyFile.3] > [BodyFile] |
||
398 | |||
399 | # mactime |
||
400 | mactime --help |
||
401 | mactime -b [BodyFile] -d -z UTC |
||
402 | |||
403 | # Vad |
||
404 | volatility -f [image] --profile=[OS Profile] -p [pid] vadinfo |
||
405 | volatility -f [image] --profile=[OS Profile] -p vaddump -D [Directory] |
||
406 | |||
407 | # Strings |
||
408 | strings -td -a [image] >> strings.txt # "FREE MEMORY"という単語がなんかしらないがよく使うらしい |
||
409 | strings -td -el -a [image] >> strings.txt |
||
410 | |||
411 | volatility -f [image] --profile=[OS Profile] strings -s strings.txt > [out.txt] |
||
412 | |||
413 | grep [string] out.txt # IPアドレス等で引っ掛けて -A -B のオプションでその前後を出力して調査 |
||
414 | |||
415 | # Malware Check |
||
416 | volatility -f [image] --profile=[OS Profile] ldrmodules -p [pid] |
||
417 | volatility -f [image] --profile=[OS Profile] malfind -p [pid] |
||
418 | |||
419 | # Yarascan |
||
420 | volatility -f [image] --profile=[OS Profile] yarascan --yara-rules="[strings]" |
||
421 | volatility -f [image] --profile=[OS Profile] yarascan -p [pid] --yara-rules="[binary code]" |
||
422 | volatility -f [image] --profile=[OS Profile] yarascan -p [pid] --yara-rules="[strings]" |
||
423 | |||
424 | # Misc |
||
425 | volatility -f [image] --profile=[OS Profile] objtypescan # Object Acan |
||
426 | volatility -f [image] --profile=[OS Profile] Volshell # Volshell |
||
427 | volatility -f [image] --profile=[OS Profile] iehistory # IEの履歴 |
||
428 | ``` |
||
429 | |||
430 | |||
431 | # FileSystem |
||
432 | |||
433 | ## ファイルシステムソムリエ |
||
434 | |||
435 | Gentoo metalog - ファイルシステムソムリエになる話 |
||
436 | http://gentoo.hatenablog.com/entry/2016/06/17/020107 |
||
437 | |||
438 | Linux ファイルシステムを理解したい |
||
439 | https://www.kimullaa.com/entry/2019/12/01/130347 |
||
440 | |||
441 | |||
442 | |||
443 | ## [FATファイルシステム](http://memes.sakura.ne.jp/memes/?page_id=2390) |
||
444 | |||
445 | FATファイルシステム(その1) |
||
446 | http://memes.sakura.ne.jp/memes/?page_id=2303 |
||
447 | |||
448 | FATファイルシステム(その2) |
||
449 | http://memes.sakura.ne.jp/memes/?page_id=2402 |
||
450 | |||
451 | Qiita - FAT12,FAT16の構造(予約領域編) |
||
452 | https://qiita.com/iria_piyo/items/d949b93bc056a8c370d6 |
||
453 | |||
454 | |||
455 | |||
456 | ## FAT16 |
||
457 | |||
458 | 参考 - ねんどろいど伊401に時報を喋らせるガジェットを作ってみた |
||
459 | http://tech.recruit-mp.co.jp/gadget/pic-inside-i401/ |
||
460 | |||
461 | |||
462 | |||
463 | ## NTFS |
||
464 | |||
465 | ### VSS削除後の復元 |
||
466 | |||
467 | https://github.com/mnrkbys/vss_carver |
||
468 | |||
469 | ### USNジャーナル(ファイルのwriteの記録) |
||
470 | |||
471 | CDI 山崎さんのUSNジャーナルの分析ツールの発表。クオリティが半端ないw |
||
472 | |||
473 | 本家 |
||
474 | https://github.com/simsong/bulk_extractor |
||
475 | |||
476 | カービングツール |
||
477 | https://www.kazamiya.net/bulk_extractor-rec |
||
478 | |||
479 | 分析ツール |
||
480 | https://www.kazamiya.net/usn_analytics/ |
||
481 | |||
482 | 資料はこちら |
||
483 | https://www.jpcert.or.jp/event/jsac2018.html |
||
484 | |||
485 | >シグネチャとして固定部分(ヘッダ:USN_RECORD_V2)/ レコード長 / ファイル名の長さを使用している。 |
||
486 | |||
487 | Python script to parse the NTFS USN Journal |
||
488 | https://github.com/PoorBillionaire/USN-Journal-Parser |
||
489 | |||
490 | |||
491 | |||
492 | |||
493 | |||
494 | ## ext |
||
495 | |||
496 | Qiita - 知っておきたいLinuxファイルシステムの概念 |
||
497 | https://qiita.com/Rairaiden/items/539d429729d5819de0aa |
||
498 | |||
499 | |||
500 | |||
501 | |||
502 | |||
503 | |||
504 | |||
505 | |||
506 | |||
507 | |||
508 | |||
509 | # Magic Number |
||
510 | |||
511 | trid(コマンドかオンラインでファイルを判別するツール) |
||
512 | http://mark0.net/onlinetrid.aspx |
||
513 | |||
514 | File Signature Database |
||
515 | http://www.filesignatures.net/index.php?page=search |
||
516 | |||
517 | http://www.astro.keele.ac.uk/oldusers/rno/Computing/File_magic.html |
||
518 | |||
519 | ## 実行形式 |
||
520 | |||
521 | | ファイルフォーマット | HEX | ASCII | Note | |
||
522 | |----------------------|---------|-------|------| |
||
523 | | ELF | 7F | | |
||
524 | | PE(.exe .dll .ocx .scr .cpl .com .fon) | 4D 5A | MZ | 頭の方(0x80~0xf0のあたり)が 50 40 00 00 4C 01 で32bit 50 40 00 00 64 86 で64bit PE(50 40)から始まっているので、見つけやすい |
||
525 | | Javaクラスファイル | CA FE BA BE | | |
||
526 | | gzip | 1F 8B | | |
||
527 | | Compress(.Z) | 1F 9D | | |
||
528 | | Bzip(.bz) | 42 5a | BZ | |
||
529 | | zip | 50 4B | PK | |
||
530 | | TAR (pre-POSIX) | | (a filename) | |
||
531 | | TAR (POSIX) | 75 73 74 61 72 | ustar | |
||
532 | | zip | 50 4B 03 04 | PK | 終端は PK 0x05 0x06 の後ろに18Byte コメントが付けられるので可変長ではある |
||
533 | | zlib | 78 9c | | 78 DA や 78 01 の場合も?ある |
||
534 | | LHA(lh0) | ?? ?? 2D 6C 68 30 2D | ??-lh0- | |
||
535 | | LHA(lh4) | ?? ?? 2D 6C 68 34 2D | ??-lh4- | |
||
536 | | LHA(lh5) | ?? ?? 2D 6C 68 35 2D | ??-lh5- | |
||
537 | | 7z | 37 7A BC AF 27 1C | 7z | |
||
538 | | xz | fd 37 7a 58 5a 00 | ?7zXZ | |
||
539 | | cab | 4d 53 43 46 | MSCF | |
||
540 | | RAR | 52 61 72 21 | Rar! | |
||
541 | | Jpeg | FF D8 FF E0 ?? ?? 4A 46 49 46 | ??????JFIF | 終端は FF D9 "・ル" |
||
542 | | PNG | 89 50 4E 47 | ?PNG → 臼NG | 終端は 00 00 00 00 49 45 4E 44 AE 42 60 82 "IENDョB`" |
||
543 | | WebP | 52 49 46 46 ?? ?? ?? ?? 57 45 42 50 | RIFF????WEBP | ????はファイルサイズ |
||
544 | | HEIF(HEIC) | ?? ?? ?? ?? 66 74 79 70 | ??????ftypmif1????mif1heichevc | ftypとheicという文字が見えるとHEIFっぽい |
||
545 | | GIF(89a) | 47 49 46 38 39 61 | GIF89a | 終端は 3B |
||
546 | | GIF(87a) | 47 49 46 38 37 61 | GIF87a | |
||
547 | | BMP | 42 4D | BM | |
||
548 | | BGP | 42 50 47 fb 20 00 | BGP | |
||
549 | | TIFF | 49 49 または 4d 4d | II または MM | 「4D 4D」なら上位から下位バイトへ読み、「49 49」なら下位から上位バイトで読みます |
||
550 | | Postscript | 25 21 | %! | |
||
551 | | Microsoft Offic e | D0 CF 11 E0 A1 B1 1A E1 || |
||
552 | | PDF | 25 50 44 46 2D | %PDF-バージョン番号 | |
||
553 | | wav | 52 49 46 46 | RIFF |
||
554 | | swf | 43 57 53 または 46 53 57 | CSW または FSW |
||
555 | | wma | 30 26 | 0& |
||
556 | | pgp public ring | 99 00 | | |
||
557 | | pgp security ring | 95 01 | | |
||
558 | | pgp security ring | 95 00 | | |
||
559 | | pgp encrypted data | a6 00 | | |
||
560 | | pcap(tcpdump) | d4 c3 b2 a1 | ヤテイ。 | |
||
561 | |||
562 | |||
563 | # Repair |
||
564 | |||
565 | 文字化けリペア |
||
566 | >=?ISO-2022-JP?B?GyRCJD8hIxsoQg==?= のような件名など |
||
567 | From, Subjectなどの読めないヘッダを修復 |
||
568 | >>http://purl.org/net/masaka/mr/mime.php |
||
569 | |||
570 | >$B$3$l$O(JJIS$B$NJ8$G$9!#(Jのような文字化け |
||
571 | 文字化けしている本文の修復 |
||
572 | >>http://purl.org/net/masaka/mr/jmr.php |
||
573 | |||
574 | >こん...のような、 '&#' と ';' に数字が挟まれたコードが連続する本文 |
||
575 | Unicode文字参照になっている本文の解読 |
||
576 | >>http://purl.org/net/masaka/mr/r2u.php |
||
577 | |||
578 | pcapリペア |
||
579 | http://f00l.de/hacking/pcapfix.php |
||
580 | |||
581 | zipリペア |
||
582 | http://www.gigafree.net/utility/archive/diskinternalsziprepair.html |
||
583 | |||
584 | ---- |
||
585 | |||
586 | Foremost ファイル復元方法(Linux編) |
||
587 | http://brand-jin.tk/?p=463 |
||
588 | |||
589 | foremostというバイナリファイルの中からファイルを復元できるツール |
||
590 | https://github.com/kira924age/CTF/tree/master/SECCON2014%E3%82%AA%E3%83%B3%E3%83%A9%E3%82%A4%E3%83%B3%E4%BA%88%E9%81%B8(%E6%97%A5%E6%9C%AC%E8%AA%9E)/%E6%8D%8F%E9%80%A0%E3%81%95%E3%82%8C%E3%81%9F%E5%A5%91%E7%B4%84%E6%9B%B8%E3%82%92%E6%9A%B4%E3%81%91 |
||
591 | |||
592 | 俺的備忘録 〜なんかいろいろ〜 - バイナリやファイル、ディスクから中のデータを抽出・復元する『foremost』コマンド |
||
593 | https://orebibou.com/2017/04/%e3%83%90%e3%82%a4%e3%83%8a%e3%83%aa%e3%82%84%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%80%81%e3%83%87%e3%82%a3%e3%82%b9%e3%82%af%e3%81%8b%e3%82%89%e4%b8%ad%e3%81%ae%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92/ |
||
594 | |||
595 | ``` |
||
596 | $ ./foremst -t all -i Timestamp.dd |
||
597 | ``` |
||
598 | |||
599 | 「PhotoRec」の使い方 ファイル復元ソフト |
||
600 | https://pctrouble.net/software/photorec.html |
||
601 | |||
602 | |||
603 | |||
604 | |||
605 | |||
606 | |||
607 | # ファイル解析 |
||
608 | |||
609 | rga: ripgrep, but also search in PDFs, E-Books, Office documents, zip, tar.gz, etc. |
||
610 | https://phiresky.github.io/blog/2019/rga--ripgrep-for-zip-targz-docx-odt-epub-jpg/ |
||
611 | |||
612 | >これが全般的に使えるんじゃないかと気になっている |
||
613 | >pdfやdocx、sqlite、画像や動画のメタデータなどを全部grepできるツール |
||
614 | |||
615 | ## pdfの解析 |
||
616 | |||
617 | PDF中の画像ファイルのみを抽出する |
||
618 | https://qiita.com/aokomoriuta/items/066b760a28da461531b6 |
||
619 | |||
620 | >libre Office Draw でpdfが編集できる |
||
621 | |||
622 | peepdf - PDF Analysis Tool |
||
623 | http://eternal-todo.com/tools/peepdf-pdf-analysis-tool |
||
624 | |||
625 | > Kali Linux に同梱されている |
||
626 | |||
627 | >かわろぐ - peepdf を使って攻撃コードの入ったPDFを解析してみた |
||
628 | >http://blog.kawa-xxx.jp/entry/2016/09/19/165709 |
||
629 | |||
630 | PDF Stream Dumper [使用例](http://ameblo.jp/norio001/entry-11372965347.html) |
||
631 | http://sandsprite.com/blogs/index.php?uid=7&pid=57 |
||
632 | |||
633 | PDFからテキストを抽出するプログラム |
||
634 | https://osdn.jp/users/mocchi_2012/pf/mocchi_stack_room/wiki/extract_pdf |
||
635 | |||
636 | >pdfファイル中のstream~endstream間は、zlib圧縮されてたりするのだが、展開くれて、json形式で出力してくれる。 |
||
637 | |||
638 | プログラムモグモグ - 詳細PDF入門 ー 実装して学ぼう!PDFファイルの構造とその書き方読み方 |
||
639 | http://itchyny.hatenablog.com/entry/2015/09/16/100000 |
||
640 | |||
641 | corkami - PDFのトリックに関するレジュメ - エンコーディング,構成,JavaScriptなど |
||
642 | https://code.google.com/p/corkami/wiki/PDFTricks |
||
643 | |||
644 | pdfcrack |
||
645 | http://pdfcrack.sourceforge.net/ |
||
646 | |||
647 | >あと[辞書](https://wiki.skullsecurity.org/index.php?title=Passwords) |
||
648 | |||
649 | evince |
||
650 | https://ja.wikipedia.org/wiki/Evince |
||
651 | |||
652 | >コピー禁止とか無視できたりする |
||
653 | |||
654 | |||
655 | |||
656 | |||
657 | |||
658 | |||
659 | ## pngの解析 |
||
660 | |||
661 | [pngcheck](https://www.google.co.jp/search?&hl=ja&lr=lang_ja&q=pngcheck&cad=h) |
||
662 | |||
663 | |||
664 | |||
665 | ## Office形式のファイル解析 |
||
666 | |||
667 | OfficeMalScanner |
||
668 | http://www.reconstructer.org/ |
||
669 | |||
670 | 73spica's Blog - EKOPARTY CTF 2016 Write-up |
||
671 | http://73spica.tech/blog/ekoparty-ctf-2016-write-up/ |
||
672 | |||
673 | Github - MalwareCantFly/Vba2Graph (VBAの解析・可視化) |
||
674 | https://github.com/MalwareCantFly/Vba2Graph |
||
675 | |||
676 | ## zlibの解析 |
||
677 | |||
678 | 展開は、以下でできる。 |
||
679 | |||
680 | ``` |
||
681 | $ cat src.bin |openssl zlib -d >dest.bin |
||
682 | ``` |
||
683 | |||
684 | zpipeでも可 |
||
685 | |||
686 | ``` |
||
687 | $ zpipe < src.bin > dest.bin #圧縮 |
||
688 | $ zpipe -d < src.bin > dest.bin #伸張 |
||
689 | ``` |
||
690 | |||
691 | pythonシェル芸だとこう |
||
692 | |||
693 | ```python |
||
694 | python -c 'import zlib; print zlib.decompress(open("File").read())' |
||
695 | ``` |
||
696 | |||
697 | |||
698 | |||
699 | バイナリからzlib圧縮データを探す |
||
700 | http://teraapi.blogspot.jp/2012/05/zlib.html |
||
701 | |||
702 | ``` |
||
703 | よくある: |
||
704 | 78 01, 78 5e, 78 9c, 78 da |
||
705 | |||
706 | 稀 : |
||
707 | 08 1d, 08 5b, 08 99, 08 d7, 18 19, 18 57, 18 95, 18 d3, |
||
708 | 28 15, 28 53, 28 91, 28 cf, 38 11, 38 4f, 38 8d, 38 cb, |
||
709 | 48 0d, 48 4b, 48 89, 48 c7, 58 09, 58 47, 58 85, 58 c3, |
||
710 | 68 05, 68 43, 68 81, 68 de |
||
711 | |||
712 | 極稀: |
||
713 | 08 3c, 08 7a, 08 b8, 08 f6, 18 38, 18 76, 18 b4, 18 f2, |
||
714 | 28 34, 28 72, 28 b0, 28 ee, 38 30, 38 6e, 38 ac, 38 ea, |
||
715 | 48 2c, 48 6a, 48 a8, 48 e6, 58 28, 58 66, 58 a4, 58 e2, |
||
716 | 68 24, 68 62, 68 bf, 68 fd, 78 3f, 78 7d, 78 bb, 78 f9 |
||
717 | ``` |
||
718 | |||
719 | ### 引数のファイルに含まれるzlib圧縮部分を抽出・展開してファイルに保存する |
||
720 | |||
721 | 自作ツール。CentOSで動作確認済み。Kali Linuxだとopensslでzlibのdecodeが出来なかったので、たぶん、Debian でも動かないかも。 |
||
722 | まぁ、zpipeで代替すれば、どの環境でも行けるはず。 |
||
723 | ちなみに、動作はめっちゃ遅い。 |
||
724 | |||
725 | attachment:zlib_extraction.sh |
||
726 | |||
727 | ```bash |
||
728 | #!/bin/bash |
||
729 | |||
730 | # zlib_extraction.sh ver 2.0 |
||
731 | # 引数のファイルに含まれるzlib圧縮部分を抽出・展開してファイルに保存する |
||
732 | # 2015.10.06 kanata |
||
733 | |||
734 | if [ ! -f "${1}" ] |
||
735 | then |
||
736 | echo "file open error ($1)" |
||
737 | exit 1 |
||
738 | fi |
||
739 | |||
740 | if echo "${2}" |egrep '(BOOST|boost|Boost)' >/dev/null |
||
741 | then |
||
742 | MODE="BOOST_MODE" |
||
743 | else |
||
744 | MODE="NORMAL_MODE" |
||
745 | fi |
||
746 | |||
747 | |||
748 | FILESIZE=`ls -l ${1}|awk '{print $5}'` |
||
749 | ZLIBPART="${1##*/}" |
||
750 | ZLIBPART="${ZLIBPART%.*}" |
||
751 | I="0" |
||
752 | FORK_COUNT="0" |
||
753 | |||
754 | if [ "${MODE}" = "NORMAL_MODE" ] |
||
755 | then |
||
756 | #--------------# |
||
757 | # シリアル処理 # |
||
758 | #--------------# |
||
759 | while [ "${I}" -lt "${FILESIZE}" ] |
||
760 | do |
||
761 | ZLIBPART_FILE="${ZLIBPART}_${I}.bin" |
||
762 | cat ${1} | dd bs=1 skip=${I} | openssl zlib -d > ${ZLIBPART_FILE} 2>/dev/null |
||
763 | |||
764 | if [ -s ${ZLIBPART_FILE} ] |
||
765 | then |
||
766 | file ${ZLIBPART_FILE} |
||
767 | else |
||
768 | rm -f ${ZLIBPART_FILE} |
||
769 | fi |
||
770 | |||
771 | echo -ne "checking.. "`printf "%d/%d" "${I}" "${FILESIZE}"`" \r" |
||
772 | I=$(( I + 1 )) |
||
773 | done |
||
774 | |||
775 | else |
||
776 | #----------# |
||
777 | # 並列処理 # |
||
778 | #----------# |
||
779 | while [ "${I}" -lt "${FILESIZE}" ] |
||
780 | do |
||
781 | ZLIBPART_FILE="${ZLIBPART}_${I}.bin" |
||
782 | ( cat ${1} | dd bs=1 skip=${I} | openssl zlib -d > ${ZLIBPART_FILE} 2>/dev/null ; if [ -s ${ZLIBPART_FILE} ] ; then file ${ZLIBPART_FILE} ; else rm -f ${ZLIBPART_FILE} ; fi )& |
||
783 | |||
784 | # 並列実行時のサブシェルが増大していくのを抑止 |
||
785 | # 同時35多重までに抑止 25回に1度チェック ( 数値を弄ってチューニングできます ) |
||
786 | if [ $(( I % 25 )) -eq "0" ] ; then FORK_COUNT=`ps -u |fgrep -c ${0}` ; fi |
||
787 | while [ "${FORK_COUNT}" -gt "35" ] |
||
788 | do |
||
789 | printf "[WARNING] SubProcess Exceed Limit. fork:%s offset:%s\n" ${FORK_COUNT} ${I} |
||
790 | FORK_COUNT=`ps -u |fgrep -c ${0}` |
||
791 | done |
||
792 | |||
793 | echo -ne "checking.. "`printf "%d/%d" "${I}" "${FILESIZE}"`" \r" |
||
794 | I=$(( I + 1 )) |
||
795 | done |
||
796 | |||
797 | fi |
||
798 | |||
799 | exit 0 |
||
800 | ``` |
||
801 | |||
802 | ### その他の展開方法 |
||
803 | |||
804 | zlib.exe - zlib でデータを圧縮/展開するだけのプログラム |
||
805 | http://cetus.sakura.ne.jp/softlab/toolbox2/#zlibexe |
||
806 | |||
807 | 各プログラム言語でのコーディング方法サンプル - Zlib Decompress |
||
808 | http://swiftapi.com/api/Zlib_Decompress |
||
809 | |||
810 | ```python |
||
811 | $ python -c 'import zlib; print zlib.decompress(open("/directory/file").read())' |
||
812 | ``` |
||
813 | |||
814 | |||
815 | ## DXアーカイブ(data.dxa)の展開 |
||
816 | |||
817 | henteko - 2012TeResAI(DXアーカイブの展開ができる) |
||
818 | https://github.com/henteko/2012TeResAI/tree/master/2012TeResAI/2012teresAI/DX%20lib/DxLib_VC/Tool/DXArchive |
||
819 | |||
820 | ## Macの.DS_Storeの解析 |
||
821 | |||
822 | Python .DS_Store parser |
||
823 | https://github.com/gehaxelt/Python-dsstore |
||
824 | |||
825 | ## PEファイルフォーマット |
||
826 | |||
827 | PE(Portable Executable)ファイルフォーマットの基本構造 めも |
||
828 | https://task4233.dev/article/20200101_pefile.html#pe-portable-executable-format |
||
829 | |||
830 | |||
831 | |||
832 | |||
833 | |||
834 | |||
835 | |||
836 | # 動画解析 |
||
837 | |||
838 | ## 動画差分 |
||
839 | |||
840 | 動画のフレームごとの差を求めて変化してた場合に保存するプログラム |
||
841 | https://github.com/teatime13/search_movie_diff |
||
842 | |||
843 | ## 比較明合成 |
||
844 | |||
845 | [SiriusComp](http://phaku.net/siriuscomp/)を使う |
||
846 | |||
847 | ## テンプレートマッチング |
||
848 | |||
849 | Qiita - SECCON 2018 Online CTF Needle in a haystack テンプレートマッチングで照明点灯判定を自動化する |
||
850 | https://qiita.com/DoranekoSystems/items/f2fd95fb9ff4ddea369f |
||
851 | |||
852 | |||
853 | |||
854 | # Memo |
||
855 | |||
856 | アンタイ・フォレンジック伝道者の独り言 - NTFS 代替データストリームとは? |
||
857 | http://port139.hatenablog.com/entries/2005/09/08 |
||
858 | |||
859 | FOCA - 文書のスキャンでメタデータと隠された情報を検索するためのツール |
||
860 | https://www.elevenpaths.com/labstools/foca/ |
||
861 | |||
862 | φ(・・*)ゞ ウーン カーネルとか弄ったりのメモ - ext4:ディスクレイアウト調査中めも1 |
||
863 | http://kernhack.hatenablog.com/entry/2014/01/28/230808 |
||
864 | |||
865 | 俺的備忘録 〜なんかいろいろ〜 - fuseを使ってファイルシステムをモニタリングできる『loggedfs』 |
||
866 | https://orebibou.com/2017/04/fuse%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%82%b7%e3%82%b9%e3%83%86%e3%83%a0%e3%82%92%e3%83%a2%e3%83%8b%e3%82%bf%e3%83%aa%e3%83%b3%e3%82%b0%e3%81%a7%e3%81%8d/ |
||
867 | |||
868 | > CTFでのバイナリ実行の挙動を追いかけるのに便利そう |
||
869 | |||
870 | Visualizing ELF binaries |
||
871 | https://reverseengineering.stackexchange.com/questions/6003/visualizing-elf-binaries |
||
872 | |||
873 | Ubuntu で $ rm ~/.bashrc を実行してしまった - Linuxで誤って削除したファイルの復活の話 |
||
874 | https://blog.fenrir-inc.com/jp/2017/10/resurrected_rm_files.html |
||
875 | |||
876 | Automate Linux Swap Analysis: swap_digger - Linux Swap解析ツール(Bashスクリプト)。SwapからLinuxアカウント情報、ウェブアカウント情報、BASIC認証、WiFi SSID・鍵等が取得可能。フォレンジック調査・ペンテスト用。 |
||
877 | https://n0where.net/automate-linux-swap-analysis-swap_digger/ |
||
878 | |||
879 | SANS DFIR Windows Forensic Analysis POSTER |
||
880 | https://www.sans.org/security-resources/posters/windows-forensic-analysis/170/download |
||
881 | |||
882 | Shi0shishi0 - Defcon DFIR CTF 2018 Writeup(HR Server + File Server) |
||
883 | http://ecoha0630.hatenablog.com/entry/2018/11/22/180306 |
||
884 | |||
885 | Windows 10 Timeline 解析記事のメモ |
||
886 | https://soji256.hatenablog.jp/entry/2019/10/05/153559?utm_source=feed |
||
887 | |||
888 | DFIR や Malware 解析などについての記事まとめ(2019年10月~2019月12月) |
||
889 | https://soji256.hatenablog.jp/entry/2020/01/16/082000 |
||
890 | |||
891 | Windowsイベントログ解析ツール「Hayabusa」を使ってみる |
||
892 | https://itib.hatenablog.com/entry/2021/12/31/222946 |
||
893 | |||
894 | 競技セキュリティまとめのまとめ |
||
895 | https://blog.hamayanhamayan.com/entry/2023/02/22/085938 |