Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/tools/smmu_payload.py
1471 views
1
'''
2
Copyright (c) 2018 balika011
3
4
This program is free software; you can redistribute it and/or modify it
5
under the terms and conditions of the GNU General Public License,
6
version 2, as published by the Free Software Foundation.
7
8
This program is distributed in the hope it will be useful, but WITHOUT
9
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11
more details.
12
13
You should have received a copy of the GNU General Public License
14
along with this program. If not, see <http://www.gnu.org/licenses/>.
15
'''
16
17
from keystone import *
18
19
CODE = b'''
20
LDR X1, =0x70019010
21
MOV X0, #0x1
22
STR W0, [X1]
23
24
loop:
25
IC IALLUIS
26
DSB ISH
27
B loop
28
MOV X0, #0x0
29
STR W0, [X1]
30
LDR X0, =0x4002B000
31
BR X0
32
'''
33
try:
34
ks = Ks(KS_ARCH_ARM64, KS_MODE_LITTLE_ENDIAN)
35
encoding, count = ks.asm(CODE, 0x0)
36
print("%s = %s (number of statements: %u)" %(CODE, ', '.join([('0x%02x' % (x)) for x in encoding]), count))
37
except KsError as e:
38
print("ERROR: %s" %e)
39