410 Commits

Author SHA1 Message Date
cclauss
af779d8baa Do not forget self (again) (#854) 2018-04-03 16:47:47 -04:00
Mark Mossberg
bda9c091b5
Manticore 0.1.8 (#851)
(thanks for 1k)

* Bump version numbers

* initial changelog update

* Add changelog content

* add contribs
2018-03-30 18:26:26 -04:00
Arun John Kuruvilla
2f382a9d1c Added KeyError Exception for offsets not in srcmap. Issue #832 (#839) 2018-03-30 10:44:34 -04:00
ggrieco-tob
03af65e55f
A more complete example to initialize and explore a smart contract with manticore (#827)
* A more complete example to initialize and explore a smart contract with manticore

* Removed outdated comments
2018-03-22 09:40:51 -03:00
Disconnect3d
9c19014e4b Fix duplicated armv7 test name (#833)
* Fix duplicate armv7rf test name

* Small refactor of armv7rf

* Proper test classes names
2018-03-21 15:34:19 -04:00
feliam
d1051f6c84
Push 0 on internal revert (#830) 2018-03-20 14:30:09 -03:00
Mark Mossberg
2eb002593e
evm: add per state trace file (#817)
* Add trace file

* Make ethersplay compatible trace format

* Small cleanup

* Record separate init and rt traces, emit separate trace files

* add todo

* More pythonic

* Add test for end insn in trace file

* Fix test

* Move trace accumulation into will_evm_execute callback

here, we can easily and correctly check the .last_exception field
to see if we were in init code or rt code. from the did_evm_execute hook
the last instruction (end instruction) had a different .last_exception
so this was causing the last instruction to not be recorded in the trace.
2018-03-19 14:22:08 -04:00
ggrieco-tob
8acd2293b8
Added --txaccount parameter to control the caller of the symbolic exploration of smart contracts (#819)
* added --txaccount parameter to control the caller of the symbolic exploration of smart contracts

* Use of the new EthereumError exception
2018-03-19 15:08:22 -03:00
Matthew Roll
e97e631d8e port ethereum tests to individual files (issue #809) (#820)
* Add contract keyword arg to IntegrationTest._simple_cli_run

* Remove inline tests from test_eth

* Refactor IntegrationTest.test_eth_regressions to support multi-contract files
2018-03-19 09:24:04 -04:00
Mark Mossberg
fb79127bc2
Graceful exit when no states to run (#815)
* rm unnecessary return, change assert to graceful handle

* Add regression test

* Add regression test

* Correct logic

* Rm unnecessary check

This branch is unnecessary, if this condition is true, then ultimately
the executor will do nothing, and we'll simply return anyway.

* Raise NoAliveStates if no alive states to execute

* docstr update

* Update mult_tx_analysis to handle NoAliveStates

* Fancy

* Update test

* Codeclimate fmt

* fmt

* better readability

* add docstr
2018-03-16 17:48:36 -04:00
Mark Mossberg
a21c8b6012
Improve evm docs (#816)
* Add docstr for finalize

* prune unnecessary stuff from docs

* Add trace file

* Revert "Add trace file"

4687810e15c2bc6cc3e729c32bdad2f617679d77
2018-03-16 13:32:32 -04:00
Mark Mossberg
eaa0e524b4
Fix off by 1 error in codecopy (#812)
* Fix off by 1 in codecopy

* Add regression test

* Improve formatting
2018-03-15 16:41:29 -04:00
Arun John Kuruvilla
fb3938bb3e Raises exception for contract with a function without code. Issue #789 (#797) 2018-03-15 16:31:18 -04:00
Yan Ivnitskiy
cf789a4291
Introduce concretized_args decorator (#803)
* Introduce concretized_args decorator

* Add docs

* Cleanup

* Add basic expression counter

* Please codeclimate

* pep8

* update docstring

* Use default concretization policy when not provided

* Add concretizer tests
2018-03-14 16:45:12 -04:00
Yan Ivnitskiy
61babdbe21
Fix evm RETURN implementation (#808)
* Fix write_buffer issue (#807)

* Add test for write_buffer fix

* Use Operators.ORD instead of ord (even though were assuming concrete vals)

* Cleanup
2018-03-12 15:27:18 -04:00
Dan Guido
bb4a7966a8
Add codeclimate, tox, and pycodestyle configs (#772)
* pep8

autopep8 -r -i -a -a manticore

* tox for testing py3k

* minimal codeclimate

* Add correct Code Climate ID

* unignore max line endings since it's set to 160

* more badges

* turn off pep8 in code climate

* need to remove for codeclimate to work right

* re-enable most checks with looser thresholds

* remove unused imports

autoflake --in-place -r manticore

* revert the autoflakes changes

* set tox to only py27 for now

* cache is hardcoded to python 2.7.13

* Comment cleanup

* Try autoflake again

* Add dev environment dependency management to tox.ini

* Remove count/statistics options from tox.ini

Per Dan, these crash pep8 analysis on codeclimate at present

* Revert setstate initialization

* Re-introduce explicit compare for flags

* add back structural comment

* rm unneeeded ` as e`

* bump py tox
2018-03-12 14:40:06 -04:00
Yan Ivnitskiy
fceb48ce0c
Update Create (evm exception) arguments (#805)
* Update Create arguments

* Add integration test

* Dial back the procs
2018-03-12 12:19:38 -04:00
ggrieco-tob
fbf0823cb6
Very quick fix to avoid STOP instructions to return random values (#792) 2018-03-07 14:57:59 -03:00
ggrieco-tob
f4118f4f0f
Added a function to generate evm testcases without using callbacks (#791)
* Added a function to generate evm testcases without using callbacks

Possible fix for #782

* The 'message' parameter in generate_testcase should be optional

Requested by @montyly
2018-03-06 18:35:19 -03:00
Disconnect3d
fe2538f6bc Add docstring for ARM's operand.is_shifted (#788)
So that people don't have to google that by themselves! lolo
2018-03-05 18:42:48 -05:00
Disconnect3d
328b62350a Change assertion->exception and add msg when target file is not present (#778) 2018-03-02 15:55:13 -05:00
Feist Josselin
7349a0b13d Fix out-of-bound index in EVMWorld._process_pending_transaction (#786) 2018-03-02 15:52:56 -05:00
Mark Mossberg
03ecb3fd9f
Fix cli --data parameter (#781)
* Actually use args.data

* Update decree
2018-03-01 18:48:10 -05:00
Arun John Kuruvilla
17e90986b8 Used a namedtuple for pending transaction. Issue #689 (#775)
* Used a namedtuple for pending transaction. Issue #689

* Changed field names in namedtuple. Issue #689
2018-03-01 18:27:52 -05:00
Disconnect3d
9b75a1f0fe Unicorn emulator: get uc_arch & uc_mode values just once (#779) 2018-03-01 18:24:27 -05:00
Disconnect3d
20cb97f7ae Fix Cpu.execute's improper reporting of Unimplemented instruction (#777)
When particular instruction's implementation raised an `AttributeError` it was catched by `Cpu.execute` and we just saw "oh this instruction is not implemented" while it was, but its implementation was broken.
2018-03-01 13:40:51 -05:00
feliam
48f88be759 Dev fix solver getvalue (#739)
* Increment default gas

* Do not solve concrete values

* Do not solve concrete values

* Do not solve concrete values

* Remove comment

* Make solver get_value return concrete values untouched - wip

* Handle solver.get_value integers

* fix reporting

* Make solver.get_value return the expression untouched when concrete

* Remove hack; we know `c` can't be an int type

* Revert "Remove hack; we know `c` can't be an int type"

0849094525d7e4cea0295d4be13552dea9c8ad72

* Fix cli --data argument

Previously, it was being ignored :/

* Fix linux output generation

solve.get_value returns back an int, if it concretized the sym var

* Revert "Fix cli --data argument"

2ee740acb20a9d393e1a7984d7ec0e0fe64dbfaf
2018-02-28 18:11:54 -05:00
39370ccf3c Let the Python interpreter be specified externally (#774) 2018-02-27 12:33:25 -05:00
feliam
461da57ea3
Array value configurable. 8,16,32..256 bits (not prefixed to 8) (#732)
* Array value configurable. 8,16,32..256 bits (not prefixed to 8)

* Test Array256->256

* Remove old 8 bit assumptions

* Add arrayProxy copy constructors and remove old 8 bit assumptions

* remove old 8 bit assumptions

* remove old 8 bit assumptions

* Better ArrayProxy special case handling

* Fix tests

* Review fixes

* review fix

* fix gas variable

* Review fixes

* Fix vm.gas access
2018-02-26 21:09:34 -03:00
Yan Ivnitskiy
a3ee31e6e6
Manticore 0.1.7 Release (#764) 2018-02-23 18:31:31 -05:00
Yan Ivnitskiy
394401e3f4
Fix ARMv7's ADD (#769)
* Fix armv7's ADD
2018-02-23 18:07:49 -05:00
Mark Mossberg
b9aa483745
evm: Fix MUL overflow false positive (#767)
* initial

* Add test for mul checker

* clean

* Rename and clean

* Rm testing

* Better comment, and clean

* Split tests, add more tests

* Clean up stuff, remove unnecessary masking

* fmt

* Add back constrain to make it match the originall buggy situation

* Clean up surrounding code, make it unit testable

* Correct name

* Use individual arguments for helpers
2018-02-23 12:42:15 -08:00
Mark Mossberg
3f1c51fa91
Improve solc error output (#765)
* Improve err handling when there's a solc error, print the error

* Fix bug, don't merge stdout/err

* Simplify

* Add more space
2018-02-23 08:13:55 -08:00
Mark Mossberg
d0f69c755c
Add ethereum regression tests (#763)
* Clean some unused variables

* Add basic infrastructure

* Add real eth regression tests

* Use check_call

* Suppress stdout

* Make 705 work

* Less error prone way of testing
2018-02-22 13:04:01 -08:00
Jean Jordaan
8e47a6ebe9 Drive-by typo correction ;-) (#762) 2018-02-22 10:17:49 -03:00
Mark Mossberg
ebe0baa178
Emit events for exception raising evm instructions (#722)
* Create EVMInstructionException, properly emit did_evm_execute_instruction for insns that trap to the platform

* Emit event before execution of platform handlers. This is because many of the
platform handles actually destroy the cpu (platform.current) via pop_vm.
Clients that receive the event may want to access the cpu though, for example
to see the current PC. so we emit the event right before, so they can do this

* simplify

* move closure below result decl

* Add comment to explain

* Fix typo

* Revert back to pythonic style

It was this way to test emitting the did execute signal here, rather
than in the evm cpu

* Remove inline function definition from critical path

* Add test for events for exception instructions
2018-02-20 12:10:29 -08:00
Mark Mossberg
9f0d25c5d9 Fix evm state handling regression (#741)
* Revert breaking change

* Add assertion to verify states being queued
2018-02-20 09:57:07 -03:00
Disconnect3d
105a7d3aee Speedup x86 execution by caching AMD64RegFile.all_registers (#755)
* Cache `all_registers` for AMD64RegFile
2018-02-19 20:48:26 -05:00
Disconnect3d
680fc8f17e Armv7 code refactor (#749)
* Armv7 code refactor

Removes dead imports, makes code style more consistent and a bit more compliant with pep8 (yeah i seems we don't enforce any particular style, but this seems to be a reasonable default for me).

* Review fix: add comment for armv7 _shift
2018-02-17 11:51:58 -05:00
Garret Reece
c6f457d72e Updates for thumb mode (#610)
* WIP. issues with setting PC correctly via POP are corrected. issues with pc relative addressing in thumb mode corrected. Still a memory access error, but getting there

* WIP - PC relative addressing in thumb mode now aligns the value for PC per the spec before applying offset

* General thumb mode fixes:
* ldr pc, <operand> now swaps modes and sets pc correctly
* the bl instruction sets the lr appropriately for the current mode
* the two operand forms of the ORR, EOR, and BIC instructions now exist
* tests added for these updates

* comment cleanup

* WIP :more thumb mode instructions, a special case for the sys_brk handled, and a really ugly solution to an internal plumbing problem

* First attempt at concretizing ARM mode

* Handle symbolic mode for ARMv7

* Clean up imports

* Make comment more accurate and use instruction.size

* Collapse _Shift and _Shift_thumb

* Make ARM mode handling more Pythonic

* Improve comment on arm shift register handling and capstone behavior
2018-02-15 15:47:36 -05:00
Srinivas P G
fca3179dd0 System calls addition - sys_getrandom and sys_openat (#640)
* version argument in manticore

* Fix 591 - Exception Handler

* Issue 597 - Remove the unused policy argument

* getrandom system call - Initial commit

* openat system call initial commit

* getrandom system call fixes

* openat and getrandom system call

* Update sys_getrandom

* Make BadFd more generic as FdError

* Resolve mode inside File

* Support opening directory with open(2)

* Fix fd leak

* add sys_openat tests
2018-02-14 16:52:54 -05:00
feliam
843a4f399e
Fix finalize (#738)
* fix finalize

* Document the state id -1
2018-02-14 18:28:50 -03:00
feliam
2f2de29d36
Better plugin context management. (#730)
* Better plugin context management. Example UseDef logging plugin for evm

* Example plugin to log use-def

* Better plugin name checking hints

* Better plugin name checking hints2

* Fix uninititalize-plugins (found via the warning)

* Remove redundant variables in example

* Typo

* Better warning print (class name)

* better safety check + context fix

* better variabke naming

* Update manticore.py
2018-02-14 17:13:40 -03:00
Mark Mossberg
84aca4ac1b
Add docs on symbolic input (#750)
* Change tagline

* Not sure socket support is a gotcha exactly

* initial docs

* Better docs

* Code blocks

* Links to the api docs

* Improve language

* Doc add_symbolic_file in public API

* Rm stray init
2018-02-13 19:15:54 -05:00
feliam
f8587ff13e Bump default gas budget (#740) 2018-02-13 18:55:52 -05:00
Arun John Kuruvilla
4d84551375 Fixed Issue #723 - changed _pop() to _pop_vm() (#745) 2018-02-08 17:25:40 -03:00
feliam
5a38737ede
Fix sha3 (#703)
* the fix

* Add default example sha3 when unknown

* Review

* Remove IF statement on potentially symbolic value
2018-02-05 15:00:05 -03:00
ggrieco-tob
2f2b081aa9 Added multiprocessing support to generate testcases in finalize (#697)
* Added multiprocessing support to generate testcase in finalize

* Improve the code using @feliam suggestions

* Fixed multiprocessing code. Now it really seems to work!™
2018-02-02 13:37:24 -05:00
Mark Mossberg
97307906c5
Fix incorrect number of transaction in certain states (#724)
* privatize Executor.put, use in evm

* better typeerror

* Simplify execute(), directly raise exception in _process...
2018-02-02 13:23:04 -05:00
Yan Ivnitskiy
9f7b87d0b8
Use the 'force' flag for bss zeroing (#719)
* Clean up bss trailer zeroing
2018-01-31 11:47:46 -05:00