Giter Club home page Giter Club logo

osx_runbin's People

Contributors

parchedmind avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

osx_runbin's Issues

Can't compile on 10.6

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$ 

Trace/BPT trap:5?

What's error? How to fix it?

dyld: NSLinkModule() error
dylb: initializer function 0x10000b740 not in mapped image for mytest

Trace/BPT trap: 5

Segmentation Fault on El Capitan

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.