Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re^2: Proxy in perl

by santosh_wagh (Novice)
on Sep 10, 2012 at 07:15 UTC ( #992685=note: print w/replies, xml ) Need Help??

in reply to Re: Proxy in perl
in thread Proxy in perl

All users are connected to one port switch this port is mirror where i have connected single machine with freebsd operating system.I am using Sniffer::HTTP module to catch the url.i want to block for all users . i dont know how i can do it please find the following codes for your reference

#!/usr/bin/perl use strict; use Net::Pcap; use Sniffer::HTTP; use Net::RawIP; my $VERBOSE = 0; my $sniffer = Sniffer::HTTP->new( callbacks => { request => sub { my ($req,$conn) = @_; my $src = $conn->tcp_connection->src_host; my $sport = $conn->tcp_connection->src_port; my $dst = $conn->tcp_connection->dest_host; my $dport = $conn->tcp_connection->dest_port; my $myurl = $req->uri; if ( $myurl =~ "" ) { system("/usr/bin/perl /myscripts/ $dst $dport $src $sport"); } print "Request: $src:$sport -> $dst:$dport -> $myurl \n"; } }, ); $sniffer->run('alc0'); # uses the "best" default device

code of /usr/bin/perl /myscripts/

use Net::RawIP; $src_host = $ARGV[0]; # The source IP/Hostname $src_port = $ARGV[1]; # The Source Port $dst_host = $ARGV[2]; # The Destination IP/Hostname $dst_port = $ARGV[3]; # The Destination Port. $n = Net::RawIP->new({ ip => { saddr => "$src_host" , daddr => "$dst_host", }, tcp => { source => "$src_port", dest => "$dst_port", rst => 1, }, }); $n->send; $n->ethnew("alc0"); $n->ethset(source => "$src_host", dest => "dst_host" ); $n->ethsend;

Replies are listed 'Best First'.
Re^3: Proxy in perl
by Corion (Pope) on Sep 10, 2012 at 07:26 UTC

    Please learn about TCP, and learn about what Sniffer::HTTP does.

    There is no way to modify the network connection or data using Sniffer::HTTP.

    Have you looked at the HTTP proxy modules on CPAN?

      Thanks for the reply. I had tried with squid ( squid working fine with Inline but not successful with span port ) . I will read HTTP:Proxy but can i block the url using span port. thanks

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://992685]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2018-02-22 13:48 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (293 votes). Check out past polls.