flat assembler
Message board for the users of flat assembler.

Index > Windows > Winsock Send Without Closing Connection.

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
Overflowz



Joined: 03 Sep 2010
Posts: 1046
Overflowz 10 Dec 2010, 11:17
drobole
Thanks for replying. I'll look at that and learn that things. BTW Here's my code thats not works good.. just see what I've tried Smile and also, its sending more and more requests and when connection is estabilished and back, its stopping sending packets but I don't know why.. and also P.S I have some commented functions (I was trying much things and I got this code only for now.)
Code:
format PE console 4.0
include 'WIN32AX.INC'  
entry main 

section '.data' data readable writeable  
CR EQU 0x0D  
LF EQU 0x0A  
wsaData WSADATA  
saddr sockaddr_in  
rHost db "127.0.0.1",0
;rHost db "192.168.21.129",0
hSock dd ? 
hThread dd ? 
req db "HEAD / HTTP/1.1",CR,LF,"Connection:Keep-Alive",CR,LF,CR,LF 
sizeof.req = $ - req

section '.code' code readable executable 
proc main
invoke WSACleanup
mov [saddr.sin_family],AF_INET
invoke inet_addr,rHost  
mov [saddr.sin_addr],eax  
invoke htons,80
mov [saddr.sin_port],ax 
;jmp triggerThread
jmp startThread

;proc triggerThread
;     .here:
;     invoke CreateThread,NULL,0,startThread,NULL,NULL,NULL
;     jmp .here
;endp
;
proc startThread
     invoke CreateThread,NULL,0,ddosit,NULL,NULL,hThread
     jmp startThread
     ret
endp
;
;jmp ddosit
proc ddosit
     invoke WSAStartup,0x202,wsaData
     invoke socket,AF_INET,SOCK_STREAM,0
     mov [hSock],eax
     invoke connect,[hSock],saddr,sizeof.sockaddr_in
     invoke send,[hSock],req,sizeof.req,0
     invoke Sleep,100
     invoke closesocket,[hSock]
     invoke WSACleanup
     jmp ddosit
     ;jmp startThread
endp
invoke ExitProcess,0
endp  
section '.idata' import data readable  
library kernel32,'kernel32.dll',ws2_32,'ws2_32.dll'  
        include 'API\KERNEL32.INC'  
        include 'API\WS2_32.INC'    
Post 10 Dec 2010, 11:17
View user's profile Send private message Reply with quote
SFeLi



Joined: 03 Nov 2004
Posts: 138
SFeLi 10 Dec 2010, 14:17
-                                                                               


Last edited by SFeLi on 10 Dec 2010, 19:06; edited 1 time in total
Post 10 Dec 2010, 14:17
View user's profile Send private message Reply with quote
Overflowz



Joined: 03 Sep 2010
Posts: 1046
Overflowz 10 Dec 2010, 18:24
SFeLi
Oh sorry, I'll read that Smile Thank you.
Post 10 Dec 2010, 18:24
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 10 Dec 2010, 20:15
Overflowz,

IIRC Windows (tcpip.sys, to be exact) limits number of outgoing TCP connections per second (around 10? I've patched this already, don't remember exact number). This might not be directly applicable to your problem, though. Add some debug output (or use debugger Wink).
Post 10 Dec 2010, 20:15
View user's profile Send private message Reply with quote
Overflowz



Joined: 03 Sep 2010
Posts: 1046
Overflowz 10 Dec 2010, 21:15
I'm already using debbuger and everytime I'm using debugger.... But I don't see what happening when calling createthread
Post 10 Dec 2010, 21:15
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 12 Dec 2010, 09:42
Overflowz,

View | Threads (or Alt+T), then Open in CPU (Enter). That will give you context of selected thread.

Options | Options... | Debugging | Events | Pause on new thread is another way.
Post 12 Dec 2010, 09:42
View user's profile Send private message Reply with quote
Overflowz



Joined: 03 Sep 2010
Posts: 1046
Overflowz 12 Dec 2010, 12:28
baldr
Oh thank you Smile I know only very basic using of debugger.
Post 12 Dec 2010, 12:28
View user's profile Send private message Reply with quote
drobole



Joined: 03 Nov 2010
Posts: 67
Location: Norway
drobole 15 Dec 2010, 07:07
Is it just me or is there something wrong here?

Im thinking that you dont need to call WSAStartup/WSACleanup more than once. Eg. WSAStartup once before you start making threads, and WSACleanup once at the end just before ExitProcess.

Also, it seems that the startThread proc is recursive, so if I am correct, your program will call startThread continously until the stack is overflowed, or until the OS runs out of available thread handles (That wouldn't take long as the OS can only have like 8k concurrent threads or something like that)

Someone please correct me if I'm wrong here
Post 15 Dec 2010, 07:07
View user's profile Send private message Reply with quote
Overflowz



Joined: 03 Sep 2010
Posts: 1046
Overflowz 15 Dec 2010, 13:39
I'll not open other thread and I'll post here.. I found information about RAW sockets.. and I'm trying to make simple program that sends raw sockets to server but I think it needs other programming style I guess. Can someone explain me what I'm doing wrong or give me some RAW Sockets example on ASM ? Cause I can't find in google.. Only C and Delphi were found. Thank you.
Code:
format PE console 4.0
include 'WIN32AX.INC'
entry main

section '.data' data readable writeable

hSock dd ?
wsaData WSADATA
saddr sockaddr_in
szIp db "127.0.0.1",0
testString db "Testing RAW Sockets..",0
sizeof.testString = $ - testString
szWsa db "Error Initializing Winsock Library.",0
szSock db "Error Creating Socket.",0
szConn db "Error Connecting To Server",0
szTitle db "RAW Sockets Example",0

section '.code' code readable executable

proc main
     invoke WSAStartup,0x202,wsaData
     cmp eax,0
     jnz .wsaError
     invoke socket,AF_INET,SOCK_RAW,255
     cmp eax,-1
     je .sockError
     mov [hSock],eax
     mov [saddr.sin_family],AF_INET
     invoke htons,80
     mov [saddr.sin_port],ax
     invoke inet_addr,szIp
     mov [saddr.sin_addr],eax
     invoke connect,[hSock],saddr,sizeof.sockaddr_in
     cmp eax,0
     jnz .connError
     invoke send,[hSock],testString,sizeof.testString,0
     invoke closesocket,[hSock]
     invoke WSACleanup
     invoke ExitProcess,0
.wsaError:
     invoke MessageBox,0,szWsa,szTitle,MB_OK
     invoke WSACleanup
     invoke ExitProcess,0
.sockError:
     invoke MessageBox,0,szSock,szTitle,MB_OK
     invoke closesocket,[hSock]
     invoke ExitProcess,0
.connError:
     invoke MessageBox,0,szConn,szTitle,MB_OK
     invoke WSACleanup
     invoke ExitProcess,0
endp

section '.idata' import data readable

library user32,'user32.dll',\
        kernel32,'kernel32.dll',\
        ws2_32,'ws2_32.dll'
include 'API\WS2_32.INC'
include 'API\KERNEL32.INC'
include 'API\USER32.INC'
section '.reloc' fixups data readable discardable    

It says everything is OK, library initialized, socket created, connected, sent and I see nobody is connected and no data is sent to server.. (using netcat) whats problem ?
Post 15 Dec 2010, 13:39
View user's profile Send private message Reply with quote
Overflowz



Joined: 03 Sep 2010
Posts: 1046
Overflowz 29 Dec 2010, 20:01
Well, if nobody knows just tell me if it's possible what I'm doing ?
Post 29 Dec 2010, 20:01
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.