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服务器脚本的更多相关文章

  1. nginx服务器是怎么执行php脚本的?

    简单的说: fastCGI是nginx和php之间的一个通信接口,该接口实际处理过程通过启动php-fpm进程来解 析php脚本,即php-fpm相 当于一个动态应用服务器,从而实现nginx动态解析 ...

  2. 利用系统函数模拟实现nginx 系统脚本启动的特殊颜色专业效果

    利用系统函数模拟实现nginx 系统脚本启动的特殊颜色专业效果/etc/init.d/nginxd {start/stop/restart/reload}利用if语句实现: ============= ...

  3. 06_Linux基础-NGINX和浏览器、网页的关系-云服务器ssh登陆-安装NGINX-上传网页-压缩命令-xz-gzip-bzip2-zip-tar-配置NGINX服务器支持下载功能-备份脚本

    06_Linux基础-NGINX和浏览器.网页的关系-云服务器ssh登陆-安装NGINX-上传网页-压缩命令-xz-gzip-bzip2-zip-tar-配置NGINX服务器支持下载功能-备份脚本 一 ...

  4. linux软件管理之------编译安装nginx服务器并手动编写自动化运行脚本

    红帽系列的 linux软件管理分为三类:1. rpm 安装软件.2. yum 安装软件.3. 源码包编译安装.前面两种会在相关专题给出详细讲解.源码包的编译安装是非常关键的,我们知道linux的相关版 ...

  5. Docker 使用入门,创建一个Nginx服务器

    运行环境: MAC Docker 版本: Docker version 17.12.0-ce, build c97c6d6 一.启动Nginx 服务器 启动Nginx 服务器,并进入模拟终端 dock ...

  6. Nginx服务器性能优化与安全配置实践指南

    转载自:https://www.bilibili.com/read/cv16151784?spm_id_from=333.999.0.0 1.引言 1.1 目的 为了更好的指导部署与测试艺术升系统ng ...

  7. nginx入门篇----nginx服务器基础配置

    1.nginx.conf文件结构...                         #全局块  events{  ...  }  http                      #http块{ ...

  8. Nginx+Keepalived(带Nginx监控脚本)

    转载于:http://www.itxuexiwang.com/a/liunxjishu/2016/0220/151.html?1456381460 Keepalived+ nginx的安装部署 主机: ...

  9. nginx服务器绑定域名和设置根目录的方法

    nginx服务器绑定域名以及设置根目录非常方便,首先进入nginx安装目录,然后执行 vim conf/nginx.conf 打开nginx的配置文件,找到 server { ..... ..... ...

随机推荐

  1. Sql面试题之三(难度:简单| 含答案)

    Sql面试题之三(难度:简单| 含答案) 答案: .SELECT B.name, B.Depart T.Content FROM B, T WHERE ( T.Content = '税法培训' and ...

  2. BZOJ 2049 SDOI2008 洞穴勘测 LCT板子

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2049 题意概述:给出N个点,一开始不连通,M次操作,删边加边,保证图是一个森林,询问两点连 ...

  3. JavaSE复习(六)函数式接口

    函数式接口 有且仅有一个抽象方法的接口 @FunctionalInterface注解 一旦使用该注解来定义接口,编译器将会强制检查该接口是否确实有且仅有一个抽象方法,否则将会报错.需要注 意的是,即使 ...

  4. JavaWeb笔记(十二)日志

    日志 日志信息根据用途与记录内容的不同,分为调试日志.运行日志.异常日志等. Java常用记录日志 logger log4j log4j2 logback 其中除了logger使用的概率较小,因此主要 ...

  5. 图书 Framework 设计指南: 可重用 .NET 库的约定、惯用法和模式 引出资料

    文章:框架设计准则     --微软 地址:https://docs.microsoft.com/zh-cn/dotnet/standard/design-guidelines/index

  6. Chromium之工程依赖关系.

    Chromium各版本可能有差异,我的版本是chromium.r197479,2013/08前后下载的source code. Visual Studio Ultimate版本有工具可以自动生成项目依 ...

  7. Visual Studio 2012,创建工程Build Driver,基于纯Source Code.

    拿到一堆纯代码,怎么去Create Project,设置Include路径,lib路径,要不要Pre-compile技术,配置Project之间的依赖关系. SourcesConverter  Bas ...

  8. elmentUI组件怎么绑定原生事件

    el-input为例: <el-input id="user-input" type="textarea" placeholder="请换行输入 ...

  9. elementUI默认样式修改不成功的问题

    问题: login.vue中引入<style lang="postcss" src="./login.css" scoped></style& ...

  10. RPC里面的序列化反序列化以及拆包粘包

    1.序列化(1)什么是序列化? Java的序列化是把对象转换成有序字节流的过程.以便进行网络传输或者保存到本地.(2)为什么要序列化? 当两个进程进行远程通信时,如果需要发送各种各样的数据,文本.音频 ...