C++ winsock hooking

c++ / delphi package - dll injection and api hooking
Post Reply
behelit
Posts: 4
Joined: Tue May 18, 2004 6:40 am
Contact:

C++ winsock hooking

Post by behelit »

could you use madcodehook to hook/inject another process and use that processes winsock send method/s
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

That is possible, but it sounds "bad" to me. Please use madCodeHook only for legal projects! :-x
nildo
Posts: 249
Joined: Mon Mar 22, 2004 11:32 am
Contact:

Post by nildo »

madshi wrote:That is possible, but it sounds "bad" to me. Please use madCodeHook only for legal projects! :-x
Not at all the time.
If you have a socket openned in another process, and if you want to send a Buffer by this Openned Socket, you can not do in our own process, we need to inject a DLL and send messages to the DLL recognize this.

If it is what you want, so you dont need to inject a DLL. Just use the API DuplicateHandle and passing the SocketID as the source parameter, then you could call SEND or RECV (whatever) in your own process.
behelit
Posts: 4
Joined: Tue May 18, 2004 6:40 am
Contact:

Post by behelit »

its not "bad" if its a process you made

that api is perfect thx for the help
but how would you get the socket descriptor
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

If the other process is your own, then I take that "bad" word back... :D

Okay, could you tell us a bit more about why one of your processes wants to use the socket functions of another of your processes? Why can't you implement the socket functions in both processes?

Anyway, there are several possibilities:

(1) Either the non-socket process can ask the socket process to send data for it. You can use SendMessage to send the request or madCodeHook's SendIpcMessage.

(2) Or the non-socket process can copy the socket's process socket (that's nildo's suggestion). Not sure how/whether this works, since I'm not socket expert at all!

(3) Or the non-socket process could execute a function in the context of the socket process (e.g. by using madRemote's RemoteExecute).

(4) Or the non-socket process could inject a dll into the socket process which could then do the sending.
behelit
Posts: 4
Joined: Tue May 18, 2004 6:40 am
Contact:

Post by behelit »

it was something my brother made
ive wanted to learn hooks for awhile so this was a good chance to start
would madshi or someone be able to write a small tutorial on how to use madcodehook even if it has nothing to do with socks
nildo
Posts: 249
Joined: Mon Mar 22, 2004 11:32 am
Contact:

Post by nildo »

Look at HELP and DEMOS.
They will help a lot.
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Yep, nildo is right. Some of the demos are pretty easy to understand and I did my best to document them well. Together with the documentation it should hopefully get you going.
behelit
Posts: 4
Joined: Tue May 18, 2004 6:40 am
Contact:

Post by behelit »

hmm the help page is all in delphi code
nildo
Posts: 249
Joined: Mon Mar 22, 2004 11:32 am
Contact:

Post by nildo »

Delphi to C++ and C++ to Delphi is easy to translate... The HELP shows the teory and How to use. See the Demos for examples of use
Post Reply