updated to version 0.3.1
This commit is contained in:
@@ -32,13 +32,13 @@ def copy():
|
|||||||
settings.in_queue.put(extension)
|
settings.in_queue.put(extension)
|
||||||
|
|
||||||
# Searching installed extensions
|
# Searching installed extensions
|
||||||
# Check on version if we get 200 or 403.
|
# Check version if getting 200 or 403.
|
||||||
def check_extension():
|
def check_extension():
|
||||||
while True:
|
while True:
|
||||||
extension = settings.in_queue.get()
|
extension = settings.in_queue.get()
|
||||||
for path in settings.EXTENSION_PATHS:
|
for path in settings.EXTENSION_PATHS:
|
||||||
try:
|
try:
|
||||||
req = urllib2.Request('http://' + settings.DOMAIN + path + extension + '/', None, settings.user_agent)
|
req = urllib2.Request(settings.DOMAIN + path + extension + '/', None, settings.user_agent)
|
||||||
connection = urllib2.urlopen(req, timeout = settings.TIMEOUT)
|
connection = urllib2.urlopen(req, timeout = settings.TIMEOUT)
|
||||||
connection.close()
|
connection.close()
|
||||||
check_extension_version(path, extension)
|
check_extension_version(path, extension)
|
||||||
@@ -52,7 +52,7 @@ def check_extension():
|
|||||||
except urllib2.URLError, e:
|
except urllib2.URLError, e:
|
||||||
pass
|
pass
|
||||||
#retry = raw_input('Error on checking ' + extension + ': ' + str(e.reason) + '\nRetrying? (y/n) ')
|
#retry = raw_input('Error on checking ' + extension + ': ' + str(e.reason) + '\nRetrying? (y/n) ')
|
||||||
#if retry:
|
#if retry is 'y':
|
||||||
# settings.in_queue.put(extension)
|
# settings.in_queue.put(extension)
|
||||||
# if extension is not in any given path, it's not installed
|
# if extension is not in any given path, it's not installed
|
||||||
if settings.verbose:
|
if settings.verbose:
|
||||||
@@ -69,7 +69,7 @@ def check_extension_version(path, extension):
|
|||||||
settings.out_queue.put(extension.ljust(32) + Fore.GREEN + 'installed' + Fore.RESET)
|
settings.out_queue.put(extension.ljust(32) + Fore.GREEN + 'installed' + Fore.RESET)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
request = urllib2.Request('http://' + settings.DOMAIN + path + extension +'/ChangeLog', None, settings.user_agent)
|
request = urllib2.Request(settings.DOMAIN + path + extension +'/ChangeLog', None, settings.user_agent)
|
||||||
response = urllib2.urlopen(request, timeout = settings.TIMEOUT)
|
response = urllib2.urlopen(request, timeout = settings.TIMEOUT)
|
||||||
changelog = response.read(1500)
|
changelog = response.read(1500)
|
||||||
response.close()
|
response.close()
|
||||||
|
|||||||
36
lib/login.py
36
lib/login.py
@@ -12,26 +12,24 @@ from colorama import Fore
|
|||||||
from lib import settings
|
from lib import settings
|
||||||
|
|
||||||
# Searching Typo3 login page
|
# Searching Typo3 login page
|
||||||
def search_login(domain):
|
def search_login():
|
||||||
try:
|
try:
|
||||||
r = requests.get('http://' + domain + '/typo3/index.php', allow_redirects=False, timeout=settings.TIMEOUT, headers=settings.user_agent)
|
r = requests.get(settings.DOMAIN + '/typo3/index.php', allow_redirects=False, timeout=settings.TIMEOUT, headers=settings.user_agent, verify=False)
|
||||||
statusCode = r.status_code
|
statusCode = r.status_code
|
||||||
httpResponse = r.text
|
httpResponse = r.text
|
||||||
if statusCode == 200:
|
if statusCode == 200:
|
||||||
return check_title(httpResponse, r.url)
|
return check_title(httpResponse, r.url)
|
||||||
elif (statusCode == 301) or (statusCode == 302):
|
elif (statusCode == 301) or (statusCode == 302):
|
||||||
location = r.headers['location']
|
location = r.headers['location']
|
||||||
if ("http://") in location:
|
redirect = raw_input('Got redirect to: ' + str(location) + '\nFollow? (y/n) ')
|
||||||
locsplit = location.split("//")
|
if redirect is 'y':
|
||||||
new_location = locsplit[1].split("/")
|
locsplit = location.split('/')
|
||||||
search_login(new_location[0])
|
settings.DOMAIN = locsplit[0] + '//' + locsplit[2]
|
||||||
elif ("https://") in location:
|
return "redirect"
|
||||||
r = requests.get(location, timeout=settings.TIMEOUT, headers=settings.user_agent, verify=False)
|
else:
|
||||||
statusCode = r.status_code
|
|
||||||
httpResponse = r.text
|
|
||||||
return check_title(httpResponse, r.url)
|
return check_title(httpResponse, r.url)
|
||||||
elif statusCode == 404:
|
elif statusCode == 404:
|
||||||
return check_main_page()
|
return False
|
||||||
else:
|
else:
|
||||||
print "Oops! Got unhandled code:".ljust(32) + str(statusCode) + ": " + str(r.raise_for_status())
|
print "Oops! Got unhandled code:".ljust(32) + str(statusCode) + ": " + str(r.raise_for_status())
|
||||||
except requests.exceptions.Timeout:
|
except requests.exceptions.Timeout:
|
||||||
@@ -52,11 +50,11 @@ def check_title(response, url):
|
|||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
return check_main_page()
|
return False
|
||||||
|
|
||||||
# Searching for Typo3 references in HTML comments
|
# Searching for Typo3 references in HTML comments
|
||||||
def check_main_page():
|
def check_main_page():
|
||||||
req = urllib2.Request('http://' + settings.DOMAIN, None, settings.user_agent)
|
req = urllib2.Request(settings.DOMAIN, None, settings.user_agent)
|
||||||
req.add_header('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')
|
req.add_header('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')
|
||||||
try:
|
try:
|
||||||
connection = urllib2.urlopen(req, timeout = settings.TIMEOUT)
|
connection = urllib2.urlopen(req, timeout = settings.TIMEOUT)
|
||||||
@@ -66,6 +64,9 @@ def check_main_page():
|
|||||||
cookie = connection.info().getheader('Set-Cookie')
|
cookie = connection.info().getheader('Set-Cookie')
|
||||||
if 'fe_typo_user' in cookie:
|
if 'fe_typo_user' in cookie:
|
||||||
return bad_url()
|
return bad_url()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print Fore.RED + "\nReceived keyboard interrupt.\nQuitting..." + Fore.RESET
|
||||||
|
exit(-1)
|
||||||
except:
|
except:
|
||||||
try:
|
try:
|
||||||
regex = re.compile("TYPO3(.*)", re.IGNORECASE)
|
regex = re.compile("TYPO3(.*)", re.IGNORECASE)
|
||||||
@@ -85,16 +86,15 @@ def check_main_page():
|
|||||||
if "404" in str(e):
|
if "404" in str(e):
|
||||||
print Fore.RED + str(e) + "\nPlease ensure you entered the right url" + Fore.RESET
|
print Fore.RED + str(e) + "\nPlease ensure you entered the right url" + Fore.RESET
|
||||||
else:
|
else:
|
||||||
print Fore.RED + "Got \"" + str(e) + "\" on testing main page." + Fore.RESET
|
print Fore.RED + str(e) + Fore.RESET
|
||||||
return False
|
return "skip"
|
||||||
print "Typo3 Login:".ljust(32) + Fore.RED + "Typo3 is not used on this domain" + Fore.RESET
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def bad_url():
|
def bad_url():
|
||||||
print "Typo3 Login:".ljust(32) + Fore.GREEN + "Typo3 is used, but could not find login" + Fore.RESET
|
print "Typo3 Login:".ljust(32) + Fore.GREEN + "Typo3 is used, but could not find login" + Fore.RESET
|
||||||
print "".ljust(32) + "This will mostly result in \"no extensions are installed\"."
|
print "".ljust(32) + "This could result in \"no extensions are installed\"."
|
||||||
print "".ljust(32) + "Seems like something is wrong with the given url."
|
print "".ljust(32) + "Seems like something is wrong with the given url."
|
||||||
var = raw_input("".ljust(32) + "Try anyway (y/n)? ")
|
var = raw_input("".ljust(32) + "Try anyway (y/n)? ")
|
||||||
if var is 'y':
|
if var is 'y':
|
||||||
return True
|
return True
|
||||||
return False
|
return "skip"
|
||||||
@@ -44,7 +44,6 @@ verbose = False
|
|||||||
|
|
||||||
#Input and output queues
|
#Input and output queues
|
||||||
in_queue = ""
|
in_queue = ""
|
||||||
in_queue2 = ""
|
|
||||||
out_queue = ""
|
out_queue = ""
|
||||||
|
|
||||||
# Seconds to wait before timeout connection.
|
# Seconds to wait before timeout connection.
|
||||||
@@ -68,7 +67,7 @@ EXTENSION_PATHS = ('/typo3conf/ext/', '/typo3/sysext/')
|
|||||||
# Possible version info file
|
# Possible version info file
|
||||||
EXTENSION_VERSION_INFO = ('ChangeLog', 'README.txt')
|
EXTENSION_VERSION_INFO = ('ChangeLog', 'README.txt')
|
||||||
|
|
||||||
EXTENSIONS_FOUND = {}
|
EXTENSIONS_FOUND = 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
86
lib/start.py
86
lib/start.py
@@ -16,49 +16,61 @@ from lib import output
|
|||||||
from lib import extensions
|
from lib import extensions
|
||||||
|
|
||||||
# Startmethod
|
# Startmethod
|
||||||
def start(domain):
|
def check_typo_installation(domain):
|
||||||
settings.in_queue = Queue()
|
|
||||||
settings.out_queue = Queue()
|
|
||||||
settings.DOMAIN = domain
|
settings.DOMAIN = domain
|
||||||
print '\n\n' + Fore.CYAN + '[ Checking ' + domain + ' ]' + '\n' + "-"* 70 + Fore.RESET
|
print '\n\n' + Fore.CYAN + '[ Checking ' + domain + ' ]' + '\n' + "-"* 70 + Fore.RESET
|
||||||
|
|
||||||
if login.search_login(domain) is True:
|
check = login.search_login()
|
||||||
versioninfo.search_version_info()
|
if check is "redirect":
|
||||||
versioninfo.output()
|
check_typo_installation(settings.DOMAIN)
|
||||||
|
|
||||||
if not settings.EXTENSION_LIST:
|
elif check is True:
|
||||||
extensions.generate_list()
|
init_extension_search()
|
||||||
|
else:
|
||||||
|
mainpage = login.check_main_page()
|
||||||
|
if mainpage is True:
|
||||||
|
init_extension_search()
|
||||||
|
elif mainpage is not "skip":
|
||||||
|
print "Typo3 Login:".ljust(32) + Fore.RED + "Typo3 is not used on this domain" + Fore.RESET
|
||||||
|
|
||||||
extensions.copy()
|
def init_extension_search():
|
||||||
extensions_to_check = settings.in_queue.qsize()
|
settings.in_queue = Queue()
|
||||||
|
settings.out_queue = Queue()
|
||||||
|
versioninfo.search_version_info()
|
||||||
|
versioninfo.output()
|
||||||
|
|
||||||
if extensions_to_check is not 0:
|
if not settings.EXTENSION_LIST:
|
||||||
print '\nChecking', extensions_to_check, 'extension(s)...'
|
extensions.generate_list()
|
||||||
# Thanks to 'RedSparrow': http://stackoverflow.com/questions/17991033/python-cant-kill-main-thread-with-keyboardinterrupt
|
|
||||||
try:
|
|
||||||
while True:
|
|
||||||
if settings.in_queue.empty() == False:
|
|
||||||
time.sleep(0.1)
|
|
||||||
for i in xrange(0, settings.THREADS):
|
|
||||||
t = Thread(target=extensions.check_extension, args=())
|
|
||||||
t.daemon = True
|
|
||||||
t.start()
|
|
||||||
else:
|
|
||||||
break
|
|
||||||
settings.in_queue.join()
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
print Fore.RED + "\nReceived keyboard interrupt.\nQuitting..." + Fore.RESET
|
|
||||||
exit(-1)
|
|
||||||
|
|
||||||
installed_ext = settings.out_queue.qsize()
|
extensions.copy()
|
||||||
if installed_ext is 0:
|
extensions_to_check = settings.in_queue.qsize()
|
||||||
print Fore.RED + "No extensions installed" + Fore.RESET
|
|
||||||
else:
|
|
||||||
t = Thread(target=output.thread, args=())
|
|
||||||
t.daemon = True
|
|
||||||
t.start()
|
|
||||||
settings.out_queue.join()
|
|
||||||
print Fore.GREEN + '\n', str(installed_ext) + '/' + str(extensions_to_check),'extension(s) installed' + Fore.RESET
|
|
||||||
|
|
||||||
|
if extensions_to_check is not 0:
|
||||||
|
print '\nChecking', extensions_to_check, 'extension(s)...'
|
||||||
|
# Thanks to 'RedSparrow': http://stackoverflow.com/questions/17991033/python-cant-kill-main-thread-with-keyboardinterrupt
|
||||||
|
try:
|
||||||
|
while True:
|
||||||
|
if settings.in_queue.empty() == False:
|
||||||
|
time.sleep(0.5)
|
||||||
|
for i in xrange(0, settings.THREADS):
|
||||||
|
t = Thread(target=extensions.check_extension, args=())
|
||||||
|
t.daemon = True
|
||||||
|
t.start()
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print Fore.RED + "\nReceived keyboard interrupt.\nQuitting..." + Fore.RESET
|
||||||
|
exit(-1)
|
||||||
|
settings.in_queue.join()
|
||||||
|
|
||||||
|
installed_ext = settings.out_queue.qsize()
|
||||||
|
if installed_ext is 0:
|
||||||
|
print Fore.RED + "No extensions installed" + Fore.RESET
|
||||||
else:
|
else:
|
||||||
print '\nSkipping check for extensions...'
|
t = Thread(target=output.thread, args=())
|
||||||
|
t.daemon = True
|
||||||
|
t.start()
|
||||||
|
settings.out_queue.join()
|
||||||
|
print Fore.GREEN + '\n', str(settings.EXTENSIONS_FOUND) + '/' + str(extensions_to_check),'extension(s) installed' + Fore.RESET
|
||||||
|
else:
|
||||||
|
print '\nSkipping check for extensions...'
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ from lib import settings
|
|||||||
def search_version_info():
|
def search_version_info():
|
||||||
for path, regex in settings.TYPO3_VERSION_INFO.iteritems():
|
for path, regex in settings.TYPO3_VERSION_INFO.iteritems():
|
||||||
try:
|
try:
|
||||||
request = urllib2.Request('http://' + settings.DOMAIN + path, None, settings.user_agent)
|
request = urllib2.Request(settings.DOMAIN + path, None, settings.user_agent)
|
||||||
response = urllib2.urlopen(request, timeout = settings.TIMEOUT)
|
response = urllib2.urlopen(request, timeout = settings.TIMEOUT)
|
||||||
news = response.read(700)
|
news = response.read(700)
|
||||||
response.close()
|
response.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user