Last active
October 17, 2022 15:47
-
-
Save mfornos/7848c7d9d67eefe0e41418981a52212d to your computer and use it in GitHub Desktop.
Revisions
-
mfornos revised this gist
Oct 17, 2022 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -27,6 +27,7 @@ def hasName(name): # Ask! # * has a start section # * has custom section named 'sourceMappingURL' # * imports declare memory after functions isAsk = bool( imports[0].kind != 'memory' and start @@ -36,6 +37,8 @@ def hasName(name): # Ink! # * no custom sections # * no start section # * imports declare memory after functions isInk = bool( imports[0].kind != 'memory' and not start @@ -49,4 +52,3 @@ def hasName(name): Ask! = {isAsk} Sol = {isSolang} """) -
mfornos revised this gist
Oct 17, 2022 . 1 changed file with 23 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ ❯ python3 contract-lang-detect.py < blobs/flipper.ink.wasm Detection results ----------------- Ink! = True Ask! = False Sol = False ❯ python3 contract-lang-detect.py < blobs/flipper.ask.wasm Detection results ----------------- Ink! = False Ask! = True Sol = False ❯ python3 contract-lang-detect.py < blobs/flipper.sol.wasm Detection results ----------------- Ink! = False Ask! = False Sol = True -
mfornos renamed this gist
Oct 17, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
mfornos revised this gist
Oct 17, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
Binary file not shown. -
mfornos created this gist
Oct 17, 2022 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,52 @@ import sys from ppci import wasm m = wasm.Module(sys.stdin.buffer.read()) sections = m.get_definitions_per_section() imports = sections['import'] start = sections['start'] customs = sections['custom'] mem = next(filter(lambda x : x.kind == 'memory', imports)) def hasName(name): lambda x : x.name == name # Tentative heuristics # (!) NOT tested with a reasonable sample set of binaries # Solang # * emits memory as the first import # * has custom sections named 'name' and 'producers' isSolang = bool( imports[0].kind == 'memory' and not start and customs and any(filter(hasName('name'), customs)) ) # Ask! # * has a start section # * has custom section named 'sourceMappingURL' isAsk = bool( imports[0].kind != 'memory' and start and customs and any(filter(hasName('sourceMappingURL'), customs)) ) # Ink! # * no custom sections isInk = bool( imports[0].kind != 'memory' and not start and not customs ) print(f""" Detection results ----------------- Ink! = {isInk} Ask! = {isAsk} Sol = {isSolang} """)