HoneyPy 模拟Nginx服务器脚本
HoneyPy是一个Python写的低交互式蜜罐,可以通过自定义Plugins的方式来配置不同的场景。这里是一个模拟Nginx空白页面的代码:
# Auth xiaoxiaoleo
# http://www.cnblogs.com/xiaoxiaoleo/
# from twisted.internet import protocol, reactor, endpoints
from twisted.python import log
import uuid
import datetime
### START CUSTOM IMPORTS ### ############################ class Web(protocol.Protocol): ### Set custom protocol class name
localhost = None
remote_host = None
session = None ### START CUSTOM VARIABLES ############################################################### ########################################################################################## # handle events
def connectionMade(self):
self.connect() ### START CUSTOM CODE #################################################################### ########################################################################################## def dataReceived(self, data):
self.rx(data) ### START CUSTOM CODE ####################################################################
time_str = datetime.datetime.now().strftime('%d %b %Y %H:%M:%S')
response = 'HTTP/1.1 200 OK\r\nServer: nginx/1.10.0 (CentOS)\r\nDate: ' + time_str +' GMT\r\nContent-Type: text/html\r\nLast-Modified: ' + time_str + ' GMT\r\nConnection: close\r\nETag: W/"583bbb00-264"\r\nContent-Length: 612\r\n'+"""
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p> <p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p>
</body>
</html>
"""
self.tx(response) ########################################################################################## ### START CUSTOM FUNCTIONS ################################################################### ############################################################################################## def connect(self):
self.local_host = self.transport.getHost()
self.remote_host = self.transport.getPeer()
self.session = uuid.uuid1()
log.msg('%s %s CONNECT %s %s %s %s %s' % (self.session, self.remote_host.type, self.local_host.host, self.local_host.port, self.factory.name, self.remote_host.host, self.remote_host.port)) def tx(self, data):
log.msg('%s %s TX %s %s %s %s %s %s' % (self.session, self.remote_host.type, self.local_host.host, self.local_host.port, self.factory.name, self.remote_host.host, self.remote_host.port, data.encode("hex")))
self.transport.write(data) def rx(self, data):
log.msg('%s %s RX %s %s %s %s %s %s' % (self.session, self.remote_host.type, self.local_host.host, self.local_host.port, self.factory.name, self.remote_host.host, self.remote_host.port, data.encode("hex"))) class pluginFactory(protocol.Factory):
protocol = Web ### Set protocol to custom protocol class name def __init__(self, name=None):
self.name = name or 'HoneyPy'
效果:
HTTP header:

HTML:

脚本写得不够完美,对Etag和Last-Modified分析一下,蜜罐就露出马脚~
HoneyPy 模拟Nginx服务器脚本的更多相关文章
- nginx服务器是怎么执行php脚本的?
简单的说: fastCGI是nginx和php之间的一个通信接口,该接口实际处理过程通过启动php-fpm进程来解 析php脚本,即php-fpm相 当于一个动态应用服务器,从而实现nginx动态解析 ...
- 利用系统函数模拟实现nginx 系统脚本启动的特殊颜色专业效果
利用系统函数模拟实现nginx 系统脚本启动的特殊颜色专业效果/etc/init.d/nginxd {start/stop/restart/reload}利用if语句实现: ============= ...
- 06_Linux基础-NGINX和浏览器、网页的关系-云服务器ssh登陆-安装NGINX-上传网页-压缩命令-xz-gzip-bzip2-zip-tar-配置NGINX服务器支持下载功能-备份脚本
06_Linux基础-NGINX和浏览器.网页的关系-云服务器ssh登陆-安装NGINX-上传网页-压缩命令-xz-gzip-bzip2-zip-tar-配置NGINX服务器支持下载功能-备份脚本 一 ...
- linux软件管理之------编译安装nginx服务器并手动编写自动化运行脚本
红帽系列的 linux软件管理分为三类:1. rpm 安装软件.2. yum 安装软件.3. 源码包编译安装.前面两种会在相关专题给出详细讲解.源码包的编译安装是非常关键的,我们知道linux的相关版 ...
- Docker 使用入门,创建一个Nginx服务器
运行环境: MAC Docker 版本: Docker version 17.12.0-ce, build c97c6d6 一.启动Nginx 服务器 启动Nginx 服务器,并进入模拟终端 dock ...
- Nginx服务器性能优化与安全配置实践指南
转载自:https://www.bilibili.com/read/cv16151784?spm_id_from=333.999.0.0 1.引言 1.1 目的 为了更好的指导部署与测试艺术升系统ng ...
- nginx入门篇----nginx服务器基础配置
1.nginx.conf文件结构... #全局块 events{ ... } http #http块{ ...
- Nginx+Keepalived(带Nginx监控脚本)
转载于:http://www.itxuexiwang.com/a/liunxjishu/2016/0220/151.html?1456381460 Keepalived+ nginx的安装部署 主机: ...
- nginx服务器绑定域名和设置根目录的方法
nginx服务器绑定域名以及设置根目录非常方便,首先进入nginx安装目录,然后执行 vim conf/nginx.conf 打开nginx的配置文件,找到 server { ..... ..... ...
随机推荐
- [转]struct2 拦截所有没有登录的用户,强行转到登录界面AuthorizationInterceptor
package com.sise.action; import java.util.Map; import com.opensymphony.xwork2.Action; import com ...
- mysql 查询当月天数
SELECT day(LAST_DAY('2018-02-01')) 思路: 先通过LAST_DAY() 查找当月最后一天,然后通过day()返回天数.
- 远程连接云主机MySql数据库
笔者最近在学习MySql数据库,试着远程连接阿里云主机数据库.在连接过程中遇到不少麻烦,这里总结一下过程中遇到的问题. 基本前提 先在本地电脑和远程主机上安装MySql数据库,保证数据库服务启动. 云 ...
- 异常处理中try,else,finally含有return的情况解析
直接看代码,拿到你的py下运行测试一下就 明白了. 例一: def f(): try: print() finally: print() print(f()) # 若注释掉finally内的retur ...
- zabbix从入门到精通
第1章 zabbix监控 1.1 为什么要监控 在需要的时刻,提前提醒我们服务器出问题了 当出问题之后,可以找到问题的根源 网站/服务器 的可用性 1.1.1 网站可用性 在软件系统的高可靠性(也 ...
- LeetCode 410——分割数组的最大值
1. 题目 2. 解答 此题目为 今日头条 2018 AI Camp 5 月 26 日在线笔试编程题第二道--最小分割分数. class Solution { public: // 若分割数组的最大值 ...
- 常量表达式 & constexpr
[常量表达式] 一个这样的表达式:值不会改变 && 在编译过程中就能够得到计算结果 常见的常量表达式:字面值.用常量表达式初始化的const对象 一个对象是不是常量表达式由它的数据类型 ...
- winform 外部组件发生异常
问题描述.先前程序运行可以正常,但是突然这次调试就弹出此异常: 解决方法:1.本次调试是不是重新生成解决方案了?应该是因为之前的解决方案删了,把引用的dll(包含此dll关联的dll)自动删掉: 2. ...
- Ext.net中TreePanel动态生成
这个问题可以参考官网例子:http://examples2.ext.net/#/TreePanel/Basic/Built_in_CodeBehind/ 贴一段本人程序中用到的动态生成核心代码: Ex ...
- C++编码规范101
组织和策略问题 第0条 不要拘泥于小节(又名:了解哪些东西不应该标准化) 第1条 在高警告级别干净利落地进行编译 第2条 使用自动构建系统 第3条 使用版本控制系统 第4条 在代码审查上投入 设计风格 ...