Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Getting backsniff from Cookbook to work under Windows

by rchiav (Deacon)
on Feb 04, 2002 at 15:51 UTC ( [id://143258]=perlquestion: print w/replies, xml ) Need Help??

rchiav has asked for the wisdom of the Perl Monks concerning the following question:

I'm currently in the process of learning more about network programming. In the Perl Cookbook on page 637, there's a script that logs all attempts to connect to local ports. I thought I'd try to get this to run under Windows, but I'm having some difficulty trying to figure out how to get the same functionality that inetd or xinetd provide. Does anyone have any advice or links to information on how you'd implement something like this? I know this is a pretty vague and general question, but I'm not looking for the answer, just where I might start looking for it.

Thanks,
Rich

  • Comment on Getting backsniff from Cookbook to work under Windows

Replies are listed 'Best First'.
Re: Getting backsniff from Cookbook to work under Windows
by gellyfish (Monsignor) on Feb 04, 2002 at 17:22 UTC

    In the first edition of Programming Perl there was an example program called receptionist which provided similar functionality to inetd. Of course it is perl 4 but despite the fact that you would probably do things differently now it is still a good example.

    The examples can be found at ftp://ftp.ora.com/published/oreilly/perl/programming_perl/perl.tar.Z

    Added Later:
    Well of course I started to think about this and wondered how I might do this on windows and I came up with this basic example:

    #!/usr/bin/perl -w use strict; use Socket; use IO::Select; use IO::Socket; my $select = IO::Select->new(); while(<DATA>) { chomp; if ( my $server = IO::Socket::INET->new(LocalPort => $_, Listen => 10, ReuseAddr => 1) ) { $select->add($server); } } while(1) { foreach my $ready ($select->can_read(1)) { my $client = $ready->accept(); print inet_ntoa($client->peeraddr()), " ",$client->sockport(),"\n"; } } __DATA__ 2048 2049 2060

    The ports that you want to monitor are the numbers after the __DATA__ . You can probably take the rest from there :)

    /J\

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (2)
As of 2025-01-23 21:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (67 votes). Check out past polls.