hackertray/hackertray/chrome.py

33 lines
975 B
Python
Raw Normal View History

2017-12-24 11:13:07 +00:00
import sqlite3
import shutil
import os
import sys
2017-12-24 13:25:20 +00:00
class Chrome:
2014-10-03 13:39:35 +00:00
HISTORY_TMP_LOCATION = '/tmp/hackertray.chrome'
2017-12-24 13:25:20 +00:00
@staticmethod
def search(urls, config_folder_path):
Chrome.setup(config_folder_path)
2014-10-03 13:39:35 +00:00
conn = sqlite3.connect(Chrome.HISTORY_TMP_LOCATION)
db = conn.cursor()
result = []
for url in urls:
2017-12-24 13:25:20 +00:00
db_result = db.execute('SELECT url from urls WHERE url=:url', {"url": url})
if(db.fetchone() == None):
result.append(False)
else:
result.append(True)
2014-10-03 13:39:35 +00:00
os.remove(Chrome.HISTORY_TMP_LOCATION)
return result
2017-12-24 13:25:20 +00:00
@staticmethod
def setup(config_folder_path):
file_name = os.path.abspath(config_folder_path+'/History')
if not os.path.isfile(file_name):
print("ERROR: ", "Could not find Chrome history file", file=sys.stderr)
sys.exit(1)
2014-10-03 13:39:35 +00:00
shutil.copyfile(file_name, Chrome.HISTORY_TMP_LOCATION)