diff --git a/mythril/mythril/mythril_leveldb.py b/mythril/mythril/mythril_leveldb.py index 8220a614..7ab78f56 100644 --- a/mythril/mythril/mythril_leveldb.py +++ b/mythril/mythril/mythril_leveldb.py @@ -15,7 +15,7 @@ class MythrilLevelDB: :param leveldb: Leveldb path """ - self.level_db = leveldb + self.leveldb = leveldb def search_db(self, search): """ @@ -33,17 +33,17 @@ class MythrilLevelDB: print("Address: " + address + ", balance: " + str(balance)) try: - self.level_db.search(search, search_callback) + self.leveldb.search(search, search_callback) except SyntaxError: raise CriticalError("Syntax error in search expression.") - def contract_hash_to_address(self, hash): + def contract_hash_to_address(self, contract_hash): """ Returns address of the corresponding hash by searching the leveldb - :param hash: Hash to be searched + :param contract_hash: Hash to be searched """ - if not re.match(r"0x[a-fA-F0-9]{64}", hash): + if not re.match(r"0x[a-fA-F0-9]{64}", contract_hash): raise CriticalError("Invalid address hash. Expected format is '0x...'.") - print(self.level_db.contract_hash_to_address(hash)) + print(self.leveldb.contract_hash_to_address(contract_hash)) diff --git a/tests/leveldb_dir/geth/LOCK b/tests/leveldb_dir/geth/LOCK new file mode 100644 index 00000000..e69de29b diff --git a/tests/leveldb_dir/geth/chaindata/000097.ldb b/tests/leveldb_dir/geth/chaindata/000097.ldb new file mode 100644 index 00000000..c9742956 Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000097.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000098.ldb b/tests/leveldb_dir/geth/chaindata/000098.ldb new file mode 100644 index 00000000..cf09bc55 Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000098.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000109.ldb b/tests/leveldb_dir/geth/chaindata/000109.ldb new file mode 100644 index 00000000..02d5316e Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000109.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000110.ldb b/tests/leveldb_dir/geth/chaindata/000110.ldb new file mode 100644 index 00000000..88ce7a65 Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000110.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000111.ldb b/tests/leveldb_dir/geth/chaindata/000111.ldb new file mode 100644 index 00000000..7ad22d8c Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000111.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000112.ldb b/tests/leveldb_dir/geth/chaindata/000112.ldb new file mode 100644 index 00000000..05ee2e54 Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000112.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000113.ldb b/tests/leveldb_dir/geth/chaindata/000113.ldb new file mode 100644 index 00000000..8daa5472 Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000113.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000126.ldb b/tests/leveldb_dir/geth/chaindata/000126.ldb new file mode 100644 index 00000000..a682ca70 Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000126.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000127.ldb b/tests/leveldb_dir/geth/chaindata/000127.ldb new file mode 100644 index 00000000..c0f976cf Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000127.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000128.ldb b/tests/leveldb_dir/geth/chaindata/000128.ldb new file mode 100644 index 00000000..5ada2da0 Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000128.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000147.ldb b/tests/leveldb_dir/geth/chaindata/000147.ldb new file mode 100644 index 00000000..d76cf1de Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000147.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000148.ldb b/tests/leveldb_dir/geth/chaindata/000148.ldb new file mode 100644 index 00000000..f6d5bbe4 Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000148.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000149.ldb b/tests/leveldb_dir/geth/chaindata/000149.ldb new file mode 100644 index 00000000..3d8c1f28 Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000149.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000150.ldb b/tests/leveldb_dir/geth/chaindata/000150.ldb new file mode 100644 index 00000000..51245918 Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000150.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000151.ldb b/tests/leveldb_dir/geth/chaindata/000151.ldb new file mode 100644 index 00000000..17c5308e Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000151.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000152.ldb b/tests/leveldb_dir/geth/chaindata/000152.ldb new file mode 100644 index 00000000..e80e3aa9 Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000152.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000157.ldb b/tests/leveldb_dir/geth/chaindata/000157.ldb new file mode 100644 index 00000000..a912d7fc Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000157.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000158.ldb b/tests/leveldb_dir/geth/chaindata/000158.ldb new file mode 100644 index 00000000..7111423f Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000158.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000159.ldb b/tests/leveldb_dir/geth/chaindata/000159.ldb new file mode 100644 index 00000000..de929984 Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000159.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000625.ldb b/tests/leveldb_dir/geth/chaindata/000625.ldb new file mode 100644 index 00000000..a95538de Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000625.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000626.ldb b/tests/leveldb_dir/geth/chaindata/000626.ldb new file mode 100644 index 00000000..1b1a5837 Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000626.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000627.ldb b/tests/leveldb_dir/geth/chaindata/000627.ldb new file mode 100644 index 00000000..7c972d05 Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000627.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000628.ldb b/tests/leveldb_dir/geth/chaindata/000628.ldb new file mode 100644 index 00000000..b3375364 Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000628.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000634.ldb b/tests/leveldb_dir/geth/chaindata/000634.ldb new file mode 100644 index 00000000..749e4759 Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000634.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000655.log b/tests/leveldb_dir/geth/chaindata/000655.log new file mode 100644 index 00000000..e69de29b diff --git a/tests/leveldb_dir/geth/chaindata/000656.ldb b/tests/leveldb_dir/geth/chaindata/000656.ldb new file mode 100644 index 00000000..deeab316 Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000656.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000657.ldb b/tests/leveldb_dir/geth/chaindata/000657.ldb new file mode 100644 index 00000000..1b1a5837 Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000657.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000658.ldb b/tests/leveldb_dir/geth/chaindata/000658.ldb new file mode 100644 index 00000000..7c972d05 Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000658.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000659.ldb b/tests/leveldb_dir/geth/chaindata/000659.ldb new file mode 100644 index 00000000..e2bb0001 Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000659.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000660.ldb b/tests/leveldb_dir/geth/chaindata/000660.ldb new file mode 100644 index 00000000..f32fef38 Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000660.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000661.ldb b/tests/leveldb_dir/geth/chaindata/000661.ldb new file mode 100644 index 00000000..725651a9 Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000661.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/000662.ldb b/tests/leveldb_dir/geth/chaindata/000662.ldb new file mode 100644 index 00000000..4330e99b Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/000662.ldb differ diff --git a/tests/leveldb_dir/geth/chaindata/CURRENT b/tests/leveldb_dir/geth/chaindata/CURRENT new file mode 100644 index 00000000..cc525bb3 --- /dev/null +++ b/tests/leveldb_dir/geth/chaindata/CURRENT @@ -0,0 +1 @@ +MANIFEST-000654 diff --git a/tests/leveldb_dir/geth/chaindata/LOCK b/tests/leveldb_dir/geth/chaindata/LOCK new file mode 100644 index 00000000..e69de29b diff --git a/tests/leveldb_dir/geth/chaindata/LOG b/tests/leveldb_dir/geth/chaindata/LOG new file mode 100644 index 00000000..a7d2e63e --- /dev/null +++ b/tests/leveldb_dir/geth/chaindata/LOG @@ -0,0 +1,17 @@ +2019/02/07-18:07:34.962750 7ff1404c2740 Recovering log #653 +2019/02/07-18:07:35.053949 7ff1404c2740 Delete type=2 #655 +2019/02/07-18:07:35.055109 7ff1404c2740 Delete type=2 #659 +2019/02/07-18:07:35.056193 7ff1404c2740 Delete type=3 #652 +2019/02/07-18:07:35.056285 7ff1404c2740 Delete type=2 #657 +2019/02/07-18:07:35.057351 7ff1404c2740 Delete type=2 #656 +2019/02/07-18:07:35.058359 7ff1404c2740 Delete type=2 #658 +2019/02/07-18:07:35.059656 7ff1404c2740 Delete type=2 #654 +2019/02/07-18:07:35.060963 7ff1404c2740 Delete type=0 #653 +2019/02/07-18:10:59.173100 7ff1327b9700 Compacting 1@1 + 7@2 files +2019/02/07-18:10:59.314520 7ff1327b9700 Generated table #656@1: 81883 keys, 2123472 bytes +2019/02/07-18:10:59.438928 7ff1327b9700 Generated table #657@1: 45465 keys, 2114646 bytes +2019/02/07-18:10:59.673460 7ff1327b9700 Generated table #658@1: 45437 keys, 2115685 bytes +2019/02/07-18:10:59.785100 7ff1327b9700 Generated table #659@1: 48074 keys, 2122150 bytes +2019/02/07-18:10:59.930253 7ff1327b9700 Generated table #660@1: 50323 keys, 2131426 bytes +2019/02/07-18:11:00.066163 7ff1327b9700 Generated table #661@1: 48817 keys, 2130856 bytes +2019/02/07-18:11:00.084794 7ff1327b9700 compacted to: files[ 0 4 20 0 0 0 0 ] diff --git a/tests/leveldb_dir/geth/chaindata/LOG.old b/tests/leveldb_dir/geth/chaindata/LOG.old new file mode 100644 index 00000000..01097cf1 --- /dev/null +++ b/tests/leveldb_dir/geth/chaindata/LOG.old @@ -0,0 +1,11 @@ +2019/02/07-18:03:01.949759 7fda91fee740 Recovering log #651 +2019/02/07-18:03:02.013668 7fda91fee740 Delete type=0 #651 +2019/02/07-18:03:02.013768 7fda91fee740 Delete type=3 #650 +2019/02/07-18:06:09.042466 7fda77fff700 Compacting 1@1 + 7@2 files +2019/02/07-18:06:09.170379 7fda77fff700 Generated table #654@1: 81883 keys, 2123472 bytes +2019/02/07-18:06:09.327300 7fda77fff700 Generated table #655@1: 45465 keys, 2114646 bytes +2019/02/07-18:06:09.459949 7fda77fff700 Generated table #656@1: 45437 keys, 2115685 bytes +2019/02/07-18:06:09.594981 7fda77fff700 Generated table #657@1: 48074 keys, 2122150 bytes +2019/02/07-18:06:09.763079 7fda77fff700 Generated table #658@1: 50323 keys, 2131426 bytes +2019/02/07-18:06:09.919488 7fda77fff700 Generated table #659@1: 48817 keys, 2130856 bytes +2019/02/07-18:06:09.919604 7fda77fff700 compacted to: files[ 0 4 20 0 0 0 0 ] diff --git a/tests/leveldb_dir/geth/chaindata/MANIFEST-000654 b/tests/leveldb_dir/geth/chaindata/MANIFEST-000654 new file mode 100644 index 00000000..4cfaa0d4 Binary files /dev/null and b/tests/leveldb_dir/geth/chaindata/MANIFEST-000654 differ diff --git a/tests/leveldb_dir/geth/nodekey b/tests/leveldb_dir/geth/nodekey new file mode 100644 index 00000000..5cb300b1 --- /dev/null +++ b/tests/leveldb_dir/geth/nodekey @@ -0,0 +1 @@ +2bdd7b2dc7ecfe3050a1b93ab7af6617093da4af0e88dfa3cb8fe3eea7bb7662 \ No newline at end of file diff --git a/tests/leveldb_dir/geth/nodes/000026.log b/tests/leveldb_dir/geth/nodes/000026.log new file mode 100644 index 00000000..6c54b9a5 Binary files /dev/null and b/tests/leveldb_dir/geth/nodes/000026.log differ diff --git a/tests/leveldb_dir/geth/nodes/000028.ldb b/tests/leveldb_dir/geth/nodes/000028.ldb new file mode 100644 index 00000000..d76d7327 Binary files /dev/null and b/tests/leveldb_dir/geth/nodes/000028.ldb differ diff --git a/tests/leveldb_dir/geth/nodes/CURRENT b/tests/leveldb_dir/geth/nodes/CURRENT new file mode 100644 index 00000000..3bf51646 --- /dev/null +++ b/tests/leveldb_dir/geth/nodes/CURRENT @@ -0,0 +1 @@ +MANIFEST-000027 diff --git a/tests/leveldb_dir/geth/nodes/LOCK b/tests/leveldb_dir/geth/nodes/LOCK new file mode 100644 index 00000000..e69de29b diff --git a/tests/leveldb_dir/geth/nodes/LOG b/tests/leveldb_dir/geth/nodes/LOG new file mode 100644 index 00000000..51153352 --- /dev/null +++ b/tests/leveldb_dir/geth/nodes/LOG @@ -0,0 +1,128 @@ +=============== Aug 2, 2018 (IST) =============== +15:14:32.205811 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +15:14:32.266053 db@open opening +15:14:32.266317 version@stat F·[] S·0B[] Sc·[] +15:14:32.299779 db@janitor F·2 G·0 +15:14:32.299794 db@open done T·33.705668ms +15:14:44.873709 db@close closing +15:14:44.873731 db@close done T·20.408µs +=============== Aug 2, 2018 (IST) =============== +15:14:53.347217 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +15:14:53.347317 version@stat F·[] S·0B[] Sc·[] +15:14:53.347323 db@open opening +15:14:53.347350 journal@recovery F·1 +15:14:53.348799 journal@recovery recovering @1 +15:14:53.384904 memdb@flush created L0@2 N·150 S·7KiB "n:\x00..ail,v103":"version,v1" +15:14:53.386135 version@stat F·[1] S·7KiB[7KiB] Sc·[0.25] +15:14:53.442461 db@janitor F·3 G·0 +15:14:53.442480 db@open done T·95.152372ms +15:16:33.049092 db@close closing +15:16:33.049141 db@close done T·48.525µs +=============== Aug 2, 2018 (IST) =============== +15:16:50.167061 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +15:16:50.167209 version@stat F·[1] S·7KiB[7KiB] Sc·[0.25] +15:16:50.167219 db@open opening +15:16:50.167256 journal@recovery F·1 +15:16:50.168671 journal@recovery recovering @3 +15:16:50.209364 memdb@flush created L0@5 N·644 S·30KiB "n:\x01..ail,v280":"n:\xfd..ail,v224" +15:16:50.210844 version@stat F·[2] S·38KiB[38KiB] Sc·[0.50] +15:16:50.277183 db@janitor F·4 G·0 +15:16:50.277199 db@open done T·109.97423ms +15:16:50.278963 table@compaction L0·2 -> L1·0 S·38KiB Q·796 +15:16:50.323429 table@build created L1@8 N·578 S·33KiB "n:\x00..ail,v103":"version,v1" +15:16:50.323521 version@stat F·[0 1] S·33KiB[0B 33KiB] Sc·[0.00 0.00] +15:16:50.345986 table@compaction committed F-1 S-5KiB Ke·0 D·216 T·66.977974ms +15:16:50.346067 table@remove removed @5 +15:16:50.346099 table@remove removed @2 +15:18:08.296045 db@close closing +15:18:08.296076 db@close done T·29.725µs +=============== Aug 2, 2018 (IST) =============== +15:18:45.392079 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +15:18:45.392213 version@stat F·[0 1] S·33KiB[0B 33KiB] Sc·[0.00 0.00] +15:18:45.392221 db@open opening +15:18:45.392254 journal@recovery F·1 +15:18:45.393510 journal@recovery recovering @6 +15:18:45.436279 memdb@flush created L0@9 N·459 S·23KiB "n:\x00..ing,v1082":"n:\xfe..ail,v964" +15:18:45.437589 version@stat F·[1 1] S·56KiB[23KiB 33KiB] Sc·[0.25 0.00] +15:18:45.481661 db@janitor F·4 G·0 +15:18:45.481678 db@open done T·89.452709ms +15:18:45.483981 table@compaction L0·1 -> L1·1 S·56KiB Q·1256 +15:18:45.526716 table@build created L1@12 N·885 S·50KiB "n:\x00..ing,v1082":"version,v1" +15:18:45.526822 version@stat F·[0 1] S·50KiB[0B 50KiB] Sc·[0.00 0.00] +15:18:45.549234 table@compaction committed F-1 S-6KiB Ke·0 D·152 T·65.209259ms +15:18:45.549299 table@remove removed @9 +15:18:45.549338 table@remove removed @8 +15:19:55.069446 db@close closing +15:19:55.069475 db@close done T·28.254µs +=============== Aug 2, 2018 (IST) =============== +15:20:04.087151 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +15:20:04.087664 version@stat F·[0 1] S·50KiB[0B 50KiB] Sc·[0.00 0.00] +15:20:04.087701 db@open opening +15:20:04.087835 journal@recovery F·1 +15:20:04.092741 journal@recovery recovering @10 +15:20:04.134293 memdb@flush created L0@13 N·439 S·21KiB "n:\x02..ail,v1549":"n:\xfa..ail,v1287" +15:20:04.139718 version@stat F·[1 1] S·72KiB[21KiB 50KiB] Sc·[0.25 0.00] +15:20:04.203301 db@janitor F·4 G·0 +15:20:04.203362 db@open done T·115.642485ms +15:20:04.212745 table@compaction L0·1 -> L1·1 S·72KiB Q·1696 +15:20:04.258940 table@build created L1@16 N·1186 S·67KiB "n:\x00..ing,v1082":"version,v1" +15:20:04.259021 version@stat F·[0 1] S·67KiB[0B 67KiB] Sc·[0.00 0.00] +15:20:04.281654 table@compaction committed F-1 S-4KiB Ke·0 D·138 T·68.817623ms +15:20:04.281730 table@remove removed @13 +15:20:04.281779 table@remove removed @12 +15:21:42.450234 db@close closing +15:21:42.450322 db@close done T·84.577µs +=============== Aug 2, 2018 (IST) =============== +15:21:52.563151 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +15:21:52.563627 version@stat F·[0 1] S·67KiB[0B 67KiB] Sc·[0.00 0.00] +15:21:52.563662 db@open opening +15:21:52.563795 journal@recovery F·1 +15:21:52.568789 journal@recovery recovering @14 +15:21:52.611840 memdb@flush created L0@17 N·600 S·28KiB "n:\x02..ing,v1795":"n:\xfd..ong,v1860" +15:21:52.617139 version@stat F·[1 1] S·95KiB[28KiB 67KiB] Sc·[0.25 0.00] +15:21:52.656312 db@janitor F·4 G·0 +15:21:52.656419 db@open done T·92.739296ms +15:21:52.668548 table@compaction L0·1 -> L1·1 S·95KiB Q·2297 +15:21:52.723247 table@build created L1@20 N·1555 S·86KiB "n:\x00..ing,v1082":"version,v1" +15:21:52.723301 version@stat F·[0 1] S·86KiB[0B 86KiB] Sc·[0.00 0.00] +15:21:52.745714 table@compaction committed F-1 S-8KiB Ke·0 D·231 T·77.093781ms +15:21:52.745797 table@remove removed @17 +15:21:52.745848 table@remove removed @16 +15:22:52.173124 db@close closing +15:22:52.173174 db@close done T·49.001µs +=============== Aug 2, 2018 (IST) =============== +15:23:02.333013 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +15:23:02.333607 version@stat F·[0 1] S·86KiB[0B 86KiB] Sc·[0.00 0.00] +15:23:02.333645 db@open opening +15:23:02.333820 journal@recovery F·1 +15:23:02.339127 journal@recovery recovering @18 +15:23:02.402190 memdb@flush created L0@21 N·409 S·22KiB "n:\x01..ing,v2522":"n:\xfd..ail,v2614" +15:23:02.408191 version@stat F·[1 1] S·108KiB[22KiB 86KiB] Sc·[0.25 0.00] +15:23:02.447827 db@janitor F·4 G·0 +15:23:02.447888 db@open done T·114.220635ms +15:23:02.458568 table@compaction L0·1 -> L1·1 S·108KiB Q·2707 +15:23:02.502706 table@build created L1@24 N·1868 S·102KiB "n:\x00..ing,v1082":"version,v1" +15:23:02.502799 version@stat F·[0 1] S·102KiB[0B 102KiB] Sc·[0.00 0.00] +15:23:02.547275 table@compaction committed F-1 S-5KiB Ke·0 D·96 T·88.620636ms +15:23:02.547348 table@remove removed @21 +15:23:02.547395 table@remove removed @20 +15:24:21.688122 db@close closing +15:24:21.688185 db@close done T·60.473µs +=============== Feb 7, 2019 (IST) =============== +16:09:20.869498 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +16:09:20.903227 version@stat F·[0 1] S·102KiB[0B 102KiB] Sc·[0.00 0.00] +16:09:20.903245 db@open opening +16:09:20.903309 journal@recovery F·1 +16:09:20.905020 journal@recovery recovering @22 +16:09:20.942643 memdb@flush created L0@25 N·551 S·27KiB "n:\x01..ail,v3020":"n:\xff..ail,v3021" +16:09:20.944518 version@stat F·[1 1] S·130KiB[27KiB 102KiB] Sc·[0.25 0.00] +16:09:20.983348 db@janitor F·4 G·0 +16:09:20.983420 db@open done T·80.161941ms +16:09:21.011768 table@compaction L0·1 -> L1·1 S·130KiB Q·3259 +16:09:21.030323 table@build created L1@28 N·2212 S·123KiB "n:\x00..ing,v1082":"version,v1" +16:09:21.030372 version@stat F·[0 1] S·123KiB[0B 123KiB] Sc·[0.00 0.00] +16:09:21.036431 table@compaction committed F-1 S-7KiB Ke·0 D·207 T·24.625754ms +16:09:21.036508 table@remove removed @25 +16:09:21.036572 table@remove removed @24 +16:09:23.786865 db@close closing +16:09:23.786997 db@close done T·149.485µs diff --git a/tests/leveldb_dir/geth/nodes/MANIFEST-000027 b/tests/leveldb_dir/geth/nodes/MANIFEST-000027 new file mode 100644 index 00000000..63e7f489 Binary files /dev/null and b/tests/leveldb_dir/geth/nodes/MANIFEST-000027 differ diff --git a/tests/leveldb_dir/geth/transactions.rlp b/tests/leveldb_dir/geth/transactions.rlp new file mode 100755 index 00000000..e69de29b diff --git a/tests/leveldb_dir/history b/tests/leveldb_dir/history new file mode 100644 index 00000000..14199b7e --- /dev/null +++ b/tests/leveldb_dir/history @@ -0,0 +1,4 @@ + +eth.sync +eth +eth.syncing \ No newline at end of file diff --git a/tests/mythril/mythril_leveldb_test.py b/tests/mythril/mythril_leveldb_test.py new file mode 100644 index 00000000..58d18134 --- /dev/null +++ b/tests/mythril/mythril_leveldb_test.py @@ -0,0 +1,37 @@ +import io +import pytest +from contextlib import redirect_stdout +from pathlib import Path + +from mythril.mythril import MythrilLevelDB, MythrilConfig +from mythril.exceptions import CriticalError + +config = MythrilConfig() +config.set_api_leveldb(str(Path(__file__).parent / "../leveldb_dir/geth/chaindata")) + + +def test_leveldb_code_search(): + leveldb_search = MythrilLevelDB(leveldb=config.eth_db) + f = io.StringIO() + with redirect_stdout(f): + leveldb_search.search_db("code#PUSH#") + out = f.getvalue() + assert len(out.split("\n")) == 67 + assert "0xddbb615cb2ffaff7233d8a6f3601621de94795e1" in out + + +def test_leveldb_hash_search_incorrect_input(): + leveldb_search = MythrilLevelDB(leveldb=config.eth_db) + with pytest.raises(CriticalError): + leveldb_search.contract_hash_to_address("0x23") + + +def test_leveldb_hash_search_correct_input(): + leveldb_search = MythrilLevelDB(leveldb=config.eth_db) + f = io.StringIO() + with redirect_stdout(f): + leveldb_search.contract_hash_to_address( + "0x0464e651bcc40de28fc7fcde269218d16850bac9689da5f4a6bd640fd3cdf6aa" + ) + out = f.getvalue() + assert out == "0xddbb615cb2ffaff7233d8a6f3601621de94795e1\n"