For the test case I'm using one from Ghidra's test suite, which is available here
It was compiled on my macOS machine with the following command:
$ clang -o decomp -O1 -g decomp.c -Wall -Wshadow -Wextra -std=c17 -arch arm64eSome metadata:
For the test case I'm using one from Ghidra's test suite, which is available here
It was compiled on my macOS machine with the following command:
$ clang -o decomp -O1 -g decomp.c -Wall -Wshadow -Wextra -std=c17 -arch arm64eSome metadata:
| #!/usr/bin/env python3 | |
| """ | |
| Copyright 2021 Trail of Bits | |
| Licensed under the Apache License, Version 2.0 (the "License"); | |
| you may not use this file except in compliance with the License. | |
| You may obtain a copy of the License at | |
| http://www.apache.org/licenses/LICENSE-2.0 |
| # This file describes the network interfaces available on your system | |
| # For more information, see netplan(5). | |
| network: | |
| version: 2 | |
| renderer: networkd | |
| ethernets: | |
| enp1s0: | |
| addresses: | |
| - 192.168.88.103/24 | |
| gateway4: 192.168.88.1 |
| #!/usr/bin/env python | |
| # Copyright 2017 Ryan Stortz (@withzombies) | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software |
| #!/usr/bin/env python | |
| # Copyright 2017 Ryan Stortz (@withzombies) | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software |
| /* | |
| Copyright (c) 2011, Thomas Dullien | |
| All rights reserved. | |
| Redistribution and use in source and binary forms, with or without | |
| modification, are permitted provided that the following conditions | |
| are met: | |
| Redistributions of source code must retain the above copyright notice, | |
| this list of conditions and the following disclaimer. Redistributions |
| #!/usr/bin/env python | |
| # Copyright 2017 Ryan Stortz (@withzombies) | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # |
| $ python binja_memcpy.py /bin/bash | |
| Analyzing /bin/bash | |
| 100038024 dst:<entry rsi> | |
| src:<entry rdi> | |
| n:<range: -0x80000000 to 0x7fffffff> | |
| 1000380c9 dst:<undetermined> | |
| src:<entry rdi> | |
| n:<range: -0x80000000 to 0x7fffffff> |
| def returnTypedString(): | |
| # type: () -> str | |
| return "lol" | |
| def returnUntypedString(): | |
| return "aww" | |
| a = returnTypedString() | |
| b = returnUntypedString() |
| >>> import binaryninja | |
| >>> bv = binaryninja.BinaryViewType["Mach-O"].open("/bin/ls") | |
| >>> bv.update_analysis_and_wait() | |
| >>> t = bv.parse_type_string("int (*lol)(int one, void* two, size_t three)") | |
| >>> t | |
| (<type: int32_t (*)(int32_t one, void* two, uint64_t three)>, 'lol') | |
| >>> ti = t[0] | |
| >>> dir(ti) | |
| ['__class__', '__del__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'alignment', 'array', 'bool', 'calling_convention', 'can_return', 'const', 'count', 'element_type', 'enumeration', 'enumeration_type', 'float', 'function', 'get_string_after_name', 'get_string_before_name', 'handle', 'has_variable_arguments', 'int', 'modified', 'parameters', 'pointer', 'return_value', 'signed', 'structure', 'structure_type', 'target', 'type_class', 'unknown_type', 'void', 'width'] | |
| >>> ti.return_value |