-
Notifications
You must be signed in to change notification settings - Fork 478
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into native-arb-cf-redirect-detector
* master: (28 commits) AArch64: fix ldrb size (#1433) System Call Audit (#1384) ManticoreBase refactor (#1385) Add missing checks for ARM boundaries (#1429) aarch64: add instruction tests: T-U (#1423) aarch64: add instruction tests: M-S (#1422) aarch64: add instruction tests: C-L (#1421) aarch64: add instruction tests: A-B (#1420) aarch64: add everything except instructions (#1418) fixup: support ARM64 in '_reg_name' Revert "fixup: remove x86-specific code from '_reg_name'" review: avoid wildcard imports review: rename the file fixup: remove x86-specific code from '_reg_name' fixup: do not use relative imports Generates a more sensible symbolic default for constructor arguments (#1414) aarch64: add instructions aarch64: add everything except instructions Switches the Travis-CI badge from .org to .com (#1416) Performance optimization : use set instead of list (#1415) ...
Showing
97 changed files
with
26,727 additions
and
6,032 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
pragma solidity ^0.4.15; | ||
contract Overflow { | ||
uint private sellerBalance=0; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
pragma solidity ^0.4.13; | ||
|
||
contract Test { | ||
event Log(string); | ||
mapping(address => uint) private balances; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// gcc -g -static -o basic basic.c | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
|
||
int main(int argc, char* argv[], char* envp[]){ | ||
unsigned int cmd; | ||
|
||
if (read(0, &cmd, sizeof(cmd)) != sizeof(cmd)) | ||
{ | ||
printf("Error reading stdin!"); | ||
exit(-1); | ||
} | ||
|
||
if (cmd > 0x41) | ||
{ | ||
printf("Message: It is greater than 0x41\n"); | ||
} | ||
else | ||
{ | ||
printf("Message: It is less than or equal to 0x41\n"); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import struct | ||
import sys | ||
|
||
from manticore.native import Manticore | ||
|
||
# Examples: | ||
# printf "\x41\x00\x00\x00" | PYTHONPATH=. ./examples/script/aarch64/basic.py | ||
# printf "++\x00\x00" | PYTHONPATH=. ./examples/script/aarch64/basic.py | ||
# printf "++++" | PYTHONPATH=. ./examples/script/aarch64/basic.py | ||
# printf "ffffff" | PYTHONPATH=. ./examples/script/aarch64/basic.py | ||
|
||
DIR = os.path.dirname(__file__) | ||
FILE = os.path.join(DIR, 'basic') | ||
STDIN = sys.stdin.readline() | ||
|
||
# Avoid writing anything to 'STDIN' here. Do it in the 'init' hook as that's | ||
# more flexible. | ||
m = Manticore(FILE, concrete_start='', stdin_size=0) | ||
|
||
|
||
@m.init | ||
def init(m, ready_states): | ||
for state in ready_states: | ||
state.platform.input.write(state.symbolicate_buffer(STDIN, label='STDIN')) | ||
|
||
|
||
# Hook the 'if' case. | ||
@m.hook(0x4006bc) | ||
def hook_if(state): | ||
print('hook if') | ||
state.abandon() | ||
|
||
|
||
# Hook the 'else' case. | ||
@m.hook(0x4006cc) | ||
def hook_else(state): | ||
print('hook else') | ||
# See how the constraints are affected by input. | ||
print_constraints(state, 6) | ||
|
||
w0 = state.cpu.W0 | ||
|
||
if isinstance(w0, int): # concrete | ||
print(hex(w0)) | ||
else: | ||
print(w0) # symbolic | ||
|
||
solved = state.solve_one(w0) | ||
print(struct.pack("<I", solved)) | ||
|
||
|
||
# Hook 'puts' in the 'else' case. | ||
@m.hook(0x4006d4) | ||
def hook_puts(state): | ||
print('hook puts') | ||
cpu = state.cpu | ||
print(cpu.read_string(cpu.X0)) | ||
|
||
|
||
def print_constraints(state, nlines): | ||
i = 0 | ||
for c in str(state.constraints).split('\n'): | ||
if i >= nlines: | ||
break | ||
print(c) | ||
i += 1 | ||
|
||
|
||
m.run() |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// gcc -g -static -o hello42 hello42.c | ||
#include <stdio.h> | ||
|
||
int main() | ||
{ | ||
puts("hello"); | ||
return 42; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
|
||
from manticore.native import Manticore | ||
|
||
# Modified 'count_instructions.py' to demonstrate execution of a | ||
# statically-linked "Hello, world!" AArch64 binary. | ||
|
||
DIR = os.path.dirname(__file__) | ||
FILE = os.path.join(DIR, 'hello42') | ||
|
||
if __name__ == '__main__': | ||
m = Manticore(FILE) | ||
|
||
with m.locked_context() as context: | ||
context['count'] = 0 | ||
|
||
@m.hook(None) | ||
def explore(state): | ||
with m.locked_context() as context: | ||
context['count'] += 1 | ||
|
||
if state.cpu.PC == 0x406f10: # puts | ||
s = state.cpu.read_string(state.cpu.X0) | ||
assert s == 'hello' | ||
print(f'puts argument: {s}') | ||
|
||
elif state.cpu.PC == 0x40706c: # puts result | ||
result = state.cpu.X0 | ||
assert result >= 0 | ||
print(f'puts result: {result}') | ||
|
||
elif state.cpu.PC == 0x415e50: # exit | ||
status = state.cpu.X0 | ||
syscall = state.cpu.X8 | ||
assert syscall == 94 # sys_exit_group | ||
print(f'exit status: {status}') | ||
|
||
def execute_instruction(self, insn, msg): | ||
print(f'{msg}: 0x{insn.address:x}: {insn.mnemonic} {insn.op_str}') | ||
|
||
m.subscribe('will_execute_instruction', lambda self, state, pc, insn: | ||
execute_instruction(self, insn, 'next')) | ||
m.subscribe('did_execute_instruction', lambda self, state, last_pc, pc, insn: | ||
execute_instruction(self, insn, 'done')) | ||
|
||
m.run(procs=1) | ||
|
||
print(f"Executed {m.context['count']} instructions") |
Oops, something went wrong.