Files
XSStrike/core/updater.py

37 lines
1.4 KiB
Python
Raw Normal View History

2018-10-27 18:58:52 +05:30
import os
import re
2018-10-27 18:58:52 +05:30
from requests import get
2018-11-11 15:16:27 +05:30
from core.config import changes
from core.colors import run, que, good, info, end, green
2018-10-27 18:58:52 +05:30
2018-11-16 21:13:45 +05:30
2018-10-27 18:58:52 +05:30
def updater():
print('%s Checking for updates' % run)
2018-11-16 21:13:45 +05:30
latestCommit = get(
'https://raw.githubusercontent.com/s0md3v/XSStrike/master/core/config.py').text
2018-10-27 18:58:52 +05:30
2018-11-16 21:13:45 +05:30
if changes not in latestCommit: # just a hack to see if a new version is available
2018-10-27 18:58:52 +05:30
changelog = re.search(r"changes = '''(.*?)'''", latestCommit)
2018-11-16 21:13:45 +05:30
changelog = changelog.group(1).split(
';') # splitting the changes to form a list
2018-10-27 18:58:52 +05:30
print('%s A new version of XSStrike is available.' % good)
print('%s Changes:' % info)
2018-11-16 21:13:45 +05:30
for change in changelog: # print changes
2018-10-27 18:58:52 +05:30
print('%s>%s %s' % (green, end, change))
2018-11-16 21:13:45 +05:30
currentPath = os.getcwd().split('/') # if you know it, you know it
folder = currentPath[-1] # current directory name
path = '/'.join(currentPath) # current directory path
2018-10-27 18:58:52 +05:30
choice = input('%s Would you like to update? [Y/n] ' % que).lower()
if choice != 'n':
print('%s Updating XSStrike' % run)
2018-11-16 21:13:45 +05:30
os.system(
'git clone --quiet https://github.com/s0md3v/XSStrike %s' % (folder))
os.system('cp -r %s/%s/* %s && rm -r %s/%s/ 2>/dev/null' %
(path, folder, path, path, folder))
2018-10-27 18:58:52 +05:30
print('%s Update successful!' % good)
else:
print('%s XSStrike is up to date!' % good)