# Sử dụng Podman tạo base images Pentest

## 🚀 Tự Build Kali Linux Base Image để Pentest với Podman

### 🧠 Tại sao nên dùng Kali với Podman?

Trong thời đại container hóa, việc sử dụng Kali Linux – hệ điều hành chuyên dụng cho kiểm thử bảo mật – dưới dạng container là một lựa chọn cực kỳ linh hoạt:

* 🧱 **Không ảnh hưởng hệ điều hành chính**
* 🔄 **Dễ rollback, versioning**
* 🔐 **Chạy rootless với Podman để tăng bảo mật**
* 📦 **Có thể đóng gói và chia sẻ dễ dàng**

***

### ⚙️ Yêu cầu ban đầu

* Hệ điều hành: Ubuntu 20.04+ hoặc Fedora, Arch, etc.
* Đã cài **Podman**:

```bash
sudo apt update && sudo apt install -y podman
```

* Kiểm tra version:

```bash
podman --version
```

***

### 🏗️ Bước 1: Tạo Dockerfile Kali cơ bản

Tạo thư mục chứa project:

```bash
mkdir -p ~/podman-kali
cd ~/podman-kali
```

Tạo file `Dockerfile`:

```dockerfile
FROM docker.io/kalilinux/kali-rolling

LABEL maintainer="you@example.com"
LABEL purpose="Kali base image for pentesting with Podman"

RUN apt-get update && apt-get upgrade -y && \
    apt-get install -y --no-install-recommends \
    nmap hydra sqlmap nikto net-tools iputils-ping \
    dnsutils curl wget git python3 python3-pip \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

CMD ["/bin/bash"]
```

> ⚠️ Lưu ý: sử dụng `docker.io/kalilinux/...` thay vì chỉ `kalilinux/...` để tránh lỗi “no unqualified-search registries”.

***

### 🔨 Bước 2: Build Image

```bash
podman build -t kali-pentest .
```

> Sau khi hoàn tất, bạn có thể kiểm tra image bằng `podman images`.

***

### 🚀 Bước 3: Chạy Container Kali

Chạy container tương tác:

```bash
podman run -it --rm --name kali kali-pentest
```

Mount thư mục chia sẻ với host:

```bash
podman run -it --rm -v $HOME/shared:/data kali-pentest
```

Chạy với quyền cao để sniff, ping, dùng tools mạng nâng cao:

```bash
sudo podman run --net=host --privileged -it kali-pentest
```

> ⚠️ Chỉ sử dụng `--privileged` khi thực sự cần (ví dụ dùng Wireshark hoặc MITM).

***

### 🔁 Bước 4: Tùy chọn nâng cao

#### 🧩 Gắn thêm nhiều công cụ

Bạn có thể sửa lại Dockerfile để thêm:

```bash
john wfuzz burpsuite zmap amass wpscan
```

Hoặc build riêng từng layer tool nếu dùng hệ thống CI.

#### 📤 Export hoặc đẩy lên registry

```bash
podman save -o kali-pentest.tar kali-pentest
# Hoặc push lên registry riêng
podman tag kali-pentest registry.local/kali
podman push registry.local/kali
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://blog.micsoftvn.com/use-cases/for-engineering/su-dung-podman-tao-base-images-pentest.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
