Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def set_prog(self, obj, n, total):
if obj:
done_ = n / total * 100
rem_ = utils.human_time((total - n) // self.rate)
obj.set(f'{done_:,.2f} % \t{rem_} reamining')
def conf():
os.environ['HOME'] = tempfile.mkdtemp()
yield config.Config()
shutil.rmtree(os.environ['HOME'])
('version', __version__, '9.9.9'),
('update_rate', '100000', '2000000'),
('theme', '', 'clam'),
])
def test_update_records(conf, key, current, new):
assert conf(key) == current
conf.update_conf(**{conf.NS: {key: new}})
assert conf(key) == new
@threaded
@log_errors
def decode_file(self, decoder):
choose_file = self.get_file(decoder.TARGET)
if choose_file and os.path.isfile(choose_file):
file_path = os.path.realpath(choose_file)
logger.info(f'Decoding: {os.path.basename(file_path)}')
work_dir = self.OUTPUT.get() or os.path.split(file_path)[0]
dec = decoder.__class__(work_dir, file_path)
html_rep = dec.report_html()
report = work_dir / pathlib.Path(html_rep)
webbrowser.open_new_tab(report.as_uri())
dec.report_xlsx()
raise FileHandlerError('The file selected is of unexpected size.')
path_ = os.path.split(dialog)[0]
self.conf.update_conf(**{'DEFAULT': {lpath: path_}})
dialog = os.path.realpath(dialog)
return dialog
def get_dir(self, path='last_path'):
dialog = filedialog.askdirectory(initialdir=self.conf(path))
if dialog:
dialog = os.path.realpath(dialog)
self.conf.update_conf(**{'DEFAULT': {'last_path': dialog}})
return dialog
# Main Window -----------------------------------------------------------------
class MainWindow(BaseWindow):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.set_title()
# ADB moved to the bottom once the logger handler is configured
# self.adb = adb_conn.ADBConn(logger=logger, log_level=self.log_level)
self.registry = decoders.Registry()
self.menubar = tk.Menu(self.root, tearoff=0)
self.root['menu'] = self.menubar
self.build_file_menus()
self.build_decoders_menus()
self.build_utils_menus()
self.build_locks_menus()
self.build_tools_menus()
self.build_adb_menus()
self.build_help_menus()
from setuptools import setup
from andriller import __version__, __website__, __package_name__
req = os.path.join(os.path.dirname(__file__), 'requirements.txt')
with open(req, 'rt', encoding="utf-8") as f:
install_requires = [dep for dep in f.read().splitlines() if not dep.startswith('#')]
reme = os.path.join(os.path.dirname(__file__), 'README.md')
with open(reme, 'rt', encoding='utf-8') as f:
long_description = f.read()
setup(
name='andriller',
scripts=['andriller-gui.py'],
version=__version__,
description='Andriller CE | Android Forensic Tools',
author='Denis Sazonov',
author_email='info@andriller.com',
url=__website__,
packages=[__package_name__],
license='MIT License',
keywords="andriller android forensic forensics adb dfir".split(),
long_description=long_description,
long_description_content_type="text/markdown",
install_requires=install_requires,
include_package_data=True,
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
try:
self.controls_state(tk.DISABLED)
for i in sel:
file_ = self.crypts[i]
fname = os.path.basename(file_)
file_ext = file_.split('.')[-1].lower()
decrypter = self.supported.get(file_ext)
if decrypter:
try:
wadec = decrypter(file_, self.key_file)
if wadec.decrypt():
vals = self.file_box.item(i)['values']
vals[1] = True
self.file_box.item(i, values=vals, tags='success')
logger.info(f'WhatsAppCrypt: {fname} successfully decrypted.')
except decrypts.WhatsAppCryptError as err:
logger.error(f'WhatsAppCrypt: {err}')
self.file_box.item(i, tags='failure')
messagebox.showerror('WhatsApp decryption error', str(err))
except Exception as err:
logger.error(f'WhatsAppCrypt: {fname}: {err}')
self.file_box.item(i, tags='failure')
finally:
self.file_box.selection_set()
self.controls_state(tk.NORMAL)
def main(self):
self.process_convos()
table = 'Messages'
kw = {'order_by': 'timestamp', 'where': {'chatmsg_type': 3}}
for i in self.sql_table_as_dict(table, **kw):
i['identity'] = self.convos.get(i['convo_id'], '')
i['chatmsg_status'] = self.skype_msg_type(i['chatmsg_status'])
i['type'] = 'Inbox' if i['author'] == i['identity'] else 'Sentbox'
i['timestamp'] = self.unix_to_time(i['timestamp'])
# i['timestamp__ms'] = self.unix_to_time_ms(i['timestamp__ms'])
self.DATA.append(i)
# -----------------------------------------------------------------------------
class SkypeMessagesDecoder(AndroidDecoder):
RETARGET = '*.db'
NAMESPACE = 'db'
PACKAGE = 'com.skype.raider'
exclude_from_decoding = True
def __init__(self, work_dir, input_file, **kwargs):
self.owner = None
self.owners = {}
self.users = {}
super().__init__(work_dir, input_file, **kwargs)
self.template_name = 'skype_messages.html'
self.title = 'Skype Messages'
self.Titles = {
'_id': 'Index',
'x_sender': 'Sender',
'x_conversation': 'Conversation',
@property
def target_path_ab(self):
return f'apps/com.android.providers.settings/f/{self.TARGET}'
@property
def target_path_posix(self):
return f'/data/misc/wifi/{self.TARGET}'
class WifiPasswordsAbDecoder(WifiPasswordsDecoder):
TARGET = 'flattened-data'
exclude_from_menus = True
# -----------------------------------------------------------------------------
class WebViewDecoder(AndroidDecoder):
TARGET = 'webview.db'
NAMESPACE = 'db'
PACKAGE = 'com.android.browser'
def __init__(self, work_dir, input_file, **kwargs):
super().__init__(work_dir, input_file, **kwargs)
self.template_name = 'web_passwords.html'
self.title = 'WebView Browser Passwords'
self.Titles = {
'_id': 'Index',
'host': 'Host',
'username': 'Username',
'password': 'Password',
}
def main(self):
target_is_db = True
def __init__(self, work_dir, input_file, **kwargs):
super().__init__(work_dir, input_file, **kwargs)
self.title = 'Google Chrome History'
def main(self):
table = 'urls'
for i in self.sql_table_as_dict(table, order_by='last_visit_time'):
i['date'] = self.webkit_to_time(i['last_visit_time'])
i['visits'] = i['visit_count']
self.DATA.append(i)
# -----------------------------------------------------------------------------
class ChromePasswordsDecoder(AndroidDecoder):
TARGET = 'Login Data'
NAMESPACE = 'app_chrome/Default'
PACKAGE = 'com.android.chrome'
target_is_db = True
def __init__(self, work_dir, input_file, **kwargs):
super().__init__(work_dir, input_file, **kwargs)
self.template_name = 'chrome_passwords.html'
self.title = 'Google Chrome Passwords'
self.Titles = {
'_id': 'Index',
'origin_url': 'URL',
'username_value': 'Username',
'password_value': 'Password',
'date_created': 'Date created',
}