News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Im stuck for years

Started by Farabi, January 28, 2010, 11:24:08 AM

Previous topic - Next topic

Farabi

Hi, sorry wasting your time again

Quote
2) Save the data received by the server to a file

3) Write something like the client network example in that same forum link to get file contents and send to the actual HTTP server

2. How to do that if I am using apache?
3. I created a test server and the data is received
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

oex

You can do that easily with a custom server like in the message here....
http://www.masm32.com/board/index.php?topic=3109.msg24059#msg24059

It's only about 20-30 lines of code to grab the data and save the recv'd data to a file and you dont have the layers of webserver code obscuring what's being received
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

Farabi

Can you please test this code on your program? This code use ws2_32
It worked before, but now not anymore. If it work on your, I guess my AV block all out access.


fInetDownload proc lptz:dword
LOCAL hOpen,hOpenUrl,brcv:dword
LOCAL filesz,mem_handle:dword
LOCAL buff[256]:dword

invoke InternetOpen,CADD("Farabi x.0"),INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0
.if eax==0
xor eax,eax
dec eax
ret
.endif
mov hOpen,eax

invoke InternetOpenUrl,hOpen,lptz,NULL,0,0,0
.if eax!=0
mov hOpenUrl,eax
invoke fInetGetFileSize,hOpenUrl
mov filesz,eax
invoke mAlloc,filesize
mov mem_handle,eax

invoke InternetReadFile,hOpenUrl,mem_handle,filesz,addr brcv
invoke InternetCloseHandle,hOpenUrl
invoke InternetCloseHandle,hOpen

mov eax,mem_handle
mov ecx,filesz
.else
xor eax,eax
dec eax
.endif

ret
fInetDownload endp
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

I used DSL router, PPoE, is that what causing me to unable to access the internet? But how firefox able to?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

oex

OK I have plagerised Danesh's software in true kiddy script style lol....

See attached a server that runs on port 80.... QUIT APACHE.... build it in console mode and run it.... It runs on port 80 and runs on localhost (127.0.0.1) so there should be no problem with the firewall....

Open the attached HTML page and post it to the server....

Finally run your application and try and replicate the output you receive from a HTML page submission through the browser to the test server application....

When it matches 100% you can redirect your submission from 127.0.0.1:80 to your actual file upload page and cleanup any crap that actually isnt used but the browser sends anyway
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

Farabi

Quote from: oex on February 15, 2010, 01:03:48 PM
OK I have plagerised Danesh's software in true kiddy script style lol....

See attached a server that runs on port 80.... QUIT APACHE.... build it in console mode and run it.... It runs on port 80 and runs on localhost (127.0.0.1) so there should be no problem with the firewall....

Open the attached HTML page and post it to the server....

Finally run your application and try and replicate the output you receive from a HTML page submission through the browser to the test server application....

When it matches 100% you can redirect your submission from 127.0.0.1:80 to your actual file upload page and cleanup any crap that actually isnt used but the browser sends anyway

No luck, your server did not respond, even when my browser sent data to the localhost. Did you know how to temporary shutdown the firewall? I guess the problem is on the AVG, but there is no shutdown button.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

oex

I'm not sure I dont use AVG firewall but I guess you could quit the app.... Be carefull though :).... Another possibility is that when you hit submit the page wont progress with that server I sent you the connection will stay open so you will need to switch to the server app to see output
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

statis

Quote from: Farabi on February 04, 2010, 01:15:27 AM
Man, this is very difficult and I got no clue.
I tested using browser to upload to my local host and it works, but when I did that it does not works.


I made this function

Quote
fInet struct
   sock dword 0
   lpszurl dword 0
fInet ends

fRequest struct
   nLenght dword 0
   lpData   dword 0
fRequest ends

.code

fConnectToUrl proc uses esi edi lps:dword,hWnd:dword,lpszHostName:dword,nPort:dword
   LOCAL a:sockaddr_in   
   
   assume esi:ptr fInet
   mov esi,lps
   invoke socket,AF_INET,SOCK_STREAM,0     ; Create a stream socket for internet use
   .if eax!=INVALID_SOCKET
      
       mov [esi].sock,eax
      invoke WSAAsyncSelect,[esi].sock,hWnd,WM_FSOCKET,FD_CONNECT+FD_READ+FD_CLOSE+FD_WRITE+FD_ACCEPT
   .else
      invoke MessageBox,hWnd,CADD("Internet connection initialization error"),CADD("Unknown cause"),MB_OK
   .endif
   
   push lpszHostName
   pop [esi].lpszurl
   
   mov a.sin_family, AF_INET
   invoke htons, nPort
   mov a.sin_port,ax
   invoke gethostbyname, lpszHostName
   .if eax==0
      invoke PERR
      ret
   .endif
   mov eax,[eax+12]
   
   mov eax,[eax]                      ; copy the pointer to the actual IP address into eax
   mov eax,[eax]                      ; copy IP address into eax
   mov a.sin_addr,eax
   
   invoke connect,[esi].sock,addr a,sizeof a
   .if eax==SOCKET_ERROR
      invoke WSAGetLastError 
      ;invoke PERR
   .endif
   assume esi:nothing
   
   ret
fConnectToUrl endp

fSockAddHeader proc uses esi edi lps:dword, lptz:dword,nSize:dword
   LOCAL nReq:dword
   LOCAL nSizeT:dword
   
   mov esi,lps
   
   mov ecx,nSize
   
   .if ecx==-1
      invoke lstrlen,lptz
      push eax
      pop nSizeT
   .else
      push nSize
      pop nSizeT
   .endif
   
   .if [esi].fRequest.lpData==0
      invoke mAlloc,nSizeT
      mov [esi].fRequest.lpData,eax
      push nSizeT
      pop [esi].fRequest.nLenght
      invoke MemCopy,lptz,[esi].fRequest.lpData,[esi].fRequest.nLenght
      ret
   .endif
   
   mov ecx,[esi].fRequest.nLenght
   add ecx,nSizeT
   invoke mAlloc,ecx
   mov nReq,eax
   
   invoke MemCopy,[esi].fRequest.lpData,nReq,[esi].fRequest.nLenght
   mov eax,nReq
   add eax,[esi].fRequest.nLenght
   invoke MemCopy,lptz,eax,nSizeT
   
   invoke GlobalFree,[esi].fRequest.lpData
   push nReq
   pop [esi].fRequest.lpData
   mov eax,[esi].fRequest.nLenght
   add eax,nSizeT
   mov [esi].fRequest.nLenght,eax
   
   xor eax,eax
   
   ret
fSockAddHeader endp

fSockUpload proc uses esi edi lps:dword,lpszObject:dword,lptzFileName:dword
   LOCAL hReq:dword
   LOCAL t:fRequest
   LOCAL fl,filesz:dword
   LOCAL buff[256]:dword
   
   push 0
   pop t.nLenght
   push 0
   pop t.lpData
   
   mov hReq,0
   mov esi,lps
   
   invoke filesize,lptzFileName
   .if eax==-1
      jmp fail
   .endif
   mov filesz,eax
   
   invoke mAlloc,filesz
   mov fl,eax
   
   invoke read_disk_file,lptzFileName,addr fl,addr filesz
   
   invoke fSockAddHeader,addr t,CADD("POST "),-1
   invoke fSockAddHeader,addr t,[esi].fInet.lpszurl,-1
   invoke fSockAddHeader,addr t,CADD("/"),-1
   invoke fSockAddHeader,addr t,lpszObject,-1
   invoke fSockAddHeader,addr t,CADD(" HTTP/1.1"),-1
   invoke fSockAddHeader,addr t,CADD(0dh),1
   
   invoke fSockAddHeader,addr t,CADD("Host: "),-1
   invoke fSockAddHeader,addr t,[esi].fInet.lpszurl,-1
   invoke fSockAddHeader,addr t,CADD(0dh),1
   
   invoke fSockAddHeader,addr t,CADD("User-Agent: Mozilla/5.0"),-1
   invoke fSockAddHeader,addr t,CADD(0dh),1
   
   invoke fSockAddHeader,addr t,CADD("Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"),-1
   invoke fSockAddHeader,addr t,CADD(0dh),1
   
   invoke fSockAddHeader,addr t,CADD("Content-Type: multipart/form-data; boundary=-----1234"),-1
   invoke fSockAddHeader,addr t,CADD(0dh),1
   
   invoke fSockAddHeader,addr t,CADD("Content-Length: "),-1
   invoke dw2a,filesz,addr buff
   invoke fSockAddHeader,addr t,addr buff,-1
   invoke fSockAddHeader,addr t,CADD(0dh),1
   
   
   invoke fSockAddHeader,addr t,CADD("-----1234"),-1
   invoke fSockAddHeader,addr t,CADD(0dh),1
   
   invoke fSockAddHeader,addr t,CADD('Content-Disposition: form-data; name="uploadedfile"; filename="test.inc"'),-1
   invoke fSockAddHeader,addr t,CADD(0dh),1
   
   invoke fSockAddHeader,addr t,CADD('Content-Type: application/octet-stream'),-1
   invoke fSockAddHeader,addr t,CADD(0dh),1
   invoke fSockAddHeader,addr t,CADD(0dh),1
   
   
   invoke fSockAddHeader,addr t,fl,filesz
   invoke fSockAddHeader,addr t,CADD(0dh),1
   
   invoke fSockAddHeader,addr t,CADD("-----1234"),-1
   
   
   invoke send,[esi].fInet.sock,t.lpData,t.nLenght,0
   
   invoke GlobalFree,t.lpData
   
   fail:
   
   ret
fSockUpload endp


hello,

I readed RFC and normally boundary start is -> - - - - - 1234   (-----1234)
boundray data does have 2x-- more -> - -  - - - - - 1234        (-------1234)
and oundary end 2x-- more infirst and later -> - -  - - - - - 1234 - - (-------1234--)

It's correct ?