quarkslab / arybo Goto Github PK
View Code? Open in Web Editor NEWManipulation, canonicalization and identification of mixed boolean-arithmetic symbolic expressions
License: BSD 3-Clause "New" or "Revised" License
Manipulation, canonicalization and identification of mixed boolean-arithmetic symbolic expressions
License: BSD 3-Clause "New" or "Revised" License
Python bindings fail on macOS with gcc12
:
:info:build /opt/local/var/macports/build/_opt_PPCRosettaPorts_math_libpetanque/libpetanque/work/arybo-1.1.0/petanque/third-party/pybind11/cast.h: In function 'std::string pybind11::detail::error_string()':
:info:build /opt/local/var/macports/build/_opt_PPCRosettaPorts_math_libpetanque/libpetanque/work/arybo-1.1.0/petanque/third-party/pybind11/cast.h:442:36: error: invalid use of incomplete type 'PyFrameObject' {aka 'struct _frame'}
:info:build 442 | " " + handle(frame->f_code->co_filename).cast<std::string>() +
:info:build | ^~
:info:build In file included from /opt/local/Library/Frameworks/Python.framework/Versions/3.11/include/python3.11/Python.h:42:
:info:build /opt/local/Library/Frameworks/Python.framework/Versions/3.11/include/python3.11/pytypedefs.h:22:16: note: forward declaration of 'PyFrameObject' {aka 'struct _frame'}
:info:build 22 | typedef struct _frame PyFrameObject;
:info:build | ^~~~~~
:info:build /opt/local/var/macports/build/_opt_PPCRosettaPorts_math_libpetanque/libpetanque/work/arybo-1.1.0/petanque/third-party/pybind11/cast.h:442:75: error: expected primary-expression before '>' token
:info:build 442 | " " + handle(frame->f_code->co_filename).cast<std::string>() +
:info:build | ^
:info:build /opt/local/var/macports/build/_opt_PPCRosettaPorts_math_libpetanque/libpetanque/work/arybo-1.1.0/petanque/third-party/pybind11/cast.h:442:77: error: expected primary-expression before ')' token
:info:build 442 | " " + handle(frame->f_code->co_filename).cast<std::string>() +
:info:build | ^
:info:build /opt/local/var/macports/build/_opt_PPCRosettaPorts_math_libpetanque/libpetanque/work/arybo-1.1.0/petanque/third-party/pybind11/cast.h:444:29: error: invalid use of incomplete type 'PyFrameObject' {aka 'struct _frame'}
:info:build 444 | handle(frame->f_code->co_name).cast<std::string>() + "\n";
:info:build | ^~
:info:build /opt/local/Library/Frameworks/Python.framework/Versions/3.11/include/python3.11/pytypedefs.h:22:16: note: forward declaration of 'PyFrameObject' {aka 'struct _frame'}
:info:build 22 | typedef struct _frame PyFrameObject;
:info:build | ^~~~~~
:info:build /opt/local/var/macports/build/_opt_PPCRosettaPorts_math_libpetanque/libpetanque/work/arybo-1.1.0/petanque/third-party/pybind11/cast.h:444:64: error: expected primary-expression before '>' token
:info:build 444 | handle(frame->f_code->co_name).cast<std::string>() + "\n";
:info:build | ^
:info:build /opt/local/var/macports/build/_opt_PPCRosettaPorts_math_libpetanque/libpetanque/work/arybo-1.1.0/petanque/third-party/pybind11/cast.h:444:66: error: expected primary-expression before ')' token
:info:build 444 | handle(frame->f_code->co_name).cast<std::string>() + "\n";
:info:build | ^
:info:build /opt/local/var/macports/build/_opt_PPCRosettaPorts_math_libpetanque/libpetanque/work/arybo-1.1.0/petanque/third-party/pybind11/cast.h:445:26: error: invalid use of incomplete type 'PyFrameObject' {aka 'struct _frame'}
:info:build 445 | frame = frame->f_back;
:info:build | ^~
:info:build /opt/local/Library/Frameworks/Python.framework/Versions/3.11/include/python3.11/pytypedefs.h:22:16: note: forward declaration of 'PyFrameObject' {aka 'struct _frame'}
:info:build 22 | typedef struct _frame PyFrameObject;
:info:build | ^~~~~~
Without Python bindings the library builds fine and all tests pass: macports/macports-ports#17103
branch 'fix/triton' the python file 'triton_.py' run error.
it can not find getKind() in AstNode.
The script to reproduce the issue is here:
from arybo.lib import MBA
def f(rdi, rsi, rdx, rcx, r8d):
cse0Mult0 = (2816510611 * r8d)
cse0Add1 = (1338184181 + (2816510611 * rdx))
cse0Add2 = (2956783114 + (1478456685 * r8d))
cse6Add4 = (1 + cse0Mult0)
cse0BitOr0 = (cse0Add2 | (2956783114 + (1478456685 * rdx)))
cse0BitOr1 = ((1338184181 + cse0Mult0) | cse0Add1)
cse1Mult7 = ((cse6Add4 + cse0BitOr0) * ((3107144530 + (1438524315 * cse0BitOr1)) + (4294967295 * r8d)))
cse0BitOr2 = (cse0Add1 | cse0Add2)
cse2Mult13 = ((cse6Add4 + cse0BitOr2) * ((2856442981 + rdx) + (2856442981 * cse0BitOr2)))
cse5Add12 = ((((((cse1Mult7 * 2816510611) + (2115068335 * rdx)) + (1338184181 * cse0BitOr1)) + (2115068335 * r8d)) + (1338184181 * cse0BitOr0)) + (cse2Mult13 * 2816510611))
cse0Mult13 = (1478456685 * rdi)
result = ((((cse5Add12 + 4294967293) + cse0Mult13) + (4294967295 * ((1618598933 + (2956913370 * rdi)) | ((((((1618598933 + (cse1Mult7 * 2956913370)) + (1618598934 * cse0BitOr0)) + (1618598934 * cse0BitOr1)) + (cse2Mult13 * 2956913370)) + (64830626 * r8d)) + (64830626 * rdx))))) + (4294967294 * ((2956783114 + cse0Mult13) | (cse5Add12 + 1338184181))))
return result
mba = MBA(32)
rdi = mba.var('rdi')
rsi = mba.var('rsi')
rdx = mba.var('rdx')
rcx = mba.var('rcx')
r8d = mba.var('r8d')
ret = f(rdi, rsi, rdx, rcx, r8d)
print(ret)
Error is thrown here:
Traceback (most recent call last):
File "ary-test", line 24, in <module>
ret = f(rdi, rsi, rdx, rcx, r8d)
File "ary-test", line 4, in f
cse0Mult0 = (2816510611 * r8d)
File "/home/vagrant/.local/lib/python3.7/site-packages/arybo/lib/mba_if.py", line 183, in __rmul__
return self.__mul__(o)
File "/home/vagrant/.local/lib/python3.7/site-packages/arybo/lib/mba_if.py", line 180, in __mul__
return self.__call_op('mul', o)
File "/home/vagrant/.local/lib/python3.7/site-packages/arybo/lib/mba_if.py", line 158, in __call_op
ret = getattr(self.mba, fname)(self.vec, o)
File "/home/vagrant/.local/lib/python3.7/site-packages/arybo/lib/mba_impl_petanque.py", line 323, in mul_n
self.iadd_lshifted_Y(ret, X, i)
File "/home/vagrant/.local/lib/python3.7/site-packages/arybo/lib/mba_impl_petanque.py", line 234, in iadd_lshifted_Y
carry_new = simplify_inplace(mul_XY + (carry * Xi))
MemoryError: std::bad_alloc
I used a function sample that can be found here.
Should be fixed with 38dd93c
I have tried the getType()
, but it still have another error.
the log said that AttributeError: 'ExprConcat' object has no attribute 'urem'
here is the complete log.
[+] Generating symbolic_expressions/sample4-unprotected.bin.py
[+] Converting symbolic expressions to an LLVM module...
Traceback (most recent call last):
File "./solve-vm.py", line 761, in <module>
retValue = main()
File "./solve-vm.py", line 671, in main
M = generateLLVMExpressions(ctx, 0)
File "./solve-vm.py", line 623, in generateLLVMExpressions
e = tritonexprs2arybo(exprs)
File "~/.local/lib/python2.7/site-packages/arybo/tools/triton_.py", line 169, in tritonexprs2arybo
e = tritonast2arybo(e.getAst(), True, False, context)
File "~/.local/lib/python2.7/site-packages/arybo/tools/triton_.py", line 36, in tritonast2arybo
v = next(children)
File "~/.local/lib/python2.7/site-packages/arybo/tools/triton_.py", line 30, in <genexpr>
children = (tritonast2arybo(c,use_exprs,use_esf,context) for c in children_)
File "~/.local/lib/python2.7/site-packages/arybo/tools/triton_.py", line 60, in tritonast2arybo
v = next(children)
File "~/.local/lib/python2.7/site-packages/arybo/tools/triton_.py", line 30, in <genexpr>
children = (tritonast2arybo(c,use_exprs,use_esf,context) for c in children_)
File "~/.local/lib/python2.7/site-packages/arybo/tools/triton_.py", line 139, in tritonast2arybo
return reduce(binop, children)
File "~/.local/lib/python2.7/site-packages/arybo/tools/triton_.py", line 132, in <lambda>
TAstN.BVUREM: lambda x,y: x.urem(y),
AttributeError: 'ExprConcat' object has no attribute 'urem'
Command exited with non-zero status 1
Originally posted by @windy1946 in https://github.com/quarkslab/arybo/issue_comments#issuecomment-456111753
Trying to use Arybo in Windows with Triton, since Triton only support Python 2.7, I hope Arybo can fix Python 2.7 support in Windows
with the exception of Python 2 not available under Windows
https://pythonhosted.org/arybo/setup.html
Steps to reproduce in Windows:
building 'pytanque' extension ... include\pa/exprs.h(30) : fatal error C1083: Cannot open include file: 'cstdint': No such file or directory
Thanks
Hi, I think you should support the new design of Triton in Python examples of Arybo.
https://github.com/JonathanSalwan/Triton/tree/master/src/examples/python
https://github.com/JonathanSalwan/Triton/releases
I noticed one example using older version of Triton API as shown below:
arybo/examples/triton_ida_patch.py
Line 34 in 89d9a42
According to JonathanSalwan/Triton#689, buildSymbolicRegister
has been renamed to getRegisterAst
.
Other examples might be affected this.
Hi:
For me it seems FindTBB()'s library has been used and linked, but it's header search path is not.
I had to add target_include_directories(petanque PUBLIC ${TBB_INCLUDE_DIRS})
for it to pick up TBB
Hi,
I am currently trying to transform this expression into an arybo expression:
(((((((- (((((((((((((((- x) & 0xffffffff) + 0x2C) & 0xffffffff) & ((((((- x) & 0xffffffff) + 0x2C) & 0xffffffff) | 0xC4) & 0xffffffff)) & 0xffffffff) ^ ((x + 0xFFFFFFD4) & 0xffffffff)) & 0xffffffff) + 0x80403064) & 0xffffffff) ^ 0xED) & 0xffffffff) | 0x403053) & 0xffffffff) & 0xff)) & 0xff) + 0x7E) & 0xff) & 0xff) << 0) | ((0x0 & 0xffffff) << 8))
With these instructions:
from arybo.lib import MBA
def transform(x):
return (((((((- (((((((((((((((- x) & 0xffffffff) + 0x2C) & 0xffffffff) & ((((((- x) & 0xffffffff) + 0x2C) & 0xffffffff) | 0xC4) & 0xffffffff)) & 0xffffffff) ^ ((x + 0xFFFFFFD4) & 0xffffffff)) & 0xffffffff) + 0x80403064) & 0xffffffff) ^ 0xED) & 0xffffffff) | 0x403053) & 0xffffffff) & 0xff)) & 0xff) + 0x7E) & 0xff) & 0xff) << 0) | ((0x0 & 0xffffff) << 8))
mba = MBA(32)
x = mba.var('x')
print transform(x)
But apparently, it somehow runs into an infinity loop as it run on 100% cpu for ~10 minutes until I killed the process.
['__add__', '__and__', '__class__', '__cmp__', '__coerce__', '__delattr__', '__div__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__iadd__', '__iand__', '__idiv__', '__ilshift__', '__imod__', '__imul__', '__init__', '__invert__', '__ior__', '__irshift__', '__isub__', '__ixor__', '__le__', '__lshift__', '__lt__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__', '__radd__', '__rand__', '__rdiv__', '__reduce__', '__reduce_ex__', '__repr__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__rrshift__', '__rshift__', '__rsub__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__xor__', 'equalTo', 'evaluate', 'getBitvectorMask', 'getBitvectorSize', 'getChildren', 'getHash', 'getKind', 'getParents', 'getValue', 'isLogical', 'isSigned', 'isSymbolized', 'setChild']
Traceback (most recent call last):
File "./solve-vm.py", line 760, in <module>
retValue = main()
File "./solve-vm.py", line 670, in main
M = generateLLVMExpressions(ctx, 0)
File "./solve-vm.py", line 623, in generateLLVMExpressions
e = tritonexprs2arybo(exprs)
File "/home/sudhakar/.virtualenvs/sym/local/lib/python2.7/site-packages/arybo/tools/triton_.py", line 168, in tritonexprs2arybo
e = tritonast2arybo(e.getAst(), True, False, context)
File "/home/sudhakar/.virtualenvs/sym/local/lib/python2.7/site-packages/arybo/tools/triton_.py", line 31, in tritonast2arybo
children_ = e.getChilds()
Although the version here in working fine. Just a heads up.
Trying to go from Triton AST to LLVM IR by running some examples but getting unsupported node type 79
for BVSMOD
Is it possible to support this in arybo or is there a workaround?
Hi, I install Arybo via pip and Python 3.6.5 32bit on Windows and receive this error:
C:\Program Files (x86)\python36-32\include\pyconfig.h(174): error C2371: 'ssize_t': redefinition; different basic types
include\pa/compat.h(32): note: see declaration of 'ssize_t'
After I comment the lines defining ssize_t in pyconfig.h, I could install Arybo via pip.
Traceback (most recent call last):
File "./solve-vm.py", line 760, in <module>
retValue = main()
File "./solve-vm.py", line 670, in main
M = generateLLVMExpressions(ctx, 0)
File "./solve-vm.py", line 625, in generateLLVMExpressions
M = to_llvm_function(e,[var.v])
File "build/bdist.linux-x86_64/egg/arybo/lib/exprs_asm.py", line 201, in to_llvm_function
RuntimeError: llvmlite module unavailable! can't assemble to LLVM IR...
Installing llvmlite fixes this problem.
However it is not listed as a dependency.
Title, results in :
AttributeError: module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecation
ERROR: Intel TBB NOT found!
-- Looked for Threading Building Blocks in /opt/intel/tbb;/usr/local/include;/usr/include
I have TBB installed:
$ pkg info | grep tbb
onetbb-2021.3.0 Library that provides thread building blocks
Version: 1.1.0
FreeBSD 13
Hi,
I'm trying to install branch feature/exprs of Arybo and I'm getting the following error when I run the command to install pytanque: sudo pip install pytanque
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-3EsubV/pytanque/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-nseUJr-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-3EsubV/pytanque/
Any ideas of how I could get passed this error or successfully install pytanque?
Thanks,
Sebastian
Thank you for building such a brilliant tool.
It seems that app_inverse does not support expressions with two or more symbols.
For example:
from arybo.lib import MBA
from arybo.tools import app_inverse
mba = MBA(32)
a = mba.var('a')
b = mba.var('b')
t = a & b
F = t.vectorial_decomp([a,b])
app_inverse(F) # returns None
Is there any workaround for this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.