Recent

Author Topic: Http GET syntax  (Read 605 times)

BSaidus

  • Sr. Member
  • ****
  • Posts: 326
  • lazarus 1.8.4 Win8.1 / cross FreeBSD
Http GET syntax
« on: February 20, 2020, 10:29:49 am »
Hello.

I wonder if some one can enlighten me about the GET method of Http Protocol.
I want to write a low level socket program to send GET command to web server
  Syntax like:
Code: Pascal  [Select]
  1.       GET /index.php : host=150.220.25.22
  2.       ....

or where can I get more info.

thanks you in advance.
lazarus 1.8.4 Win8.1 / cross FreeBSD
dhukmucmur vernadh!

lucamar

  • Hero Member
  • *****
  • Posts: 2591
Re: Http GET syntax
« Reply #1 on: February 20, 2020, 11:06:10 am »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.6/FPC 3.0.4 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Thaddy

  • Hero Member
  • *****
  • Posts: 9809
Re: Http GET syntax
« Reply #2 on: February 20, 2020, 12:02:22 pm »
 :) ;D :D Correct.
I am more like donkey than shrek

BSaidus

  • Sr. Member
  • ****
  • Posts: 326
  • lazarus 1.8.4 Win8.1 / cross FreeBSD
Re: Http GET syntax
« Reply #3 on: February 20, 2020, 01:59:24 pm »
:) ;D :D Correct.

 ;D What correct !??

could you give me a little exemple.
lazarus 1.8.4 Win8.1 / cross FreeBSD
dhukmucmur vernadh!

lucamar

  • Hero Member
  • *****
  • Posts: 2591
Re: Http GET syntax
« Reply #4 on: February 20, 2020, 02:50:25 pm »
Read the standard; it's all there. As for code, it shouldn't be too difficult: connect to the server, send the request, get the response and close the connection. I'm sure you can find examples in higher libs: dive into the source of, say, fcl-web and similar and see the examples for fcl-net and alike.

Although why you want to do it with socket programming instead of using a higher level lib is a complete mistery to me :P
« Last Edit: February 20, 2020, 02:53:35 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.6/FPC 3.0.4 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

rvk

  • Hero Member
  • *****
  • Posts: 3952
Re: Http GET syntax
« Reply #5 on: February 20, 2020, 03:08:05 pm »
could you give me a little exemple.
Something like this:
https://forum.lazarus.freepascal.org/index.php/topic,31205.msg200003.html#msg200003

But looking at procedure TFPCustomHTTPClient.SendRequest() from fpc/packages/fcl-web/src/base/fphttpclient.pp might give you more insight.

BSaidus

  • Sr. Member
  • ****
  • Posts: 326
  • lazarus 1.8.4 Win8.1 / cross FreeBSD
Re: Http GET syntax
« Reply #6 on: February 20, 2020, 03:17:43 pm »
Read the standard; it's all there. As for code, it shouldn't be too difficult: connect to the server, send the request, get the response and close the connection. I'm sure you can find examples in higher libs: dive into the source of, say, fcl-web and similar and see the examples for fcl-net and alike.

Although why you want to do it with socket programming instead of using a higher level lib is a complete mistery to me :P

Thank you for your response.
  I know doing it using indy idHttpCLient, synapse http client, FPHttpClient, ICS THttpCli.
I want to write an Http Flooder .
    */ Connect to server,
    */ Send Get request,
    */ disconnect without waiting server to response me.

I write the tool for pentest purpose, not anything other.

So I decided to use TidTCPClient from Indy palette, but the syntax of GET may be so complicated to write (each browser or client sends with different syntax)

This is why I'm aking for Help.


Thnk you.



lazarus 1.8.4 Win8.1 / cross FreeBSD
dhukmucmur vernadh!

lucamar

  • Hero Member
  • *****
  • Posts: 2591
Re: Http GET syntax
« Reply #7 on: February 20, 2020, 03:26:14 pm »
[...] but the syntax of GET may be so complicated to write (each browser or client sends with different syntax)

Not really: any client must use a standard request, using the standard syntax; otherwise the server(s) wouldn't know what to do with it. Of course different clients might send different information in the headers; if nothing else (an unless it's "spoofing") they will each send a different Agent string. But the syntax itself? It must be the standard one. That's what standards are for (at least in the web).
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.6/FPC 3.0.4 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

rvk

  • Hero Member
  • *****
  • Posts: 3952
Re: Http GET syntax
« Reply #8 on: February 20, 2020, 03:29:03 pm »
So I decided to use TidTCPClient from Indy palette, but the syntax of GET may be so complicated to write (each browser or client sends with different syntax)
I don't use Indy... but I can't imagine each browser or client sends the GET differently.
It's a standard so they need to stick to that.
They can, however, send more headers. That depends on your requirements.
(where do you see any differences in the clients???)

The link I provided has the simplest form.
Code: Pascal  [Select]
  1. aSocket.SendString('GET /index.php HTTP/1.1'#13#10'Host: hostname'#13#10#13#10);
or even
Code: Pascal  [Select]
  1. aSocket.SendString('GET /index.php HTTP/1.1'#13#10#13#10);

Thaddy

  • Hero Member
  • *****
  • Posts: 9809
Re: Http GET syntax
« Reply #9 on: February 20, 2020, 05:36:46 pm »
@rvk
Are you sure about the linebreak as #13#10 ? I find that rather disturbing... Protocols tend not to listen to one particular company.... That part is wrong or incomplete:sLinebreak solves this cross-platform.
« Last Edit: February 20, 2020, 05:41:40 pm by Thaddy »
I am more like donkey than shrek

rvk

  • Hero Member
  • *****
  • Posts: 3952
Re: Http GET syntax
« Reply #10 on: February 20, 2020, 05:44:43 pm »
@rvk
Are you sure about the linebreak as #13#10 ? I find that rather disturbing... Protocols tend not to listen to one particular company.... That part is wrong or incomplete.
Yes. According to the standard.

Quote
An HTTP request contains a series of lines that each end with a carriage return and a line feed, represented as either <CR><LF> or \r\n . The rest of the request contains HTTP headers, including a required Host header and, if applicable, a message body. The request ends with a bank line (an extra <CR><LF> or \r\n).

But you could use the standard definition but you need to make sure not to just use linefeed.

Not sending Host in the headers isn't exactly according to the standard but for flooding purposes it will work just fine.

rvk

  • Hero Member
  • *****
  • Posts: 3952
Re: Http GET syntax
« Reply #11 on: February 20, 2020, 10:39:39 pm »
@rvk
Are you sure about the linebreak as #13#10 ? I find that rather disturbing... Protocols tend not to listen to one particular company.... That part is wrong or incomplete:sLinebreak solves this cross-platform.
NO. Don't use sLinebreak !!! It is defined as #10 on Linux while the HTTP standard dictates you need to use #13#10 in ALL uses !! (See my quote in my previous post)



BSaidus

  • Sr. Member
  • ****
  • Posts: 326
  • lazarus 1.8.4 Win8.1 / cross FreeBSD
Re: Http GET syntax
« Reply #12 on: February 21, 2020, 03:21:22 pm »
Thank you for your help and recommendations.
Do you know open source written in Delphi or FPC/lazarus flooders (http, ... ) ??
Most my internet search I found in python and C#.
What's wrong with pascal ??
 :o

lazarus 1.8.4 Win8.1 / cross FreeBSD
dhukmucmur vernadh!

rvk

  • Hero Member
  • *****
  • Posts: 3952
Re: Http GET syntax
« Reply #13 on: February 21, 2020, 03:43:14 pm »
Do you know open source written in Delphi or FPC/lazarus flooders (http, ... ) ??
Most my internet search I found in python and C#.
What's wrong with pascal ??
Nothing.

Maybe it's too advanced for most script-kiddies :)

And when someone wrote this for pen-testing in Pascal, it's not really of useful (or appropriate) to distribute it on the internet.