Skip to content

Commit

Permalink
fix the word lose under some condition
Browse files Browse the repository at this point in the history
  • Loading branch information
nanshihui committed Aug 31, 2016
1 parent 2d11a8c commit d8788b6
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 102 deletions.
102 changes: 30 additions & 72 deletions .idea/workspace.xml

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions elasticsearchmanage/elastictool.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,18 @@ def decodestr(msg):
def getproperty(dic,property):
return decodestring(str(dic.get(property,' ')))
def decodestring(msg):

if str:
item=msg
if str==type(msg):
try:

return decodestr(msg.decode('string_escape').decode('string_escape'))
try:
item=msg.decode('string_escape').decode('string_escape')
except Exception,e:
item=msg.decode('string_escape')
print e,47

except Exception,e:
print e,42


return decodestr(item)


else:
Expand Down Expand Up @@ -215,7 +218,7 @@ def search(page='0',dic=None,content=None):
if count>0:
for temp in response :
dic=temp.to_dict()
aport=ports.Port(ip=getproperty(dic,'ip'),port=getproperty(dic,'port'),timesearch=getproperty(dic,'timesearch'),state=getproperty(dic,'state'),name=getproperty(dic,'name'),product=getproperty(dic,'product'),version=getproperty(dic,'version'),script=base64.b64encode(getproperty(dic,'script')),detail=getproperty(dic,'detail'),head=getproperty(dic,'head'),city='',hackinfo=getproperty(dic,'hackinfo'),disclosure=getproperty(dic,'disclosure'),keywords=getproperty(dic,'keywords'),webtitle=base64.b64encode(getproperty(dic,'webtitle')),webkeywords=getproperty(dic,'webkeywords'))
aport=ports.Port(ip=getproperty(dic,'ip'),port=getproperty(dic,'port'),timesearch=getproperty(dic,'timesearch'),state=getproperty(dic,'state'),name=getproperty(dic,'name'),product=getproperty(dic,'product'),version=getproperty(dic,'version'),script=base64.b64encode(str(getproperty(dic,'script'))),detail=getproperty(dic,'detail'),head=getproperty(dic,'head'),city='',hackinfo=getproperty(dic,'hackinfo'),disclosure=getproperty(dic,'disclosure'),keywords=getproperty(dic,'keywords'),webtitle=base64.b64encode(str(getproperty(dic,'webtitle'))),webkeywords=getproperty(dic,'webkeywords'))

# ip=getproperty(dic,'ip')
# port=getproperty(dic,'port')
Expand Down
20 changes: 11 additions & 9 deletions spidermanage/fontsearch/searchroute.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@ def indexpage(request):
return render_to_response('fontsearchview/search.html', {'data':'','username':username})
def mainpage(request):
content=request.GET.get('searchcontent','')

page=request.GET.get('page','0')
username = request.COOKIES.get('username','')
content=content.replace(' ','%20')
return render_to_response('fontsearchview/searchdetail.html', {'data':content,'page':page,'username':username})
def mapsearchmain(request):
username = request.COOKIES.get('username', '')
return render_to_response('fontsearchview/mapsearchmain.html',{'username':username})
def detailpage(request):
from spidertool import redistool, webtool
content=request.POST.get('content','')
print content
page=request.POST.get('page','0')
username = request.COOKIES.get('username','')
response_data = {}
Expand Down Expand Up @@ -149,9 +152,7 @@ def detailpage(request):
try:
item =str(webtool.md5('sch_' + str(jsoncontent) + '_page' + str(page)))
print item
print 'sch_' + str(jsoncontent) + '_page' + str(page)
redisresult = redistool.get(item)
print type(redisresult),'result'
if redisresult:
print '从redids取的数据'
try:
Expand Down Expand Up @@ -187,7 +188,7 @@ def detailpage(request):
sys.path.append("..")
from elasticsearchmanage import elastictool
ports,portcount,portpagecount=elastictool.search(page=page,dic=jsoncontent,content=None)

print '设置返回值'

response_data['ports'] = ports
response_data['portslength'] = portcount
Expand All @@ -200,17 +201,18 @@ def detailpage(request):
redisdic['portslength'] = portcount
redisdic['portspagecount'] = portpagecount
redisdic['portspage'] = page
print '准备存入redis'
redistool.set(item, redisdic)
redistool.expire(item, timeout)
print '存入redis'

except Exception,e:
print e
ports, portcount, portpagecount = getattr(portcontrol, 'portabstractshow', 'portabstractshow')(**jsoncontent)
response_data['ports']=ports
response_data['portslength']=portcount
response_data['portspagecount']=portpagecount
response_data['portspage']=page
print e,206
# ports, portcount, portpagecount = getattr(portcontrol, 'portabstractshow', 'portabstractshow')(**jsoncontent)
# response_data['ports']=ports
# response_data['portslength']=portcount
# response_data['portspagecount']=portpagecount
# response_data['portspage']=page

response_data['result'] = '1'
response_data['keywords'] = jsoncontent.values()
Expand Down
2 changes: 1 addition & 1 deletion spidermanage/nmaptoolbackground/control/taskcontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def scheduleinit():
# mainschedule.addschedule(event=taskitem.normaltask,type='date') # 后台异步任务

# mainschedule.addschedule(taskitem.listiptask,'0-7','*/21','13','0',id='listiptask')#自定义扫描段任务器
mainschedule.addschedule(taskitem.tick,'0-7','0-23','*/5','0',id='nmap')#nmap定时任务器
# mainschedule.addschedule(taskitem.tick,'0-7','0-23','*/5','0',id='nmap')#nmap定时任务器
# mainschedule.addschedule(taskitem.ticknormal,'0-7','0-23','*/14','0',id='zmap')#zmap定时任务器
# mainschedule.addschedule(taskitem.gchelp,'0-7','0-23','0','0',id='gc')#gc collect

Expand Down
7 changes: 4 additions & 3 deletions spidermanage/spidertool/redistool.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ def iterobj(dic,func):
dic[i]=iterobj(dic[i],func)
return dic
elif type(dic)==tuple:
for i in xrange(len(dic)):
print dic[i]
dic[i] = iterobj(dic[i],func)
listitem=list(dic)
for i in xrange(len(listitem)):
listitem[i] = iterobj(listitem[i],func)
dic=tuple(listitem)
return dic
elif type(dic)==dict:
for i in dic.keys():
Expand Down
26 changes: 17 additions & 9 deletions spidermanage/view/fontsearchview/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,20 @@
<div class="container"> -->
<div class="row">
<div class="col-xs-11">

<form action="/search/searchmain/" method="GET" role="search" lpformnum="1"
_lpchecked="1">
<div class="form-group">
<input type="hidden" id="page" name="page" value='0'>
<input type="text" id="searchcontent" name="searchcontent"
<input type="text" id="content" name="content"
class="form-control search clearable"
onkeydown="if(event.keyCode==13){sendsearch(1,1);}"
placeholder="搜索组件,例如:MySQL">
<i class="fa fa-search" onclick="sendsearch(2,1);"></i>

<form action="/search/searchmain/" method="GET" role="search" lpformnum="1"
_lpchecked="1" id="formid">

<div class="form-group">
<input type="hidden" id="page" name="page" value='0'>
<input type="hidden" id="searchcontent" name="searchcontent" >


</div>
</form>
</div>
Expand Down Expand Up @@ -136,15 +139,20 @@

function sendsearch(issearch, num) {

content = document.getElementById('searchcontent').value;
content =document.getElementById('content').value;
if (issearch == '2' || content == "") {
document.getElementById('searchcontent').value = "";
document.getElementById('content').value = "";
}
// else
// alert(content);

document.getElementById('searchcontent').value=content;


document.getElementById("formid").submit();
}


</script>
<script src="/static/fontsearch/js/base64.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion spidermanage/view/fontsearchview/searchdetail.html
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ <h4>关于 Scan-T</h4>

console.log(titleweb+'------'+titleweb.charCodeAt(0)+'------title'+titleweb.charCodeAt(1)+'----'+cutitem(titleweb)+'--------------'+ports[i].ip);

if((potocalname!='http'&&potocalname!='https')||(titleweb.charCodeAt()==0||cutitem(titleweb)==''||titleweb == ' ' || titleweb ==''||titleweb==null)){
if((potocalname!='http'&&potocalname!='https'&&potocalname!='tcpwrapped'&&potocalname!='None')||(titleweb.charCodeAt()==0||cutitem(titleweb)==''||titleweb == ' ' || titleweb ==''||titleweb==null)){
bodyhtml += "<a target=\"_black\" href=\"" + potocalname + "://" + ports[i].ip + ':' + ports[i].port +
"\" title=\"访问该网页\"><i class=\"fa fa-external-link\"></i></a></p>" ;

Expand Down

0 comments on commit d8788b6

Please sign in to comment.