Skip to content

Commit

Permalink
v1.o finished
Browse files Browse the repository at this point in the history
  • Loading branch information
boy-hack committed Aug 6, 2018
1 parent 2df550e commit c99a978
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,4 @@ venv.bak/

# mypy
.mypy_cache/
.vscode/
37 changes: 33 additions & 4 deletions app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,44 @@
import time
from cms.tasks import buildPayload
from urllib.parse import urlparse
import re

# Create your views here.
def mgo_text_split(query_text):
''' split text to support mongodb $text match on a phrase '''
sep = r'[`\-=~!@#$%^&*()_+\[\]{};\'\\:"|<,./<>?]'
word_lst = re.split(sep, query_text)
text_query = ' '.join('\"{}\"'.format(w) for w in word_lst)
return text_query

def search(request):
if not request.session.get('is_login',None):
return redirect(login)

dict = {}
return render(request,"search.html",dict)
keyword = request.GET.get("q", None)
if keyword is None or keyword == "":
return render(request, "search.html")
words = keyword.split(";")
query = {}
for word in words:
if ":" not in word:
word = "all:" + word
pro, suff = word.split(":")
if pro == "cms":
query["webdna.cmsname"] = suff
elif pro == "url":
query["url"] = {"$regex":suff,"$options":"i"}
elif pro == "other":
text_query = mgo_text_split(suff)
query['$text'] = {'$search': text_query, '$caseSensitive': True}
elif pro == "all":
text_query = mgo_text_split(suff)
query['$text'] = {'$search': text_query, '$caseSensitive': True}
db = Conn.MongDB(database="w11scan_config")
cursor = db.coll['result'].find(query)
data = list(cursor)

return render(request, "task_detail.html", {"cursor":data,"tasks":{"name":"{}的搜索结果".format(keyword)},"len":len(data)})

def task(request):
if not request.session.get('is_login',None):
Expand All @@ -26,7 +55,7 @@ def task(request):
data = list(db.coll["tasks"].find().sort("time",-1))

for item in data:
item["time"] = time.strftime("%Y-%m-%d %X",time.localtime(item["time"]))
item["time"] = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(item["time"]))


return render(request,"task.html",{"data":data,"len":len(data)})
Expand Down Expand Up @@ -91,7 +120,7 @@ def plugin(request,slug = None):
return render(request,"plugin.html",{"cmsdata":webdata,"cmslen":count,"pagination":pagination})

def makeurl(url):
if "http://" not in url:
if not url.startswith("http"):
url = "http://" + url
p = urlparse(url)
path = p.netloc
Expand Down
1 change: 0 additions & 1 deletion cms/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ def buildPayload(url,taskid):
otherscan.delay(url,taskid)
# other


@celery_app.task
def singscan(url,ordict,taskid):
value = redisConn.get(url)
Expand Down
8 changes: 8 additions & 0 deletions static/css/core.css
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,14 @@ pre {
background-color: rgba(59, 62, 71, 0.4);
}

table td button.update{
width: 33%;
margin-top:4px;
}
table td button.delete{
width: 33%;
margin-top:1px;
}


/* =============
Expand Down
18 changes: 7 additions & 11 deletions templates/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
<a href="#" class="logo"><span>w11scan fingerprint</span></a>
</div>
<div class="panel-body">
<form method="get" action="/" role="form" class="text-center">
<form method="get" action="" role="form" class="text-center">
<div class="form-group">
<input type="text" class="form-control"
placeholder="Example: app: discuz"
placeholder="Example: cms: wordpress"
style="color: #797979;" id="filter" name="q">

<button type="submit"
Expand Down Expand Up @@ -74,15 +74,11 @@
fade: false,
slide: false,
content: "<p>查询方法:</p> \
<p>1.按端口: port:端口号 eg. port:22</p>\
<p>2.按banner: banner:banner内容关键词 eg. banner:ftp</p>\
<p>3.按ip(支持c段,b段模糊查询): ip:ip地址 eg. ip:192.168.1.1/ip:192.168.1.</p>\
<p>4.按服务名: server:服务名 eg. server:iis</p>\
<p>5.按标题: title:标题内容关键词 eg. title:xxx管理系统</p>\
<p>6.按服务类型标签: tag:服务类型 eg. tag:apache</p>\
<p>7.按主机名: hostname:主机名 eg. hostname:server001</p>\
<p>8.全局模糊: all:查询内容 eg. all:tongcheng</p>\
<p>9.多条件: 条件1:内容1;条件2:内容2 eg. ip:192.168.1.1;port:22</p>",
<p>1.按cms: cms:cms名称 eg. cms:wordpress </p>\
<p>2.按url: url:url地址(可模糊搜索) eg. url:baidu</p>\
<p>3.其他框架查询: other:(其他框架模糊搜索) eg. other:apache </p>\
<p>8.全局模糊: all:查询内容 eg. all:nginx</p>\
<p>9.多条件: 条件1:内容1;条件2:内容2 eg. cms:wordpress;other:apache</p>",
});
</script>
<script src="{% static 'js/jquery.core.js' %}"></script>
Expand Down
11 changes: 9 additions & 2 deletions templates/task.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,15 @@ <h4 class="modal-title">新的任务</h4>
"taskcontent":content
},function (data,status) {
if(data["status"] == "ok"){
swal("添加成功!","请继续操作","success");
window.location.reload()
swal({
title: "添加成功!",
text: "请继续操作!",
type: "success",
},
function(){
window.location.reload()
});

}else{

swal("添加失败!","请重试","error");
Expand Down
2 changes: 1 addition & 1 deletion xun/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'
TIME_ZONE = 'Asia/Shanghai'

USE_I18N = True

Expand Down

0 comments on commit c99a978

Please sign in to comment.