i'm trying to write a backdoor for windows in ASM. so far i have a sourcefile of 8kb (lot of options). one of the options (spawning a shell) is hard to get to work.
since most people do not know assembly but maybe they know C, i have written a testprogram in C which should spawn the shell. as soon as i have this program working like it should, i am able to finish writing my program.
while (TRUE) { if (ReadFile(hRead,sendbuf,sizeof(sendbuf),&bytesRead,NULL)==0) break; send(clientsock,sendbuf,bytesRead,0); memset(sendbuf,0,sizeof (sendbuf));
}
} }
if you compile and run this program it will listen to port 34567. when connected to the port it starts cmd.exe and redirects the output to the socket.
so far so good, but unfortunately this is about it. the client will receive a command prompt, but when he enters his first command the program hangs in an infinite loop.
my problem is that i do not know how to get the command that is given to cmd.exe (process).
any ideas are highly appreciated
Kind regards,
x^r
Jan 30 2005, 10:31 PM
hi,
I think you need to create another pipe that handles 'hStdInput'
then, recv() the the 'cmds' from sock and WriteFile() them into new pipe.
well, you'r making it a bit complicated like this...
the first one (edited one) you have added several structures which i do not understand yet... it compiles fine, but it will not keep running, so it is not listening like it should.
the other one is more like my way of coding (not too complicated), but i can not compile it. which compiler are you using?
if i use dev-cpp i get the error:
QUOTE
undefined reference to 'WSASocketA@24'
i've added the normal parameter to the linker (libwsock32.a). this parameter normally is sufficient for winsock API's, but appearently not when using WSASocket.
i've tried googling for WSASocket, and all you seem to need is
CODE
#include <winsock2.h>
however, this doesn't work for me
i've tried figuring out the pipes some more, since i might be able to use them with local input and if i manage to do that, then the link to the socket is pretty easy
Kind regards,
and congratz with your membership btw
x^r
Feb 1 2005, 02:34 PM
QUOTE
the first one (edited one) you have added several structures which i do not understand yet... it compiles fine, but it will not keep running, so it is not listening like it should.
I only added a timout on the recv() from socket else it will wait forever, while the cmd.exe might have output waiting...
here it stays running and is listening like it should..
I use Microsoft Visual Studio 6.0 to compile
Greetz x^r
B3T4
Feb 1 2005, 03:39 PM
[in reply to x^r's code]
to fix the problem do :: Project -> Settings -> Link -> Catagory Output -> and fill in as Entr-point-symbol : mainCRTStartup
its should compile fine now
althou i must say the program is in-perfect. It shows a flash of a consolewindow on connection and no output is given.
the console flash thou is easily solved by changing :
to fix the input output thing i dont quite know. I ported the code to Delphi and it all goes smooth except one thing, the shell is spawned inside the window i run it in
:edit: ow, i found out it was because of the change with usesstadhandles and usesshowwindow...
White Scorpion
Feb 1 2005, 06:00 PM
Hi,
well, i've tried with USESHOWWINDOW and with stdhandles, well with stdhandles nothing happens when you connect, and with the following code:
you get an endless loop of spawning CMD.exe processes... i'm glad i had a program in handy which killed all the cmd.exe when i told it to, otherwise i might had to reboot my complete computer to get it to work again
thank god i have a couple of hours spare time tonight, so i will try to figure out how the pipes work without using sockets. if i can manage to get that to work, then i think it won't be a problem getting the sockets involved as well...
passi
Feb 3 2005, 10:06 AM
Sounds like you want the same shell option like NetCat already has. So why not check the code of NetCat? There you'll find the answer I attached ver 1.11NT - good luck!
Btw: You only need the doexec.c
White Scorpion
Feb 3 2005, 08:49 PM
thanks for the idea, but unfortunately i already done that (it was the first thing i did several months ago when i first started with it).
i can't really get enough info out it, it is a bit too complicated / long
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.