Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
alterakey committed Jan 10, 2024
1 parent 7bd159c commit 11818f9
Show file tree
Hide file tree
Showing 21 changed files with 1,149 additions and 1,108 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dev = [
Source = "https://github.com/alterakey/trueseeing"

[project.scripts]
trueseeing = "trueseeing.app._dummy:invoke"
trueseeing = "trueseeing.app.shell:entry"

[tool.mypy]
strict = true
Expand Down
31 changes: 0 additions & 31 deletions trueseeing/app/_dummy.py

This file was deleted.

21 changes: 11 additions & 10 deletions trueseeing/app/exploit.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ def apply(self, context: Context) -> None:
manifest = context.parsed_manifest()
for e in manifest.xpath('.//application'):
e.attrib['{http://schemas.android.com/apk/res/android}debuggable'] = "true"
with context.store().db as c:
c.execute('replace into patches (path, blob) values (:path,:blob)', dict(path='AndroidManifest.xml', blob=context.manifest_as_xml(manifest)))
context.store().query().patch_put(path='AndroidManifest.xml', blob=context.manifest_as_xml(manifest))

class ExploitEnableBackup:
_patcher: Patcher
Expand All @@ -98,8 +97,7 @@ def apply(self, context: Context) -> None:
manifest = context.parsed_manifest()
for e in manifest.xpath('.//application'):
e.attrib['{http://schemas.android.com/apk/res/android}allowBackup'] = "true"
with context.store().db as c:
c.execute('replace into patches (path, blob) values (:path,:blob)', dict(path='AndroidManifest.xml', blob=context.manifest_as_xml(manifest)))
context.store().query().patch_put(path='AndroidManifest.xml', blob=context.manifest_as_xml(manifest))

class ExploitDisablePinning:
_patcher: Patcher
Expand All @@ -117,8 +115,11 @@ def apply(self, context: Context) -> None:
e.attrib['{http://schemas.android.com/apk/res/android}networkSecurityConfig'] = "@xml/network_security_config"

with context.store().db as c:
c.execute('replace into patches (path, blob) values (:path,:blob)', dict(path='AndroidManifest.xml', blob=context.manifest_as_xml(manifest)))
c.execute('replace into patches (path, blob) values (:path,:blob)', dict(path='resources/package_1/res/xml/network_security_config.xml', blob=b'''\
from trueseeing.core.literalquery import Query
query = Query(c=c)

query.patch_put(path='AndroidManifest.xml', blob=context.manifest_as_xml(manifest))
query.patch_put(path='resources/package_1/res/xml/network_security_config.xml', blob=b'''\
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
Expand All @@ -128,9 +129,9 @@ def apply(self, context: Context) -> None:
</trust-anchors>
</base-config>
</network-security-config>
'''))
for r, in c.execute('select blob from files where path=:path', dict(path='resources/package_1/res/values/public.xml')):
root = ET.fromstring(r, parser=ET.XMLParser(recover=True))
''')
root = query.file_get_xml('resources/package_1/res/values/public.xml')
assert root is not None
if root.xpath('./public[@type="xml"]'):
maxid = max(int(e.attrib["id"], 16) for e in root.xpath('./public[@type="xml"]'))
n = ET.SubElement(root, 'public')
Expand All @@ -143,4 +144,4 @@ def apply(self, context: Context) -> None:
n.attrib['id'] = f'0x{maxid+0x10000:08x}'
n.attrib['type'] = 'xml'
n.attrib['name'] = 'network_security_config'
c.execute('replace into patches (path, blob) values (:path,:blob)', dict(path='resources/package_1/res/values/public.xml', blob=ET.tostring(root)))
query.patch_put(path='resources/package_1/res/values/public.xml', blob=ET.tostring(root))
Loading

0 comments on commit 11818f9

Please sign in to comment.