LoginSignup
0
0

Volatility 2の環境構築

Posted at

はじめに

本記事はメモリフォレンジックで使用されるVolatility Frameworkについて記載しています。

本記事執筆時点で最新のバージョンは、Python3で動作するVolatility 3ですが、便宜上Python2で動作するVolatility 2の環境構築についてまとめています。

Volatility 2の環境構築

Volatility 2を使用するためには、前提としてPython2の動作環境が必要です。

  • Python2
  • pip2
  • パッケージのインストール(pycryptodomeとdistorm3)

本記事ではKali Linuxを例にVolatility 2の環境構築を行います。python2のバージョンは2.7.18を使用しています。

Python環境のセットアップ

はじめにPython2のpipをインストールするために、以下のコマンドを実行してget-pip.pyファイルを取得します。

# curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py

pipをインストールします。

# python2 get-pip.py

環境変数のPATHを通します。

# vi ~/.bashrc

export PATH=$PATH:/home/kali/.local/bin

必要なパッケージをインストールせずにVolatility 2のプラグインを使用すると、以下の様なエラーが出力されます。

Volatility Foundation Volatility Framework 2.6.1
*** Failed to import volatility.plugins.registry.shutdown (ImportError: No module named Crypto.Hash)
*** Failed to import volatility.plugins.getservicesids (ImportError: No module named Crypto.Hash)
*** Failed to import volatility.plugins.timeliner (ImportError: No module named Crypto.Hash)
*** Failed to import volatility.plugins.malware.apihooks (NameError: name 'distorm3' is not defined)
*** Failed to import volatility.plugins.malware.servicediff (ImportError: No module named Crypto.Hash)
*** Failed to import volatility.plugins.registry.userassist (ImportError: No module named Crypto.Hash)
*** Failed to import volatility.plugins.getsids (ImportError: No module named Crypto.Hash)
*** Failed to import volatility.plugins.registry.shellbags (ImportError: No module named Crypto.Hash)
*** Failed to import volatility.plugins.evtlogs (ImportError: No module named Crypto.Hash)
*** Failed to import volatility.plugins.registry.shimcache (ImportError: No module named Crypto.Hash)
*** Failed to import volatility.plugins.tcaudit (ImportError: No module named Crypto.Hash)
*** Failed to import volatility.plugins.registry.dumpregistry (ImportError: No module named Crypto.Hash)
*** Failed to import volatility.plugins.registry.lsadump (ImportError: No module named Crypto.Hash)
*** Failed to import volatility.plugins.malware.threads (NameError: name 'distorm3' is not defined)
*** Failed to import volatility.plugins.mac.apihooks_kernel (ImportError: No module named distorm3)
*** Failed to import volatility.plugins.registry.amcache (ImportError: No module named Crypto.Hash)
*** Failed to import volatility.plugins.mac.check_syscall_shadow (ImportError: No module named distorm3)
*** Failed to import volatility.plugins.malware.svcscan (ImportError: No module named Crypto.Hash)
*** Failed to import volatility.plugins.registry.auditpol (ImportError: No module named Crypto.Hash)
*** Failed to import volatility.plugins.ssdt (NameError: name 'distorm3' is not defined)
*** Failed to import volatility.plugins.registry.registryapi (ImportError: No module named Crypto.Hash)
*** Failed to import volatility.plugins.mac.apihooks (ImportError: No module named distorm3)
*** Failed to import volatility.plugins.envars (ImportError: No module named Crypto.Hash)
ERROR   : volatility.debug    : You must specify something to do (try -h)

上記エラーの(ImportError: No module named Crypto.Hash)を回避するためには、pycryptodomeのパッケージをインストールします。

# pip2 install pycryptodome

pycryptodomeのパッケージがインストールされたことを確認します。

# pip2 list

Package      Version
------------ -------
cffi         1.14.0
pip          20.3.4
pycryptodome 3.20.0
volatility   2.6.1
wheel        0.37.1

次に(ImportError: No module named distorm3)のエラーを回避するためには、distorm3をインストールします。

$ pip2.7 install distorm3==3.4.4

しかし、setuptoolsが存在しない場合、以下の様なエラーが出力されます。

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Defaulting to user installation because normal site-packages is not writeable
Collecting distorm3==3.4.4
  Using cached distorm3-3.4.4.tar.gz (134 kB)
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python2 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-5LUoEE/distorm3/setup.py'"'"'; __file__='"'"'/tmp/pip-install-5LUoEE/distorm3/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-De6wHx
         cwd: /tmp/pip-install-5LUoEE/distorm3/
    Complete output (6 lines):
    usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
       or: setup.py --help [cmd1 cmd2 ...]
       or: setup.py --help-commands
       or: setup.py cmd --help
    
    error: invalid command 'egg_info'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

従って以下の様なコマンドを実行してsetuptoolsをインストールします。

$ pip2 install -U setuptools Wheel

setuptoolsのパッケージがインストールされたことを確認します。

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Package      Version
------------ -------
cffi         1.14.0
pip          20.3.4
pycryptodome 3.20.0
setuptools   44.1.1
volatility   2.6.1
wheel        0.37.1

再度、以下のコマンドを実行すると、インストールできます。

$ pip2.7 install distorm3==3.4.4

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Defaulting to user installation because normal site-packages is not writeable
Collecting distorm3==3.4.4
  Using cached distorm3-3.4.4.tar.gz (134 kB)
Building wheels for collected packages: distorm3
  Building wheel for distorm3 (setup.py) ... done
  Created wheel for distorm3: filename=distorm3-3.4.4-cp27-cp27mu-linux_x86_64.whl size=104829 sha256=a9bf0262ca63504fca78875c86beec8a818ed944be22c3f8302520f01000b35f
  Stored in directory: /home/kali/.cache/pip/wheels/93/14/6f/aaeed0f34af1f5028e3ed4b7929b094caf7e4a62fcbf3e3623
Successfully built distorm3
Installing collected packages: distorm3
Successfully installed distorm3-3.4.4

Volatility 2

GitHubの以下リポジトリからVolatility 2をクローンします。

クローンしたvolatilityのディレクトリ配下で以下のコマンドを実行すると、/usr/local/bin/vol.pyが生成されるため、/usr/local/bin/配下のパスが通っていればvol.pyで実行可能です。

# sudo python2 setup.py install

  • setup.py の出力例
    copying build/scripts-2.7/vol.py -> /usr/local/bin
    changing mode of /usr/local/bin/vol.py to 755
    

おわりに

Volatility 2は、CTFなど特定のタスクを行う場合に重宝すると思います。

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0