opencanary_web安装记录

Opencanary内网低交互蜜罐

Tornado+Vue+Mysql+APScheduler+Nginx+Supervisor

opencanary_web安装记录_第1张图片

后台可统计的信息

  1. ftp登录尝试;
  2. http访问请求;
  3. http登录请求;
  4. ssh建立连接;
  5. ssh远程版本发送;
  6. ssh登录尝试;
  7. telnet登录尝试;
  8. 全端口(SYN)扫描识别;
  9. NMAP OS扫描识别;
  10. NMAP NULL扫描识别;
  11. NMAP XMAS扫描识别;
  12. NMAP FIN扫描识别;
  13. mysql登录尝试;
  14. git clone请求;
  15. ntp monlist请求(默认关闭);
  16. redis命令请求;
  17. TCP连接请求;
  18. vnc连接请求;
  19. rdp协议windows远程登录;
  20. snmp扫描;
  21. sip请求;
  22. mssql登录sql账户认证;
  23. mssql登录win身份认证;
  24. http代理登录尝试;

操作系统:

  • CentOS 7.5

安装蜜罐管理后台-Web

在安装之前,请自行更换yum

打开终端,在 root 用户 Shell 下,输入以下命令:

curl -O https://raw.githubusercontent.com/p1r06u3/opencanary_web/master/install/install_opencanary_web.sh

或者输入输入以下命令:

wget --no-check-certificate https://raw.githubusercontent.com/p1r06u3/opencanary_web/master/install/install_opencanary_web.sh

下载后输入

bash install_opencanary_web.sh

提示IP是否正确,yes之后开始安装,安装

############ 是否配置Opencanary_Web蜜罐邮件收发,输入yes/no?Enter.默认no. ############

yes
############正在配置opencanary蜜罐邮件收发###########
smtp服务器地址:smtp.****.net
邮箱用户名:****@***.net
输入邮箱密码:****
邮箱后缀名:****.net
############配置已完成,下一步配置收件人邮箱###########
收件人邮箱:****@qq.com

#######正在开启告警邮件开关##########
#######开启告警邮件成功##########
############告警邮件配置已完成############
############正在重启服务############
已同步cn.pool.ntp.org时间,已关闭SELINUX和防火墙
已安装pip,及安装并配置supervisor
已安装mysql,并配置普通用户honeypot密码Weiho@2019,可以通过mysql -u honeypot@'localhost' -pWeiho@2019 进行管理
已经安装并配置nginx并把原nginx配置文件备份到/etc/nginx/nginx.conf.bak
已成功安装opencanary_web,文件路径:/usr/local/src/opencanary_web
可以打开http://IP,输入账号admin密码admin进行访问操作
如要修改opencanary_web管理密码,可以通过mysql进行更改,请执行sql语句password的值换成自己的32位md5.
UPDATE User SET password='*****' WHERE id=1;
以及修改/usr/local/src/opencanary_web/dbs/initdb.py,DB_USER/DB_PWD字段
已经配置成功蜜罐告警邮件,具体配置浏览/usr/local/src/opencanary_web/application.py
收件人邮件配置(以及告警开关):/usr/local/src/opencanary_web/util/conf/email.ini
更多信息请参考https://github.com/p1r06u3/opencanary_web
 

 

 

安装完毕

本脚本安装完毕后会以系统服务形式启动Supervisord/Nginx/Mysql

启动服务

systemctl start supervisord.service
systemctl start nginx.service
systemctl start mariadb.service

停止服务

systemctl stop supervisord.service
systemctl stop nginx.service
systemctl stop mariadb.service

重启服务

systemctl restart supervisord.service
systemctl restart nginx.service
systemctl restart mariadb.service

查看服务运行状态

systemctl status supervisord.service
systemctl status nginx.service
systemctl status mariadb.service

Supervisor( http://supervisord.org/ )是用Python开发的一个client/server服务,是Linux/Unix系统下的一个进程管理工具,不支持Windows系统。它可以很方便的监听、启动、停止、重启一个或多个进程。用Supervisor管理的进程,当一个进程意外被杀死,supervisort监听到进程死后,会自动将它重新拉起,很方便的做到进程自动恢复的功能,不再需要自己写shell脚本来控制。

 supervisor子配置:

vim /etc/supervisord.d/tornado.ini

 

nginx反向代理tornado

 vim /etc/nginx/nginx.conf

 

安装Web后信息

访问URL:http://$ip

类型 用户名 密码
Web账号 admin admin
mysql 数据库 honeypot Weiho@2019
mysql 端口 3306 -
OpenCanary_Web物理路径 /usr/src/local/opencanary_web -
发件人邮件配置 /usr/local/src/opencanary_web/application.py -
收件人邮件配置(以及告警开关) /usr/local/src/opencanary_web/util/conf/email.ini -

 

 




 

安装蜜罐客户端-Agent

另外开一台虚拟主机(VPS)安装蜜罐客户端.

curl -O https://raw.githubusercontent.com/p1r06u3/opencanary_web/master/install/install_opencanary_agent.sh

或者输入输入以下命令:

wget --no-check-certificate https://raw.githubusercontent.com/p1r06u3/opencanary_web/master/install/install_opencanary_agent.sh

echo "###########正在下载opencanary_agent#########"
opencanary_folder="/usr/local/src/opencanary"

下载后输入

bash install_opencanary_agent.sh

输入上面Web服务端的IP.等待脚本执行完毕,即可.

到服务端的Web页面进行管理http://$ip.

[root@jjjj ~]# curl -O https://raw.githubusercontent.com/p1r06u3/opencanary_web/master/install/install_opencanary_agent.sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  6694  100  6694    0     0  16300      0 --:--:-- --:--:-- --:--:-- 16326
[root@jjjj ~]# bash install_opencanary_agent.sh
###############请确认已经安装Web服务端##############
请确认是否已经安装OpenCanary_Web服务端(y/n)y
请确认本机IP:***.***.***.***是否正确?(y/n)y
请输入Web服务端IP:***.***.***.***

节点名称:test1

###########正在安装系统依赖#########
...

Please look at log file for more information.
################第一次运行,初始化opencanaryd############
################已安装完成opencanaryd_agent############
安装opencanary_agent成功.opencanary支持以下协议
ftp登录尝试/http访问请求/http登录请求/ssh建立连接
ssh远程版本发送/ssh登录尝试/telnet登录尝试/mysql登录尝试
建议使用iptables对相关端口进行管理,详细请参考https://github.com/p1r06u3/opencanary_web
请登陆至http://***.***.***.*** 进行管理.

 

 

如果后台和客户端都安装在一个服务器上:

An error has occurred: 'Couldn't listen on ***.***.***.*** :80: [Errno 98] Address already in use.'
Please look at log file for more information.

vim /etc/nginx/conf.d/hp.conf

修改80端口可以达到修改后台的访问端口

upstream hp {
    server 127.0.0.1:8000;
    server 127.0.0.1:8001;
    server 127.0.0.1:8002;
    server 127.0.0.1:8003;
}
server {
    listen  801;

upstream模块:将使nginx跨越单机的限制,完成网络数据的接收、处理和转发。

从本质上说,upstream属于handler,只是他不产生自己的内容,而是通过请求后端服务器得到内容,所以才称为upstream(上游)。请求并取得响应内容的整个过程已经被封装到nginx内部,所以upstream模块只需要开发若干回调函数,完成构造请求和解析响应等具体的工作。

Nginx配置upstream实现负载均衡...

 

An error has occurred: 'Couldn't listen on ***.***.***.*** :3306: [Errno 98] Address already in use.'
Please look at log file for more information.

 

后台安装目录:

git clone https://github.com/p1r06u3/opencanary_web.git /usr/local/src/opencanary_web

mysql数据库:

CentOS 7.0 使用 yum 安装 MariaDB 与 MariaDB 的简单配置

修改MariaDB默认端口

vim /etc/my.cnf

添加port=3308

systemctl restart mariadb.service

[root@jjjj opencanary_web]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.60-MariaDB MariaDB Server

...

MariaDB [(none)]> show global variables like 'port';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port          | 3308  |
+---------------+-------+
1 row in set (0.01 sec)
 

 

 

修改数据库连接密码:

vim /usr/local/src/opencanary_web/dbs/initdb.py

# 数据库配置
DB_HOST = '127.0.0.1'
DB_USER = 'honeypot'
DB_PWD = 'Weiho@2019'
DB_NAME = 'honeypot'
DB_PORT = '3308'

# 创建对象基类
Base = declarative_base()

# 初始化数据库连接
engine = create_engine('mysql+pymysql://%s:%s@%s:%s/%s?charset=utf8' %
                       (DB_USER, DB_PWD, DB_HOST, DB_PORT, DB_NAME),
                   encoding='utf-8', echo=True,
                 pool_size=100, pool_pre_ping=True, pool_recycle=3600)

#mysql -u root -phuanchengzijidemima -P3308 -h127.0.0.1

[root@jjjj opencanary_web]# mysql -uroot -P3308
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> use honeypot
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [honeypot]> delete from Host where status='offline';
Query OK, 2 rows affected (0.02 sec)

MariaDB [honeypot]> delete from OpencanaryLog where white=1;
Query OK, 0 rows affected (0.00 sec)

MariaDB [honeypot]> delete from OpencanaryLog where white=2;
Query OK, 26 rows affected (0.00 sec)

MariaDB [honeypot]> UPDATE User SET password='*********' WHERE id=1;
Query OK, 1 row affected (0.02 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [honeypot]>

 

开发模式运行: opencanaryd --dev

opencanary日志: /var/tmp/opencanary.log

配置文件位置: /root/.opencanary.conf

 

vim /usr/local/src/opencanary/opencanary/data/settings.json

  • 将第2行,device.node_id的值opencanary-1代表将来告警的节点,可以改为主机名等任意字符(不改也可以)。

    "device.node_id": "opencanary-1",
    
  • 将第3行,server.ip改成自己web服务端的ip(重要)。

    注意: 如果你的web端,不是80端口,要在配置的ip后面跟上“:端口号”。

    "server.ip": "172.18.214.121:801",

rm -rf /root/.opencanary.conf

opencanaryd --copyconfig

opencanaryd --restart

如果这个不生效,就直接修改/root/.opencanary.conf

 

An error has occurred: 'Couldn't listen on any:8001: [Errno 98] Address already in use.'
Please look at log file for more information.

https://github.com/p1r06u3/opencanary/blob/master/opencanary/data/settings.json
"tcpbanner_1.port": 8001,
    "tcpbanner_1.datareceivedbanner": "cmdserver",

vim /etc/nginx/conf.d/hp.conf

upstream hp {
    server 127.0.0.1:8000;
    server 127.0.0.1:8004;
    server 127.0.0.1:8002;
    server 127.0.0.1:8003;
}

[root@jjjj conf.d]# ls /etc/supervisord.d/
conf.dtornado.ini
[root@jjjj conf.d]#vim /etc/supervisord.d/conf.dtornado.ini  #这个文件最好用Tab键获取完整路径

[group:tornadoes]
programs=tornado-8000,tornado-8004,tornado-8002,tornado-8003

[program:tornado-8000]
command=python /usr/local/src/opencanary_web/server.py --port=8000
directory=/usr/local/src/opencanary_web
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/tornado.log
loglevel=debug

[program:tornado-8004]
command=python /usr/local/src/opencanary_web/server.py --port=8004
...

systemctl restart supervisord.service
systemctl restart nginx.service

opencanaryd --start

opencanary_web安装记录_第2张图片

 


 

更多:

https://github.com/p1r06u3/opencanary_web/blob/master/docs/install/Document.md

https://github.com/p1r06u3/opencanary_web/blob/master/docs/install/Manual_Installation.md

https://github.com/p1r06u3/opencanary

https://github.com/p1r06u3/opencanary_web

 

 

 

你可能感兴趣的:(网络安全知识,蜜罐)