Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: logging internet activity on win32

by Dog and Pony (Priest)
on Sep 03, 2002 at 17:02 UTC ( [id://194814]=note: print w/replies, xml ) Need Help??


in reply to logging internet activity on win32

You can easily build proxies for your web browser with HTTP::Daemon and LWP::UserAgent, since they both uses HTTP::Request and HTTP::Response. Basically, you get the request from HTTP::Daemon, possibly examines it (Data:Dumper is very useful for details), get the page/whatever by using the request in LWP::UserAgent and return the resulting request (again, possibly after examining) to the browser via HTTP::Daemon.

I wish I had some sample code here, but that is at work. Although it should be easy to figure out from the examples and the docs.

Now, I haven't tried this with HTTPS, so I have no idea if it would work. It is also possible you may need to fire up separate proxies for different protocols too, I am not sure offhand and without anything to test with. :)

ZoneAlarm should be no problem, you just allow perl to connect to the outside (it even asks for permission, like TPF, right?).

If this doesn't cut it, you could go more low-level with IO::Socket::INET. Basically, you have open two sockets, one to communicate with the browser, and one to do the same with the internet. Beware though, that now you will need to grok HTTP to do this. The upside is that you can proxy just about anything, here is a small example of a IMAP proxy that does nothing but pass on the data. I intend to do something with this at some point, but for now it will serve as an example on what you can do - principle should be the same. Is probably lousy code though, is just proof of concept to myself... :)

use IO::Socket; my $listener = IO::Socket::INET->new ( Listen => 5, LocalAddr => 'localhost', LocalPort => 143, Proto => 'tcp' ); while(defined(my $connection = $listener->accept)) { print "New connection\n"; my $sender = IO::Socket::INET->new("$host:143"); $connection->print($sender->getline()); ## open LOG, '>>imaplog.txt' or die "$!"; while(my $line = $connection->getline()) { my ($id) = $line =~ /^(\w+)/; ## print LOG "Q: $line"; $sender->print($line); my $total_answer = ''; while(my $answer = $sender->getline()) { ## print LOG "A: $answer"; $total_answer .= $answer; #$connection->print($answer); last if($answer =~ /^$id\s+(OK|NO|BAD)/i); } $connection->print($total_answer); } ## close LOG; $sender->close; $connection->close; undef $sender; undef $connection; }

Maybe, just maybe any of this helps. :)


You have moved into a dark place.
It is pitch black. You are likely to be eaten by a grue.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://194814]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-25 15:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found