flat assembler
Message board for the users of flat assembler.

Index > Windows > http get

Author
Thread Post new topic Reply to topic
sina



Joined: 18 Aug 2003
Posts: 132
Location: istanbul turkey
sina
does any one have an example code of http downloader ?

for example

i want the file somefile.htm from
http://www.somename.com/somefile.htm

then i will get the values from that file and print some out to screen
Post 17 Apr 2004, 22:14
View user's profile Send private message ICQ Number Reply with quote
coconut



Joined: 02 Apr 2004
Posts: 326
Location: usa
coconut
i believe mad wizard goes over that in his winsock tutorial, the link is around here somewhere
Post 18 Apr 2004, 00:32
View user's profile Send private message Reply with quote
roticv



Joined: 19 Jun 2003
Posts: 374
Location: Singapore
roticv
HTTP File Transfer v1.0 found @ http://www.madwizard.org/view.php?page=downloads
Post 18 Apr 2004, 02:50
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
sina



Joined: 18 Aug 2003
Posts: 132
Location: istanbul turkey
sina
thanks ppl
Post 18 Apr 2004, 14:03
View user's profile Send private message ICQ Number Reply with quote
sina



Joined: 18 Aug 2003
Posts: 132
Location: istanbul turkey
sina
hmm victor the madwizards program is http send Smile i need something simpler anyone finds something pls send info
thanks anyway
Post 21 Apr 2004, 15:11
View user's profile Send private message ICQ Number Reply with quote
Dr.X



Joined: 29 Aug 2003
Posts: 60
Location: St. Petersburg, Fl. USA.
Dr.X
VeSCeRa,
Get the tutorial about sockets from this page.

http://www.madwizard.org/view.php?page=tutorials.contents

In that tutorial there is an example of retrieving a file from a website.
hth
Dr.X
PS: or copy and paste this into a DOS window: Wink
Code:
telnet google.com 80
GET /index.html HTTP/1.1
Host: www.google.com
User-agent: TelnetBrowser
Connection: close


REM the two lines above are actually the enter key.    
Post 21 Apr 2004, 17:35
View user's profile Send private message Visit poster's website Reply with quote
inskipp



Joined: 23 Jun 2003
Posts: 25
Location: Poland
inskipp
Code:
format PE GUI 4.0
entry start

include '%fasminc%/win32a.inc'

b equ byte
section '.code' code readable executable

start:
  invoke  InternetOpen,szAgent,0,0,0,0
        test    eax,eax
     jz      error1
      mov     [InternetHandle],eax
        
    invoke  InternetOpenUrl,eax,szURL,0,0,0,0
   test    eax,eax
     jz      error2
      mov     [FileHandle],eax
    invoke  InternetReadFile,eax,FileBuffer,1023,BytesRead
      test    eax,eax
     jz      error3
      mov     eax,[BytesRead]
     mov     b[FileBuffer+eax],0
 invoke  MessageBox,0,FileBuffer,szAgent,0
error3:
    invoke  InternetCloseHandle,[FileHandle]
error2:
     invoke  InternetCloseHandle,[InternetHandle]
error1:
 invoke  ExitProcess,0


section '.data' data readable writeable

szAgent               db 'Bla bla bla',0
szURL           db 'http://www.google.com/',0
szHeader db 'Host: www.google.com',0

InternetHandle dd ?
FileHandle      dd ?
BytesRead       dd ?
FileBuffer      rb 1024

section '.idata' import data readable writeable

library kernel32,'KERNEL32.DLL',\
        wininet,'WININET.DLL',\
  user32,'USER32.DLL'

import     kernel32,\
 ExitProcess,'ExitProcess'

import       user32,\
   MessageBox,'MessageBoxA'

import        wininet,\
  InternetOpen,'InternetOpenA',\
   InternetReadFile,'InternetReadFile',\
    InternetOpenUrl,'InternetOpenUrlA',\
     InternetCloseHandle,'InternetCloseHandle'
    

I think this is the simplest way to do it.
Post 21 Apr 2004, 19:46
View user's profile Send private message ICQ Number Reply with quote
sina



Joined: 18 Aug 2003
Posts: 132
Location: istanbul turkey
sina
hmm golden replies thanks
Post 25 Apr 2004, 12:40
View user's profile Send private message ICQ Number Reply with quote
sina



Joined: 18 Aug 2003
Posts: 132
Location: istanbul turkey
sina
hmm then what do u suggest for searching for a string in that filebuffer?
for example if the buffer is

"some text in the buffer"

and i want to get the "text"
Post 26 Apr 2004, 17:21
View user's profile Send private message ICQ Number Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2141
Location: Estonia
Madis731
The robust way is to search all buffer for "t" and if found, try if the next character is "e" and so on. If not, you'll fall through and continue searching for "t" until you find a "text" string or reach the end of your buffer. You can even spare time by stopping n charachters (n=len(string)) from the end when there is no way you can find any instances.
Xmpl.
"Some kind of string"
There is no possibility you can come to a "text" when you have reached to "r" char in "stRing".
Hope you get the point Wink
Post 26 Apr 2004, 22:02
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
sina



Joined: 18 Aug 2003
Posts: 132
Location: istanbul turkey
sina
so how to do this
The robust way is to search all buffer for "t" and if found, try if the next character is "e" and so on
Post 27 Apr 2004, 01:30
View user's profile Send private message ICQ Number Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2141
Location: Estonia
Madis731
When buf is your buffer and len is length:
Code:
mov eax,buf
mov ebx,len
Loop:
cmp [eax],"t"
jne Next
add eax,1
cmp [eax],"e"
jne Next
add eax,1
cmp [eax],"x"
jne Next
add eax,1
cmp [eax],"t"
je FoundIt
Next:
add eax,1
sub ebx,1
jnz Loop
jmp DidntFindIt ;obviously when we reach the end, we don't have our string
FoundIt: ;Decide what are you going to do with it
...
    
Post 27 Apr 2004, 08:49
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
roticv



Joined: 19 Jun 2003
Posts: 374
Location: Singapore
roticv
Not coded for speed and no error handlign, may crash if text not found
Code:
mov eax, buf
dec eax
@@:
inc eax
cmp [eax], "test"
jnz @B
    
Post 27 Apr 2004, 11:55
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
sina



Joined: 18 Aug 2003
Posts: 132
Location: istanbul turkey
sina
ok what if i have some buffer like
"some text and 19/10"
the numbers 19 and 10 will be changing and i want to get them
so i will search for "/" in the buffer and get the chars around it with +2 and -2 into strings

any suggestions?
Post 27 Apr 2004, 13:03
View user's profile Send private message ICQ Number Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
what about this? It searches string at [edi] for the first occurrence of the pattern at [esi].
Code:
StrPos:
        stdcall StrLen, edi
        mov     ebx,eax                 ; now ebx holds lenght of the string to search
        stdcall StrLen, esi
        mov     edx,eax                 ; now edx holds length of the pattern string
        lodsb                           ; load first character of the pattern
        mov     ecx,ebx                 ;
        mov     ebx,edx                 ; put str_len(pattern)-1 in ebx
        dec     ebx                     ;
  .search:
        repne   scasb
        jne     .not_found
        cmp     ecx,ebx
        jb      .not_found
        push    edi esi ecx
        or      ebx,ebx                 ; ebx==0 means that we were searching for one
        jz      .got_it                 ; character. We found it, so we stop.
        mov     ecx,ebx
        repe    cmpsb
        jne     .not_match
  .got_it:
        pop     ecx esi edi
        dec     edi
        mov     eax,edi
  .ret:
        pop     edi esi edx ecx ebx
        ret     8
  .not_match:
        pop     ecx esi edi
        jmp     .search
  .not_found:
        xor     eax,eax
        jmp     .ret
    
Post 27 Apr 2004, 13:41
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< 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-2020, Tomasz Grysztar.

Powered by rwasa.