package S3::Webscan;
# $Id: chapG.sgml,v 1.1.1.1 2003/08/14 00:26:12 ols3 Exp $
use 5.006;
use strict;
use warnings;
use Carp qw(croak);
require Exporter;
our @ISA = qw(Exporter);
use Socket;
use Net::Ping;
# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.
# This allows declaration use S3::Webscan ':all';
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
# will save memory.
our %EXPORT_TAGS = ( 'all' => [ qw(
) ] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw(
);
our $VERSION = '0.02';
# Preloaded methods go here.
sub new {
my $pkg = shift;
my $self = { p => Net::Ping->new('icmp') };
bless($self, $pkg);
return $self;
}
sub pingit {
my ($self, $host, $second)=@_;
return $self->{p}->ping($host, $second);
}
sub printWebServer {
my ($selft, $host)=@_;
socket(FH, PF_INET, SOCK_STREAM, getprotobyname('tcp')) || croak("Socket failed: $!");
my $sin=sockaddr_in(80, inet_aton($host));
if (!connect(FH, $sin)) {
print "Unable to connect to $host.\n";
close(FH); return;
}
my $old_fh=select(FH);
$|=1;
select($old_fh);
print FH "GET / HTTP/1.0\n\n";
while (<FH>) {
if (/^Server: (.+)/) {
print "$host -\> $1\n"; close(FH); return;
}
}
print "$host -> unknow web server type!\n";
}
sub closeping {
my $self=shift;
$self->{p}->close();
}
sub usage {
print <<HERE;
Usage:
-----------------------------------------------------------------
chmod +x ols3webscan.pl
then
./ols3webscan.pl IP
OR
./ols3webscan.pl net/mask
-----------------------------------------------------------------
ex1:
./ols3webscan.pl 10.0.0.1
ex2:
./ols3webscan.pl 10.0.0.0/24 for 1C subnetwork
./ols3webscan.pl 10.0.0.0/25 for 1/2C subnetwork
./ols3webscan.pl 10.0.0.0/26 for 1/4C subnetwork
note:
./ols3webscan.pl 10.0.0.1/32 is same as ./ols3webscan.pl 10.0.0.1
-----------------------------------------------------------------
HERE
exit;
}
sub getnodes {
my ($self, $j)=@_;
if (!$j) { return 1; }
$j == 24 && do { return 253; };
$j == 25 && do { return 126; };
$j == 26 && do { return 61; };
$j == 27 && do { return 29; };
$j == 28 && do { return 13; };
$j == 29 && do { return 5; };
$j == 30 && do { return 1; };
$j == 32 && do { return 1; };
return 1;
}
1;
__END__
#
=head1 NAME
S3::Webscan - Perl extension for scaning web server in your network.
=head1 SYNOPSIS
use S3::Webscan;
=head1 ABSTRACT
S3::Webscan.
=head1 DESCRIPTION
Perl extension for scaning web server in your network.
=head2 EXPORT
None by default.
=head1 SEE ALSO
http://teacher.mdjh.tnc.edu.tw/~ols3/
=head1 AUTHOR
OLS3 <lt>ols3@www.tnc.edu.tw<gt>
=head1 COPYRIGHT AND LICENSE
Copyright 2003 by OLS3
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
|