def post(self, id, do): if id: row=db.ct("module", "*", "id="+id) if row: description = urlen(self.get_argument('description', 'None')) name = urlen(self.get_argument('name', 'None')) code = urlen(self.get_argument('code', 'None')) addtime = int(time.time()) db.u( "module", "description='"+description+"',name='"+name+"',code='"+code+"',addtime="+str(addtime), "id="+id) self.redirect("http://"+URL+"/module") else: self.render('404.html') else: if do == 'add': description = urlen(self.get_argument('description', 'None')) name = urlen(self.get_argument('name', 'None')) code = urlen(self.get_argument('code', 'None')) addtime = int(time.time()) db.i( "module", "description,name,code,addtime", "'"+description+"','"+name+"','"+code+"','"+str(addtime)+"'") self.redirect("http://"+URL+"/module") elif do == 'del': db.d("module", "id in ("+self.get_argument('id')+")") else: self.render('404.html')
def post(self, id, do): if id: row = db.ct("module", "*", "id=" + id) if row: description = urlen(self.get_argument('description', 'None')) name = urlen(self.get_argument('name', 'None')) code = urlen(self.get_argument('code', 'None')) addtime = int(time.time()) db.u( "module", "description='" + description + "',name='" + name + "',code='" + code + "',addtime=" + str(addtime), "id=" + id) self.redirect("http://" + URL + "/module") else: self.render('404.html') else: if do == 'add': description = urlen(self.get_argument('description', 'None')) name = urlen(self.get_argument('name', 'None')) code = urlen(self.get_argument('code', 'None')) addtime = int(time.time()) db.i( "module", "description,name,code,addtime", "'" + description + "','" + name + "','" + code + "','" + str(addtime) + "'") self.redirect("http://" + URL + "/module") elif do == 'del': db.d("module", "id in (" + self.get_argument('id') + ")") else: self.render('404.html')
def get(self, projectid, ip, page, do): def getname(id): return urlde(db.ct("project", "name", "id=" + id)['name']) if ip and projectid: num = db.c('host', "hostip='" + ip + "' and projectid='" + projectid + "'") if num: page = str(page and (int(page) - 1 > 0 and (int(page) - 1 < num and int(page) - 1 or 0) or 0) or 0) host = db.ct( "host", "*", "hostip = '" + ip + "' and projectid='" + projectid + "' order by id desc limit " + page + ",1") if do == 'del': db.d("host", "id=" + str(host['id'])) if num == 1: hostlist = json.loads( db.ct("project", "hosts", "id=" + projectid)['hosts']) hostlist.remove(ip) db.u("project", "hosts='" + json.dumps(hostlist) + "'", "id=" + projectid) self.redirect("http://" + URL + "/project/" + projectid) self.redirect("http://" + URL + "/host/" + projectid + "/" + ip) else: self.render( "host.html", heads=[ { 'name': getname(projectid), 'title': 'Go to ' + getname(projectid), 'url': 'project/' + projectid }, { 'name': ip, 'title': '', 'url': '' }, ], username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), urlde=urlde, timede=timede, url=URL, urljson=urljson, host=host, num=range(num), page=int(page) + 1, ) else: self.render('404.html') else: self.render('404.html')
def post(self, id, do): if id: if do == 'del': hostip = self.get_argument('hostip').split(',') hostlist = json.loads(db.ct("project","hosts","id="+id)['hosts']) hostips = '' for x in hostip: hostlist.remove(x) hostips += "'"+x+"'," print hostlist,hostips db.u("project", "hosts='"+json.dumps(hostlist)+"'", "id="+id) db.d("host", "hostip in ("+hostips[:-1]+") and projectid="+id) else: row = db.ct("project", "*", "id="+id) if row: post_data = {} for key in self.request.arguments: post_data[key] = self.get_arguments(key) i = 0 module = {} if 'moduleid' in post_data: for key in post_data['moduleid']: module[key] = urlen(post_data['modulecustom'][i]) i += 1 module = json.dumps(module) else: module = '[]' addtime = int(time.time()) db.u( "project", "name='"+urlen(post_data['name'][0])+"',description='"+urlen(post_data['description'][0])+"',email='"+post_data['email'][0]+ "',custom='"+urlen(post_data['custom'][0])+"',fip='"+post_data['fip'][0]+"',furl='"+post_data['furl'][0]+"',status='"+post_data['status'][0]+ "',module='"+module+"',addtime="+str(addtime), "id="+id) self.redirect("http://"+URL+"/project") else: self.render('404.html') else: if do == 'add': post_data = {} for key in self.request.arguments: post_data[key] = self.get_arguments(key) i = 0 module = {} if 'moduleid' in post_data: for key in post_data['moduleid']: module[key]=urlen(post_data['modulecustom'][i]) i += 1 module = json.dumps(module) else: module = '[]' addtime = int(time.time()) db.i( "project","name,description,email,custom,fip,furl,status,hosts,module,addtime","'"+urlen(post_data['name'][0])+"','"+ urlen(post_data['description'][0])+"','"+post_data['email'][0]+"','"+urlen(post_data['custom'][0])+"','"+post_data['fip'][0]+"','"+ post_data['furl'][0]+"','"+post_data['status'][0]+"','[]','"+module+"','"+str(addtime)+"'") self.redirect("http://"+URL+"/project") elif do == 'del': db.d("project", "id in ("+self.get_argument('id')+")")
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, projectid, ip, page, do): def getname(id): return urlde(db.ct("project", "name", "id=" + id)["name"]) if ip and projectid: num = db.c("host", "hostip='" + ip + "' and projectid='" + projectid + "'") if num: page = str(page and (int(page) - 1 > 0 and (int(page) - 1 < num and int(page) - 1 or 0) or 0) or 0) host = db.ct( "host", "*", "hostip = '" + ip + "' and projectid='" + projectid + "' order by id desc limit " + page + ",1", ) if do == "del": db.d("host", "id=" + str(host["id"])) if num == 1: hostlist = json.loads(db.ct("project", "hosts", "id=" + projectid)["hosts"]) hostlist.remove(ip) db.u("project", "hosts='" + json.dumps(hostlist) + "'", "id=" + projectid) self.redirect("http://" + URL + "/project/" + projectid) self.redirect("http://" + URL + "/host/" + projectid + "/" + ip) else: self.render( "host.html", heads=[ { "name": getname(projectid), "title": "Go to " + getname(projectid), "url": "project/" + projectid, }, {"name": ip, "title": "", "url": ""}, ], username=self.get_secure_cookie("username"), datainfo=db.datainfo(), urlde=urlde, timede=timede, url=URL, urljson=urljson, host=host, num=range(num), page=int(page) + 1, ) else: self.render("404.html") else: self.render("404.html")
def get(self, projectid, ip, page, do): def getname(id): return urlde(db.ct("project","name","id="+id)['name']) if ip and projectid: num = db.c('host', "hostip='"+ip+"' and projectid='"+projectid+"'") if num: page = str(page and (int(page)-1>0 and (int(page)-1<num and int(page)-1 or 0) or 0) or 0) host = db.ct( "host", "*", "hostip = '"+ip+"' and projectid='"+projectid+"' order by id desc limit "+page+",1") if do == 'del': db.d("host", "id="+str(host['id'])) if num == 1: hostlist = json.loads(db.ct("project", "hosts", "id="+projectid)['hosts']) hostlist.remove(ip) db.u("project", "hosts='"+json.dumps(hostlist)+"'", "id="+projectid) self.redirect("http://"+URL+"/project/"+projectid) self.redirect("http://"+URL+"/host/"+projectid+"/"+ip) else: self.render( "host.html", heads=[ {'name':getname(projectid), 'title': 'Go to ' + getname(projectid), 'url': 'project/'+projectid}, {'name': ip, 'title': '', 'url': ''}, ], username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), urlde=urlde, timede=timede, url=URL, urljson=urljson, host=host, num=range(num), page=int(page)+1, ) else: self.render('404.html') else: self.render('404.html')
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 post(self, id, do): if id: if do == "del": hostip = self.get_argument("hostip").split(",") hostlist = json.loads(db.ct("project", "hosts", "id=" + id)["hosts"]) for x in hostip: hostlist.remove(x) hostips = "'" + x + "'," db.u("project", "hosts='" + json.dumps(hostlist) + "'", "id=" + id) db.d("host", "hostip in (" + hostips[:-1] + ") and projectid=" + id) else: row = db.ct("project", "*", "id=" + id) if row: post_data = {} for key in self.request.arguments: post_data[key] = self.get_arguments(key) i = 0 module = {} if "moduleid" in post_data: for key in post_data["moduleid"]: module[key] = urlen(post_data["modulecustom"][i]) i += 1 module = json.dumps(module) else: module = "[]" addtime = int(time.time()) db.u( "project", "name='" + urlen(post_data["name"][0]) + "',description='" + urlen(post_data["description"][0]) + "',email='" + post_data["email"][0] + "',custom='" + urlen(post_data["custom"][0]) + "',fip='" + post_data["fip"][0] + "',furl='" + post_data["furl"][0] + "',status='" + post_data["status"][0] + "',module='" + module + "',addtime=" + str(addtime), "id=" + id, ) self.redirect("http://" + URL + "/project") else: self.render("404.html") else: if do == "add": post_data = {} for key in self.request.arguments: post_data[key] = self.get_arguments(key) i = 0 module = {} if "moduleid" in post_data: for key in post_data["moduleid"]: module[key] = urlen(post_data["modulecustom"][i]) i += 1 module = json.dumps(module) else: module = "[]" addtime = int(time.time()) db.i( "project", "name,description,email,custom,fip,furl,status,hosts,module,addtime", "'" + urlen(post_data["name"][0]) + "','" + urlen(post_data["description"][0]) + "','" + post_data["email"][0] + "','" + urlen(post_data["custom"][0]) + "','" + post_data["fip"][0] + "','" + post_data["furl"][0] + "','" + post_data["status"][0] + "','[]','" + module + "','" + str(addtime) + "'", ) self.redirect("http://" + URL + "/project") elif do == "del": db.d("project", "id in (" + self.get_argument("id") + ")")
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 post(self, id, do): if id: if do == 'del': hostip = self.get_argument('hostip').split(',') hostlist = json.loads( db.ct("project", "hosts", "id=" + id)['hosts']) for x in hostip: hostlist.remove(x) hostips = "'" + x + "'," db.u("project", "hosts='" + json.dumps(hostlist) + "'", "id=" + id) db.d("host", "hostip in (" + hostips[:-1] + ") and projectid=" + id) else: row = db.ct("project", "*", "id=" + id) if row: post_data = {} for key in self.request.arguments: post_data[key] = self.get_arguments(key) i = 0 module = {} if 'moduleid' in post_data: for key in post_data['moduleid']: module[key] = urlen(post_data['modulecustom'][i]) i += 1 module = json.dumps(module) else: module = '[]' addtime = int(time.time()) db.u( "project", "name='" + urlen(post_data['name'][0]) + "',description='" + urlen(post_data['description'][0]) + "',email='" + post_data['email'][0] + "',custom='" + urlen(post_data['custom'][0]) + "',fip='" + post_data['fip'][0] + "',furl='" + post_data['furl'][0] + "',status='" + post_data['status'][0] + "',module='" + module + "',addtime=" + str(addtime), "id=" + id) self.redirect("http://" + URL + "/project") else: self.render('404.html') else: if do == 'add': post_data = {} for key in self.request.arguments: post_data[key] = self.get_arguments(key) i = 0 module = {} if 'moduleid' in post_data: for key in post_data['moduleid']: module[key] = urlen(post_data['modulecustom'][i]) i += 1 module = json.dumps(module) else: module = '[]' addtime = int(time.time()) db.i( "project", "name,description,email,custom,fip,furl,status,hosts,module,addtime", "'" + urlen(post_data['name'][0]) + "','" + urlen(post_data['description'][0]) + "','" + post_data['email'][0] + "','" + urlen(post_data['custom'][0]) + "','" + post_data['fip'][0] + "','" + post_data['furl'][0] + "','" + post_data['status'][0] + "','[]','" + module + "','" + str(addtime) + "'") self.redirect("http://" + URL + "/project") elif do == 'del': db.d("project", "id in (" + self.get_argument('id') + ")")
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, )