python web.py部署蜜罐

python web模块下载地址:https://github.com/webpy/webpy/releases

部署蜜罐代码:

# coding=utf-8
import sys
import logging
# sys.setdefaultencoding("utf-8")
import web  
import platform  
import os
import time
from web.template import ALLOWED_AST_NODES
ALLOWED_AST_NODES.append('Constant')

# reload(sys) 
port = sys.argv[1] 
 
urls = ('/.*','All')  
  
class All:  
    def GET(self):  
        con = web.ctx.fullpath  
        ip = web.ctx.ip
        web.header('server','avtech cisco-IOS GoAhead-Webs zte huawei Router Start MikroTik voip mini_httpd DrayTek Vigor ADSL Canon Hikvision-Webs HP HTTP Server Oracle') 
        web.header('www_authenticate','NETCORE DVR Router')
        if ip == 'x.x.x.x':  
            pass  
        else:  
            aa=web.cookies()
            print(aa)
            fw=open('/root/python/log.txt','a')            
            txtdata=time.asctime()+'---GET---'+ip+'-'+con+'---cookie:'+str(aa)+'\r\n'
            fw.write(txtdata)
            fw.close()  
        render = web.template.render('templates/') 
        return render.index()
    def POST(self):  
        con = web.ctx.fullpath  
        postdata = web.data() 
        postdata = postdata.replace('\r\n',' ')  
        postdata = postdata.replace('\r',' ')
        ip = web.ctx.ip
        web.header('server','avtech cisco-IOS GoAhead-Webs zte huawei Router Start MikroTik voip mini_httpd DrayTek Vigor ADSL Canon Hikvision-Webs HP HTTP Server Oracle') 
        web.header('www_authenticate','NETCORE DVR Router')
        if ip == 'x.x.x.x':  
            pass  
        else:  
            fw=open('/root/python/log.txt','a')      
            aa=web.cookies()
            txtdata=time.asctime()+'---POST---'+ip+'-'+con+'---cookie:'+str(aa)+'---postdata:'+postdata+'\r\n'
            fw.write(txtdata)
            fw.close()
        print (postdata)
        render = web.template.render('templates/') 
        return render.index() 
        return ''  
  
if __name__ == '__main__':  
    app = web.application(urls,globals())  
    app.run()

在templates目录下放置蜜罐html文件

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值