プロジェクト

全般

プロフィール

CTF Forensic » 履歴 » リビジョン 2

リビジョン 1 (kanata, 2025/04/13 14:34) → リビジョン 2/4 (kanata, 2025/04/13 14:34)

# CTF Forensic 

 {{rawhtml(<canvas id="map"></canvas><script src="/javascripts/pagemap.min.js"></script><script>pagemap(document.querySelector("#map"));</script>)}} 

 {{toc}} 

 # Command gadgets 

 - ハッシュ値生成 

 md5sum sha1sum sha224sum sha256sum 

 ## find 

 通常のファイル検索 

 ``` 
 find `pwd` -name "${1}" -print 2>/dev/null 
 ``` 

 どんな種類のファイルがあるか検索 

 ``` 
 find ./ | xargs file 
 ``` 

 ## xz 

 圧縮 

 ``` 
 xz -zk ファイル 
 ``` 

 展開 

 ``` 
 unxz -dk ファイル 
 ``` 

 ## ディスクイメージからzipファイルを抜き出す(python) 

 dは1個目、yは二個目 

 ``` 
 $python 
 >>> d = open("入力ファイル名","rb").read() 
 >>> z = d[d.find("PK\x03\x04"):d.find("PK\x05\x06")+22] 
 >>> len(z) 
 >>> open("出力ファイル名","wb").write(d[d.find("PK\x03\x04"):d.find("PK\x05\x06")+22]) 
 >>> y = d[d.find("PK\x05\x06")+22:] 
 >>> open("出力ファイル名","wb").write(y[y.find("PK\x03\x04"):y.find("PK\x05\x06")+22]) 
 ``` 

 ## gzipファイルに付けられたコメントを表示する 

 標準的なコマンドがない。ただ、 

 - ファイル名 
 - NULL(0x00) 
 - コメント 

 というフォーマットになっているので、がんばれは読めると思われる。 

 参考:http://www.gzip.org/zlib/rfc-gzip.html 

 ちなみにコメントの有無は、fileコマンドで 

 ``` 
 comment, 
 ``` 

 が出てきたらコメント在り。 

 ## zipファイルに付けられたコメントを表示する 

 zipの中のファイル毎にコメントを付けられる仕様。あんまり使われてないけど。 

 ``` 
 unzip -lz a.zip 
 ``` 

 ## Exif情報を取得する 

 ImageMagickでExif情報を取得するには、identifyコマンドを使う。  

 ``` 
 identify -verbose a.jpg 
 ``` 

 ## ddコマンドで保存したイメージファイルをマウントする  

 ``` 
 % sudo fdisk -u -l disk_20130530-1400.img 

 ディスク acid_20130530-1400.img: 4012 MB, 4012900352 バイト 
 ヘッド 255, セクタ 63, シリンダ 487, 合計 7837696 セクタ 
 Units = セクタ数 of 1 * 512 = 512 バイト 
 セクタサイズ (論理 / 物理): 512 バイト / 512 バイト 
 I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト 
 ディスク識別子: 0x00014d34 

 デバイス ブート 始点 終点 ブロック Id システム 
 disk_20130530-1400.img1 8192 122879 57344 c W95 FAT32 (LBA) 
 disk_20130530-1400.img2 122880 7774207 3825664 83 Linux 

 % sudo mount -o loop,offset=$((512*122880)) disk_20130530-1400.img /mnt 
 ``` 

 ## 時刻指定でgrepする 

 find_by_date.sh 

 ``` 
 #!/bin/sh 

 DATE_FROM="201504250000.00" 
 DATE_TO="201504262359.59" 

 touch -t $DATE_FROM /tmp/tmp_date_from.$$ 
 touch -t $DATE_TO     /tmp/tmp_date_to.$$ 

 find $SEARCH_PATH -type f -newer /tmp/tmp_date_from.$$ ! -newer /tmp/tmp_date_to.$$ -ls; 

 exit 0 
 ``` 

 grep_by_date.sh 

 ``` 
 #!/bin/sh 

 LIST=`/usr/local/bin/find_by_date.sh $1 $2 $3|awk '{print $NF'}` 

 for WORD in ${LIST} 
 do 
         grep $4 ${WORD} 2>/dev/null 
         if [ $? = "0" ] 
         then 
                 echo "########## ${WORD} is founded ##########" 
         fi 
 done 

 exit 0 
 ``` 

 ## 画像ファイルのEXIF情報を取得する 

 ```bash  
 $ identify -verbose ファイルPATH 
 ``` 

 [俺的備忘録 〜なんかいろいろ〜 - コンソール上で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/) 











 # WebService / Application 

 ## Online TrID File Identifier 

 http://mark0.net/onlinetrid.aspx 

 ## binvis.io - バイナリビューア 

 http://binvis.io/#/ 




 # Setup 

 ## hachoir-subfile のインストール 

 CentOSへの[hachoir-subfile](https://bitbucket.org/haypo/hachoir/wiki/hachoir-subfile)のインストール 

 ``` 
 $ cd /home/user/PythonSandBox 
 $ source bin/activate # virtualenvによる仮想環境に移行 

 (PythonSandBox)$ cd tmp 
 (PythonSandBox)$ mkdir hachoir 
 (PythonSandBox)$ hachoir 
 (PythonSandBox)$ wget http://cheeseshop.python.org/packages/source/h/hachoir-core/hachoir-core-1.3.3.tar.gz 
 (PythonSandBox)$ wget http://cheeseshop.python.org/packages/source/h/hachoir-parser/hachoir-parser-1.3.4.tar.gz 
 (PythonSandBox)$ wget http://cheeseshop.python.org/packages/source/h/hachoir-metadata/hachoir-metadata-1.3.3.tar.gz 
 (PythonSandBox)$ wget http://cheeseshop.python.org/packages/source/h/hachoir-urwid/hachoir-urwid-1.1.tar.gz 
 (PythonSandBox)$ wget http://cheeseshop.python.org/packages/source/h/hachoir-wx/hachoir-wx-0.3.tar.gz 
 (PythonSandBox)$ wget http://cheeseshop.python.org/packages/source/h/hachoir-subfile/hachoir-subfile-0.5.3.tar.gz 
 (PythonSandBox)$ wget http://cheeseshop.python.org/packages/source/h/hachoir-regex/hachoir-regex-1.0.5.tar.gz 
 ``` 

 次に、ダウンロードした全てのファイルをtar xvfzで展開。その中に入っているsetup.py全てについて 

 ``` 
 (PythonSandBox)$./setup.py build 
 (PythonSandBox)$./setup.py install 
 ``` 

 を実施する。順番はあんまり関係ないみたい 

 ## zpipeのインストール 

 zlib部分の圧縮・伸張ができるプログラム 

 使い方 

 ``` 
 $ zpipe < src.bin > dest.bin      #圧縮 
 $ zpipe -d < src.bin > dest.bin #伸張 
 ``` 

 注: deflateInitで圧縮されたzlib圧縮データのことである。deflateInit2でGZIP圧縮されたデータではない。 

 ビルド方法 

 ``` 
 $ cd /tmp 
 $ git clone https://github.com/madler/zlib 
 $ cd zlib 
 $ ./configure 
 $ make 
 $ cd examples 
 $ gcc zpipe.c -lz -o zpipe 
 ``` 




 # フォレンジック調査で使用するマウント関連のコマンド  

 http://sec-v6.blogspot.jp/2013/03/blog-post.html 

 ## ディスクイメージをそのままマウントする 

 ``` 
 mount [image_file] [mount_point] 
 ``` 

 ## 特定のパーティションをマウントする 

 ディスクイメージの中の特定パーティションのみマウントするにはまずオフセットを調べる。 
 オフセットを調べるには fdisk または mmls を使用する。 

 ``` 
 fdisk -lu [image_file] 
 mmls [image_file] 
 ``` 

 mmls は sleuthkit.org で開発されている sleuthkit に入っているコマンド。SIFT ではデフォルトで使用可能。 
 マウントしたいパーティションの start となっている数値にセクタサイズ(通常512)をかけた数が offset となり、この値を mount コマンドで指定する。 

 ``` 
 mount -o loop,offset=[start*512] [image_file] [mount_point] 
 ``` 

 フォレンジック調査なら読み取り専用のオプション -o ro loop、ファイルタイプとして -t ntfs とか nls=utf8 とか付け加える。 

 ## E01 イメージの取り扱い 

 EnCase image file format で保全されたディスクイメージを扱いたい場合にいは SIFT に入っている ewfmount を使う。 
 ewfmount により E01 イメージを dd イメージで操作できる。 

 ``` 
 ewfmount [e01_image_file] [mount_point] 
 ``` 

  E01 イメージが一つではなく複数に分割されている場合は末尾がE01のファイルを指定するだけ。  
 この状態で [mount_point] 配下に ewf1 という dd イメージファイルができ、それをマウントすることができる。 アンマウントは通常通り umount コマンドでできる。 

 ## イメージディスクの作成 
 イメージディスクの作成は下記コマンドで実行。 

 ``` 
 dd if=[input_disk] of=[output_file] bs=512 obs=1024k count=[number] conv=sync,noerror  
 ``` 

 # メモリフォレンジック 

 ## volatility 

 [volatility](http://www.volatilityfoundation.org/)一択 

 >ちなみにこの分野は日本語書籍がほぼ無い 

 1. imageinfoオプションで、OS判別してvolatilityのプロファイルを特定 
 2. その上で、各種コマンドを叩いて調べる 
 3. [SANSのチートシート](https://digital-forensics.sans.org/media/poster_2014_find_evil.pdf)から怪しいプロセスを発見するのがまず一歩か 

 > 1個しかないプロセスが複数あるとか、親プロセスがおかしいとか 


  * dllの読み込みは、false false false だったら怪しい、true    false true    は正常な可能性が高い 

 >> DLLの隠蔽、DLLのリンクは三種類の双方向リストで管理されており、これを細工して隠蔽できる 

  * 後述のstringsコマンドで抽出した文字列を、volatilityを使ってメモリイメージと紐付けられる。それをgrepでいろいろ見る。 


 ``` 
 # Help 
 volatility -h 
 volatility pslist --help 

 # Info これでOSを特定する 
 volatility -f [image] imageinfo 

 $ volatility    -f win7_trial_64bit.raw imageinfo 
 Volatility Foundation Volatility Framework 2.4 
 Determining profile based on KDBG search... 

           Suggested Profile(s) : Win7SP0x64, Win7SP1x64, Win2008R2SP0x64, Win2008R2SP1x64 
                      AS Layer1 : AMD64PagedMemory (Kernel AS) 
                      AS Layer2 : FileAddressSpace (/Users/Michael/Desktop/win7_trial_64bit.raw) 
                       PAE type : PAE 
                            DTB : 0x187000L 
                           KDBG : 0xf80002803070 
           Number of Processors : 1 
      Image Type (Service Pack) : 0 
                 KPCR for CPU 0 : 0xfffff80002804d00L 
              KUSER_SHARED_DATA : 0xfffff78000000000L 
            Image date and time : 2012-02-22 11:29:02 UTC+0000 
      Image local date and time : 2012-02-22 03:29:02 -0800 
 ``` 

 >この場合、プロファイルは Win7SP0x64 か Win2008R2SP0x64 (Image Type (Service Pack) : 0 から絞り込める) 


 ``` 
 # Process 
 volatility -f [image] --profile=[OS Profile] pslist 
 volatility -f [image] --profile=[OS Profile] psscan 
 volatility -f [image] --profile=[OS Profile] pstree 
 volatility -f [image] --profile=[OS Profile] psxview 
 volatility -f [image] --profile=[OS Profile] psxview --apply-rules 

 # Network 
 volatility -f [image] --profile=[OS Profile] netscan #Vista以降 
 volatility -f [image] --profile=[OS Profile] connections # 
 volatility -f [image] --profile=[OS Profile] connscan      # 
 volatility -f [image] --profile=[OS Profile] sockscan      # 

 # Registry 
 volatility -f [image] --profile=[OS Profile] hivelist 
 volatility -f [image] --profile=[OS Profile] printkey -K "[registry key]" 
 volatility -f [image] --profile=[OS Profile] userassist 
 volatility -f [image] --profile=[OS Profile] shellbags 
 volatility -f [image] --profile=[OS Profile] shellbags --output-file=[shellbags.body] --output=body 
 volatility -f [image] --profile=[OS Profile] shimcache 
 volatility -f [image] --profile=[OS Profile] getsids --offset [address] 
 volatility -f [image] --profile=[OS Profile] privs --offset [address] 
 volatility -f [image] --profile=[OS Profile] hashdump 
 volatility -f [image] --profile=[OS Profile] lsadump 

 # Command history 
 volatility -f [image] --profile=[OS Profile] cmdscan 
 volatility -f [image] --profile=[OS Profile] consoles 

 # DLL 
 volatility -f [image] --profile=[OS Profile] dlllist 
 volatility -f [image] --profile=[OS Profile] handles -p [pid] -t File 
 volatility -f [image] --profile=[OS Profile] handles -p [pid] -t Key 
 volatility -f [image] --profile=[OS Profile] handles -p [pid] -t Directory 
 volatility -f [image] --profile=[OS Profile] handles -p [pid] -t Port 
 volatility -f [image] --profile=[OS Profile] handles -p [pid] -t Mutant 
 volatility -f [image] --profile=[OS Profile] handles --offset [address] 

 # evtlog 
 volatility -f [image] --profile=[OS Profile] evtlogs -D [Directory] 
 volatility -f [image] --profile=[OS Profile] evtlogs --save-evt -D [Directory] 

 # Service 
 volatility -f [image] --profile=[OS Profile] svcscan 

 # FileSystem 
 volatility -f [image] --profile=[OS Profile] mftparser --output-file=[outfile.txt] 
 volatility -f [image] --profile=[OS Profile] mftparser --output-file=[outfile.txt] --output=body # body形式は別のソフトで読める 

 # Dump 
 volatility -f [image] --profile=[OS Profile] dlldump -p [pid] -D [Directory] 
 volatility -f [image] --profile=[OS Profile] procdump -p [pid] -D [Directory] 
 volatility -f [image] --profile=[OS Profile] dumpfiles -r .evtx$ --ignore-case -D [Directory] 
 procdump -p [pid] --dump-dir=/tmp 
 photorec /d [Directory] [image] 

 # Timeline 
 volatility -f [image] --profile=[OS Profile] timeliner --output-file=timeliner.body --output=body 

  # bodyファイルは結合できる 
  cat [BodyFile.1] [BodyFile.2] [BodyFile.3] > [BodyFile] 

  # mactime 
  mactime --help 
  mactime -b [BodyFile] -d -z UTC 

 # Vad 
 volatility -f [image] --profile=[OS Profile] -p [pid] vadinfo 
 volatility -f [image] --profile=[OS Profile] -p vaddump -D [Directory] 

 # Strings 
 strings -td -a [image] >> strings.txt # "FREE MEMORY"という単語がなんかしらないがよく使うらしい 
 strings -td -el -a [image] >> strings.txt 

 volatility -f [image] --profile=[OS Profile] strings -s strings.txt > [out.txt] 

 grep [string] out.txt # IPアドレス等で引っ掛けて -A -B のオプションでその前後を出力して調査 

 # Malware Check 
 volatility -f [image] --profile=[OS Profile] ldrmodules -p [pid] 
 volatility -f [image] --profile=[OS Profile] malfind -p [pid] 

 # Yarascan 
 volatility -f [image] --profile=[OS Profile] yarascan --yara-rules="[strings]" 
 volatility -f [image] --profile=[OS Profile] yarascan -p [pid] --yara-rules="[binary code]" 
 volatility -f [image] --profile=[OS Profile] yarascan -p [pid] --yara-rules="[strings]" 

 # Misc 
 volatility -f [image] --profile=[OS Profile] objtypescan # Object Acan 
 volatility -f [image] --profile=[OS Profile] Volshell      # Volshell 
 volatility -f [image] --profile=[OS Profile] iehistory     # IEの履歴 
 ``` 


 # FileSystem 

 ## ファイルシステムソムリエ 

 Gentoo metalog - ファイルシステムソムリエになる話 
 http://gentoo.hatenablog.com/entry/2016/06/17/020107 

 Linux ファイルシステムを理解したい 
 https://www.kimullaa.com/entry/2019/12/01/130347 



 ## [FATファイルシステム](http://memes.sakura.ne.jp/memes/?page_id=2390) 

 FATファイルシステム(その1) 
 http://memes.sakura.ne.jp/memes/?page_id=2303 

 FATファイルシステム(その2) 
 http://memes.sakura.ne.jp/memes/?page_id=2402 

 Qiita - FAT12,FAT16の構造(予約領域編) 
 https://qiita.com/iria_piyo/items/d949b93bc056a8c370d6 



 ## FAT16 

 参考 - ねんどろいど伊401に時報を喋らせるガジェットを作ってみた 
 http://tech.recruit-mp.co.jp/gadget/pic-inside-i401/ 



 ## NTFS 

 ### VSS削除後の復元 

 https://github.com/mnrkbys/vss_carver 

 ### USNジャーナル(ファイルのwriteの記録) 

 CDI 山崎さんのUSNジャーナルの分析ツールの発表。クオリティが半端ないw 

 本家 
 https://github.com/simsong/bulk_extractor 

 カービングツール 
 https://www.kazamiya.net/bulk_extractor-rec 

 分析ツール 
 https://www.kazamiya.net/usn_analytics/ 

 資料はこちら 
 https://www.jpcert.or.jp/event/jsac2018.html 

 >シグネチャとして固定部分(ヘッダ:USN_RECORD_V2)/ レコード長 / ファイル名の長さを使用している。 

 Python script to parse the NTFS USN Journal 
 https://github.com/PoorBillionaire/USN-Journal-Parser 





 ## ext 

 Qiita - 知っておきたいLinuxファイルシステムの概念 
 https://qiita.com/Rairaiden/items/539d429729d5819de0aa 











 # Magic Number 

 trid(コマンドかオンラインでファイルを判別するツール) 
 http://mark0.net/onlinetrid.aspx 

 File Signature Database 
 http://www.filesignatures.net/index.php?page=search 

 http://www.astro.keele.ac.uk/oldusers/rno/Computing/File_magic.html 

 ## 実行形式 

 | ファイルフォーマット | HEX       | ASCII | Note | 
 |----------------------|---------|-------|------| 
 | ELF                    | 7F        |         | 
 | 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)から始まっているので、見つけやすい  
 | Javaクラスファイル     | CA FE BA BE |     | 
 | gzip                   | 1F 8B     |         | 
 | Compress(.Z)           | 1F 9D     |         | 
 | Bzip(.bz)              | 42 5a     | BZ      | 
 | zip                    | 50 4B     | PK      | 
 | TAR (pre-POSIX)        |           | (a filename) | 
 | TAR (POSIX)            | 75 73 74 61 72    | ustar | 
 | zip                    | 50 4B 03 04 | PK | 終端は PK 0x05 0x06 の後ろに18Byte コメントが付けられるので可変長ではある 
 | zlib                   | 78 9c | | 78 DA や 78 01 の場合も?ある 
 | LHA(lh0)               | ?? ?? 2D 6C 68 30 2D | ??-lh0- | 
 | LHA(lh4)               | ?? ?? 2D 6C 68 34 2D | ??-lh4- | 
 | LHA(lh5)               | ?? ?? 2D 6C 68 35 2D | ??-lh5- | 
 | 7z                     | 37 7A BC AF 27 1C | 7z | 
 | xz                     | fd 37 7a 58 5a 00 | ?7zXZ |  
 | cab                    | 4d 53 43 46 | MSCF |  
 | RAR                    | 52 61 72 21 | Rar! | 
 | Jpeg                   | FF D8 FF E0 ?? ?? 4A 46 49 46 | ??????JFIF | 終端は FF D9 "・ル" 
 | PNG                    | 89 50 4E 47 | ?PNG → 臼NG | 終端は 00 00 00 00 49 45 4E 44 AE 42 60 82 "IENDョB`" 
 | WebP                   | 52 49 46 46 ?? ?? ?? ?? 57 45 42 50 | RIFF????WEBP | ????はファイルサイズ 
 | HEIF(HEIC)             | ?? ?? ?? ?? 66 74 79 70 | ??????ftypmif1????mif1heichevc | ftypとheicという文字が見えるとHEIFっぽい 
 | GIF(89a)               | 47 49 46 38 39 61 | GIF89a | 終端は 3B 
 | GIF(87a)               | 47 49 46 38 37 61 | GIF87a |  
 | BMP                    | 42 4D     | BM      | 
 | BGP                    | 42 50 47 fb 20 00 | BGP      | 
 | TIFF                   | 49 49 または 4d 4d | II または MM | 「4D 4D」なら上位から下位バイトへ読み、「49 49」なら下位から上位バイトで読みます 
 | Postscript             | 25 21     | %!      | 
 | Microsoft Offic e      | D0 CF 11 E0 A1 B1 1A E1 || 
 | PDF                    | 25 50 44 46 2D | %PDF-バージョン番号 | 
 | wav                    | 52 49 46 46 | RIFF 
 | swf                    | 43 57 53 または 46 53 57 | CSW または FSW 
 | wma                    | 30 26     | 0& 
 | pgp public ring        | 99 00     |         | 
 | pgp security ring      | 95 01     |         |  
 | pgp security ring      | 95 00     |         |  
 | pgp encrypted data     | a6 00     |         | 
 | pcap(tcpdump)          | d4 c3 b2 a1 | ヤテイ。 | 


 # Repair 

 文字化けリペア 
 >=?ISO-2022-JP?B?GyRCJD8hIxsoQg==?= のような件名など 
 From, Subjectなどの読めないヘッダを修復 
 >>http://purl.org/net/masaka/mr/mime.php 

 >$B$3$l$O(JJIS$B$NJ8$G$9!#(Jのような文字化け 
 文字化けしている本文の修復 
 >>http://purl.org/net/masaka/mr/jmr.php 

 >&#12371;&#12435;...のような、 '&#' と ';' に数字が挟まれたコードが連続する本文 
 Unicode文字参照になっている本文の解読 
 >>http://purl.org/net/masaka/mr/r2u.php 

 pcapリペア 
 http://f00l.de/hacking/pcapfix.php 

 zipリペア 
 http://www.gigafree.net/utility/archive/diskinternalsziprepair.html 

 ---- 

 Foremost ファイル復元方法(Linux編) 
 http://brand-jin.tk/?p=463 

 foremostというバイナリファイルの中からファイルを復元できるツール 
 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 

 俺的備忘録 〜なんかいろいろ〜 - バイナリやファイル、ディスクから中のデータを抽出・復元する『foremost』コマンド 
 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/ 

 ``` 
 $ ./foremst -t all -i Timestamp.dd 
 ``` 

 「PhotoRec」の使い方 ファイル復元ソフト 
 https://pctrouble.net/software/photorec.html 






 # ファイル解析 

 rga: ripgrep, but also search in PDFs, E-Books, Office documents, zip, tar.gz, etc. 
 https://phiresky.github.io/blog/2019/rga--ripgrep-for-zip-targz-docx-odt-epub-jpg/ 

 >これが全般的に使えるんじゃないかと気になっている 
 >pdfやdocx、sqlite、画像や動画のメタデータなどを全部grepできるツール 

 ## pdfの解析 

 PDF中の画像ファイルのみを抽出する 
 https://qiita.com/aokomoriuta/items/066b760a28da461531b6 

 >libre Office Draw でpdfが編集できる 

 peepdf - PDF Analysis Tool 
 http://eternal-todo.com/tools/peepdf-pdf-analysis-tool 

 > Kali Linux に同梱されている 

 >かわろぐ - peepdf を使って攻撃コードの入ったPDFを解析してみた 
 >http://blog.kawa-xxx.jp/entry/2016/09/19/165709 

 PDF Stream Dumper [使用例](http://ameblo.jp/norio001/entry-11372965347.html) 
 http://sandsprite.com/blogs/index.php?uid=7&pid=57 

 PDFからテキストを抽出するプログラム 
 https://osdn.jp/users/mocchi_2012/pf/mocchi_stack_room/wiki/extract_pdf 

 >pdfファイル中のstream~endstream間は、zlib圧縮されてたりするのだが、展開くれて、json形式で出力してくれる。 

 プログラムモグモグ - 詳細PDF入門 ー 実装して学ぼう!PDFファイルの構造とその書き方読み方  
 http://itchyny.hatenablog.com/entry/2015/09/16/100000 

 corkami - PDFのトリックに関するレジュメ - エンコーディング,構成,JavaScriptなど  
 https://code.google.com/p/corkami/wiki/PDFTricks 

 pdfcrack 
 http://pdfcrack.sourceforge.net/ 

 >あと[辞書](https://wiki.skullsecurity.org/index.php?title=Passwords) 

 evince 
 https://ja.wikipedia.org/wiki/Evince 

 >コピー禁止とか無視できたりする 






 ## pngの解析 

 [pngcheck](https://www.google.co.jp/search?&hl=ja&lr=lang_ja&q=pngcheck&cad=h) 



 ## Office形式のファイル解析 

 OfficeMalScanner 
 http://www.reconstructer.org/ 

 73spica's Blog - EKOPARTY CTF 2016 Write-up 
 http://73spica.tech/blog/ekoparty-ctf-2016-write-up/ 

 Github - MalwareCantFly/Vba2Graph (VBAの解析・可視化) 
 https://github.com/MalwareCantFly/Vba2Graph 

 ## zlibの解析 

 展開は、以下でできる。 

 ``` 
 $ cat src.bin |openssl zlib -d >dest.bin 
 ``` 

 zpipeでも可 

 ``` 
 $ zpipe < src.bin > dest.bin      #圧縮 
 $ zpipe -d < src.bin > dest.bin #伸張 
 ``` 

 pythonシェル芸だとこう 

 ```python 
 python -c 'import zlib; print zlib.decompress(open("File").read())' 
 ``` 



 バイナリからzlib圧縮データを探す  
 http://teraapi.blogspot.jp/2012/05/zlib.html 

 ``` 
 よくある:  
 78 01, 78 5e, 78 9c, 78 da  

 稀 : 
 08 1d, 08 5b, 08 99, 08 d7, 18 19, 18 57, 18 95, 18 d3,  
  28 15, 28 53, 28 91, 28 cf, 38 11, 38 4f, 38 8d, 38 cb,  
  48 0d, 48 4b, 48 89, 48 c7, 58 09, 58 47, 58 85, 58 c3,  
  68 05, 68 43, 68 81, 68 de  

 極稀: 
 08 3c, 08 7a, 08 b8, 08 f6, 18 38, 18 76, 18 b4, 18 f2,  
  28 34, 28 72, 28 b0, 28 ee, 38 30, 38 6e, 38 ac, 38 ea,  
  48 2c, 48 6a, 48 a8, 48 e6, 58 28, 58 66, 58 a4, 58 e2,  
  68 24, 68 62, 68 bf, 68 fd, 78 3f, 78 7d, 78 bb, 78 f9   
 ``` 

 ### 引数のファイルに含まれるzlib圧縮部分を抽出・展開してファイルに保存する 

 自作ツール。CentOSで動作確認済み。Kali Linuxだとopensslでzlibのdecodeが出来なかったので、たぶん、Debian でも動かないかも。 
 まぁ、zpipeで代替すれば、どの環境でも行けるはず。 
 ちなみに、動作はめっちゃ遅い。 

 attachment:zlib_extraction.sh 

 ```bash 
 #!/bin/bash 

 # zlib_extraction.sh ver 2.0 
 # 引数のファイルに含まれるzlib圧縮部分を抽出・展開してファイルに保存する 
 # 2015.10.06 kanata  

 if [ ! -f "${1}" ] 
 then 
   echo "file open error ($1)" 
   exit 1 
 fi 

 if echo "${2}" |egrep '(BOOST|boost|Boost)' >/dev/null 
 then 
   MODE="BOOST_MODE" 
 else 
   MODE="NORMAL_MODE" 
 fi 


 FILESIZE=`ls -l ${1}|awk '{print $5}'` 
 ZLIBPART="${1##*/}" 
 ZLIBPART="${ZLIBPART%.*}" 
 I="0" 
 FORK_COUNT="0" 

 if [ "${MODE}" = "NORMAL_MODE" ] 
 then 
   #--------------# 
   # シリアル処理 # 
   #--------------# 
   while [ "${I}" -lt "${FILESIZE}" ] 
   do 
     ZLIBPART_FILE="${ZLIBPART}_${I}.bin" 
     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 

     echo -ne "checking.. "`printf "%d/%d" "${I}" "${FILESIZE}"`" \r" 
     I=$(( I + 1 )) 
   done 

 else 
   #----------# 
   # 並列処理 # 
   #----------# 
   while [ "${I}" -lt "${FILESIZE}" ] 
   do 
     ZLIBPART_FILE="${ZLIBPART}_${I}.bin" 
     ( 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 )& 

     # 並列実行時のサブシェルが増大していくのを抑止 
     # 同時35多重までに抑止 25回に1度チェック ( 数値を弄ってチューニングできます ) 
     if [ $(( I % 25 )) -eq "0" ] ; then FORK_COUNT=`ps -u |fgrep -c ${0}` ; fi 
     while    [ "${FORK_COUNT}" -gt "35" ]  
     do 
       printf "[WARNING] SubProcess Exceed Limit. fork:%s offset:%s\n" ${FORK_COUNT} ${I} 
       FORK_COUNT=`ps -u |fgrep -c ${0}` 
     done 

     echo -ne "checking.. "`printf "%d/%d" "${I}" "${FILESIZE}"`" \r" 
     I=$(( I + 1 )) 
   done 

 fi 

 exit 0 
 ``` 

 ### その他の展開方法 

 zlib.exe - zlib でデータを圧縮/展開するだけのプログラム 
 http://cetus.sakura.ne.jp/softlab/toolbox2/#zlibexe 

 各プログラム言語でのコーディング方法サンプル - Zlib Decompress 
 http://swiftapi.com/api/Zlib_Decompress 

 ```python 
 $ python -c 'import zlib; print zlib.decompress(open("/directory/file").read())' 
 ``` 


 ## DXアーカイブ(data.dxa)の展開 

 henteko - 2012TeResAI(DXアーカイブの展開ができる) 
 https://github.com/henteko/2012TeResAI/tree/master/2012TeResAI/2012teresAI/DX%20lib/DxLib_VC/Tool/DXArchive 

 ## Macの.DS_Storeの解析 

 Python .DS_Store parser 
 https://github.com/gehaxelt/Python-dsstore 

 ## PEファイルフォーマット 

 PE(Portable Executable)ファイルフォーマットの基本構造 めも 
 https://task4233.dev/article/20200101_pefile.html#pe-portable-executable-format 







 # 動画解析 

 ## 動画差分 

 動画のフレームごとの差を求めて変化してた場合に保存するプログラム 
 https://github.com/teatime13/search_movie_diff 

 ## 比較明合成 

 [SiriusComp](http://phaku.net/siriuscomp/)を使う 

 ## テンプレートマッチング 

 Qiita - SECCON 2018 Online CTF Needle in a haystack テンプレートマッチングで照明点灯判定を自動化する 
 https://qiita.com/DoranekoSystems/items/f2fd95fb9ff4ddea369f 



 # Memo 

 アンタイ・フォレンジック伝道者の独り言 - NTFS 代替データストリームとは? 
 http://port139.hatenablog.com/entries/2005/09/08 

 FOCA - 文書のスキャンでメタデータと隠された情報を検索するためのツール 
 https://www.elevenpaths.com/labstools/foca/ 

 φ(・・*)ゞ ウーン カーネルとか弄ったりのメモ - ext4:ディスクレイアウト調査中めも1 
 http://kernhack.hatenablog.com/entry/2014/01/28/230808 

 俺的備忘録 〜なんかいろいろ〜    - fuseを使ってファイルシステムをモニタリングできる『loggedfs』 
 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/ 

 > CTFでのバイナリ実行の挙動を追いかけるのに便利そう 

 Visualizing ELF binaries 
 https://reverseengineering.stackexchange.com/questions/6003/visualizing-elf-binaries 

 Ubuntu で $ rm ~/.bashrc を実行してしまった - Linuxで誤って削除したファイルの復活の話 
 https://blog.fenrir-inc.com/jp/2017/10/resurrected_rm_files.html 

 Automate Linux Swap Analysis: swap_digger - Linux Swap解析ツール(Bashスクリプト)。SwapからLinuxアカウント情報、ウェブアカウント情報、BASIC認証、WiFi SSID・鍵等が取得可能。フォレンジック調査・ペンテスト用。 
 https://n0where.net/automate-linux-swap-analysis-swap_digger/ 

 SANS DFIR Windows Forensic Analysis POSTER 
 https://www.sans.org/security-resources/posters/windows-forensic-analysis/170/download 

 Shi0shishi0 - Defcon DFIR CTF 2018 Writeup(HR Server + File Server)  
 http://ecoha0630.hatenablog.com/entry/2018/11/22/180306 

 Windows 10 Timeline 解析記事のメモ 
 https://soji256.hatenablog.jp/entry/2019/10/05/153559?utm_source=feed 

 DFIR や Malware 解析などについての記事まとめ(2019年10月~2019月12月) 
 https://soji256.hatenablog.jp/entry/2020/01/16/082000 

 Windowsイベントログ解析ツール「Hayabusa」を使ってみる 
 https://itib.hatenablog.com/entry/2021/12/31/222946 

 競技セキュリティまとめのまとめ 
 https://blog.hamayanhamayan.com/entry/2023/02/22/085938