Ubuntu 安装工控蜜罐 Conpot
变更记录
本文自初次发布以来有如下变更。
# 修改时间 变更内容 2 2023年4月14日(英国时间) 修正Conpot拼写错误 1 2020年8月27日(中国时间) 截图内容热修复 0 2020年8月27日(中国时间) 首次发布
- 当前版本#: 2
- 最后修改时间: 2023年4月14日 (英国夏令时时区 UTC+0100)
- 感谢指出截图问题的学生。
- 感谢青衫旧矣指出拼写问题。
信息
可选环境: 适用于 Linux 的 Windows 子系统(WSL), Ubuntu 18.04 LTS, Python 3.6, pip 3
先决条件: Linux 已安装,合适版本的 Python 和 pip 已安装
重要提示
重要: 本文仅介绍如何下载并安装 Conpot,不介绍如何详细地配置使用它。如果您要查找如何配置 Conpot,那么这篇文章或许对您帮助不大。
重要: 本文的所有内容不提供任何担保。
0. 准备环境
0.1 如果您需要 WSL 环境,请参考如何 在 Windows 10 中安装 WSL (适用于 Linux 的 Windows 子系统)。
0.2 如果您尚未安装 Python 3.6,请执行
sudo apt-cache madison python3
sudo apt-get install python3
0.3 如果您尚未安装 pip,请执行
#sudo apt install python-pip
sudo apt install python3-pip
1. 安装依赖
使用 apt 安装如下依赖。
sudo apt-get install libsmi2ldbl snmp-mibs-downloader python-dev libevent-dev libxslt1-dev libxml2-dev
2. 安装 Conpot
使用如下命令安装 Conpot。
sudo pip3 install conpot
安装时可能遇到一些问题,请参考以下提示。
提示
您可以使用国内镜像代替上述命令,为获得更快的下载速度。
pip install conpot -i https://pypi.douban.com/simple/
提示
如果出现如下错误:
ERROR: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-oqFhKx/MySQL-python/
则以 root 身份登录,并执行
python -m pip install --upgrade --force pip pip3 install setuptools==33.1.1
提示
如果您使用
sudo
而非以 root 身份登录,可能会出现如下警告The directory '/home/(Username)/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag. The directory '/home/(Username)/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
出现以下错误,请尝试以 root 身份登录
sudo su
然后重试。
提示
如果您收到以下警告(以 Python 2.7 为例)
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
则表明您的 Python 或 pip 版本不正确,请打断当前正在执行的命令,并尝试以
pip3
代替pip
。
3. 运行 Conpot
首先找到 Conpot,可能会在如下位置找到
cd ~/.local/lib/python3.6/site-packages/bin
您可能会发现该目录下有这些文件
ls -l
-rw-r--r-- 1 Username Username 0 Date Time __init__.py
drwxr-xr-x 1 Username Username 512 Date Time __pycache__
-rwxr-xr-x 1 Username Username 18963 Date Time conpot
-rw-r--r-- 1 Username Username Size Date Time conpot.log
-rw-r--r-- 1 Username Username 6833 Date Time kamstrup_prober.py
此时,您可执行
./conpot -f -t default
便会看到如下内容以及日志。
WARNING:scapy.runtime:No route found for IPv6 destination :: (no default route?)
_
___ ___ ___ ___ ___| |_
| _| . | | . | . | _|
|___|___|_|_| _|___|_|
|_|
Version 0.6.0
MushMush Foundation
# 一些日志 . . .
当看到
# 一些日志 . . .
Starting TFTP server at ('0.0.0.0', 6969)
则表明 Conpot 已经启动了。
提示
如果您使用 WSL,则会看到 Windows Defender Firewall 防火墙的提示。请选择允许访问,以便开放防火墙端口。
这时,可以打开浏览器,访问 http://localhost:8800/index.html 【点击此处打开】,即可看到 Overview 页面。
当您想停止时,请在终端按下 Control + C。您会看到一下内容。
# 一些日志 . . .
^CKeyboardInterrupt
# 一些日志 . . .
Conpot 会退出,您会回到 shell。
信息
另外,如果您查看文件 conpot,应该看到如下内容
cat conpot
其中,第一行的#!/usr/bin/env python3
应为 Python 的环境变量。如果不是,您应该改正。
提示
您可以将 conpot 加入系统环境变量,以便日后作为命令便于使用。
Enjoy it!
至此,Conpot 安装完毕。接下来,您应该考虑如何详细地配置它。