partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | Workspace.save_state | Save a state to storage, return identifier.
:param state: The state to save
:param int state_id: If not None force the state id potentially overwriting old states
:return: New state id
:rtype: int | manticore/core/workspace.py | def save_state(self, state, state_id=None):
"""
Save a state to storage, return identifier.
:param state: The state to save
:param int state_id: If not None force the state id potentially overwriting old states
:return: New state id
:rtype: int
"""
assert... | def save_state(self, state, state_id=None):
"""
Save a state to storage, return identifier.
:param state: The state to save
:param int state_id: If not None force the state id potentially overwriting old states
:return: New state id
:rtype: int
"""
assert... | [
"Save",
"a",
"state",
"to",
"storage",
"return",
"identifier",
"."
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/core/workspace.py#L386-L402 | [
"def",
"save_state",
"(",
"self",
",",
"state",
",",
"state_id",
"=",
"None",
")",
":",
"assert",
"isinstance",
"(",
"state",
",",
"StateBase",
")",
"if",
"state_id",
"is",
"None",
":",
"state_id",
"=",
"self",
".",
"_get_id",
"(",
")",
"else",
":",
... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | ManticoreOutput._named_stream | Create an indexed output stream i.e. 'test_00000001.name'
:param name: Identifier for the stream
:return: A context-managed stream-like object | manticore/core/workspace.py | def _named_stream(self, name, binary=False):
"""
Create an indexed output stream i.e. 'test_00000001.name'
:param name: Identifier for the stream
:return: A context-managed stream-like object
"""
with self._store.save_stream(self._named_key(name), binary=binary) as s:
... | def _named_stream(self, name, binary=False):
"""
Create an indexed output stream i.e. 'test_00000001.name'
:param name: Identifier for the stream
:return: A context-managed stream-like object
"""
with self._store.save_stream(self._named_key(name), binary=binary) as s:
... | [
"Create",
"an",
"indexed",
"output",
"stream",
"i",
".",
"e",
".",
"test_00000001",
".",
"name"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/core/workspace.py#L470-L478 | [
"def",
"_named_stream",
"(",
"self",
",",
"name",
",",
"binary",
"=",
"False",
")",
":",
"with",
"self",
".",
"_store",
".",
"save_stream",
"(",
"self",
".",
"_named_key",
"(",
"name",
")",
",",
"binary",
"=",
"binary",
")",
"as",
"s",
":",
"yield",
... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | t_UINTN | r"uint(?P<size>256|248|240|232|224|216|208|200|192|184|176|168|160|152|144|136|128|120|112|104|96|88|80|72|64|56|48|40|32|24|16|8) | manticore/ethereum/abitypes.py | def t_UINTN(t):
r"uint(?P<size>256|248|240|232|224|216|208|200|192|184|176|168|160|152|144|136|128|120|112|104|96|88|80|72|64|56|48|40|32|24|16|8)"
size = int(t.lexer.lexmatch.group('size'))
t.value = ('uint', size)
return t | def t_UINTN(t):
r"uint(?P<size>256|248|240|232|224|216|208|200|192|184|176|168|160|152|144|136|128|120|112|104|96|88|80|72|64|56|48|40|32|24|16|8)"
size = int(t.lexer.lexmatch.group('size'))
t.value = ('uint', size)
return t | [
"r",
"uint",
"(",
"?P<size",
">",
"256|248|240|232|224|216|208|200|192|184|176|168|160|152|144|136|128|120|112|104|96|88|80|72|64|56|48|40|32|24|16|8",
")"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/ethereum/abitypes.py#L51-L55 | [
"def",
"t_UINTN",
"(",
"t",
")",
":",
"size",
"=",
"int",
"(",
"t",
".",
"lexer",
".",
"lexmatch",
".",
"group",
"(",
"'size'",
")",
")",
"t",
".",
"value",
"=",
"(",
"'uint'",
",",
"size",
")",
"return",
"t"
] | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | t_INTN | r"int(?P<size>256|248|240|232|224|216|208|200|192|184|176|168|160|152|144|136|128|120|112|104|96|88|80|72|64|56|48|40|32|24|16|8) | manticore/ethereum/abitypes.py | def t_INTN(t):
r"int(?P<size>256|248|240|232|224|216|208|200|192|184|176|168|160|152|144|136|128|120|112|104|96|88|80|72|64|56|48|40|32|24|16|8)"
size = int(t.lexer.lexmatch.group('size'))
t.value = ('int', size)
return t | def t_INTN(t):
r"int(?P<size>256|248|240|232|224|216|208|200|192|184|176|168|160|152|144|136|128|120|112|104|96|88|80|72|64|56|48|40|32|24|16|8)"
size = int(t.lexer.lexmatch.group('size'))
t.value = ('int', size)
return t | [
"r",
"int",
"(",
"?P<size",
">",
"256|248|240|232|224|216|208|200|192|184|176|168|160|152|144|136|128|120|112|104|96|88|80|72|64|56|48|40|32|24|16|8",
")"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/ethereum/abitypes.py#L76-L80 | [
"def",
"t_INTN",
"(",
"t",
")",
":",
"size",
"=",
"int",
"(",
"t",
".",
"lexer",
".",
"lexmatch",
".",
"group",
"(",
"'size'",
")",
")",
"t",
".",
"value",
"=",
"(",
"'int'",
",",
"size",
")",
"return",
"t"
] | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | t_UFIXEDMN | r"ufixed(?P<M>256|248|240|232|224|216|208|200|192|184|176|168|160|152|144|136|128|120|112|104|96|88|80|72|64|56|48|40|32|24|16|8)x(?P<N>80|79|78|77|76|75|74|73|72|71|70|69|68|67|66|65|64|63|62|61|60|59|58|57|56|55|54|53|52|51|50|49|48|47|46|45|44|43|42|41|40|39|38|37|36|35|34|33|32|31|30|29|28|27|26|25|24|23|22|21|20|1... | manticore/ethereum/abitypes.py | def t_UFIXEDMN(t):
r"ufixed(?P<M>256|248|240|232|224|216|208|200|192|184|176|168|160|152|144|136|128|120|112|104|96|88|80|72|64|56|48|40|32|24|16|8)x(?P<N>80|79|78|77|76|75|74|73|72|71|70|69|68|67|66|65|64|63|62|61|60|59|58|57|56|55|54|53|52|51|50|49|48|47|46|45|44|43|42|41|40|39|38|37|36|35|34|33|32|31|30|29|28|27... | def t_UFIXEDMN(t):
r"ufixed(?P<M>256|248|240|232|224|216|208|200|192|184|176|168|160|152|144|136|128|120|112|104|96|88|80|72|64|56|48|40|32|24|16|8)x(?P<N>80|79|78|77|76|75|74|73|72|71|70|69|68|67|66|65|64|63|62|61|60|59|58|57|56|55|54|53|52|51|50|49|48|47|46|45|44|43|42|41|40|39|38|37|36|35|34|33|32|31|30|29|28|27... | [
"r",
"ufixed",
"(",
"?P<M",
">",
"256|248|240|232|224|216|208|200|192|184|176|168|160|152|144|136|128|120|112|104|96|88|80|72|64|56|48|40|32|24|16|8",
")",
"x",
"(",
"?P<N",
">",
"80|79|78|77|76|75|74|73|72|71|70|69|68|67|66|65|64|63|62|61|60|59|58|57|56|55|54|53|52|51|50|49|48|47|46|45|44|43|... | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/ethereum/abitypes.py#L103-L108 | [
"def",
"t_UFIXEDMN",
"(",
"t",
")",
":",
"M",
"=",
"int",
"(",
"t",
".",
"lexer",
".",
"lexmatch",
".",
"group",
"(",
"'M'",
")",
")",
"N",
"=",
"int",
"(",
"t",
".",
"lexer",
".",
"lexmatch",
".",
"group",
"(",
"'N'",
")",
")",
"t",
".",
"... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | t_BYTESM | r"bytes(?P<nbytes>32|31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|9|8|7|6|5|4|3|2|1) | manticore/ethereum/abitypes.py | def t_BYTESM(t):
r"bytes(?P<nbytes>32|31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|9|8|7|6|5|4|3|2|1)"
size = int(t.lexer.lexmatch.group('nbytes'))
t.value = ('bytesM', size)
return t | def t_BYTESM(t):
r"bytes(?P<nbytes>32|31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|9|8|7|6|5|4|3|2|1)"
size = int(t.lexer.lexmatch.group('nbytes'))
t.value = ('bytesM', size)
return t | [
"r",
"bytes",
"(",
"?P<nbytes",
">",
"32|31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|9|8|7|6|5|4|3|2|1",
")"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/ethereum/abitypes.py#L117-L121 | [
"def",
"t_BYTESM",
"(",
"t",
")",
":",
"size",
"=",
"int",
"(",
"t",
".",
"lexer",
".",
"lexmatch",
".",
"group",
"(",
"'nbytes'",
")",
")",
"t",
".",
"value",
"=",
"(",
"'bytesM'",
",",
"size",
")",
"return",
"t"
] | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | p_dynamic_fixed_type | T : T LBRAKET NUMBER RBRAKET | manticore/ethereum/abitypes.py | def p_dynamic_fixed_type(p):
"""
T : T LBRAKET NUMBER RBRAKET
"""
reps = int(p[3])
base_type = p[1]
p[0] = ('array', reps, base_type) | def p_dynamic_fixed_type(p):
"""
T : T LBRAKET NUMBER RBRAKET
"""
reps = int(p[3])
base_type = p[1]
p[0] = ('array', reps, base_type) | [
"T",
":",
"T",
"LBRAKET",
"NUMBER",
"RBRAKET"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/ethereum/abitypes.py#L210-L216 | [
"def",
"p_dynamic_fixed_type",
"(",
"p",
")",
":",
"reps",
"=",
"int",
"(",
"p",
"[",
"3",
"]",
")",
"base_type",
"=",
"p",
"[",
"1",
"]",
"p",
"[",
"0",
"]",
"=",
"(",
"'array'",
",",
"reps",
",",
"base_type",
")"
] | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | cmp_regs | Compare registers from a remote gdb session to current mcore.
:param manticore.core.cpu Cpu: Current cpu
:param bool should_print: Whether to print values to stdout
:return: Whether or not any differences were detected
:rtype: bool | scripts/verify.py | def cmp_regs(cpu, should_print=False):
"""
Compare registers from a remote gdb session to current mcore.
:param manticore.core.cpu Cpu: Current cpu
:param bool should_print: Whether to print values to stdout
:return: Whether or not any differences were detected
:rtype: bool
"""
differin... | def cmp_regs(cpu, should_print=False):
"""
Compare registers from a remote gdb session to current mcore.
:param manticore.core.cpu Cpu: Current cpu
:param bool should_print: Whether to print values to stdout
:return: Whether or not any differences were detected
:rtype: bool
"""
differin... | [
"Compare",
"registers",
"from",
"a",
"remote",
"gdb",
"session",
"to",
"current",
"mcore",
"."
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/scripts/verify.py#L36-L60 | [
"def",
"cmp_regs",
"(",
"cpu",
",",
"should_print",
"=",
"False",
")",
":",
"differing",
"=",
"False",
"gdb_regs",
"=",
"gdb",
".",
"getCanonicalRegisters",
"(",
")",
"for",
"name",
"in",
"sorted",
"(",
"gdb_regs",
")",
":",
"vg",
"=",
"gdb_regs",
"[",
... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | post_mcore | Handle syscalls (import memory) and bail if we diverge | scripts/verify.py | def post_mcore(state, last_instruction):
"""
Handle syscalls (import memory) and bail if we diverge
"""
global in_helper
# Synchronize qemu state to manticore's after a system call
if last_instruction.mnemonic.lower() == 'svc':
# Synchronize all writes that have happened
writes ... | def post_mcore(state, last_instruction):
"""
Handle syscalls (import memory) and bail if we diverge
"""
global in_helper
# Synchronize qemu state to manticore's after a system call
if last_instruction.mnemonic.lower() == 'svc':
# Synchronize all writes that have happened
writes ... | [
"Handle",
"syscalls",
"(",
"import",
"memory",
")",
"and",
"bail",
"if",
"we",
"diverge"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/scripts/verify.py#L67-L112 | [
"def",
"post_mcore",
"(",
"state",
",",
"last_instruction",
")",
":",
"global",
"in_helper",
"# Synchronize qemu state to manticore's after a system call",
"if",
"last_instruction",
".",
"mnemonic",
".",
"lower",
"(",
")",
"==",
"'svc'",
":",
"# Synchronize all writes tha... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | sync_svc | Mirror some service calls in manticore. Happens after qemu executed a SVC
instruction, but before manticore did. | scripts/verify.py | def sync_svc(state):
"""
Mirror some service calls in manticore. Happens after qemu executed a SVC
instruction, but before manticore did.
"""
syscall = state.cpu.R7 # Grab idx from manticore since qemu could have exited
name = linux_syscalls.armv7[syscall]
logger.debug(f"Syncing syscall: {n... | def sync_svc(state):
"""
Mirror some service calls in manticore. Happens after qemu executed a SVC
instruction, but before manticore did.
"""
syscall = state.cpu.R7 # Grab idx from manticore since qemu could have exited
name = linux_syscalls.armv7[syscall]
logger.debug(f"Syncing syscall: {n... | [
"Mirror",
"some",
"service",
"calls",
"in",
"manticore",
".",
"Happens",
"after",
"qemu",
"executed",
"a",
"SVC",
"instruction",
"but",
"before",
"manticore",
"did",
"."
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/scripts/verify.py#L122-L143 | [
"def",
"sync_svc",
"(",
"state",
")",
":",
"syscall",
"=",
"state",
".",
"cpu",
".",
"R7",
"# Grab idx from manticore since qemu could have exited",
"name",
"=",
"linux_syscalls",
".",
"armv7",
"[",
"syscall",
"]",
"logger",
".",
"debug",
"(",
"f\"Syncing syscall:... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | initialize | Synchronize the stack and register state (manticore->qemu) | scripts/verify.py | def initialize(state):
"""
Synchronize the stack and register state (manticore->qemu)
"""
logger.debug(f"Copying {stack_top - state.cpu.SP} bytes in the stack..")
stack_bottom = min(state.cpu.SP, gdb.getR('SP'))
for address in range(stack_bottom, stack_top):
b = state.cpu.read_int(addres... | def initialize(state):
"""
Synchronize the stack and register state (manticore->qemu)
"""
logger.debug(f"Copying {stack_top - state.cpu.SP} bytes in the stack..")
stack_bottom = min(state.cpu.SP, gdb.getR('SP'))
for address in range(stack_bottom, stack_top):
b = state.cpu.read_int(addres... | [
"Synchronize",
"the",
"stack",
"and",
"register",
"state",
"(",
"manticore",
"-",
">",
"qemu",
")"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/scripts/verify.py#L145-L169 | [
"def",
"initialize",
"(",
"state",
")",
":",
"logger",
".",
"debug",
"(",
"f\"Copying {stack_top - state.cpu.SP} bytes in the stack..\"",
")",
"stack_bottom",
"=",
"min",
"(",
"state",
".",
"cpu",
".",
"SP",
",",
"gdb",
".",
"getR",
"(",
"'SP'",
")",
")",
"f... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | to_constant | Iff the expression can be simplified to a Constant get the actual concrete value.
This discards/ignore any taint | manticore/core/smtlib/visitors.py | def to_constant(expression):
"""
Iff the expression can be simplified to a Constant get the actual concrete value.
This discards/ignore any taint
"""
value = simplify(expression)
if isinstance(value, Expression) and value.taint:
raise ValueError("Can not simplify tainted values t... | def to_constant(expression):
"""
Iff the expression can be simplified to a Constant get the actual concrete value.
This discards/ignore any taint
"""
value = simplify(expression)
if isinstance(value, Expression) and value.taint:
raise ValueError("Can not simplify tainted values t... | [
"Iff",
"the",
"expression",
"can",
"be",
"simplified",
"to",
"a",
"Constant",
"get",
"the",
"actual",
"concrete",
"value",
".",
"This",
"discards",
"/",
"ignore",
"any",
"taint"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/core/smtlib/visitors.py#L580-L601 | [
"def",
"to_constant",
"(",
"expression",
")",
":",
"value",
"=",
"simplify",
"(",
"expression",
")",
"if",
"isinstance",
"(",
"value",
",",
"Expression",
")",
"and",
"value",
".",
"taint",
":",
"raise",
"ValueError",
"(",
"\"Can not simplify tainted values to co... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | Visitor.visit | The entry point of the visitor.
The exploration algorithm is a DFS post-order traversal
The implementation used two stacks instead of a recursion
The final result is store in self.result
:param node: Node to explore
:type node: Expression
:param use_fixed_point: if True,... | manticore/core/smtlib/visitors.py | def visit(self, node, use_fixed_point=False):
"""
The entry point of the visitor.
The exploration algorithm is a DFS post-order traversal
The implementation used two stacks instead of a recursion
The final result is store in self.result
:param node: Node to explore
... | def visit(self, node, use_fixed_point=False):
"""
The entry point of the visitor.
The exploration algorithm is a DFS post-order traversal
The implementation used two stacks instead of a recursion
The final result is store in self.result
:param node: Node to explore
... | [
"The",
"entry",
"point",
"of",
"the",
"visitor",
".",
"The",
"exploration",
"algorithm",
"is",
"a",
"DFS",
"post",
"-",
"order",
"traversal",
"The",
"implementation",
"used",
"two",
"stacks",
"instead",
"of",
"a",
"recursion",
"The",
"final",
"result",
"is",... | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/core/smtlib/visitors.py#L65-L107 | [
"def",
"visit",
"(",
"self",
",",
"node",
",",
"use_fixed_point",
"=",
"False",
")",
":",
"cache",
"=",
"self",
".",
"_cache",
"visited",
"=",
"set",
"(",
")",
"stack",
"=",
"[",
"]",
"stack",
".",
"append",
"(",
"node",
")",
"while",
"stack",
":",... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | PrettyPrinter._method | Overload Visitor._method because we want to stop to iterate over the
visit_ functions as soon as a valid visit_ function is found | manticore/core/smtlib/visitors.py | def _method(self, expression, *args):
"""
Overload Visitor._method because we want to stop to iterate over the
visit_ functions as soon as a valid visit_ function is found
"""
assert expression.__class__.__mro__[-1] is object
for cls in expression.__class__.__mro__:
... | def _method(self, expression, *args):
"""
Overload Visitor._method because we want to stop to iterate over the
visit_ functions as soon as a valid visit_ function is found
"""
assert expression.__class__.__mro__[-1] is object
for cls in expression.__class__.__mro__:
... | [
"Overload",
"Visitor",
".",
"_method",
"because",
"we",
"want",
"to",
"stop",
"to",
"iterate",
"over",
"the",
"visit_",
"functions",
"as",
"soon",
"as",
"a",
"valid",
"visit_",
"function",
"is",
"found"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/core/smtlib/visitors.py#L197-L210 | [
"def",
"_method",
"(",
"self",
",",
"expression",
",",
"*",
"args",
")",
":",
"assert",
"expression",
".",
"__class__",
".",
"__mro__",
"[",
"-",
"1",
"]",
"is",
"object",
"for",
"cls",
"in",
"expression",
".",
"__class__",
".",
"__mro__",
":",
"sort",... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | ConstantFolderSimplifier.visit_Operation | constant folding, if all operands of an expression are a Constant do the math | manticore/core/smtlib/visitors.py | def visit_Operation(self, expression, *operands):
""" constant folding, if all operands of an expression are a Constant do the math """
operation = self.operations.get(type(expression), None)
if operation is not None and \
all(isinstance(o, Constant) for o in operands):
... | def visit_Operation(self, expression, *operands):
""" constant folding, if all operands of an expression are a Constant do the math """
operation = self.operations.get(type(expression), None)
if operation is not None and \
all(isinstance(o, Constant) for o in operands):
... | [
"constant",
"folding",
"if",
"all",
"operands",
"of",
"an",
"expression",
"are",
"a",
"Constant",
"do",
"the",
"math"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/core/smtlib/visitors.py#L317-L331 | [
"def",
"visit_Operation",
"(",
"self",
",",
"expression",
",",
"*",
"operands",
")",
":",
"operation",
"=",
"self",
".",
"operations",
".",
"get",
"(",
"type",
"(",
"expression",
")",
",",
"None",
")",
"if",
"operation",
"is",
"not",
"None",
"and",
"al... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | ArithmeticSimplifier.visit_Operation | constant folding, if all operands of an expression are a Constant do the math | manticore/core/smtlib/visitors.py | def visit_Operation(self, expression, *operands):
""" constant folding, if all operands of an expression are a Constant do the math """
if all(isinstance(o, Constant) for o in operands):
expression = constant_folder(expression)
if self._changed(expression, operands):
expr... | def visit_Operation(self, expression, *operands):
""" constant folding, if all operands of an expression are a Constant do the math """
if all(isinstance(o, Constant) for o in operands):
expression = constant_folder(expression)
if self._changed(expression, operands):
expr... | [
"constant",
"folding",
"if",
"all",
"operands",
"of",
"an",
"expression",
"are",
"a",
"Constant",
"do",
"the",
"math"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/core/smtlib/visitors.py#L362-L368 | [
"def",
"visit_Operation",
"(",
"self",
",",
"expression",
",",
"*",
"operands",
")",
":",
"if",
"all",
"(",
"isinstance",
"(",
"o",
",",
"Constant",
")",
"for",
"o",
"in",
"operands",
")",
":",
"expression",
"=",
"constant_folder",
"(",
"expression",
")"... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | ArithmeticSimplifier.visit_BitVecConcat | concat( extract(k1, 0, a), extract(sizeof(a)-k1, k1, a)) ==> a
concat( extract(k1, beg, a), extract(end, k1, a)) ==> extract(beg, end, a) | manticore/core/smtlib/visitors.py | def visit_BitVecConcat(self, expression, *operands):
""" concat( extract(k1, 0, a), extract(sizeof(a)-k1, k1, a)) ==> a
concat( extract(k1, beg, a), extract(end, k1, a)) ==> extract(beg, end, a)
"""
op = expression.operands[0]
value = None
end = None
begini... | def visit_BitVecConcat(self, expression, *operands):
""" concat( extract(k1, 0, a), extract(sizeof(a)-k1, k1, a)) ==> a
concat( extract(k1, beg, a), extract(end, k1, a)) ==> extract(beg, end, a)
"""
op = expression.operands[0]
value = None
end = None
begini... | [
"concat",
"(",
"extract",
"(",
"k1",
"0",
"a",
")",
"extract",
"(",
"sizeof",
"(",
"a",
")",
"-",
"k1",
"k1",
"a",
"))",
"==",
">",
"a",
"concat",
"(",
"extract",
"(",
"k1",
"beg",
"a",
")",
"extract",
"(",
"end",
"k1",
"a",
"))",
"==",
">",
... | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/core/smtlib/visitors.py#L388-L420 | [
"def",
"visit_BitVecConcat",
"(",
"self",
",",
"expression",
",",
"*",
"operands",
")",
":",
"op",
"=",
"expression",
".",
"operands",
"[",
"0",
"]",
"value",
"=",
"None",
"end",
"=",
"None",
"begining",
"=",
"None",
"for",
"o",
"in",
"operands",
":",
... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | ArithmeticSimplifier.visit_BitVecExtract | extract(sizeof(a), 0)(a) ==> a
extract(16, 0)( concat(a,b,c,d) ) => concat(c, d)
extract(m,M)(and/or/xor a b ) => and/or/xor((extract(m,M) a) (extract(m,M) a) | manticore/core/smtlib/visitors.py | def visit_BitVecExtract(self, expression, *operands):
""" extract(sizeof(a), 0)(a) ==> a
extract(16, 0)( concat(a,b,c,d) ) => concat(c, d)
extract(m,M)(and/or/xor a b ) => and/or/xor((extract(m,M) a) (extract(m,M) a)
"""
op = expression.operands[0]
begining = exp... | def visit_BitVecExtract(self, expression, *operands):
""" extract(sizeof(a), 0)(a) ==> a
extract(16, 0)( concat(a,b,c,d) ) => concat(c, d)
extract(m,M)(and/or/xor a b ) => and/or/xor((extract(m,M) a) (extract(m,M) a)
"""
op = expression.operands[0]
begining = exp... | [
"extract",
"(",
"sizeof",
"(",
"a",
")",
"0",
")",
"(",
"a",
")",
"==",
">",
"a",
"extract",
"(",
"16",
"0",
")",
"(",
"concat",
"(",
"a",
"b",
"c",
"d",
")",
")",
"=",
">",
"concat",
"(",
"c",
"d",
")",
"extract",
"(",
"m",
"M",
")",
"... | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/core/smtlib/visitors.py#L422-L452 | [
"def",
"visit_BitVecExtract",
"(",
"self",
",",
"expression",
",",
"*",
"operands",
")",
":",
"op",
"=",
"expression",
".",
"operands",
"[",
"0",
"]",
"begining",
"=",
"expression",
".",
"begining",
"end",
"=",
"expression",
".",
"end",
"size",
"=",
"end... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | ArithmeticSimplifier.visit_BitVecAdd | a + 0 ==> a
0 + a ==> a | manticore/core/smtlib/visitors.py | def visit_BitVecAdd(self, expression, *operands):
""" a + 0 ==> a
0 + a ==> a
"""
left = expression.operands[0]
right = expression.operands[1]
if isinstance(right, BitVecConstant):
if right.value == 0:
return left
if isinstance(le... | def visit_BitVecAdd(self, expression, *operands):
""" a + 0 ==> a
0 + a ==> a
"""
left = expression.operands[0]
right = expression.operands[1]
if isinstance(right, BitVecConstant):
if right.value == 0:
return left
if isinstance(le... | [
"a",
"+",
"0",
"==",
">",
"a",
"0",
"+",
"a",
"==",
">",
"a"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/core/smtlib/visitors.py#L454-L465 | [
"def",
"visit_BitVecAdd",
"(",
"self",
",",
"expression",
",",
"*",
"operands",
")",
":",
"left",
"=",
"expression",
".",
"operands",
"[",
"0",
"]",
"right",
"=",
"expression",
".",
"operands",
"[",
"1",
"]",
"if",
"isinstance",
"(",
"right",
",",
"Bit... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | ArithmeticSimplifier.visit_BitVecSub | a - 0 ==> 0
(a + b) - b ==> a
(b + a) - b ==> a | manticore/core/smtlib/visitors.py | def visit_BitVecSub(self, expression, *operands):
""" a - 0 ==> 0
(a + b) - b ==> a
(b + a) - b ==> a
"""
left = expression.operands[0]
right = expression.operands[1]
if isinstance(left, BitVecAdd):
if self._same_constant(left.operands[0], ri... | def visit_BitVecSub(self, expression, *operands):
""" a - 0 ==> 0
(a + b) - b ==> a
(b + a) - b ==> a
"""
left = expression.operands[0]
right = expression.operands[1]
if isinstance(left, BitVecAdd):
if self._same_constant(left.operands[0], ri... | [
"a",
"-",
"0",
"==",
">",
"0",
"(",
"a",
"+",
"b",
")",
"-",
"b",
"==",
">",
"a",
"(",
"b",
"+",
"a",
")",
"-",
"b",
"==",
">",
"a"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/core/smtlib/visitors.py#L467-L478 | [
"def",
"visit_BitVecSub",
"(",
"self",
",",
"expression",
",",
"*",
"operands",
")",
":",
"left",
"=",
"expression",
".",
"operands",
"[",
"0",
"]",
"right",
"=",
"expression",
".",
"operands",
"[",
"1",
"]",
"if",
"isinstance",
"(",
"left",
",",
"BitV... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | ArithmeticSimplifier.visit_BitVecOr | a | 0 => a
0 | a => a
0xffffffff & a => 0xffffffff
a & 0xffffffff => 0xffffffff | manticore/core/smtlib/visitors.py | def visit_BitVecOr(self, expression, *operands):
""" a | 0 => a
0 | a => a
0xffffffff & a => 0xffffffff
a & 0xffffffff => 0xffffffff
"""
left = expression.operands[0]
right = expression.operands[1]
if isinstance(right, BitVecConstant):
... | def visit_BitVecOr(self, expression, *operands):
""" a | 0 => a
0 | a => a
0xffffffff & a => 0xffffffff
a & 0xffffffff => 0xffffffff
"""
left = expression.operands[0]
right = expression.operands[1]
if isinstance(right, BitVecConstant):
... | [
"a",
"|",
"0",
"=",
">",
"a",
"0",
"|",
"a",
"=",
">",
"a",
"0xffffffff",
"&",
"a",
"=",
">",
"0xffffffff",
"a",
"&",
"0xffffffff",
"=",
">",
"0xffffffff"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/core/smtlib/visitors.py#L480-L500 | [
"def",
"visit_BitVecOr",
"(",
"self",
",",
"expression",
",",
"*",
"operands",
")",
":",
"left",
"=",
"expression",
".",
"operands",
"[",
"0",
"]",
"right",
"=",
"expression",
".",
"operands",
"[",
"1",
"]",
"if",
"isinstance",
"(",
"right",
",",
"BitV... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | ArithmeticSimplifier.visit_BitVecAnd | ct & x => x & ct move constants to the right
a & 0 => 0 remove zero
a & 0xffffffff => a remove full mask
(b & ct2) & ct => b & (ct&ct2) associative property
(a & (b | c) => a&b | a&c distribute over | | manticore/core/smtlib/visitors.py | def visit_BitVecAnd(self, expression, *operands):
""" ct & x => x & ct move constants to the right
a & 0 => 0 remove zero
a & 0xffffffff => a remove full mask
(b & ct2) & ct => b & (ct&ct2) associative property
(a &... | def visit_BitVecAnd(self, expression, *operands):
""" ct & x => x & ct move constants to the right
a & 0 => 0 remove zero
a & 0xffffffff => a remove full mask
(b & ct2) & ct => b & (ct&ct2) associative property
(a &... | [
"ct",
"&",
"x",
"=",
">",
"x",
"&",
"ct",
"move",
"constants",
"to",
"the",
"right",
"a",
"&",
"0",
"=",
">",
"0",
"remove",
"zero",
"a",
"&",
"0xffffffff",
"=",
">",
"a",
"remove",
"full",
"mask",
"(",
"b",
"&",
"ct2",
")",
"&",
"ct",
"=",
... | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/core/smtlib/visitors.py#L502-L527 | [
"def",
"visit_BitVecAnd",
"(",
"self",
",",
"expression",
",",
"*",
"operands",
")",
":",
"left",
"=",
"expression",
".",
"operands",
"[",
"0",
"]",
"right",
"=",
"expression",
".",
"operands",
"[",
"1",
"]",
"if",
"isinstance",
"(",
"right",
",",
"Bit... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | ArithmeticSimplifier.visit_BitVecShiftLeft | a << 0 => a remove zero
a << ct => 0 if ct > sizeof(a) remove big constant shift | manticore/core/smtlib/visitors.py | def visit_BitVecShiftLeft(self, expression, *operands):
""" a << 0 => a remove zero
a << ct => 0 if ct > sizeof(a) remove big constant shift
"""
left = expression.operands[0]
right = expression.operands[1]
if isinstance(right, BitVecConstant):... | def visit_BitVecShiftLeft(self, expression, *operands):
""" a << 0 => a remove zero
a << ct => 0 if ct > sizeof(a) remove big constant shift
"""
left = expression.operands[0]
right = expression.operands[1]
if isinstance(right, BitVecConstant):... | [
"a",
"<<",
"0",
"=",
">",
"a",
"remove",
"zero",
"a",
"<<",
"ct",
"=",
">",
"0",
"if",
"ct",
">",
"sizeof",
"(",
"a",
")",
"remove",
"big",
"constant",
"shift"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/core/smtlib/visitors.py#L529-L539 | [
"def",
"visit_BitVecShiftLeft",
"(",
"self",
",",
"expression",
",",
"*",
"operands",
")",
":",
"left",
"=",
"expression",
".",
"operands",
"[",
"0",
"]",
"right",
"=",
"expression",
".",
"operands",
"[",
"1",
"]",
"if",
"isinstance",
"(",
"right",
",",
... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | ArithmeticSimplifier.visit_ArraySelect | ArraySelect (ArrayStore((ArrayStore(x0,v0) ...),xn, vn), x0)
-> v0 | manticore/core/smtlib/visitors.py | def visit_ArraySelect(self, expression, *operands):
""" ArraySelect (ArrayStore((ArrayStore(x0,v0) ...),xn, vn), x0)
-> v0
"""
arr, index = operands
if isinstance(arr, ArrayVariable):
return
if isinstance(index, BitVecConstant):
ival = ind... | def visit_ArraySelect(self, expression, *operands):
""" ArraySelect (ArrayStore((ArrayStore(x0,v0) ...),xn, vn), x0)
-> v0
"""
arr, index = operands
if isinstance(arr, ArrayVariable):
return
if isinstance(index, BitVecConstant):
ival = ind... | [
"ArraySelect",
"(",
"ArrayStore",
"((",
"ArrayStore",
"(",
"x0",
"v0",
")",
"...",
")",
"xn",
"vn",
")",
"x0",
")",
"-",
">",
"v0"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/core/smtlib/visitors.py#L541-L561 | [
"def",
"visit_ArraySelect",
"(",
"self",
",",
"expression",
",",
"*",
"operands",
")",
":",
"arr",
",",
"index",
"=",
"operands",
"if",
"isinstance",
"(",
"arr",
",",
"ArrayVariable",
")",
":",
"return",
"if",
"isinstance",
"(",
"index",
",",
"BitVecConsta... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | ABI._type_size | Calculate `static` type size | manticore/ethereum/abi.py | def _type_size(ty):
""" Calculate `static` type size """
if ty[0] in ('int', 'uint', 'bytesM', 'function'):
return 32
elif ty[0] in ('tuple'):
result = 0
for ty_i in ty[1]:
result += ABI._type_size(ty_i)
return result
elif t... | def _type_size(ty):
""" Calculate `static` type size """
if ty[0] in ('int', 'uint', 'bytesM', 'function'):
return 32
elif ty[0] in ('tuple'):
result = 0
for ty_i in ty[1]:
result += ABI._type_size(ty_i)
return result
elif t... | [
"Calculate",
"static",
"type",
"size"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/ethereum/abi.py#L24-L40 | [
"def",
"_type_size",
"(",
"ty",
")",
":",
"if",
"ty",
"[",
"0",
"]",
"in",
"(",
"'int'",
",",
"'uint'",
",",
"'bytesM'",
",",
"'function'",
")",
":",
"return",
"32",
"elif",
"ty",
"[",
"0",
"]",
"in",
"(",
"'tuple'",
")",
":",
"result",
"=",
"0... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | ABI.function_call | Build transaction data from function signature and arguments | manticore/ethereum/abi.py | def function_call(type_spec, *args):
"""
Build transaction data from function signature and arguments
"""
m = re.match(r"(?P<name>[a-zA-Z_][a-zA-Z_0-9]*)(?P<type>\(.*\))", type_spec)
if not m:
raise EthereumError("Function signature expected")
ABI._check_and_... | def function_call(type_spec, *args):
"""
Build transaction data from function signature and arguments
"""
m = re.match(r"(?P<name>[a-zA-Z_][a-zA-Z_0-9]*)(?P<type>\(.*\))", type_spec)
if not m:
raise EthereumError("Function signature expected")
ABI._check_and_... | [
"Build",
"transaction",
"data",
"from",
"function",
"signature",
"and",
"arguments"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/ethereum/abi.py#L56-L68 | [
"def",
"function_call",
"(",
"type_spec",
",",
"*",
"args",
")",
":",
"m",
"=",
"re",
".",
"match",
"(",
"r\"(?P<name>[a-zA-Z_][a-zA-Z_0-9]*)(?P<type>\\(.*\\))\"",
",",
"type_spec",
")",
"if",
"not",
"m",
":",
"raise",
"EthereumError",
"(",
"\"Function signature e... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | ABI.serialize | Serialize value using type specification in ty.
ABI.serialize('int256', 1000)
ABI.serialize('(int, int256)', 1000, 2000) | manticore/ethereum/abi.py | def serialize(ty, *values, **kwargs):
"""
Serialize value using type specification in ty.
ABI.serialize('int256', 1000)
ABI.serialize('(int, int256)', 1000, 2000)
"""
try:
parsed_ty = abitypes.parse(ty)
except Exception as e:
# Catch and re... | def serialize(ty, *values, **kwargs):
"""
Serialize value using type specification in ty.
ABI.serialize('int256', 1000)
ABI.serialize('(int, int256)', 1000, 2000)
"""
try:
parsed_ty = abitypes.parse(ty)
except Exception as e:
# Catch and re... | [
"Serialize",
"value",
"using",
"type",
"specification",
"in",
"ty",
".",
"ABI",
".",
"serialize",
"(",
"int256",
"1000",
")",
"ABI",
".",
"serialize",
"(",
"(",
"int",
"int256",
")",
"1000",
"2000",
")"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/ethereum/abi.py#L71-L95 | [
"def",
"serialize",
"(",
"ty",
",",
"*",
"values",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"parsed_ty",
"=",
"abitypes",
".",
"parse",
"(",
"ty",
")",
"except",
"Exception",
"as",
"e",
":",
"# Catch and rebrand parsing errors",
"raise",
"EthereumErr... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | ABI.function_selector | Makes a function hash id from a method signature | manticore/ethereum/abi.py | def function_selector(method_name_and_signature):
"""
Makes a function hash id from a method signature
"""
s = sha3.keccak_256()
s.update(method_name_and_signature.encode())
return bytes(s.digest()[:4]) | def function_selector(method_name_and_signature):
"""
Makes a function hash id from a method signature
"""
s = sha3.keccak_256()
s.update(method_name_and_signature.encode())
return bytes(s.digest()[:4]) | [
"Makes",
"a",
"function",
"hash",
"id",
"from",
"a",
"method",
"signature"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/ethereum/abi.py#L180-L186 | [
"def",
"function_selector",
"(",
"method_name_and_signature",
")",
":",
"s",
"=",
"sha3",
".",
"keccak_256",
"(",
")",
"s",
".",
"update",
"(",
"method_name_and_signature",
".",
"encode",
"(",
")",
")",
"return",
"bytes",
"(",
"s",
".",
"digest",
"(",
")",... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | ABI._serialize_uint | Translates a python integral or a BitVec into a 32 byte string, MSB first | manticore/ethereum/abi.py | def _serialize_uint(value, size=32, padding=0):
"""
Translates a python integral or a BitVec into a 32 byte string, MSB first
"""
if size <= 0 or size > 32:
raise ValueError
from .account import EVMAccount # because of circular import
if not isinstance(value... | def _serialize_uint(value, size=32, padding=0):
"""
Translates a python integral or a BitVec into a 32 byte string, MSB first
"""
if size <= 0 or size > 32:
raise ValueError
from .account import EVMAccount # because of circular import
if not isinstance(value... | [
"Translates",
"a",
"python",
"integral",
"or",
"a",
"BitVec",
"into",
"a",
"32",
"byte",
"string",
"MSB",
"first"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/ethereum/abi.py#L254-L281 | [
"def",
"_serialize_uint",
"(",
"value",
",",
"size",
"=",
"32",
",",
"padding",
"=",
"0",
")",
":",
"if",
"size",
"<=",
"0",
"or",
"size",
">",
"32",
":",
"raise",
"ValueError",
"from",
".",
"account",
"import",
"EVMAccount",
"# because of circular import"... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | ABI._serialize_int | Translates a signed python integral or a BitVec into a 32 byte string, MSB first | manticore/ethereum/abi.py | def _serialize_int(value, size=32, padding=0):
"""
Translates a signed python integral or a BitVec into a 32 byte string, MSB first
"""
if size <= 0 or size > 32:
raise ValueError
if not isinstance(value, (int, BitVec)):
raise ValueError
if issymbo... | def _serialize_int(value, size=32, padding=0):
"""
Translates a signed python integral or a BitVec into a 32 byte string, MSB first
"""
if size <= 0 or size > 32:
raise ValueError
if not isinstance(value, (int, BitVec)):
raise ValueError
if issymbo... | [
"Translates",
"a",
"signed",
"python",
"integral",
"or",
"a",
"BitVec",
"into",
"a",
"32",
"byte",
"string",
"MSB",
"first"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/ethereum/abi.py#L284-L304 | [
"def",
"_serialize_int",
"(",
"value",
",",
"size",
"=",
"32",
",",
"padding",
"=",
"0",
")",
":",
"if",
"size",
"<=",
"0",
"or",
"size",
">",
"32",
":",
"raise",
"ValueError",
"if",
"not",
"isinstance",
"(",
"value",
",",
"(",
"int",
",",
"BitVec"... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | ABI._deserialize_uint | Read a `nbytes` bytes long big endian unsigned integer from `data` starting at `offset`
:param data: sliceable buffer; symbolic buffer of Eth ABI encoded data
:param nbytes: number of bytes to read starting from least significant byte
:rtype: int or Expression | manticore/ethereum/abi.py | def _deserialize_uint(data, nbytes=32, padding=0, offset=0):
"""
Read a `nbytes` bytes long big endian unsigned integer from `data` starting at `offset`
:param data: sliceable buffer; symbolic buffer of Eth ABI encoded data
:param nbytes: number of bytes to read starting from least sign... | def _deserialize_uint(data, nbytes=32, padding=0, offset=0):
"""
Read a `nbytes` bytes long big endian unsigned integer from `data` starting at `offset`
:param data: sliceable buffer; symbolic buffer of Eth ABI encoded data
:param nbytes: number of bytes to read starting from least sign... | [
"Read",
"a",
"nbytes",
"bytes",
"long",
"big",
"endian",
"unsigned",
"integer",
"from",
"data",
"starting",
"at",
"offset"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/ethereum/abi.py#L334-L345 | [
"def",
"_deserialize_uint",
"(",
"data",
",",
"nbytes",
"=",
"32",
",",
"padding",
"=",
"0",
",",
"offset",
"=",
"0",
")",
":",
"assert",
"isinstance",
"(",
"data",
",",
"(",
"bytearray",
",",
"Array",
")",
")",
"value",
"=",
"ABI",
".",
"_readBE",
... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | ABI._deserialize_int | Read a `nbytes` bytes long big endian signed integer from `data` starting at `offset`
:param data: sliceable buffer; symbolic buffer of Eth ABI encoded data
:param nbytes: number of bytes to read starting from least significant byte
:rtype: int or Expression | manticore/ethereum/abi.py | def _deserialize_int(data, nbytes=32, padding=0):
"""
Read a `nbytes` bytes long big endian signed integer from `data` starting at `offset`
:param data: sliceable buffer; symbolic buffer of Eth ABI encoded data
:param nbytes: number of bytes to read starting from least significant byte
... | def _deserialize_int(data, nbytes=32, padding=0):
"""
Read a `nbytes` bytes long big endian signed integer from `data` starting at `offset`
:param data: sliceable buffer; symbolic buffer of Eth ABI encoded data
:param nbytes: number of bytes to read starting from least significant byte
... | [
"Read",
"a",
"nbytes",
"bytes",
"long",
"big",
"endian",
"signed",
"integer",
"from",
"data",
"starting",
"at",
"offset"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/ethereum/abi.py#L348-L363 | [
"def",
"_deserialize_int",
"(",
"data",
",",
"nbytes",
"=",
"32",
",",
"padding",
"=",
"0",
")",
":",
"assert",
"isinstance",
"(",
"data",
",",
"(",
"bytearray",
",",
"Array",
")",
")",
"value",
"=",
"ABI",
".",
"_readBE",
"(",
"data",
",",
"nbytes",... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | concretized_args | Make sure an EVM instruction has all of its arguments concretized according to
provided policies.
Example decoration:
@concretized_args(size='ONE', address='')
def LOG(self, address, size, *topics):
...
The above will make sure that the |size| parameter to LOG is Concretized w... | manticore/platforms/evm.py | def concretized_args(**policies):
"""
Make sure an EVM instruction has all of its arguments concretized according to
provided policies.
Example decoration:
@concretized_args(size='ONE', address='')
def LOG(self, address, size, *topics):
...
The above will make sure tha... | def concretized_args(**policies):
"""
Make sure an EVM instruction has all of its arguments concretized according to
provided policies.
Example decoration:
@concretized_args(size='ONE', address='')
def LOG(self, address, size, *topics):
...
The above will make sure tha... | [
"Make",
"sure",
"an",
"EVM",
"instruction",
"has",
"all",
"of",
"its",
"arguments",
"concretized",
"according",
"to",
"provided",
"policies",
"."
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L402-L445 | [
"def",
"concretized_args",
"(",
"*",
"*",
"policies",
")",
":",
"def",
"concretizer",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"spec",
"=",
"inspect",
".",
"getful... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | Transaction.to_dict | Only meant to be used with concrete Transaction objects! (after calling .concretize()) | manticore/platforms/evm.py | def to_dict(self, mevm):
"""
Only meant to be used with concrete Transaction objects! (after calling .concretize())
"""
return dict(type=self.sort,
from_address=self.caller,
from_name=mevm.account_name(self.caller),
to_address=s... | def to_dict(self, mevm):
"""
Only meant to be used with concrete Transaction objects! (after calling .concretize())
"""
return dict(type=self.sort,
from_address=self.caller,
from_name=mevm.account_name(self.caller),
to_address=s... | [
"Only",
"meant",
"to",
"be",
"used",
"with",
"concrete",
"Transaction",
"objects!",
"(",
"after",
"calling",
".",
"concretize",
"()",
")"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L98-L109 | [
"def",
"to_dict",
"(",
"self",
",",
"mevm",
")",
":",
"return",
"dict",
"(",
"type",
"=",
"self",
".",
"sort",
",",
"from_address",
"=",
"self",
".",
"caller",
",",
"from_name",
"=",
"mevm",
".",
"account_name",
"(",
"self",
".",
"caller",
")",
",",
... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | Transaction.dump | Concretize and write a human readable version of the transaction into the stream. Used during testcase
generation.
:param stream: Output stream to write to. Typically a file.
:param manticore.ethereum.State state: state that the tx exists in
:param manticore.ethereum.ManticoreEVM mevm: ... | manticore/platforms/evm.py | def dump(self, stream, state, mevm, conc_tx=None):
"""
Concretize and write a human readable version of the transaction into the stream. Used during testcase
generation.
:param stream: Output stream to write to. Typically a file.
:param manticore.ethereum.State state: state that... | def dump(self, stream, state, mevm, conc_tx=None):
"""
Concretize and write a human readable version of the transaction into the stream. Used during testcase
generation.
:param stream: Output stream to write to. Typically a file.
:param manticore.ethereum.State state: state that... | [
"Concretize",
"and",
"write",
"a",
"human",
"readable",
"version",
"of",
"the",
"transaction",
"into",
"the",
"stream",
".",
"Used",
"during",
"testcase",
"generation",
"."
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L111-L203 | [
"def",
"dump",
"(",
"self",
",",
"stream",
",",
"state",
",",
"mevm",
",",
"conc_tx",
"=",
"None",
")",
":",
"from",
".",
".",
"ethereum",
"import",
"ABI",
"# circular imports",
"from",
".",
".",
"ethereum",
".",
"manticore",
"import",
"flagged",
"is_som... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM._get_memfee | This calculates the amount of extra gas needed for accessing to
previously unused memory.
:param address: base memory offset
:param size: size of the memory access | manticore/platforms/evm.py | def _get_memfee(self, address, size=1):
"""
This calculates the amount of extra gas needed for accessing to
previously unused memory.
:param address: base memory offset
:param size: size of the memory access
"""
if not issymbolic(size) and size == 0:
... | def _get_memfee(self, address, size=1):
"""
This calculates the amount of extra gas needed for accessing to
previously unused memory.
:param address: base memory offset
:param size: size of the memory access
"""
if not issymbolic(size) and size == 0:
... | [
"This",
"calculates",
"the",
"amount",
"of",
"extra",
"gas",
"needed",
"for",
"accessing",
"to",
"previously",
"unused",
"memory",
"."
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L659-L681 | [
"def",
"_get_memfee",
"(",
"self",
",",
"address",
",",
"size",
"=",
"1",
")",
":",
"if",
"not",
"issymbolic",
"(",
"size",
")",
"and",
"size",
"==",
"0",
":",
"return",
"0",
"address",
"=",
"self",
".",
"safe_add",
"(",
"address",
",",
"size",
")"... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.read_code | Read size byte from bytecode.
If less than size bytes are available result will be pad with \x00 | manticore/platforms/evm.py | def read_code(self, address, size=1):
"""
Read size byte from bytecode.
If less than size bytes are available result will be pad with \x00
"""
assert address < len(self.bytecode)
value = self.bytecode[address:address + size]
if len(value) < size:
value... | def read_code(self, address, size=1):
"""
Read size byte from bytecode.
If less than size bytes are available result will be pad with \x00
"""
assert address < len(self.bytecode)
value = self.bytecode[address:address + size]
if len(value) < size:
value... | [
"Read",
"size",
"byte",
"from",
"bytecode",
".",
"If",
"less",
"than",
"size",
"bytes",
"are",
"available",
"result",
"will",
"be",
"pad",
"with",
"\\",
"x00"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L699-L708 | [
"def",
"read_code",
"(",
"self",
",",
"address",
",",
"size",
"=",
"1",
")",
":",
"assert",
"address",
"<",
"len",
"(",
"self",
".",
"bytecode",
")",
"value",
"=",
"self",
".",
"bytecode",
"[",
"address",
":",
"address",
"+",
"size",
"]",
"if",
"le... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.instruction | Current instruction pointed by self.pc | manticore/platforms/evm.py | def instruction(self):
"""
Current instruction pointed by self.pc
"""
# FIXME check if pc points to invalid instruction
# if self.pc >= len(self.bytecode):
# return InvalidOpcode('Code out of range')
# if self.pc in self.invalid:
# raise InvalidOpcod... | def instruction(self):
"""
Current instruction pointed by self.pc
"""
# FIXME check if pc points to invalid instruction
# if self.pc >= len(self.bytecode):
# return InvalidOpcode('Code out of range')
# if self.pc in self.invalid:
# raise InvalidOpcod... | [
"Current",
"instruction",
"pointed",
"by",
"self",
".",
"pc"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L718-L747 | [
"def",
"instruction",
"(",
"self",
")",
":",
"# FIXME check if pc points to invalid instruction",
"# if self.pc >= len(self.bytecode):",
"# return InvalidOpcode('Code out of range')",
"# if self.pc in self.invalid:",
"# raise InvalidOpcode('Opcode inside a PUSH immediate')",
"try",
":"... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM._push | Push into the stack
ITEM0
ITEM1
ITEM2
sp-> {empty} | manticore/platforms/evm.py | def _push(self, value):
"""
Push into the stack
ITEM0
ITEM1
ITEM2
sp-> {empty}
"""
assert isinstance(value, int) or isinstance(value, BitVec) and value.size == 256
if len(self.stack) >= 1024:
raise StackOverflow()
... | def _push(self, value):
"""
Push into the stack
ITEM0
ITEM1
ITEM2
sp-> {empty}
"""
assert isinstance(value, int) or isinstance(value, BitVec) and value.size == 256
if len(self.stack) >= 1024:
raise StackOverflow()
... | [
"Push",
"into",
"the",
"stack"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L751-L770 | [
"def",
"_push",
"(",
"self",
",",
"value",
")",
":",
"assert",
"isinstance",
"(",
"value",
",",
"int",
")",
"or",
"isinstance",
"(",
"value",
",",
"BitVec",
")",
"and",
"value",
".",
"size",
"==",
"256",
"if",
"len",
"(",
"self",
".",
"stack",
")",... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM._top | Read a value from the top of the stack without removing it | manticore/platforms/evm.py | def _top(self, n=0):
"""Read a value from the top of the stack without removing it"""
if len(self.stack) - n < 0:
raise StackUnderflow()
return self.stack[n - 1] | def _top(self, n=0):
"""Read a value from the top of the stack without removing it"""
if len(self.stack) - n < 0:
raise StackUnderflow()
return self.stack[n - 1] | [
"Read",
"a",
"value",
"from",
"the",
"top",
"of",
"the",
"stack",
"without",
"removing",
"it"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L772-L776 | [
"def",
"_top",
"(",
"self",
",",
"n",
"=",
"0",
")",
":",
"if",
"len",
"(",
"self",
".",
"stack",
")",
"-",
"n",
"<",
"0",
":",
"raise",
"StackUnderflow",
"(",
")",
"return",
"self",
".",
"stack",
"[",
"n",
"-",
"1",
"]"
] | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM._checkpoint | Save and/or get a state checkpoint previous to current instruction | manticore/platforms/evm.py | def _checkpoint(self):
"""Save and/or get a state checkpoint previous to current instruction"""
#Fixme[felipe] add a with self.disabled_events context mangr to Eventful
if self._checkpoint_data is None:
if not self._published_pre_instruction_events:
self._published_pr... | def _checkpoint(self):
"""Save and/or get a state checkpoint previous to current instruction"""
#Fixme[felipe] add a with self.disabled_events context mangr to Eventful
if self._checkpoint_data is None:
if not self._published_pre_instruction_events:
self._published_pr... | [
"Save",
"and",
"/",
"or",
"get",
"a",
"state",
"checkpoint",
"previous",
"to",
"current",
"instruction"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L919-L938 | [
"def",
"_checkpoint",
"(",
"self",
")",
":",
"#Fixme[felipe] add a with self.disabled_events context mangr to Eventful",
"if",
"self",
".",
"_checkpoint_data",
"is",
"None",
":",
"if",
"not",
"self",
".",
"_published_pre_instruction_events",
":",
"self",
".",
"_published_... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM._rollback | Revert the stack, gas, pc and memory allocation so it looks like before executing the instruction | manticore/platforms/evm.py | def _rollback(self):
"""Revert the stack, gas, pc and memory allocation so it looks like before executing the instruction"""
last_pc, last_gas, last_instruction, last_arguments, fee, allocated = self._checkpoint_data
self._push_arguments(last_arguments)
self._gas = last_gas
self.... | def _rollback(self):
"""Revert the stack, gas, pc and memory allocation so it looks like before executing the instruction"""
last_pc, last_gas, last_instruction, last_arguments, fee, allocated = self._checkpoint_data
self._push_arguments(last_arguments)
self._gas = last_gas
self.... | [
"Revert",
"the",
"stack",
"gas",
"pc",
"and",
"memory",
"allocation",
"so",
"it",
"looks",
"like",
"before",
"executing",
"the",
"instruction"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L940-L947 | [
"def",
"_rollback",
"(",
"self",
")",
":",
"last_pc",
",",
"last_gas",
",",
"last_instruction",
",",
"last_arguments",
",",
"fee",
",",
"allocated",
"=",
"self",
".",
"_checkpoint_data",
"self",
".",
"_push_arguments",
"(",
"last_arguments",
")",
"self",
".",
... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM._check_jmpdest | If the previous instruction was a JUMP/JUMPI and the conditional was
True, this checks that the current instruction must be a JUMPDEST.
Here, if symbolic, the conditional `self._check_jumpdest` would be
already constrained to a single concrete value. | manticore/platforms/evm.py | def _check_jmpdest(self):
"""
If the previous instruction was a JUMP/JUMPI and the conditional was
True, this checks that the current instruction must be a JUMPDEST.
Here, if symbolic, the conditional `self._check_jumpdest` would be
already constrained to a single concrete value... | def _check_jmpdest(self):
"""
If the previous instruction was a JUMP/JUMPI and the conditional was
True, this checks that the current instruction must be a JUMPDEST.
Here, if symbolic, the conditional `self._check_jumpdest` would be
already constrained to a single concrete value... | [
"If",
"the",
"previous",
"instruction",
"was",
"a",
"JUMP",
"/",
"JUMPI",
"and",
"the",
"conditional",
"was",
"True",
"this",
"checks",
"that",
"the",
"current",
"instruction",
"must",
"be",
"a",
"JUMPDEST",
"."
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L958-L979 | [
"def",
"_check_jmpdest",
"(",
"self",
")",
":",
"should_check_jumpdest",
"=",
"self",
".",
"_check_jumpdest",
"if",
"issymbolic",
"(",
"should_check_jumpdest",
")",
":",
"should_check_jumpdest_solutions",
"=",
"solver",
".",
"get_all_values",
"(",
"self",
".",
"cons... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM._store | Stores value in memory as a big endian | manticore/platforms/evm.py | def _store(self, offset, value, size=1):
"""Stores value in memory as a big endian"""
self.memory.write_BE(offset, value, size)
for i in range(size):
self._publish('did_evm_write_memory', offset + i, Operators.EXTRACT(value, (size - i - 1) * 8, 8)) | def _store(self, offset, value, size=1):
"""Stores value in memory as a big endian"""
self.memory.write_BE(offset, value, size)
for i in range(size):
self._publish('did_evm_write_memory', offset + i, Operators.EXTRACT(value, (size - i - 1) * 8, 8)) | [
"Stores",
"value",
"in",
"memory",
"as",
"a",
"big",
"endian"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1101-L1105 | [
"def",
"_store",
"(",
"self",
",",
"offset",
",",
"value",
",",
"size",
"=",
"1",
")",
":",
"self",
".",
"memory",
".",
"write_BE",
"(",
"offset",
",",
"value",
",",
"size",
")",
"for",
"i",
"in",
"range",
"(",
"size",
")",
":",
"self",
".",
"_... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.DIV | Integer division operation | manticore/platforms/evm.py | def DIV(self, a, b):
"""Integer division operation"""
try:
result = Operators.UDIV(a, b)
except ZeroDivisionError:
result = 0
return Operators.ITEBV(256, b == 0, 0, result) | def DIV(self, a, b):
"""Integer division operation"""
try:
result = Operators.UDIV(a, b)
except ZeroDivisionError:
result = 0
return Operators.ITEBV(256, b == 0, 0, result) | [
"Integer",
"division",
"operation"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1146-L1152 | [
"def",
"DIV",
"(",
"self",
",",
"a",
",",
"b",
")",
":",
"try",
":",
"result",
"=",
"Operators",
".",
"UDIV",
"(",
"a",
",",
"b",
")",
"except",
"ZeroDivisionError",
":",
"result",
"=",
"0",
"return",
"Operators",
".",
"ITEBV",
"(",
"256",
",",
"... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.SDIV | Signed integer division operation (truncated) | manticore/platforms/evm.py | def SDIV(self, a, b):
"""Signed integer division operation (truncated)"""
s0, s1 = to_signed(a), to_signed(b)
try:
result = (Operators.ABS(s0) // Operators.ABS(s1) * Operators.ITEBV(256, (s0 < 0) != (s1 < 0), -1, 1))
except ZeroDivisionError:
result = 0
re... | def SDIV(self, a, b):
"""Signed integer division operation (truncated)"""
s0, s1 = to_signed(a), to_signed(b)
try:
result = (Operators.ABS(s0) // Operators.ABS(s1) * Operators.ITEBV(256, (s0 < 0) != (s1 < 0), -1, 1))
except ZeroDivisionError:
result = 0
re... | [
"Signed",
"integer",
"division",
"operation",
"(",
"truncated",
")"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1154-L1164 | [
"def",
"SDIV",
"(",
"self",
",",
"a",
",",
"b",
")",
":",
"s0",
",",
"s1",
"=",
"to_signed",
"(",
"a",
")",
",",
"to_signed",
"(",
"b",
")",
"try",
":",
"result",
"=",
"(",
"Operators",
".",
"ABS",
"(",
"s0",
")",
"//",
"Operators",
".",
"ABS... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.MOD | Modulo remainder operation | manticore/platforms/evm.py | def MOD(self, a, b):
"""Modulo remainder operation"""
try:
result = Operators.ITEBV(256, b == 0, 0, a % b)
except ZeroDivisionError:
result = 0
return result | def MOD(self, a, b):
"""Modulo remainder operation"""
try:
result = Operators.ITEBV(256, b == 0, 0, a % b)
except ZeroDivisionError:
result = 0
return result | [
"Modulo",
"remainder",
"operation"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1166-L1172 | [
"def",
"MOD",
"(",
"self",
",",
"a",
",",
"b",
")",
":",
"try",
":",
"result",
"=",
"Operators",
".",
"ITEBV",
"(",
"256",
",",
"b",
"==",
"0",
",",
"0",
",",
"a",
"%",
"b",
")",
"except",
"ZeroDivisionError",
":",
"result",
"=",
"0",
"return",... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.SMOD | Signed modulo remainder operation | manticore/platforms/evm.py | def SMOD(self, a, b):
"""Signed modulo remainder operation"""
s0, s1 = to_signed(a), to_signed(b)
sign = Operators.ITEBV(256, s0 < 0, -1, 1)
try:
result = (Operators.ABS(s0) % Operators.ABS(s1)) * sign
except ZeroDivisionError:
result = 0
return O... | def SMOD(self, a, b):
"""Signed modulo remainder operation"""
s0, s1 = to_signed(a), to_signed(b)
sign = Operators.ITEBV(256, s0 < 0, -1, 1)
try:
result = (Operators.ABS(s0) % Operators.ABS(s1)) * sign
except ZeroDivisionError:
result = 0
return O... | [
"Signed",
"modulo",
"remainder",
"operation"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1174-L1183 | [
"def",
"SMOD",
"(",
"self",
",",
"a",
",",
"b",
")",
":",
"s0",
",",
"s1",
"=",
"to_signed",
"(",
"a",
")",
",",
"to_signed",
"(",
"b",
")",
"sign",
"=",
"Operators",
".",
"ITEBV",
"(",
"256",
",",
"s0",
"<",
"0",
",",
"-",
"1",
",",
"1",
... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.ADDMOD | Modulo addition operation | manticore/platforms/evm.py | def ADDMOD(self, a, b, c):
"""Modulo addition operation"""
try:
result = Operators.ITEBV(256, c == 0, 0, (a + b) % c)
except ZeroDivisionError:
result = 0
return result | def ADDMOD(self, a, b, c):
"""Modulo addition operation"""
try:
result = Operators.ITEBV(256, c == 0, 0, (a + b) % c)
except ZeroDivisionError:
result = 0
return result | [
"Modulo",
"addition",
"operation"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1185-L1191 | [
"def",
"ADDMOD",
"(",
"self",
",",
"a",
",",
"b",
",",
"c",
")",
":",
"try",
":",
"result",
"=",
"Operators",
".",
"ITEBV",
"(",
"256",
",",
"c",
"==",
"0",
",",
"0",
",",
"(",
"a",
"+",
"b",
")",
"%",
"c",
")",
"except",
"ZeroDivisionError",... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.EXP_gas | Calculate extra gas fee | manticore/platforms/evm.py | def EXP_gas(self, base, exponent):
"""Calculate extra gas fee"""
EXP_SUPPLEMENTAL_GAS = 10 # cost of EXP exponent per byte
def nbytes(e):
result = 0
for i in range(32):
result = Operators.ITEBV(512, Operators.EXTRACT(e, i * 8, 8) != 0, i + 1, result)
... | def EXP_gas(self, base, exponent):
"""Calculate extra gas fee"""
EXP_SUPPLEMENTAL_GAS = 10 # cost of EXP exponent per byte
def nbytes(e):
result = 0
for i in range(32):
result = Operators.ITEBV(512, Operators.EXTRACT(e, i * 8, 8) != 0, i + 1, result)
... | [
"Calculate",
"extra",
"gas",
"fee"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1201-L1210 | [
"def",
"EXP_gas",
"(",
"self",
",",
"base",
",",
"exponent",
")",
":",
"EXP_SUPPLEMENTAL_GAS",
"=",
"10",
"# cost of EXP exponent per byte",
"def",
"nbytes",
"(",
"e",
")",
":",
"result",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"32",
")",
":",
"result"... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.SIGNEXTEND | Extend length of two's complement signed integer | manticore/platforms/evm.py | def SIGNEXTEND(self, size, value):
"""Extend length of two's complement signed integer"""
# FIXME maybe use Operators.SEXTEND
testbit = Operators.ITEBV(256, size <= 31, size * 8 + 7, 257)
result1 = (value | (TT256 - (1 << testbit)))
result2 = (value & ((1 << testbit) - 1))
... | def SIGNEXTEND(self, size, value):
"""Extend length of two's complement signed integer"""
# FIXME maybe use Operators.SEXTEND
testbit = Operators.ITEBV(256, size <= 31, size * 8 + 7, 257)
result1 = (value | (TT256 - (1 << testbit)))
result2 = (value & ((1 << testbit) - 1))
... | [
"Extend",
"length",
"of",
"two",
"s",
"complement",
"signed",
"integer"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1220-L1227 | [
"def",
"SIGNEXTEND",
"(",
"self",
",",
"size",
",",
"value",
")",
":",
"# FIXME maybe use Operators.SEXTEND",
"testbit",
"=",
"Operators",
".",
"ITEBV",
"(",
"256",
",",
"size",
"<=",
"31",
",",
"size",
"*",
"8",
"+",
"7",
",",
"257",
")",
"result1",
"... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.LT | Less-than comparison | manticore/platforms/evm.py | def LT(self, a, b):
"""Less-than comparison"""
return Operators.ITEBV(256, Operators.ULT(a, b), 1, 0) | def LT(self, a, b):
"""Less-than comparison"""
return Operators.ITEBV(256, Operators.ULT(a, b), 1, 0) | [
"Less",
"-",
"than",
"comparison"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1231-L1233 | [
"def",
"LT",
"(",
"self",
",",
"a",
",",
"b",
")",
":",
"return",
"Operators",
".",
"ITEBV",
"(",
"256",
",",
"Operators",
".",
"ULT",
"(",
"a",
",",
"b",
")",
",",
"1",
",",
"0",
")"
] | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.GT | Greater-than comparison | manticore/platforms/evm.py | def GT(self, a, b):
"""Greater-than comparison"""
return Operators.ITEBV(256, Operators.UGT(a, b), 1, 0) | def GT(self, a, b):
"""Greater-than comparison"""
return Operators.ITEBV(256, Operators.UGT(a, b), 1, 0) | [
"Greater",
"-",
"than",
"comparison"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1235-L1237 | [
"def",
"GT",
"(",
"self",
",",
"a",
",",
"b",
")",
":",
"return",
"Operators",
".",
"ITEBV",
"(",
"256",
",",
"Operators",
".",
"UGT",
"(",
"a",
",",
"b",
")",
",",
"1",
",",
"0",
")"
] | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.SGT | Signed greater-than comparison | manticore/platforms/evm.py | def SGT(self, a, b):
"""Signed greater-than comparison"""
# http://gavwood.com/paper.pdf
s0, s1 = to_signed(a), to_signed(b)
return Operators.ITEBV(256, s0 > s1, 1, 0) | def SGT(self, a, b):
"""Signed greater-than comparison"""
# http://gavwood.com/paper.pdf
s0, s1 = to_signed(a), to_signed(b)
return Operators.ITEBV(256, s0 > s1, 1, 0) | [
"Signed",
"greater",
"-",
"than",
"comparison"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1245-L1249 | [
"def",
"SGT",
"(",
"self",
",",
"a",
",",
"b",
")",
":",
"# http://gavwood.com/paper.pdf",
"s0",
",",
"s1",
"=",
"to_signed",
"(",
"a",
")",
",",
"to_signed",
"(",
"b",
")",
"return",
"Operators",
".",
"ITEBV",
"(",
"256",
",",
"s0",
">",
"s1",
","... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.BYTE | Retrieve single byte from word | manticore/platforms/evm.py | def BYTE(self, offset, value):
"""Retrieve single byte from word"""
offset = Operators.ITEBV(256, offset < 32, (31 - offset) * 8, 256)
return Operators.ZEXTEND(Operators.EXTRACT(value, offset, 8), 256) | def BYTE(self, offset, value):
"""Retrieve single byte from word"""
offset = Operators.ITEBV(256, offset < 32, (31 - offset) * 8, 256)
return Operators.ZEXTEND(Operators.EXTRACT(value, offset, 8), 256) | [
"Retrieve",
"single",
"byte",
"from",
"word"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1275-L1278 | [
"def",
"BYTE",
"(",
"self",
",",
"offset",
",",
"value",
")",
":",
"offset",
"=",
"Operators",
".",
"ITEBV",
"(",
"256",
",",
"offset",
"<",
"32",
",",
"(",
"31",
"-",
"offset",
")",
"*",
"8",
",",
"256",
")",
"return",
"Operators",
".",
"ZEXTEND... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.SHA3 | Compute Keccak-256 hash | manticore/platforms/evm.py | def SHA3(self, start, size):
"""Compute Keccak-256 hash"""
# read memory from start to end
# http://gavwood.com/paper.pdf
data = self.try_simplify_to_constant(self.read_buffer(start, size))
if issymbolic(data):
known_sha3 = {}
# Broadcast the signal
... | def SHA3(self, start, size):
"""Compute Keccak-256 hash"""
# read memory from start to end
# http://gavwood.com/paper.pdf
data = self.try_simplify_to_constant(self.read_buffer(start, size))
if issymbolic(data):
known_sha3 = {}
# Broadcast the signal
... | [
"Compute",
"Keccak",
"-",
"256",
"hash"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1302-L1326 | [
"def",
"SHA3",
"(",
"self",
",",
"start",
",",
"size",
")",
":",
"# read memory from start to end",
"# http://gavwood.com/paper.pdf",
"data",
"=",
"self",
".",
"try_simplify_to_constant",
"(",
"self",
".",
"read_buffer",
"(",
"start",
",",
"size",
")",
")",
"if"... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.CALLDATALOAD | Get input data of current environment | manticore/platforms/evm.py | def CALLDATALOAD(self, offset):
"""Get input data of current environment"""
if issymbolic(offset):
if solver.can_be_true(self._constraints, offset == self._used_calldata_size):
self.constraints.add(offset == self._used_calldata_size)
raise ConcretizeArgument(1, p... | def CALLDATALOAD(self, offset):
"""Get input data of current environment"""
if issymbolic(offset):
if solver.can_be_true(self._constraints, offset == self._used_calldata_size):
self.constraints.add(offset == self._used_calldata_size)
raise ConcretizeArgument(1, p... | [
"Get",
"input",
"data",
"of",
"current",
"environment"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1353-L1374 | [
"def",
"CALLDATALOAD",
"(",
"self",
",",
"offset",
")",
":",
"if",
"issymbolic",
"(",
"offset",
")",
":",
"if",
"solver",
".",
"can_be_true",
"(",
"self",
".",
"_constraints",
",",
"offset",
"==",
"self",
".",
"_used_calldata_size",
")",
":",
"self",
"."... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.CALLDATACOPY | Copy input data in current environment to memory | manticore/platforms/evm.py | def CALLDATACOPY(self, mem_offset, data_offset, size):
"""Copy input data in current environment to memory"""
if issymbolic(size):
if solver.can_be_true(self._constraints, size <= len(self.data) + 32):
self.constraints.add(size <= len(self.data) + 32)
raise Concr... | def CALLDATACOPY(self, mem_offset, data_offset, size):
"""Copy input data in current environment to memory"""
if issymbolic(size):
if solver.can_be_true(self._constraints, size <= len(self.data) + 32):
self.constraints.add(size <= len(self.data) + 32)
raise Concr... | [
"Copy",
"input",
"data",
"in",
"current",
"environment",
"to",
"memory"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1392-L1414 | [
"def",
"CALLDATACOPY",
"(",
"self",
",",
"mem_offset",
",",
"data_offset",
",",
"size",
")",
":",
"if",
"issymbolic",
"(",
"size",
")",
":",
"if",
"solver",
".",
"can_be_true",
"(",
"self",
".",
"_constraints",
",",
"size",
"<=",
"len",
"(",
"self",
".... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.CODECOPY | Copy code running in current environment to memory | manticore/platforms/evm.py | def CODECOPY(self, mem_offset, code_offset, size):
"""Copy code running in current environment to memory"""
self._allocate(mem_offset, size)
GCOPY = 3 # cost to copy one 32 byte word
copyfee = self.safe_mul(GCOPY, Operators.UDIV(self.safe_add(size, 31), 32))
self._co... | def CODECOPY(self, mem_offset, code_offset, size):
"""Copy code running in current environment to memory"""
self._allocate(mem_offset, size)
GCOPY = 3 # cost to copy one 32 byte word
copyfee = self.safe_mul(GCOPY, Operators.UDIV(self.safe_add(size, 31), 32))
self._co... | [
"Copy",
"code",
"running",
"in",
"current",
"environment",
"to",
"memory"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1424-L1454 | [
"def",
"CODECOPY",
"(",
"self",
",",
"mem_offset",
",",
"code_offset",
",",
"size",
")",
":",
"self",
".",
"_allocate",
"(",
"mem_offset",
",",
"size",
")",
"GCOPY",
"=",
"3",
"# cost to copy one 32 byte word",
"copyfee",
"=",
"self",
".",
"safe_mul",
"(",
... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.EXTCODECOPY | Copy an account's code to memory | manticore/platforms/evm.py | def EXTCODECOPY(self, account, address, offset, size):
"""Copy an account's code to memory"""
extbytecode = self.world.get_code(account)
self._allocate(address + size)
for i in range(size):
if offset + i < len(extbytecode):
self._store(address + i, extbytecod... | def EXTCODECOPY(self, account, address, offset, size):
"""Copy an account's code to memory"""
extbytecode = self.world.get_code(account)
self._allocate(address + size)
for i in range(size):
if offset + i < len(extbytecode):
self._store(address + i, extbytecod... | [
"Copy",
"an",
"account",
"s",
"code",
"to",
"memory"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1472-L1481 | [
"def",
"EXTCODECOPY",
"(",
"self",
",",
"account",
",",
"address",
",",
"offset",
",",
"size",
")",
":",
"extbytecode",
"=",
"self",
".",
"world",
".",
"get_code",
"(",
"account",
")",
"self",
".",
"_allocate",
"(",
"address",
"+",
"size",
")",
"for",
... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.MLOAD | Load word from memory | manticore/platforms/evm.py | def MLOAD(self, address):
"""Load word from memory"""
self._allocate(address, 32)
value = self._load(address, 32)
return value | def MLOAD(self, address):
"""Load word from memory"""
self._allocate(address, 32)
value = self._load(address, 32)
return value | [
"Load",
"word",
"from",
"memory"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1536-L1540 | [
"def",
"MLOAD",
"(",
"self",
",",
"address",
")",
":",
"self",
".",
"_allocate",
"(",
"address",
",",
"32",
")",
"value",
"=",
"self",
".",
"_load",
"(",
"address",
",",
"32",
")",
"return",
"value"
] | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.MSTORE | Save word to memory | manticore/platforms/evm.py | def MSTORE(self, address, value):
"""Save word to memory"""
if istainted(self.pc):
for taint in get_taints(self.pc):
value = taint_with(value, taint)
self._allocate(address, 32)
self._store(address, value, 32) | def MSTORE(self, address, value):
"""Save word to memory"""
if istainted(self.pc):
for taint in get_taints(self.pc):
value = taint_with(value, taint)
self._allocate(address, 32)
self._store(address, value, 32) | [
"Save",
"word",
"to",
"memory"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1545-L1551 | [
"def",
"MSTORE",
"(",
"self",
",",
"address",
",",
"value",
")",
":",
"if",
"istainted",
"(",
"self",
".",
"pc",
")",
":",
"for",
"taint",
"in",
"get_taints",
"(",
"self",
".",
"pc",
")",
":",
"value",
"=",
"taint_with",
"(",
"value",
",",
"taint",... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.MSTORE8 | Save byte to memory | manticore/platforms/evm.py | def MSTORE8(self, address, value):
"""Save byte to memory"""
if istainted(self.pc):
for taint in get_taints(self.pc):
value = taint_with(value, taint)
self._allocate(address, 1)
self._store(address, Operators.EXTRACT(value, 0, 8), 1) | def MSTORE8(self, address, value):
"""Save byte to memory"""
if istainted(self.pc):
for taint in get_taints(self.pc):
value = taint_with(value, taint)
self._allocate(address, 1)
self._store(address, Operators.EXTRACT(value, 0, 8), 1) | [
"Save",
"byte",
"to",
"memory"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1556-L1562 | [
"def",
"MSTORE8",
"(",
"self",
",",
"address",
",",
"value",
")",
":",
"if",
"istainted",
"(",
"self",
".",
"pc",
")",
":",
"for",
"taint",
"in",
"get_taints",
"(",
"self",
".",
"pc",
")",
":",
"value",
"=",
"taint_with",
"(",
"value",
",",
"taint"... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.SLOAD | Load word from storage | manticore/platforms/evm.py | def SLOAD(self, offset):
"""Load word from storage"""
storage_address = self.address
self._publish('will_evm_read_storage', storage_address, offset)
value = self.world.get_storage_data(storage_address, offset)
self._publish('did_evm_read_storage', storage_address, offset, value)
... | def SLOAD(self, offset):
"""Load word from storage"""
storage_address = self.address
self._publish('will_evm_read_storage', storage_address, offset)
value = self.world.get_storage_data(storage_address, offset)
self._publish('did_evm_read_storage', storage_address, offset, value)
... | [
"Load",
"word",
"from",
"storage"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1564-L1570 | [
"def",
"SLOAD",
"(",
"self",
",",
"offset",
")",
":",
"storage_address",
"=",
"self",
".",
"address",
"self",
".",
"_publish",
"(",
"'will_evm_read_storage'",
",",
"storage_address",
",",
"offset",
")",
"value",
"=",
"self",
".",
"world",
".",
"get_storage_d... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.SSTORE | Save word to storage | manticore/platforms/evm.py | def SSTORE(self, offset, value):
"""Save word to storage"""
storage_address = self.address
self._publish('will_evm_write_storage', storage_address, offset, value)
#refund = Operators.ITEBV(256,
# previous_value != 0,
# Opera... | def SSTORE(self, offset, value):
"""Save word to storage"""
storage_address = self.address
self._publish('will_evm_write_storage', storage_address, offset, value)
#refund = Operators.ITEBV(256,
# previous_value != 0,
# Opera... | [
"Save",
"word",
"to",
"storage"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1588-L1601 | [
"def",
"SSTORE",
"(",
"self",
",",
"offset",
",",
"value",
")",
":",
"storage_address",
"=",
"self",
".",
"address",
"self",
".",
"_publish",
"(",
"'will_evm_write_storage'",
",",
"storage_address",
",",
"offset",
",",
"value",
")",
"#refund = Operators.ITEBV(25... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.JUMPI | Conditionally alter the program counter | manticore/platforms/evm.py | def JUMPI(self, dest, cond):
"""Conditionally alter the program counter"""
self.pc = Operators.ITEBV(256, cond != 0, dest, self.pc + self.instruction.size)
#This set ups a check for JMPDEST in the next instruction if cond != 0
self._set_check_jmpdest(cond != 0) | def JUMPI(self, dest, cond):
"""Conditionally alter the program counter"""
self.pc = Operators.ITEBV(256, cond != 0, dest, self.pc + self.instruction.size)
#This set ups a check for JMPDEST in the next instruction if cond != 0
self._set_check_jmpdest(cond != 0) | [
"Conditionally",
"alter",
"the",
"program",
"counter"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1609-L1613 | [
"def",
"JUMPI",
"(",
"self",
",",
"dest",
",",
"cond",
")",
":",
"self",
".",
"pc",
"=",
"Operators",
".",
"ITEBV",
"(",
"256",
",",
"cond",
"!=",
"0",
",",
"dest",
",",
"self",
".",
"pc",
"+",
"self",
".",
"instruction",
".",
"size",
")",
"#Th... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.SWAP | Exchange 1st and 2nd stack items | manticore/platforms/evm.py | def SWAP(self, *operands):
"""Exchange 1st and 2nd stack items"""
a = operands[0]
b = operands[-1]
return (b,) + operands[1:-1] + (a,) | def SWAP(self, *operands):
"""Exchange 1st and 2nd stack items"""
a = operands[0]
b = operands[-1]
return (b,) + operands[1:-1] + (a,) | [
"Exchange",
"1st",
"and",
"2nd",
"stack",
"items"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1645-L1649 | [
"def",
"SWAP",
"(",
"self",
",",
"*",
"operands",
")",
":",
"a",
"=",
"operands",
"[",
"0",
"]",
"b",
"=",
"operands",
"[",
"-",
"1",
"]",
"return",
"(",
"b",
",",
")",
"+",
"operands",
"[",
"1",
":",
"-",
"1",
"]",
"+",
"(",
"a",
",",
")... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.CREATE | Create a new account with associated code | manticore/platforms/evm.py | def CREATE(self, value, offset, size):
"""Create a new account with associated code"""
address = self.world.create_account(address=EVMWorld.calculate_new_address(sender=self.address, nonce=self.world.get_nonce(self.address)))
self.world.start_transaction('CREATE',
... | def CREATE(self, value, offset, size):
"""Create a new account with associated code"""
address = self.world.create_account(address=EVMWorld.calculate_new_address(sender=self.address, nonce=self.world.get_nonce(self.address)))
self.world.start_transaction('CREATE',
... | [
"Create",
"a",
"new",
"account",
"with",
"associated",
"code"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1669-L1679 | [
"def",
"CREATE",
"(",
"self",
",",
"value",
",",
"offset",
",",
"size",
")",
":",
"address",
"=",
"self",
".",
"world",
".",
"create_account",
"(",
"address",
"=",
"EVMWorld",
".",
"calculate_new_address",
"(",
"sender",
"=",
"self",
".",
"address",
",",... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.CREATE | Create a new account with associated code | manticore/platforms/evm.py | def CREATE(self, value, offset, size):
"""Create a new account with associated code"""
tx = self.world.last_transaction # At this point last and current tx are the same.
address = tx.address
if tx.result == 'RETURN':
self.world.set_code(tx.address, tx.return_data)
el... | def CREATE(self, value, offset, size):
"""Create a new account with associated code"""
tx = self.world.last_transaction # At this point last and current tx are the same.
address = tx.address
if tx.result == 'RETURN':
self.world.set_code(tx.address, tx.return_data)
el... | [
"Create",
"a",
"new",
"account",
"with",
"associated",
"code"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1682-L1691 | [
"def",
"CREATE",
"(",
"self",
",",
"value",
",",
"offset",
",",
"size",
")",
":",
"tx",
"=",
"self",
".",
"world",
".",
"last_transaction",
"# At this point last and current tx are the same.",
"address",
"=",
"tx",
".",
"address",
"if",
"tx",
".",
"result",
... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.CALLCODE | Message-call into this account with alternative account's code | manticore/platforms/evm.py | def CALLCODE(self, gas, _ignored_, value, in_offset, in_size, out_offset, out_size):
"""Message-call into this account with alternative account's code"""
self.world.start_transaction('CALLCODE',
address=self.address,
data=self.rea... | def CALLCODE(self, gas, _ignored_, value, in_offset, in_size, out_offset, out_size):
"""Message-call into this account with alternative account's code"""
self.world.start_transaction('CALLCODE',
address=self.address,
data=self.rea... | [
"Message",
"-",
"call",
"into",
"this",
"account",
"with",
"alternative",
"account",
"s",
"code"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1723-L1731 | [
"def",
"CALLCODE",
"(",
"self",
",",
"gas",
",",
"_ignored_",
",",
"value",
",",
"in_offset",
",",
"in_size",
",",
"out_offset",
",",
"out_size",
")",
":",
"self",
".",
"world",
".",
"start_transaction",
"(",
"'CALLCODE'",
",",
"address",
"=",
"self",
".... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.RETURN | Halt execution returning output data | manticore/platforms/evm.py | def RETURN(self, offset, size):
"""Halt execution returning output data"""
data = self.read_buffer(offset, size)
raise EndTx('RETURN', data) | def RETURN(self, offset, size):
"""Halt execution returning output data"""
data = self.read_buffer(offset, size)
raise EndTx('RETURN', data) | [
"Halt",
"execution",
"returning",
"output",
"data"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1747-L1750 | [
"def",
"RETURN",
"(",
"self",
",",
"offset",
",",
"size",
")",
":",
"data",
"=",
"self",
".",
"read_buffer",
"(",
"offset",
",",
"size",
")",
"raise",
"EndTx",
"(",
"'RETURN'",
",",
"data",
")"
] | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVM.SELFDESTRUCT | Halt execution and register account for later deletion | manticore/platforms/evm.py | def SELFDESTRUCT(self, recipient):
"""Halt execution and register account for later deletion"""
#This may create a user account
recipient = Operators.EXTRACT(recipient, 0, 160)
address = self.address
#FIXME for on the known addresses
if issymbolic(recipient):
... | def SELFDESTRUCT(self, recipient):
"""Halt execution and register account for later deletion"""
#This may create a user account
recipient = Operators.EXTRACT(recipient, 0, 160)
address = self.address
#FIXME for on the known addresses
if issymbolic(recipient):
... | [
"Halt",
"execution",
"and",
"register",
"account",
"for",
"later",
"deletion"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L1814-L1830 | [
"def",
"SELFDESTRUCT",
"(",
"self",
",",
"recipient",
")",
":",
"#This may create a user account",
"recipient",
"=",
"Operators",
".",
"EXTRACT",
"(",
"recipient",
",",
"0",
",",
"160",
")",
"address",
"=",
"self",
".",
"address",
"#FIXME for on the known addresse... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVMWorld.human_transactions | Completed human transaction | manticore/platforms/evm.py | def human_transactions(self):
"""Completed human transaction"""
txs = []
for tx in self.transactions:
if tx.depth == 0:
txs.append(tx)
return tuple(txs) | def human_transactions(self):
"""Completed human transaction"""
txs = []
for tx in self.transactions:
if tx.depth == 0:
txs.append(tx)
return tuple(txs) | [
"Completed",
"human",
"transaction"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L2058-L2064 | [
"def",
"human_transactions",
"(",
"self",
")",
":",
"txs",
"=",
"[",
"]",
"for",
"tx",
"in",
"self",
".",
"transactions",
":",
"if",
"tx",
".",
"depth",
"==",
"0",
":",
"txs",
".",
"append",
"(",
"tx",
")",
"return",
"tuple",
"(",
"txs",
")"
] | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVMWorld.current_vm | current vm | manticore/platforms/evm.py | def current_vm(self):
"""current vm"""
try:
_, _, _, _, vm = self._callstack[-1]
return vm
except IndexError:
return None | def current_vm(self):
"""current vm"""
try:
_, _, _, _, vm = self._callstack[-1]
return vm
except IndexError:
return None | [
"current",
"vm"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L2088-L2094 | [
"def",
"current_vm",
"(",
"self",
")",
":",
"try",
":",
"_",
",",
"_",
",",
"_",
",",
"_",
",",
"vm",
"=",
"self",
".",
"_callstack",
"[",
"-",
"1",
"]",
"return",
"vm",
"except",
"IndexError",
":",
"return",
"None"
] | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVMWorld.current_transaction | current tx | manticore/platforms/evm.py | def current_transaction(self):
"""current tx"""
try:
tx, _, _, _, _ = self._callstack[-1]
if tx.result is not None:
#That tx finished. No current tx.
return None
return tx
except IndexError:
return None | def current_transaction(self):
"""current tx"""
try:
tx, _, _, _, _ = self._callstack[-1]
if tx.result is not None:
#That tx finished. No current tx.
return None
return tx
except IndexError:
return None | [
"current",
"tx"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L2097-L2106 | [
"def",
"current_transaction",
"(",
"self",
")",
":",
"try",
":",
"tx",
",",
"_",
",",
"_",
",",
"_",
",",
"_",
"=",
"self",
".",
"_callstack",
"[",
"-",
"1",
"]",
"if",
"tx",
".",
"result",
"is",
"not",
"None",
":",
"#That tx finished. No current tx.... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVMWorld.current_human_transaction | Current ongoing human transaction | manticore/platforms/evm.py | def current_human_transaction(self):
"""Current ongoing human transaction"""
try:
tx, _, _, _, _ = self._callstack[0]
if tx.result is not None:
#That tx finished. No current tx.
return None
assert tx.depth == 0
return tx
... | def current_human_transaction(self):
"""Current ongoing human transaction"""
try:
tx, _, _, _, _ = self._callstack[0]
if tx.result is not None:
#That tx finished. No current tx.
return None
assert tx.depth == 0
return tx
... | [
"Current",
"ongoing",
"human",
"transaction"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L2109-L2119 | [
"def",
"current_human_transaction",
"(",
"self",
")",
":",
"try",
":",
"tx",
",",
"_",
",",
"_",
",",
"_",
",",
"_",
"=",
"self",
".",
"_callstack",
"[",
"0",
"]",
"if",
"tx",
".",
"result",
"is",
"not",
"None",
":",
"#That tx finished. No current tx."... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVMWorld.get_storage_data | Read a value from a storage slot on the specified account
:param storage_address: an account address
:param offset: the storage slot to use.
:type offset: int or BitVec
:return: the value
:rtype: int or BitVec | manticore/platforms/evm.py | def get_storage_data(self, storage_address, offset):
"""
Read a value from a storage slot on the specified account
:param storage_address: an account address
:param offset: the storage slot to use.
:type offset: int or BitVec
:return: the value
:rtype: int or Bit... | def get_storage_data(self, storage_address, offset):
"""
Read a value from a storage slot on the specified account
:param storage_address: an account address
:param offset: the storage slot to use.
:type offset: int or BitVec
:return: the value
:rtype: int or Bit... | [
"Read",
"a",
"value",
"from",
"a",
"storage",
"slot",
"on",
"the",
"specified",
"account"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L2149-L2160 | [
"def",
"get_storage_data",
"(",
"self",
",",
"storage_address",
",",
"offset",
")",
":",
"value",
"=",
"self",
".",
"_world_state",
"[",
"storage_address",
"]",
"[",
"'storage'",
"]",
".",
"get",
"(",
"offset",
",",
"0",
")",
"return",
"simplify",
"(",
"... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVMWorld.set_storage_data | Writes a value to a storage slot in specified account
:param storage_address: an account address
:param offset: the storage slot to use.
:type offset: int or BitVec
:param value: the value to write
:type value: int or BitVec | manticore/platforms/evm.py | def set_storage_data(self, storage_address, offset, value):
"""
Writes a value to a storage slot in specified account
:param storage_address: an account address
:param offset: the storage slot to use.
:type offset: int or BitVec
:param value: the value to write
:... | def set_storage_data(self, storage_address, offset, value):
"""
Writes a value to a storage slot in specified account
:param storage_address: an account address
:param offset: the storage slot to use.
:type offset: int or BitVec
:param value: the value to write
:... | [
"Writes",
"a",
"value",
"to",
"a",
"storage",
"slot",
"in",
"specified",
"account"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L2162-L2172 | [
"def",
"set_storage_data",
"(",
"self",
",",
"storage_address",
",",
"offset",
",",
"value",
")",
":",
"self",
".",
"_world_state",
"[",
"storage_address",
"]",
"[",
"'storage'",
"]",
"[",
"offset",
"]",
"=",
"value"
] | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVMWorld.get_storage_items | Gets all items in an account storage
:param address: account address
:return: all items in account storage. items are tuple of (index, value). value can be symbolic
:rtype: list[(storage_index, storage_value)] | manticore/platforms/evm.py | def get_storage_items(self, address):
"""
Gets all items in an account storage
:param address: account address
:return: all items in account storage. items are tuple of (index, value). value can be symbolic
:rtype: list[(storage_index, storage_value)]
"""
storage... | def get_storage_items(self, address):
"""
Gets all items in an account storage
:param address: account address
:return: all items in account storage. items are tuple of (index, value). value can be symbolic
:rtype: list[(storage_index, storage_value)]
"""
storage... | [
"Gets",
"all",
"items",
"in",
"an",
"account",
"storage"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L2174-L2188 | [
"def",
"get_storage_items",
"(",
"self",
",",
"address",
")",
":",
"storage",
"=",
"self",
".",
"_world_state",
"[",
"address",
"]",
"[",
"'storage'",
"]",
"items",
"=",
"[",
"]",
"array",
"=",
"storage",
".",
"array",
"while",
"not",
"isinstance",
"(",
... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVMWorld.has_storage | True if something has been written to the storage.
Note that if a slot has been erased from the storage this function may
lose any meaning. | manticore/platforms/evm.py | def has_storage(self, address):
"""
True if something has been written to the storage.
Note that if a slot has been erased from the storage this function may
lose any meaning.
"""
storage = self._world_state[address]['storage']
array = storage.array
while ... | def has_storage(self, address):
"""
True if something has been written to the storage.
Note that if a slot has been erased from the storage this function may
lose any meaning.
"""
storage = self._world_state[address]['storage']
array = storage.array
while ... | [
"True",
"if",
"something",
"has",
"been",
"written",
"to",
"the",
"storage",
".",
"Note",
"that",
"if",
"a",
"slot",
"has",
"been",
"erased",
"from",
"the",
"storage",
"this",
"function",
"may",
"lose",
"any",
"meaning",
"."
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L2190-L2202 | [
"def",
"has_storage",
"(",
"self",
",",
"address",
")",
":",
"storage",
"=",
"self",
".",
"_world_state",
"[",
"address",
"]",
"[",
"'storage'",
"]",
"array",
"=",
"storage",
".",
"array",
"while",
"not",
"isinstance",
"(",
"array",
",",
"ArrayVariable",
... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVMWorld.block_hash | Calculates a block's hash
:param block_number: the block number for which to calculate the hash, defaulting to the most recent block
:param force_recent: if True (the default) return zero for any block that is in the future or older than 256 blocks
:return: the block hash | manticore/platforms/evm.py | def block_hash(self, block_number=None, force_recent=True):
"""
Calculates a block's hash
:param block_number: the block number for which to calculate the hash, defaulting to the most recent block
:param force_recent: if True (the default) return zero for any block that is in the future ... | def block_hash(self, block_number=None, force_recent=True):
"""
Calculates a block's hash
:param block_number: the block number for which to calculate the hash, defaulting to the most recent block
:param force_recent: if True (the default) return zero for any block that is in the future ... | [
"Calculates",
"a",
"block",
"s",
"hash",
":",
"param",
"block_number",
":",
"the",
"block",
"number",
"for",
"which",
"to",
"calculate",
"the",
"hash",
"defaulting",
"to",
"the",
"most",
"recent",
"block",
":",
"param",
"force_recent",
":",
"if",
"True",
"... | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L2302-L2324 | [
"def",
"block_hash",
"(",
"self",
",",
"block_number",
"=",
"None",
",",
"force_recent",
"=",
"True",
")",
":",
"if",
"block_number",
"is",
"None",
":",
"block_number",
"=",
"self",
".",
"block_number",
"(",
")",
"-",
"1",
"# We are not maintaining an actual -... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVMWorld.new_address | Create a fresh 160bit address | manticore/platforms/evm.py | def new_address(self, sender=None, nonce=None):
"""Create a fresh 160bit address"""
if sender is not None and nonce is None:
nonce = self.get_nonce(sender)
new_address = self.calculate_new_address(sender, nonce)
if sender is None and new_address in self:
return s... | def new_address(self, sender=None, nonce=None):
"""Create a fresh 160bit address"""
if sender is not None and nonce is None:
nonce = self.get_nonce(sender)
new_address = self.calculate_new_address(sender, nonce)
if sender is None and new_address in self:
return s... | [
"Create",
"a",
"fresh",
"160bit",
"address"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L2338-L2346 | [
"def",
"new_address",
"(",
"self",
",",
"sender",
"=",
"None",
",",
"nonce",
"=",
"None",
")",
":",
"if",
"sender",
"is",
"not",
"None",
"and",
"nonce",
"is",
"None",
":",
"nonce",
"=",
"self",
".",
"get_nonce",
"(",
"sender",
")",
"new_address",
"="... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVMWorld.create_account | Low level account creation. No transaction is done.
:param address: the address of the account, if known. If omitted, a new address will be generated as closely to the Yellow Paper as possible.
:param balance: the initial balance of the account in Wei
:param code: the runtime code of the account... | manticore/platforms/evm.py | def create_account(self, address=None, balance=0, code=None, storage=None, nonce=None):
"""
Low level account creation. No transaction is done.
:param address: the address of the account, if known. If omitted, a new address will be generated as closely to the Yellow Paper as possible.
:p... | def create_account(self, address=None, balance=0, code=None, storage=None, nonce=None):
"""
Low level account creation. No transaction is done.
:param address: the address of the account, if known. If omitted, a new address will be generated as closely to the Yellow Paper as possible.
:p... | [
"Low",
"level",
"account",
"creation",
".",
"No",
"transaction",
"is",
"done",
".",
":",
"param",
"address",
":",
"the",
"address",
"of",
"the",
"account",
"if",
"known",
".",
"If",
"omitted",
"a",
"new",
"address",
"will",
"be",
"generated",
"as",
"clos... | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L2376-L2432 | [
"def",
"create_account",
"(",
"self",
",",
"address",
"=",
"None",
",",
"balance",
"=",
"0",
",",
"code",
"=",
"None",
",",
"storage",
"=",
"None",
",",
"nonce",
"=",
"None",
")",
":",
"if",
"code",
"is",
"None",
":",
"code",
"=",
"bytes",
"(",
"... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVMWorld.create_contract | Create a contract account. Sends a transaction to initialize the contract
:param address: the address of the new account, if known. If omitted, a new address will be generated as closely to the Yellow Paper as possible.
:param balance: the initial balance of the account in Wei
:param init: the ... | manticore/platforms/evm.py | def create_contract(self, price=0, address=None, caller=None, balance=0, init=None, gas=None):
"""
Create a contract account. Sends a transaction to initialize the contract
:param address: the address of the new account, if known. If omitted, a new address will be generated as closely to the Ye... | def create_contract(self, price=0, address=None, caller=None, balance=0, init=None, gas=None):
"""
Create a contract account. Sends a transaction to initialize the contract
:param address: the address of the new account, if known. If omitted, a new address will be generated as closely to the Ye... | [
"Create",
"a",
"contract",
"account",
".",
"Sends",
"a",
"transaction",
"to",
"initialize",
"the",
"contract"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L2434-L2457 | [
"def",
"create_contract",
"(",
"self",
",",
"price",
"=",
"0",
",",
"address",
"=",
"None",
",",
"caller",
"=",
"None",
",",
"balance",
"=",
"0",
",",
"init",
"=",
"None",
",",
"gas",
"=",
"None",
")",
":",
"expected_address",
"=",
"self",
".",
"cr... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | EVMWorld.start_transaction | Initiate a transaction
:param sort: the type of transaction. CREATE or CALL or DELEGATECALL
:param address: the address of the account which owns the code that is executing.
:param price: the price of gas in the transaction that originated this execution.
:param data: the byte array that... | manticore/platforms/evm.py | def start_transaction(self, sort, address, price=None, data=None, caller=None, value=0, gas=2300):
"""
Initiate a transaction
:param sort: the type of transaction. CREATE or CALL or DELEGATECALL
:param address: the address of the account which owns the code that is executing.
:pa... | def start_transaction(self, sort, address, price=None, data=None, caller=None, value=0, gas=2300):
"""
Initiate a transaction
:param sort: the type of transaction. CREATE or CALL or DELEGATECALL
:param address: the address of the account which owns the code that is executing.
:pa... | [
"Initiate",
"a",
"transaction",
":",
"param",
"sort",
":",
"the",
"type",
"of",
"transaction",
".",
"CREATE",
"or",
"CALL",
"or",
"DELEGATECALL",
":",
"param",
"address",
":",
"the",
"address",
"of",
"the",
"account",
"which",
"owns",
"the",
"code",
"that"... | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L2463-L2476 | [
"def",
"start_transaction",
"(",
"self",
",",
"sort",
",",
"address",
",",
"price",
"=",
"None",
",",
"data",
"=",
"None",
",",
"caller",
"=",
"None",
",",
"value",
"=",
"0",
",",
"gas",
"=",
"2300",
")",
":",
"assert",
"self",
".",
"_pending_transac... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | Armv7Operand._get_expand_imm_carry | Manually compute the carry bit produced by expanding an immediate operand (see ARMExpandImm_C) | manticore/native/cpu/arm.py | def _get_expand_imm_carry(self, carryIn):
"""Manually compute the carry bit produced by expanding an immediate operand (see ARMExpandImm_C)"""
insn = struct.unpack('<I', self.cpu.instruction.bytes)[0]
unrotated = insn & Mask(8)
shift = Operators.EXTRACT(insn, 8, 4)
_, carry = sel... | def _get_expand_imm_carry(self, carryIn):
"""Manually compute the carry bit produced by expanding an immediate operand (see ARMExpandImm_C)"""
insn = struct.unpack('<I', self.cpu.instruction.bytes)[0]
unrotated = insn & Mask(8)
shift = Operators.EXTRACT(insn, 8, 4)
_, carry = sel... | [
"Manually",
"compute",
"the",
"carry",
"bit",
"produced",
"by",
"expanding",
"an",
"immediate",
"operand",
"(",
"see",
"ARMExpandImm_C",
")"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/native/cpu/arm.py#L197-L203 | [
"def",
"_get_expand_imm_carry",
"(",
"self",
",",
"carryIn",
")",
":",
"insn",
"=",
"struct",
".",
"unpack",
"(",
"'<I'",
",",
"self",
".",
"cpu",
".",
"instruction",
".",
"bytes",
")",
"[",
"0",
"]",
"unrotated",
"=",
"insn",
"&",
"Mask",
"(",
"8",
... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | Armv7RegisterFile._write_APSR | Auxiliary function - Writes flags from a full APSR (only 4 msb used) | manticore/native/cpu/arm.py | def _write_APSR(self, apsr):
"""Auxiliary function - Writes flags from a full APSR (only 4 msb used)"""
V = Operators.EXTRACT(apsr, 28, 1)
C = Operators.EXTRACT(apsr, 29, 1)
Z = Operators.EXTRACT(apsr, 30, 1)
N = Operators.EXTRACT(apsr, 31, 1)
self.write('APSR_V', V)
... | def _write_APSR(self, apsr):
"""Auxiliary function - Writes flags from a full APSR (only 4 msb used)"""
V = Operators.EXTRACT(apsr, 28, 1)
C = Operators.EXTRACT(apsr, 29, 1)
Z = Operators.EXTRACT(apsr, 30, 1)
N = Operators.EXTRACT(apsr, 31, 1)
self.write('APSR_V', V)
... | [
"Auxiliary",
"function",
"-",
"Writes",
"flags",
"from",
"a",
"full",
"APSR",
"(",
"only",
"4",
"msb",
"used",
")"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/native/cpu/arm.py#L270-L280 | [
"def",
"_write_APSR",
"(",
"self",
",",
"apsr",
")",
":",
"V",
"=",
"Operators",
".",
"EXTRACT",
"(",
"apsr",
",",
"28",
",",
"1",
")",
"C",
"=",
"Operators",
".",
"EXTRACT",
"(",
"apsr",
",",
"29",
",",
"1",
")",
"Z",
"=",
"Operators",
".",
"E... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | Armv7Cpu._swap_mode | Toggle between ARM and Thumb mode | manticore/native/cpu/arm.py | def _swap_mode(self):
"""Toggle between ARM and Thumb mode"""
assert self.mode in (cs.CS_MODE_ARM, cs.CS_MODE_THUMB)
if self.mode == cs.CS_MODE_ARM:
self.mode = cs.CS_MODE_THUMB
else:
self.mode = cs.CS_MODE_ARM | def _swap_mode(self):
"""Toggle between ARM and Thumb mode"""
assert self.mode in (cs.CS_MODE_ARM, cs.CS_MODE_THUMB)
if self.mode == cs.CS_MODE_ARM:
self.mode = cs.CS_MODE_THUMB
else:
self.mode = cs.CS_MODE_ARM | [
"Toggle",
"between",
"ARM",
"and",
"Thumb",
"mode"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/native/cpu/arm.py#L411-L417 | [
"def",
"_swap_mode",
"(",
"self",
")",
":",
"assert",
"self",
".",
"mode",
"in",
"(",
"cs",
".",
"CS_MODE_ARM",
",",
"cs",
".",
"CS_MODE_THUMB",
")",
"if",
"self",
".",
"mode",
"==",
"cs",
".",
"CS_MODE_ARM",
":",
"self",
".",
"mode",
"=",
"cs",
".... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | Armv7Cpu.set_flags | Note: For any unmodified flags, update _last_flags with the most recent
committed value. Otherwise, for example, this could happen:
overflow=0
instr1 computes overflow=1, updates _last_flags, doesn't commit
instr2 updates all flags in _last_flags except overflow (overflow re... | manticore/native/cpu/arm.py | def set_flags(self, **flags):
"""
Note: For any unmodified flags, update _last_flags with the most recent
committed value. Otherwise, for example, this could happen:
overflow=0
instr1 computes overflow=1, updates _last_flags, doesn't commit
instr2 updates all... | def set_flags(self, **flags):
"""
Note: For any unmodified flags, update _last_flags with the most recent
committed value. Otherwise, for example, this could happen:
overflow=0
instr1 computes overflow=1, updates _last_flags, doesn't commit
instr2 updates all... | [
"Note",
":",
"For",
"any",
"unmodified",
"flags",
"update",
"_last_flags",
"with",
"the",
"most",
"recent",
"committed",
"value",
".",
"Otherwise",
"for",
"example",
"this",
"could",
"happen",
":"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/native/cpu/arm.py#L423-L438 | [
"def",
"set_flags",
"(",
"self",
",",
"*",
"*",
"flags",
")",
":",
"unupdated_flags",
"=",
"self",
".",
"_last_flags",
".",
"keys",
"(",
")",
"-",
"flags",
".",
"keys",
"(",
")",
"for",
"flag",
"in",
"unupdated_flags",
":",
"flag_name",
"=",
"f'APSR_{f... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | Armv7Cpu._shift | See Shift() and Shift_C() in the ARM manual | manticore/native/cpu/arm.py | def _shift(cpu, value, _type, amount, carry):
"""See Shift() and Shift_C() in the ARM manual"""
assert(cs.arm.ARM_SFT_INVALID < _type <= cs.arm.ARM_SFT_RRX_REG)
# XXX: Capstone should set the value of an RRX shift to 1, which is
# asserted in the manual, but it sets it to 0, so we have ... | def _shift(cpu, value, _type, amount, carry):
"""See Shift() and Shift_C() in the ARM manual"""
assert(cs.arm.ARM_SFT_INVALID < _type <= cs.arm.ARM_SFT_RRX_REG)
# XXX: Capstone should set the value of an RRX shift to 1, which is
# asserted in the manual, but it sets it to 0, so we have ... | [
"See",
"Shift",
"()",
"and",
"Shift_C",
"()",
"in",
"the",
"ARM",
"manual"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/native/cpu/arm.py#L448-L481 | [
"def",
"_shift",
"(",
"cpu",
",",
"value",
",",
"_type",
",",
"amount",
",",
"carry",
")",
":",
"assert",
"(",
"cs",
".",
"arm",
".",
"ARM_SFT_INVALID",
"<",
"_type",
"<=",
"cs",
".",
"arm",
".",
"ARM_SFT_RRX_REG",
")",
"# XXX: Capstone should set the valu... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | Armv7Cpu.MOV | Implement the MOV{S} instruction.
Note: If src operand is PC, temporarily release our logical PC
view and conform to the spec, which dictates PC = curr instr + 8
:param Armv7Operand dest: The destination operand; register.
:param Armv7Operand src: The source operand; register or immedi... | manticore/native/cpu/arm.py | def MOV(cpu, dest, src):
"""
Implement the MOV{S} instruction.
Note: If src operand is PC, temporarily release our logical PC
view and conform to the spec, which dictates PC = curr instr + 8
:param Armv7Operand dest: The destination operand; register.
:param Armv7Operan... | def MOV(cpu, dest, src):
"""
Implement the MOV{S} instruction.
Note: If src operand is PC, temporarily release our logical PC
view and conform to the spec, which dictates PC = curr instr + 8
:param Armv7Operand dest: The destination operand; register.
:param Armv7Operan... | [
"Implement",
"the",
"MOV",
"{",
"S",
"}",
"instruction",
"."
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/native/cpu/arm.py#L640-L658 | [
"def",
"MOV",
"(",
"cpu",
",",
"dest",
",",
"src",
")",
":",
"if",
"cpu",
".",
"mode",
"==",
"cs",
".",
"CS_MODE_ARM",
":",
"result",
",",
"carry_out",
"=",
"src",
".",
"read",
"(",
"with_carry",
"=",
"True",
")",
"dest",
".",
"write",
"(",
"resu... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | Armv7Cpu.MOVT | MOVT writes imm16 to Rd[31:16]. The write does not affect Rd[15:0].
:param Armv7Operand dest: The destination operand; register
:param Armv7Operand src: The source operand; 16-bit immediate | manticore/native/cpu/arm.py | def MOVT(cpu, dest, src):
"""
MOVT writes imm16 to Rd[31:16]. The write does not affect Rd[15:0].
:param Armv7Operand dest: The destination operand; register
:param Armv7Operand src: The source operand; 16-bit immediate
"""
assert src.type == 'immediate'
imm = sr... | def MOVT(cpu, dest, src):
"""
MOVT writes imm16 to Rd[31:16]. The write does not affect Rd[15:0].
:param Armv7Operand dest: The destination operand; register
:param Armv7Operand src: The source operand; 16-bit immediate
"""
assert src.type == 'immediate'
imm = sr... | [
"MOVT",
"writes",
"imm16",
"to",
"Rd",
"[",
"31",
":",
"16",
"]",
".",
"The",
"write",
"does",
"not",
"affect",
"Rd",
"[",
"15",
":",
"0",
"]",
"."
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/native/cpu/arm.py#L661-L671 | [
"def",
"MOVT",
"(",
"cpu",
",",
"dest",
",",
"src",
")",
":",
"assert",
"src",
".",
"type",
"==",
"'immediate'",
"imm",
"=",
"src",
".",
"read",
"(",
")",
"low_halfword",
"=",
"dest",
".",
"read",
"(",
")",
"&",
"Mask",
"(",
"16",
")",
"dest",
... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | Armv7Cpu.MRC | MRC moves to ARM register from coprocessor.
:param Armv7Operand coprocessor: The name of the coprocessor; immediate
:param Armv7Operand opcode1: coprocessor specific opcode; 3-bit immediate
:param Armv7Operand dest: the destination operand: register
:param Armv7Operand coprocessor_reg_n... | manticore/native/cpu/arm.py | def MRC(cpu, coprocessor, opcode1, dest, coprocessor_reg_n, coprocessor_reg_m, opcode2):
"""
MRC moves to ARM register from coprocessor.
:param Armv7Operand coprocessor: The name of the coprocessor; immediate
:param Armv7Operand opcode1: coprocessor specific opcode; 3-bit immediate
... | def MRC(cpu, coprocessor, opcode1, dest, coprocessor_reg_n, coprocessor_reg_m, opcode2):
"""
MRC moves to ARM register from coprocessor.
:param Armv7Operand coprocessor: The name of the coprocessor; immediate
:param Armv7Operand opcode1: coprocessor specific opcode; 3-bit immediate
... | [
"MRC",
"moves",
"to",
"ARM",
"register",
"from",
"coprocessor",
"."
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/native/cpu/arm.py#L674-L701 | [
"def",
"MRC",
"(",
"cpu",
",",
"coprocessor",
",",
"opcode1",
",",
"dest",
",",
"coprocessor_reg_n",
",",
"coprocessor_reg_m",
",",
"opcode2",
")",
":",
"assert",
"coprocessor",
".",
"type",
"==",
"'coprocessor'",
"assert",
"opcode1",
".",
"type",
"==",
"'im... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | Armv7Cpu.LDRD | Loads double width data from memory. | manticore/native/cpu/arm.py | def LDRD(cpu, dest1, dest2, src, offset=None):
"""Loads double width data from memory."""
assert dest1.type == 'register'
assert dest2.type == 'register'
assert src.type == 'memory'
mem1 = cpu.read_int(src.address(), 32)
mem2 = cpu.read_int(src.address() + 4, 32)
... | def LDRD(cpu, dest1, dest2, src, offset=None):
"""Loads double width data from memory."""
assert dest1.type == 'register'
assert dest2.type == 'register'
assert src.type == 'memory'
mem1 = cpu.read_int(src.address(), 32)
mem2 = cpu.read_int(src.address() + 4, 32)
... | [
"Loads",
"double",
"width",
"data",
"from",
"memory",
"."
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/native/cpu/arm.py#L704-L714 | [
"def",
"LDRD",
"(",
"cpu",
",",
"dest1",
",",
"dest2",
",",
"src",
",",
"offset",
"=",
"None",
")",
":",
"assert",
"dest1",
".",
"type",
"==",
"'register'",
"assert",
"dest2",
".",
"type",
"==",
"'register'",
"assert",
"src",
".",
"type",
"==",
"'mem... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | Armv7Cpu.STRD | Writes the contents of two registers to memory. | manticore/native/cpu/arm.py | def STRD(cpu, src1, src2, dest, offset=None):
"""Writes the contents of two registers to memory."""
assert src1.type == 'register'
assert src2.type == 'register'
assert dest.type == 'memory'
val1 = src1.read()
val2 = src2.read()
writeback = cpu._compute_writeback(... | def STRD(cpu, src1, src2, dest, offset=None):
"""Writes the contents of two registers to memory."""
assert src1.type == 'register'
assert src2.type == 'register'
assert dest.type == 'memory'
val1 = src1.read()
val2 = src2.read()
writeback = cpu._compute_writeback(... | [
"Writes",
"the",
"contents",
"of",
"two",
"registers",
"to",
"memory",
"."
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/native/cpu/arm.py#L717-L727 | [
"def",
"STRD",
"(",
"cpu",
",",
"src1",
",",
"src2",
",",
"dest",
",",
"offset",
"=",
"None",
")",
":",
"assert",
"src1",
".",
"type",
"==",
"'register'",
"assert",
"src2",
".",
"type",
"==",
"'register'",
"assert",
"dest",
".",
"type",
"==",
"'memor... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | Armv7Cpu.LDREX | LDREX loads data from memory.
* If the physical address has the shared TLB attribute, LDREX
tags the physical address as exclusive access for the current
processor, and clears any exclusive access tag for this
processor for any other physical address.
* Otherwise, it tags t... | manticore/native/cpu/arm.py | def LDREX(cpu, dest, src, offset=None):
"""
LDREX loads data from memory.
* If the physical address has the shared TLB attribute, LDREX
tags the physical address as exclusive access for the current
processor, and clears any exclusive access tag for this
processor fo... | def LDREX(cpu, dest, src, offset=None):
"""
LDREX loads data from memory.
* If the physical address has the shared TLB attribute, LDREX
tags the physical address as exclusive access for the current
processor, and clears any exclusive access tag for this
processor fo... | [
"LDREX",
"loads",
"data",
"from",
"memory",
".",
"*",
"If",
"the",
"physical",
"address",
"has",
"the",
"shared",
"TLB",
"attribute",
"LDREX",
"tags",
"the",
"physical",
"address",
"as",
"exclusive",
"access",
"for",
"the",
"current",
"processor",
"and",
"cl... | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/native/cpu/arm.py#L730-L744 | [
"def",
"LDREX",
"(",
"cpu",
",",
"dest",
",",
"src",
",",
"offset",
"=",
"None",
")",
":",
"# TODO: add lock mechanism to underlying memory --GR, 2017-06-06",
"cpu",
".",
"_LDR",
"(",
"dest",
",",
"src",
",",
"32",
",",
"False",
",",
"offset",
")"
] | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | Armv7Cpu.STREX | STREX performs a conditional store to memory.
:param Armv7Operand status: the destination register for the returned status; register | manticore/native/cpu/arm.py | def STREX(cpu, status, *args):
"""
STREX performs a conditional store to memory.
:param Armv7Operand status: the destination register for the returned status; register
"""
# TODO: implement conditional return with appropriate status --GR, 2017-06-06
status.write(0)
... | def STREX(cpu, status, *args):
"""
STREX performs a conditional store to memory.
:param Armv7Operand status: the destination register for the returned status; register
"""
# TODO: implement conditional return with appropriate status --GR, 2017-06-06
status.write(0)
... | [
"STREX",
"performs",
"a",
"conditional",
"store",
"to",
"memory",
".",
":",
"param",
"Armv7Operand",
"status",
":",
"the",
"destination",
"register",
"for",
"the",
"returned",
"status",
";",
"register"
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/native/cpu/arm.py#L747-L754 | [
"def",
"STREX",
"(",
"cpu",
",",
"status",
",",
"*",
"args",
")",
":",
"# TODO: implement conditional return with appropriate status --GR, 2017-06-06",
"status",
".",
"write",
"(",
"0",
")",
"return",
"cpu",
".",
"_STR",
"(",
"cpu",
".",
"address_bit_size",
",",
... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | Armv7Cpu._UXT | Helper for UXT* family of instructions.
:param ARMv7Operand dest: the destination register; register
:param ARMv7Operand dest: the source register; register
:param int src_width: bits to consider of the src operand | manticore/native/cpu/arm.py | def _UXT(cpu, dest, src, src_width):
"""
Helper for UXT* family of instructions.
:param ARMv7Operand dest: the destination register; register
:param ARMv7Operand dest: the source register; register
:param int src_width: bits to consider of the src operand
"""
val... | def _UXT(cpu, dest, src, src_width):
"""
Helper for UXT* family of instructions.
:param ARMv7Operand dest: the destination register; register
:param ARMv7Operand dest: the source register; register
:param int src_width: bits to consider of the src operand
"""
val... | [
"Helper",
"for",
"UXT",
"*",
"family",
"of",
"instructions",
"."
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/native/cpu/arm.py#L756-L766 | [
"def",
"_UXT",
"(",
"cpu",
",",
"dest",
",",
"src",
",",
"src_width",
")",
":",
"val",
"=",
"GetNBits",
"(",
"src",
".",
"read",
"(",
")",
",",
"src_width",
")",
"word",
"=",
"Operators",
".",
"ZEXTEND",
"(",
"val",
",",
"cpu",
".",
"address_bit_si... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | Armv7Cpu.ADR | Address to Register adds an immediate value to the PC value, and writes the result to the destination register.
:param ARMv7Operand dest: Specifies the destination register.
:param ARMv7Operand src:
Specifies the label of an instruction or literal data item whose address is to be loaded int... | manticore/native/cpu/arm.py | def ADR(cpu, dest, src):
"""
Address to Register adds an immediate value to the PC value, and writes the result to the destination register.
:param ARMv7Operand dest: Specifies the destination register.
:param ARMv7Operand src:
Specifies the label of an instruction or litera... | def ADR(cpu, dest, src):
"""
Address to Register adds an immediate value to the PC value, and writes the result to the destination register.
:param ARMv7Operand dest: Specifies the destination register.
:param ARMv7Operand src:
Specifies the label of an instruction or litera... | [
"Address",
"to",
"Register",
"adds",
"an",
"immediate",
"value",
"to",
"the",
"PC",
"value",
"and",
"writes",
"the",
"result",
"to",
"the",
"destination",
"register",
"."
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/native/cpu/arm.py#L943-L954 | [
"def",
"ADR",
"(",
"cpu",
",",
"dest",
",",
"src",
")",
":",
"aligned_pc",
"=",
"(",
"cpu",
".",
"instruction",
".",
"address",
"+",
"4",
")",
"&",
"0xfffffffc",
"dest",
".",
"write",
"(",
"aligned_pc",
"+",
"src",
".",
"read",
"(",
")",
")"
] | 54c5a15b1119c523ae54c09972413e8b97f11629 |
valid | Armv7Cpu.ADDW | This instruction adds an immediate value to a register value, and writes the result to the destination register.
It doesn't update the condition flags.
:param ARMv7Operand dest: Specifies the destination register. If omitted, this register is the same as src.
:param ARMv7Operand src:
... | manticore/native/cpu/arm.py | def ADDW(cpu, dest, src, add):
"""
This instruction adds an immediate value to a register value, and writes the result to the destination register.
It doesn't update the condition flags.
:param ARMv7Operand dest: Specifies the destination register. If omitted, this register is the same ... | def ADDW(cpu, dest, src, add):
"""
This instruction adds an immediate value to a register value, and writes the result to the destination register.
It doesn't update the condition flags.
:param ARMv7Operand dest: Specifies the destination register. If omitted, this register is the same ... | [
"This",
"instruction",
"adds",
"an",
"immediate",
"value",
"to",
"a",
"register",
"value",
"and",
"writes",
"the",
"result",
"to",
"the",
"destination",
"register",
".",
"It",
"doesn",
"t",
"update",
"the",
"condition",
"flags",
"."
] | trailofbits/manticore | python | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/native/cpu/arm.py#L957-L975 | [
"def",
"ADDW",
"(",
"cpu",
",",
"dest",
",",
"src",
",",
"add",
")",
":",
"aligned_pc",
"=",
"(",
"cpu",
".",
"instruction",
".",
"address",
"+",
"4",
")",
"&",
"0xfffffffc",
"if",
"src",
".",
"type",
"==",
"'register'",
"and",
"src",
".",
"reg",
... | 54c5a15b1119c523ae54c09972413e8b97f11629 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.