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文件