Re: Perl and advanced networking question...
by Illuminatus (Curate) on Jan 29, 2009 at 11:53 UTC
|
- Is there some reason that you can't setup your security box as a proxy, using HTTP::Proxy? Your proxy can then maintain a 'blacklist' of non-redirected requests
- I suppose you could send a RST or a FIN packet to the 'evil box'. As long as you know something about IP, you can send these via a 'raw' IP socket. The standard Socket::* modules handle these operations
| [reply] |
|
|
Any one of you guys have a good example of a socket module sending FIN or RST as mentioned in the thread?
Thank you guys for all the response!!!
| [reply] |
|
|
use strict;
use warnings;
use Net::RawIP;
my $n = Net::RawIP->new(
{
ip => {
saddr => '192.168.1.33',
daddr => '192.168.1.1',
},
tcp => {
source => 80,
dest => 22222,
seq => 12345,
rst => 1,
},
}
);
$n->send;
$n->ethnew("wlan0");
$n->ethset( source => '00:11:22:33:44:55', dest => '00:12:23:34:45:56'
+ );
$n->ethsend;
| [reply] [d/l] |
|
|
As brother zwon has indicated above, the Net::RawIP module (and all its many friends) allows you to drive libpcap -- which appears to be pretty comprehensive...
I think your best bet is to send a RST in both directions -- telling your server, as soon as possible, to give up and telling the client to "go away". I guess you're then going to keep a look out for the "evil" IP address and bounce all further TCP open requests ?
You'll have to concentrate on the sequence numbers, and getting your RST packets in promptly -- I seem to remember that stacks will accept RST even if the sequence number is not exactly as expected... but I cannot remember the range of this tolerance.
On some systems you can open a raw socket: socket $ETH, PF_INET, SOCK_RAW, IPPROTO_RAW (where IPPROTO_RAW is 255). This socket can be used for output only. You can then send entire IP packets (complete with IP header) via the socket. The socket will fill in these IP header fields: (a) checksum; (b) source address, if zero; (c) packet id, if zero; and (d) total length. The socket will then send out the packet as per the destination address. If your system supports it, you may or may not find this easier than getting to grips with Net::RawIP et al.
The enclosed code certainly sends packets as required from my Linux box. YMMV. To do what you want requires picking apart the IP and TCP headers of your "evil" packet, and mungeing up suitable RST packets to send.
| [reply] [d/l] [select] |
Re: Perl and advanced networking question...
by marto (Cardinal) on Jan 29, 2009 at 14:20 UTC
|
| [reply] |
Re: Perl and advanced networking question...
by jethro (Monsignor) on Jan 29, 2009 at 13:49 UTC
|
Nice idea, but your method has some drawbacks you should take into account.
If you block the attacker at the same time you send the RST you gained no additional security. So why bother?
If you don't block at the same time then the attacker can find out exactly which packet caused your sniffer to react and either change his code until your sniffer doesn't react anymore or just ignore any RST packages coming from your webserver
If you don't block and an attacker wants to try out lots of attacks on your web server, the RST package might speed up his attacks since he doesn't have to wait for a time out
| [reply] |
Re: Perl and advanced networking question...
by salva (Canon) on Jan 29, 2009 at 12:19 UTC
|
If you tell the remote client to close the connection, your webserver TCP layer would get really confused. Sending the packets faking the connection close to the webserver would probably be a better solution. | [reply] |
Re: Perl and advanced networking question...
by Anonymous Monk on Jan 29, 2009 at 11:41 UTC
|
nice try in perl, get yourself a firewall to guard webserver | [reply] |
|
|
A firewall will only protect against attacks aimed towards the web server it self, and not the actual web application on it. Some firewalls have basic protection agains the most common attacks towards applications like SQL injection and XSS ... but if you want protection for attacks like the once im referring to, you need a full Web Application Firewall, .. and normal one just wount cut it....
| [reply] |
|
|
| [reply] |
|
|
Great, you already know what to get :)
| [reply] |