Jim's
Tutorials

Fall 2016
course
navigation

11-15-16

Dylan says:
I'm spending these last few weeks writing a paper on modifying running programs on linux -- this will become part of my Plan as well. This week I've been off in my own world reversing a game and writing a memory hack.
The game:
Tools:
Github project:
Will says:
I spent some time modifying programs on OS/X.
Some methods I found were:
1a. Find a function you wish to exploit, then create a dynamic library (dylib) with your own version of that function and link it with t he program as you start it.
Like this:
sudo gcc -shared -fPIC -v -o lib"leet function here".dylib "leet function"
1b. Now inject this function into the process you want to exploit with (this is apparently tricky on mac os/x) one of the following methods:
DYLD_FORCE_FLAT_NAMESPACE=1 DYLD_INSERT_LIBRARIES [then call program]
[compile sources] [compile .o files into a dylib] DYLD_INSERT_LIBRARIES=./[program name]
Forcing flat namespaces is especially important on mac. There is a chance this will break larger programs that have hierarchical headers and namespaces, but the injection will likely not succeed without it.
including this—
  1. define DYLD_INTERPOSE(_replacment,_replacee)__attribute__((used)) static struct{ const void* replacment; const void* replacee; } _interpose_##_replacee__attribute__ ((section ("__DATA,__interpose"))) = { (const void*)(unsigned long)&_replacment, (const void*)(unsigned long)&_replacee };
In the source for your injected dylib function is sometimes important under recent versions of OS X

Sources:
https://github.com/dennis714/RE-for-beginners/tree/master/examples/minesweeper
http://blog.timac.org/?p=761
^that's an old example that will not work anymore
https://blogs.oracle.com/DatabaseEmporium/entry/where_is_ld_preload_under
Defcon stuff below:
https://www.youtube.com/watch?v=EnmoI2dRwX4
https://www.youtube.com/watch?v=0ZPgD-8p9nA
https://www.youtube.com/watch?v=hABj_mrP-no
^ that last one is good to watch just for the humor IMO
http://cs.marlboro.edu/ courses/ fall2016/jims_tutorials/ malware/ 11-15-16
last modified Tuesday November 15 2016 2:05 pm EST