현재 개발중인 버전으로 공식 문서와 여러 엔지니어들의 글을 참고하였다
1. 시스템 구성
Ubuntu Server 22.04.4 LTS 이며 GUI 환경은 아니다
PRETTY_NAME="Ubuntu 22.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.3 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
We are building with Python version 3.10.12.
# python3 --version
Python 3.10.12
2. 의존성 설치 및 사용자 추가, 권한 변경
sudo apt update && sudo apt upgrade -y
sudo apt install git build-essential python3-dev python3.10-venv libhyperscan5 libhyperscan-dev libjpeg8-dev zlib1g-dev unzip p7zip-full rar unace-nonfree cabextract yara tcpdump genisoimage qemu-system-x86 qemu-utils qemu-system-common -y
# centos
# sudo yum update -y
# sudo yum install git make gcc python3-devel python3.10 python3.10-venv hs-devel libjpeg-turbo-devel zlib-devel unzip p7zip p7zip-plugins unrar unace cabextract yara tcpdump genisoimage qemu-kvm qemu-img qemu-common -y
우분투가 아닌 경우는 어떻게 설치하는지 chat gpt 에게 물어보면 이렇게 할 수 있다고 한다
주석 참고하여 명령어 입력, 입력하는 권한은 root 외의 권한에서 작업을 권장
sudo useradd -s /bin/bash cuckoo
sudo adduser cuckoo kvm
sudo chmod 666 /dev/kvm
# cuckoo 계정이 꼭 설정되어 있어야 한다
sudo groupadd pcap # Allow non-root users to create pcap.
sudo adduser cuckoo pcap # Allow non-root users to create pcap.
sudo chgrp pcap /usr/bin/tcpdump
sudo setcap cap_net_raw,cap_net_admin=eip /usr/bin/tcpdump
sudo ln -s /etc/apparmor.d/usr.bin.tcpdump /etc/apparmor.d/disable/
# Change Ubuntu Apparmor settings.
sudo apparmor_parser -R /etc/apparmor.d/disable/usr.bin.tcpdump
sudo apparmor_parser -R /etc/apparmor.d/usr.bin.tcpdump
3. Cuckoo3 설치
git 에서 클론~~~~
sudo chown cuckoo /opt && cd /opt
git clone https://github.com/cert-ee/cuckoo3
cd cuckoo3
'processing/setup.py ' 파일의 'install_requires' 섹션을 편집하여 버전 사양을 수정
"pefile<2023.0.0",.
"hyperscan>=0.4.0",.
"yara-python==4.2.0",.
변경 전
install_requires=[
"Cuckoo-common>=0.1.0",
"sflock>=1.0, <1.1",
"protobuf>=3.20.1, <4.0.0",
"httpreplay>=1.0, <1.1",
"pefile>=2022.5.30, <2024.0.0",
"oletools>=0.60.1, <0.61",
"cryptography>=41.0.4, <42.0.0",
"hyperscan>=0.2.0, <0.7",
"yara-python>=4.2.0, <4.4",
"roach>=1.0, <1.1",
"suricatactl==0.0.1.dev3",
"dpkt>=1.9.7.2, <1.10"
],
변경 후
install_requires=[
"Cuckoo-common>=0.1.0",
"sflock>=1.0, <1.1",
"protobuf>=3.20.1, <4.0.0",
"httpreplay>=1.0, <1.1",
"pefile<2023.0.0",
"hyperscan>=0.4.0",
"oletools>=0.60.1, <0.61",
"cryptography>=41.0.4, <42.0.0",
"hyperscan>=0.2.0, <0.7",
"yara-python==4.2.0",
"roach>=1.0, <1.1",
"suricatactl==0.0.1.dev3",
"dpkt>=1.9.7.2, <1.10"
],
새로운 파이썬 환경 구축
python3 -m venv venv
source venv/bin/activate
설치 스크립트 실행
pip install wheel
./install.sh
Create the Cuckoo working directory (CWD).
cuckoo createcwd
Install stager and monitoring binaries.
cuckoo getmonitor monitor.zip
unzip signatures.zip -d ~/.cuckoocwd/signatures/cuckoo/
가상화를 제어하는 VMcloak 설치
Download
git clone https://github.com/hatching/vmcloak.git && cd vmcloak
setup.py 을 편집하고 install_requires pefile 버전을 다음으로 변경
"pefile<2023.0.0",
변경 전
install_requires=[
"click",
"jinja2",
"pefile>=2019.4.18, <2019.5.0"
"pyyaml>=5.1",
"sqlalchemy>=1.4, <1.5",
"alembic>=1.7.4, <1.8",
"requests>=2.22.0, <3",
"psutil>=5.4.8, <6"
],
변경 후
install_requires=[
"click",
"jinja2",
"pefile<2023.0.0",
"pyyaml>=5.1",
"sqlalchemy>=1.4, <1.5",
"alembic>=1.7.4, <1.8",
"requests>=2.22.0, <3",
"psutil>=5.4.8, <6"
],
vmcloak/platforms/qemu.py 를 편집하고 _create_snapshot_disk 함수를 다음으로 변경한다
subprocess.check_call(["qemu-img", "create", "-F", "qcow2", "-o",
"lazy_refcounts=on,cluster_size=2M", "-b",
image_path, "-f", "qcow2", path])
변경 전
def _create_snapshot_disk(image_path, path):
log.info("Creating snapshot %s with master %s", path, image_path)
subprocess.check_call(["qemu-img", "create", "-f", "qcow2", "-o",
"lazy_refcounts=on,cluster_size=2M", "-b",
image_path, path])
변경 후
def _create_snapshot_disk(image_path, path):
log.info("Creating snapshot %s with master %s", path, image_path)
subprocess.check_call(["qemu-img", "create", "-F", "qcow2", "-o",
"lazy_refcounts=on,cluster_size=2M", "-b",
image_path, "-f", "qcow2", path])
강제 설치하기
pip install . && cd ..
VM 생성
QEMU 네트워크 인터페이스를 구성합니다.
sudo /opt/cuckoo3/venv/bin/vmcloak-qemubridge br0 192.168.30.1/24
sudo mkdir -p /etc/qemu
echo 'allow br0' | sudo tee /etc/qemu/bridge.conf
sudo chmod u+s /usr/lib/qemu/qemu-bridge-helper
아이피는 구축 환경에 맞게 변경하면 된다
윈도우 이미지( ISO ) 다운로드
vmcloak isodownload --win10x64 --download-to ~/win10x64.iso
sudo mkdir /mnt/win10x64
sudo mount -o loop,ro /home/cuckoo/win10x64.iso /mnt/win10x64 # mount
분석시 사용하려는 윈도우 10 이미지를 생성합니다
vmcloak --debug init --win10x64 --hddsize 128 --cpus 2 --ramsize 4096 --network 192.168.30.0/24 --vm qemu --ip 192.168.30.2 --iso-mount /mnt/win10x64 win10base br0
추가 옵션을 지정하여 이미지를 설정할 수 있습니다
vmcloak --debug install win10base dotnet:4.7.2 java:7u80 vcredist:2013 vcredist:2019 edge carootcert wallpaper disableservices
스냅샷을 저장하여 쿠쿠가 로드할 수 있도록 저장합니다
vmcloak --debug snapshot --count 1 win10base win10vm_192.168.30.20
Cuckoo3 설정
VM 추가
cuckoo machine import qemu ~/.vmcloak/vms/qemu
cuckoo machine delete qemu example1 # remove default
DB 생성
cuckoomigrate database all
# 에러가 나도 우선 무시!!!
yaml 파일 설정
vi ~/.cuckoocwd/conf/cuckoo.yaml
구성 환경에 따라 아이피는 다르지만 게이트웨이를 작성합니다
# route/forward traffic between the analysis machines and the resultserver.
resultserver:
listen_ip: 192.168.30.1
listen_port: 2042
# Settings used by Cuckoo to find the tcpdump binary to use for network capture of machine traffic.
tcpdump:
enabled: True
path: /usr/bin/tcpdump
다운로드 등 접근이 허용되는 네트워크 대역을 설정한다 10.0.0.X/24 를 적었다
vi ~/.cuckoocwd/conf/web/web.yaml
관리자 웹을 이제 준비합니다
cd /opt/cuckoo3/docs
pip install -r requirements.txt
mkdocs build
cp -R site ../web/cuckoo/web/static/docs
테스트 목적으로 쿠쿠를 실행해봅니다
cuckoo --debug
웹서버 Nginx 와 uWSGI 연동
pip install uwsgi
sudo apt-get install uwsgi uwsgi-plugin-python3 nginx -y
sudo adduser www-data cuckoo
uwsgi 설정 생성
cuckoo web generateconfig --uwsgi > cuckoo-web.ini
웹 서버에 설정 추가
sudo mv cuckoo-web.ini /etc/uwsgi/apps-available/
sudo ln -s /etc/uwsgi/apps-available/cuckoo-web.ini /etc/uwsgi/apps-enabled/cuckoo-web.ini
uWSGI 서버 설정 수정
vi ~/.cuckoocwd/web/web_local_settings.py
STATIC_ROOT = "/opt/cuckoo3/web/cuckoo/web/static" # 경로 추가
nginx 설정 생성
cuckoo web generateconfig --nginx > cuckoo-web.conf
listen 127.0.0.1:8000 => listen 80 으로 포트 변경
# vi cuckoo-web.conf
server {
listen 80;
# Directly serve the static files for Cuckoo web. Copy
# (and update these after Cuckoo updates) these by running:
# 'cuckoo web djangocommand collectstatic'. The path after alias should
# be the same path as STATIC_ROOT. These files can be cached. Be sure
# to clear the cache after any updates.
location /static {
alias /opt/cuckoo3/web/cuckoo/web/static;
}
Change the location of the Nginx config.
sudo mv cuckoo-web.conf /etc/nginx/sites-available/cuckoo-web.conf
sudo ln -s /etc/nginx/sites-available/cuckoo-web.conf /etc/nginx/sites-enabled/cuckoo-web.conf
# 기본 삭제
sudo rm /etc/nginx/sites-enabled/default
Restart Nginx and uwsgi.
# 실행 순서 중요
sudo uwsgi
sudo systemctl restart nginx
Start Cuckoo3.
# 마지막으로 쿠쿠 실행, 실행되지 않으면 동적 분석 불가
cuckoo
4. UI 동작 확인
아래처럼 화면이 표시됩니다
References
Cuckoo3 ビルド手順 (2024年3月7日現在)
公式ドキュメントとオンライン記事を使用して、検討して Cuckoo3 をビルドすることができましたので、お知らせしたいと思います。 Cuckoo3 は現在開発中です 。
medium.com
Cuckoo3 Official Documentation
https://github.com/cert-ee/cuckoo3/blob/main/docs/src/installation/cuckoo.md
cuckoo3/docs/src/installation/cuckoo.md at main · cert-ee/cuckoo3
Cuckoo 3 is a Python 3 open source automated malware analysis system. - cert-ee/cuckoo3
github.com
Nikola’s Blog Cuckoo 3 Installation Guide
https://reversingfun.com/posts/cuckoo-3-installation-guide/
Cuckoo 3 Installation Guide | Nikola's Blog
In this blogpost, I’ll share my notes on the installation of the Cuckoo 3 Sandbox. Cuckoo is the leading open source automated malware analysis system. It is used to launch malware in a secure and isolated environment. Thanks to folks at Hatching and CER
reversingfun.com
Hamza Megahed Cuckoo 3 Installation
https://www.hamza-megahed.com/cuckoo3/
Cuckoo 3 Installation
www.hamza-megahed.com
'Server' 카테고리의 다른 글
413 request entity too large nginx (0) | 2024.05.12 |
---|---|
험난한 구글 클라우드 API 를 위한 서비스 계정 발급하기 (0) | 2024.05.07 |
우분투 캐시 메모리 점유를 트러블 슈팅해보기 (0) | 2024.03.20 |
shasum: command not foun (0) | 2024.03.19 |
[centos7 adduser] 유저 추가/삭제 (0) | 2024.03.07 |