我有想要验证某些恶意脚本的场景。我希望每当URL获得像<~script>
这样的内容时,它就会重定向到错误页面。
搜索代码: -
dv.RowFilter = "Description LIKE ('%" + Request.QueryString["tx"].Trim().ToLower() + "%') or Title LIKE ('%" + Request.QueryString["tx"].Trim().ToLower() + "%')";
dv.Sort = "Title ASC";
dgrdPages.DataSource = dv;
dgrdPages.DataBind();
lblSearchWords.Text = Request.QueryString["tx"].ToString();
lblFilesFound.Text = dv.Count.ToString();
答案 0 :(得分:0)
在Python中
import re
text = 'http://localhost:54149/RBLBank/search.aspx?tx=test<~script>'
text2='http://localhost:54149/RBLBank/search.aspx?tx=test'
m = re.search('(<~script>.*)', text)
n = re.search('(<~script>.*)', text2)
if m:
found = m.group(1)
print found," found"
else:
print "URL is safe"
if n:
found = n.group(1)
print found," found"
else:
print "URL is safe"