SoftSec-KAIST / Smartian

Smartian: Enhancing Smart Contract Fuzzing with Static and Dynamic Data-Flow Analyses (ASE '21)
MIT License
140 stars 21 forks source link

Error while working on TokenSale.sol: Unhandled exception. System.Exception: Odd length string as input #3

Closed crypto50z closed 4 months ago

crypto50z commented 2 years ago

I was reading the paper and thought this might be a very interesting tool. So I want to gave it some tries.

I set up the docker as instructed in https://github.com/SoftSec-KAIST/Smartian-Artifact. And run the fuzzing session on some examples in B1, B2, B3. Very nice, Smartian did reported very high-quality bugs.

Then I want to try Smartian on some other code, so I think of one example named TokenSale.sol(from https://capturetheether.com/challenges/math/token-sale/). After I generated bin and abi for this contract and feed them to Smartian, it reported the following error:

test@bff77534d133:~$ dotnet tools/Smartian/build/Smartian.dll fuzz -p ts-rt.bin -a ts.abi -t 1200 -o ~/tmp/ts [00:00:00:00] Fuzz target : ts-rt.bin [00:00:00:00] Fuzzing starts at 02:00:59 [00:00:00:00] Time limit : 1200 s Unhandled exception. System.Exception: Odd length string as input at Smartian.BytesUtils.hexStrToBytes(String s) in /home/test/tools/Smartian/src/Core/BytesUtils.fs:line 18 at Smartian.Executor.initialize(String targetPath) in /home/test/tools/Smartian/src/Fuzz/Executor.fs:line 53 at Smartian.Fuzz.run[a](String[] args) in /home/test/tools/Smartian/src/Fuzz/Fuzz.fs:line 143 at Smartian.Main.runMode(String mode, String[] optArgs) in /home/test/tools/Smartian/src/Main/Main.fs:line 14 at Smartian.Main.main(String[] args) in /home/test/tools/Smartian/src/Main/Main.fs:line 22 Aborted

Could you please help me fix this? Thanks a lot!

jchoi2022 commented 2 years ago

Hello,

Will you take a look at the length of the ts-rt.bin file? The file length should be an even number, because EVM bytecode is represented in a hexadecimal string.

I often experienced that exception when there was an unwanted trailing newline ("\n") at the end of the file. For example, if you are redirecting the stdout of solc to compile a program (like solc A.sol --bin > A.bin), there can be a trailing newline character in A.bin.