Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

NIGGERS !

Name: JEWS ! 2009-09-22 8:15

sup /prog/

i wrote a .so which overrides a function and calls the original function inside (a warper of some kind) , or atleast this is what i should do but ofcourse it doesnt .
is there anyway in C to save the address of a overridden function or do i have to use some dark loader/symboltable hackery ?

sorry for posting this shit on /prog/ but i dont know where to ask and im sure this thread is still better than half of the other ones here .

Name: Anonymous 2009-09-22 8:21

I read your post once, and I'm not sure what you mean. The fact that your topic is NIGGERS ! doesn't help.

Name: Anonymous 2009-09-22 8:23

>>2
hmm , yeah i tried to be funny , i fucked up it seems .

what i mean is i need to call a external function inside a function which has the same name .

Name: Anonymous 2009-09-22 8:43

>>1

alternatively, you can flip burgers at mcdonalds for 10$/hour.

Name: bitches and hoes 2009-09-22 8:44

bitches and hoes

Name: Anonymous 2009-09-22 8:44

*Grabs dick*

Name: Anonymous 2009-09-22 8:46

yes.
http://en.wikipedia.org/wiki/Function_pointer
start here and figure it out for yourself.

Name: Anonymous 2009-09-22 8:46

>>4
i tried , it doesnt work .

Name: Anonymous 2009-09-22 9:52

This thread is now about process management in BASH.

Like, how do I create two child processes?

Name: Anonymous 2009-09-22 9:54

>>9

first things first, why the hell would you want a child, nevermind two? Think with your head for once Anonymous, for christs sake.

Name: Anonymous 2009-09-22 10:06

>>10
In some instances, splitting the working into multiple processes can improve certain processing characteristics. Mainly, it's done in the hope of improving the processing rate.

Name: Anonymous 2009-09-22 10:07

are you trying to write an aimbot or something like that??

Name: Anonymous 2009-09-22 10:09

>>9
process1 &
process2 &

Name: TRUE TRUTH EXPERT !tQq1sLlmuk 2009-09-22 10:24

>>13
process1& && process2&

Name: Anonymous 2009-09-22 10:25

>>10
I don't know what you mean, I'm new to UBUNTU and BASH, sorry.

Name: Anonymous 2009-09-22 11:35

>>1
If I understood your question right, I think what you want is code hooking. There's many ways to do this, I know all kinds of ways to do this on Windows, but don't know enough about *nix internals to write some code that does it(I did see some examples out there in the past, so I could probably find out how, if I needed it), the concepts are generic enough that they can be applied to other platforms or operating systems, so I'll describe them here:

The most general case is when you need need to hook a function so you would intercept it's calls, but at the same time, you'd like to be able to call the original function. To solve this you:
 a. Locate the function(get a pointer to it), Win32 examples:
  i) You already have the pointer - you either do &fun for the code you can access, or you reverse engineered some code and know the address (ex.:0x401000)
  ii) The function is located in a dynamically loaded module, in which case you find the base address of that module (GetModuleHandleA/W) and then add a RVA(Relative Value Address) of your function
  iii) The function is an exported function/API of some module, you use the OS loader's own import resolver (GetProcAddress), or you use knowledge of the executable format(like PE or ELF) to locate the function in the export table of the module.
 b) You hook the function, Methods
  i) For imports/APIs, you could try to locate the function in the Import Address Table, and just save that pointer as old_function_address, then replace that pointer with your new one. You can call old_function_address if needed from your new code.
  ii) For most other code(or just a very reliable hook that would work even if the user resolved the APIs manually), you need to do an overwriting hook, this is most general, and I have no doubt that it would work on other OSes or platforms:
    1)Disassemble about sizeof(long_jump)+==5(on x86)+ bytes from the start of the function
    2)Patch/Assemble Jump {your_function} at that address(E9 XX XX XX XX = size 5 bytes), where xx is a relative value (go look it up in the Intel manuals for x86). Smarter hooking systems/libraries may generate a special trampouline buffer which checks against some locked memory areas and only jumps to your code once the lock is free. This avoids some nasty concurrency bugs.
    3)Generate a trampouline which contains the disassembled first 5+ bytes and a Long jump to the continuing function code. You can call this trampuline whenever you need to call the original function.

Other notes:
- Uninstalling the hook can be done by restoring the IAT if patched, or restoring the patched jump code when code hooking was done.
- Make sure to set memory protection to the buffers you want to write to and restore to original memory protection after you're done. On Windows, see VirtualProtect.
- There are other hooking methods, usually they involve patching tables, like the IAT or the export table(less reliable, for obvious reasons), or some vtables of some objects, or a system descriptor table and so on. There's literally hundreds of methods. The code hooking one is the most generic and reliable for obvious reasons, but it can also be detected by code scanners, so you should know what you're doing.
- On Windows, there are already a couple of such libraries like APIHooks or MadCodeHook(commercial), which are not very hard to use, and save you most of the trouble of doing this by hand, they're also quite reliable and made to be compatible with older Win32 OSes as well as newer ones.
- On Linux and other *nixes, code overwriting should work just fine, as it doesn't depend much on underlying OS APIs, as long as you can write and read other libraries/modules code, you should be able to do it.

I don't know your problem at all OP, so this is just a guess. Some programming languages/implementations offer ways to do hooks and code ADIVISing(wrapping other functions in your own code) which are hundreds of times more friendly then such low-level hacks.

Name: Anonymous 2009-09-22 11:41

im using the "/etc/ld.so.preload" file on linux which essentially just loads a .so into memory .
in my case my function gets loaded .

im still struggling with this , the function pointer method didnt work either .

Name: Anonymous 2009-09-22 11:42

>>16
+5 informative

Name: Anonymous 2011-02-03 4:18

Name: Anonymous 2011-02-18 13:06

dubz

Name: Anonymous 2013-08-18 6:24

check em

Name: Anonymous 2013-08-18 10:36



    lol /prog/ gets so butthurt over a word. what a bunch of pussies.

Name: Anonymous 2013-08-18 16:32

☺☺☺☺☺☺☺☺☺☺☹☻☹☺☺☺☺☺☺☺
☺☺☹☹☹☹☺☺☺☺☹☹☹☺☺☺☺☹☹☹
☺☺☹☻☻☹☺☺☺☺☺☺☺☺☺☺☺☹☻☹
☺☺☹☹☹☹☺☺☺☺☺☹☹☹☺☺☺☹☹☹
☺☺☺☺☺☺☺☺☺☺☺☹☻☹☺☺☺☺☺☺
☺☺☺☺☹☹☹☺☺☺☺☹☹☹☺☺☺☺☺☺
☺☺☺☺☹☻☹☹☺☺☺☺☺☺☺☹☹☹☺☺
☺☺☺☺☹☻☻☹☺☺☺☺☺☺☺☹☻☹☺☺
☺☺☺☺☹☹☹☹☺☺☺☺☺☺☺☹☻☹☺☺
☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☹☹☹☺☺

Name: Anonymous 2013-08-18 16:34


Don't change these.
Name: Email:
Entire Thread Thread List