cylancevulnresearch / osx_runbin Goto Github PK
View Code? Open in Web Editor NEWLicense: BSD 3-Clause "New" or "Revised" License
License: BSD 3-Clause "New" or "Revised" License
run_bin.c:82:41: warning: declaration of 'struct entry_point_command' will not be visible outside of this function
int find_epc(unsigned long base, struct entry_point_command **entry) {
^
run_bin.c:95:17: error: use of undeclared identifier 'LC_MAIN'
if(lc->cmd == LC_MAIN) { //0x80000028
^
run_bin.c:96:11: warning: incompatible pointer types assigning to 'struct entry_point_command *' from 'struct entry_point_command *'
*entry = (struct entry_point_command *)lc;
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
run_bin.c:242:29: warning: incompatible pointer types passing 'struct entry_point_command **' to parameter of type 'struct entry_point_command **'
if(find_epc(execute_base, &epc)) {
^~~~
run_bin.c:82:63: note: passing argument to parameter 'entry' here
int find_epc(unsigned long base, struct entry_point_command **entry) {
^
run_bin.c:247:101: error: incomplete definition of type 'struct entry_point_command'
int(*main)(int, char**, char**, char**) = (int(*)(int, char**, char**, char**))(execute_base + epc->entryoff);
~~~^
run_bin.c:235:10: note: forward declaration of 'struct entry_point_command'
struct entry_point_command *epc;
^
3 warnings and 2 errors generated.
macOS-Snow-Leopard:~ catap$ gcc -o run_bin run_bin.c
run_bin.c:82: warning: 'struct entry_point_command' declared inside parameter list
run_bin.c:82: warning: its scope is only this definition or declaration, which is probably not what you want
run_bin.c: In function 'find_epc':
run_bin.c:94: error: 'for' loop initial declaration used outside C99 mode
run_bin.c:95: error: 'LC_MAIN' undeclared (first use in this function)
run_bin.c:95: error: (Each undeclared identifier is reported only once
run_bin.c:95: error: for each function it appears in.)
run_bin.c: In function 'resolve_symbol':
run_bin.c:121: error: 'for' loop initial declaration used outside C99 mode
run_bin.c:144: error: redefinition of 'i'
run_bin.c:121: error: previous definition of 'i' was here
run_bin.c:144: error: 'for' loop initial declaration used outside C99 mode
run_bin.c: In function 'load_and_exec':
run_bin.c:242: warning: passing argument 2 of 'find_epc' from incompatible pointer type
run_bin.c:247: error: dereferencing pointer to incomplete type
macOS-Snow-Leopard:~ catap$
What's error? How to fix it?
dyld: NSLinkModule() error
dylb: initializer function 0x10000b740 not in mapped image for mytest
Trace/BPT trap: 5
I'm getting a -1 for execute_base on El Capitan:
https://github.com/CylanceVulnResearch/osx_runbin/blob/master/run_bin.c#L230
Debug output (added a printf for verification):
➜ osx_runbin git:(master) ✗ ./run_bin /bin/ls
18446744073709551615
[1] 50963 segmentation fault ./run_bin /bin/ls
➜ osx_runbin git:(master) ✗ lldb ./run_bin
(lldb) target create "./run_bin"
Current executable set to './run_bin' (x86_64).
(lldb) r /bin/ls
Process 50990 launched: './run_bin' (x86_64)
18446744073709551615
Process 50990 stopped
* thread #1: tid = 0x8cf8bd, 0x00000001000015ed run_bin`find_epc(base=18446744073709551615, entry=0x00007fff5fbff478) + 93 at run_bin.c:90, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xf)
frame #0: 0x00000001000015ed run_bin`find_epc(base=18446744073709551615, entry=0x00007fff5fbff478) + 93 at run_bin.c:90
87 printf("%lu\n", base);
88 mh = (struct mach_header_64 *)base;
89 lc = (struct load_command *)(base + sizeof(struct mach_header_64));
-> 90 for(int i=0; i<mh->ncmds; i++) {
91 if(lc->cmd == LC_MAIN) { //0x80000028
92 *entry = (struct entry_point_command *)lc;
93 return 0;
(lldb)
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.