Jump to content

Recommended Posts

Posted

Hi.
Assume there is a network with 100 users, all of whom share the same IP address to access the internet.
Now, one user runs a program that sends a large number of "POST" commands to a website address at once,
causing the website to become inaccessible! How can this problem be solved?
Since the IP addresses are the same, the IP address cannot be blocked.

Posted
9 minutes ago, WSIINNDA said:

Hi.
Assume there is a network with 100 users, all of whom share the same IP address to access the internet.
Now, one user runs a program that sends a large number of "POST" commands to a website address at once,
causing the website to become inaccessible! How can this problem be solved?
Since the IP addresses are the same, the IP address cannot be blocked.

fMkqlgn.gif

Posted
1 hour ago, WSIINNDA said:

Hi.
Assume there is a network with 100 users, all of whom share the same IP address to access the internet.
Now, one user runs a program that sends a large number of "POST" commands to a website address at once,
causing the website to become inaccessible! How can this problem be solved?
Since the IP addresses are the same, the IP address cannot be blocked.

You can try to disable POST commands on UniGUIServerModuleHTTPCommand

1.

  If (AnsiUpperCase (ARequestInfo.TransferEncoding) = AnsiUpperCase ('chunked'))
  OR (PosEx (AnsiUpperCase ('chunked'),AnsiUpperCase (ARequestInfo.CustomHeaders.Text)) > 0)
  OR (PosEx (AnsiUpperCase ('chunked'),AnsiUpperCase (ARequestInfo.RawHeaders.Text)) > 0)
  then begin
            AResponseInfo.ContentText := 'Disabled POST command';
            Handled := True;
            AResponseInfo.CloseConnection:=true;
            AResponseInfo.CloseSession;
            SaveHTMLLog ('CLOSED SESSION (DISABLED Post.Chunked Encoding: ' 
                      + ', COMMAND: ' + ARequestInfo.Command
                      + ', RAW COMMAND: ' + ARequestInfo.RawHTTPCommand
                      );
          end;
  end;

 

2. or disable POST custom headers

DisabledPOSTHeaders - your list with disabled post headers

    for I := DisabledPOSTHeaders.Count - 1 downto 0 do begin
        if (I <= DisabledPOSTHeaders.Count-1)
        AND (ARequestInfo <> nil)
        AND (ARequestInfo.CustomHeaders <> nil)
        then begin
          If ARequestInfo.CustomHeaders <> nil then begin
            if (PosEx (TRIM (DisabledPOSTHeaders [I]) + ':',ARequestInfo.CustomHeaders.Text) > 0)
            AND (TRIM (DisabledPOSTHeaders [I]) <> '')
            then begin
              TRY
                  AResponseInfo.ContentText := 'Disabled POST headers';
                  Handled := True;
                  AResponseInfo.CloseConnection:=true;
                  AResponseInfo.CloseSession;
                  SaveHTMLLog ('CLOSSED SESSION (DISABLED POST Custom Headers):' + DisabledPOSTHeaders [I]
                              + #13#10 + 'Headers:' + ARequestInfo.CustomHeaders.Text
                              + ', COMMAND: ' + ARequestInfo.Command
                              + ', RAW COMMAND: ' + ARequestInfo.RawHTTPCommand
                      );
              EXCEPT

              END;
                break;
            end;//If
          end;//If ARequestInfo.CustomHeaders.
        end;//If I < DisabledPOSTHeaders.Count

Posted
16 minutes ago, irigsoft said:

You can try to disable POST comands on UniGUIServerModuleHTTPCommand

1.

  If (AnsiUpperCase (ARequestInfo.TransferEncoding) = AnsiUpperCase ('chunked'))
  OR (PosEx (AnsiUpperCase ('chunked'),AnsiUpperCase (ARequestInfo.CustomHeaders.Text)) > 0)
  OR (PosEx (AnsiUpperCase ('chunked'),AnsiUpperCase (ARequestInfo.RawHeaders.Text)) > 0)
  then begin
            AResponseInfo.ContentText := 'Disabled POST command';
            Handled := True;
            AResponseInfo.CloseConnection:=true;
            AResponseInfo.CloseSession;
            SaveHTMLLog ('CLOSED SESSION (DISABLED Post.Chunked Encoding: ' 
                      + ', COMMAND: ' + ARequestInfo.Command
                      + ', RAW COMMAND: ' + ARequestInfo.RawHTTPCommand
                      );
          end;
  end;

 

2. or disable POST custom headers

DisabledPOSTHeaders - your list with disabled post headers

    for I := DisabledPOSTHeaders.Count - 1 downto 0 do begin
        if (I <= DisabledPOSTHeaders.Count-1)
        AND (ARequestInfo <> nil)
        AND (ARequestInfo.CustomHeaders <> nil)
        then begin
          If ARequestInfo.CustomHeaders <> nil then begin
            if (PosEx (TRIM (DisabledPOSTHeaders [I]) + ':',ARequestInfo.CustomHeaders.Text) > 0)
            AND (TRIM (DisabledPOSTHeaders [I]) <> '')
            then begin
              TRY
                  AResponseInfo.ContentText := 'Disable POST headers';
                  Handled := True;
                  AResponseInfo.CloseConnection:=true;
                  AResponseInfo.CloseSession;
                  SaveHTMLLog ('CLOSSED SESSION (DISABLED POST Custom Headers):' + DisabledPOSTHeaders [I]
                              + #13#10 + 'Headers:' + ARequestInfo.CustomHeaders.Text
                              + ', COMMAND: ' + ARequestInfo.Command
                              + ', RAW COMMAND: ' + ARequestInfo.RawHTTPCommand
                      );
              EXCEPT

              END;
                break;
            end;//If
          end;//If ARequestInfo.CustomHeaders.
        end;//If I < DisabledPOSTHeaders.Count

This can't be done; I've tested it before. If I disable "POST," the website won't work.
The code you wrote, I tested the first part; still, the site completely crashes, and I couldn't test the second part.

Posted
7 minutes ago, WSIINNDA said:

This can't be done; I've tested it before. If I disable "POST," the website won't work.
The code you wrote, I tested the first part; still, the site completely crashes, and I couldn't test the second part.

can you share some post commands ?

I see you can freeze your app

Posted
1 minute ago, irigsoft said:

can you share some post commands ?

I see you can freeze your app

The "POST" command itself can be sent in various ways with different headers and so on, meaning there is never a fixed pattern that allows me to say: if a large number of identical commands are received, block them.
I don't know, it seems like a major issue to me, as it can easily disable a web application.

I think it would be better for you to share a website address and see the results.

  • Confused 1
Posted
7 minutes ago, WSIINNDA said:

The "POST" command itself can be sent in various ways with different headers and so on, meaning there is never a fixed pattern that allows me to say: if a large number of identical commands are received, block them.
I don't know, it seems like a major issue to me, as it can easily disable a web application.

I think it would be better for you to share a website address and see the results.

did you try it ?

 

https://stackoverflow.com/questions/5009326/block-http-post-request

https://security.stackexchange.com/questions/268202/how-to-block-a-post-curl-request

 

my second part block list of POST headers, try only this option !

Posted
1 hour ago, WSIINNDA said:

This can't be done; I've tested it before. If I disable "POST," the website won't work.

maybe they want to work and receive POST commands without freezing or blocking

Posted
1 hour ago, Farshad Mohajeri said:

For HyperServer:

image.png

This way it became much better, I tested it and everything was correct.
Only if a user with a shared IP runs the "POST" command repeatedly, no new user will be able to use the website anymore.

  • Administrators
Posted
1 hour ago, WSIINNDA said:

This way it became much better, I tested it and everything was correct.
Only if a user with a shared IP runs the "POST" command repeatedly, no new user will be able to use the website anymore.

Yes, but only if new users are from same IP. The situation will be back to normal after antiflood duration is passed.

  • Like 1
Posted
On 12/26/2025 at 8:17 PM, Farshad Mohajeri said:

Yes, but only if new users are from same IP. The situation will be back to normal after antiflood duration is passed.


@Farshad Mohajeri
 

When the network is configured as a Reverse Proxy or Load Balancer,
the following code unfortunately does not work:

ARequestInfo.RemoteIP;

This means that for all clients, this code displays the same shared IP address, regardless of which ISP the user is using.
All users will have the same IP address.

However, the real IP address of users can be obtained using one of the following two methods:

procedure TUniServerModule.UniGUIServerModuleHTTPCommand(
  ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo;
  var Handled: Boolean);
var
  ClientIP: string;
begin
 ClientIP := '';

 // 1
 ClientIP := ARequestInfo.RawHeaders.Values['X-Forwarded-For'];

 // 2
 if ClientIP = '' then
   begin
     ClientIP := ARequestInfo.RawHeaders.Values['X-Real-IP'];
 end;


 // ClientIP ......
end;

Is it possible in future updates that the above codes could also be included in ARequestInfo.RemoteIP;?
Otherwise, the IP address will not be displayed correctly if the user is using an intermediate server.

Posted

I found an excellent solution for when a large number of requests are received from one IP address, and I want to share it with others.

 

First, in the UniGUIServerModuleHTTPCommand section, you should show the current time to the user in encoded form as a parameter. After the user checks the "I'm not a robot" box, the page reloads with the new parameter. Then, you need to decode the parameter value and check if it is still valid—for this, I have only allowed 5 seconds. As you can see, if it takes more than 5 seconds for the user to click, the page refreshes. This is the best and fastest method I have found to solve this problem.

fhNhRWX.gif

Posted
4 minutes ago, WSIINNDA said:

I found an excellent solution for when a large number of requests are received from one IP address, and I want to share it with others.

 

First, in the UniGUIServerModuleHTTPCommand section, you should show the current time to the user in encoded form as a parameter. After the user checks the "I'm not a robot" box, the page reloads with the new parameter. Then, you need to decode the parameter value and check if it is still valid—for this, I have only allowed 5 seconds. As you can see, if it takes more than 5 seconds for the user to click, the page refreshes. This is the best and fastest method I have found to solve this problem.

fhNhRWX.gif

The advantage of this method is that the user is required to check the "I am not a robot" box at the very beginning. They will not have access to the site until they select this option. After selection, the parameter that allows the user to access the site is only valid for 5 seconds. That is, if the same parameter is entered again, the "I am not a robot" page will reappear. This way, DDoS attacks can easily be prevented.

Posted
8 hours ago, WSIINNDA said:

The advantage of this method is that the user is required to check the "I am not a robot" box at the very beginning. They will not have access to the site until they select this option. After selection, the parameter that allows the user to access the site is only valid for 5 seconds. That is, if the same parameter is entered again, the "I am not a robot" page will reappear. This way, DDoS attacks can easily be prevented.

fight with DDOS, you can try and this: 

 

 

 

  • Confused 1
  • 2 months later...
Posted
On 12/26/2025 at 5:28 PM, Farshad Mohajeri said:

I enabled AntiFlood for Customer Portal:

You will get this when flood is occurred:

 

image.png

@Farshad Mohajeri

The issue in the Uni framework has not been fully resolved, and it is easy to disable the web application by sending too many requests!!!

 

qaAqB4a.png

qaAnyMP.gif

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...