Skip to content

Commit

Permalink
added update checking feature
Browse files Browse the repository at this point in the history
  • Loading branch information
SpenGietz committed May 7, 2020
1 parent b4db477 commit ab03a1f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions last_update.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2020-05-07
20 changes: 18 additions & 2 deletions pacu.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,21 @@ def fetch_data(self, data, module, args, force=False):
self.exec_module(['exec', module])
return True

def check_for_updates(self):
with open('./last_update.txt', 'r') as f:
local_last_update = f.read().rstrip()

latest_update = requests.get('https://raw.githubusercontent.com/RhinoSecurityLabs/pacu/master/last_update.txt').text.rstrip()

local_year, local_month, local_day = local_last_update.split('-')
datetime_local = datetime.date(local_year, local_month, local_day)

latest_year, latest_month, latest_day = latest_update.split('-')
datetime_latest = datetime.date(latest_year, latest_month, latest_day)

if datetime_local < datetime_latest:
print('Pacu has a new version available! Clone it from GitHub to receive the updates.\n git clone https://github.com/RhinoSecurityLabs/pacu.git')

def key_info(self, alias=''):
""" Return the set of information stored in the session's active key
or the session's key with a specified alias, as a dictionary. """
Expand Down Expand Up @@ -1527,6 +1542,8 @@ def run_gui(self):
self.initialize_tab_completion()
self.display_pacu_help()

self.check_for_updates()

idle_ready = True

self.check_user_agent()
Expand Down Expand Up @@ -1583,10 +1600,9 @@ def run(self):
print('When running Pacu from the CLI, a session is necessary')
exit()
self.run_cli(args)

elif any([args.list_modules, args.pacu_help, args.module_info]):
self.check_for_updates()
self.run_cli(args)

else:
self.run_gui()

Expand Down

0 comments on commit ab03a1f

Please sign in to comment.