keivan
08-20-2008, 05:59 PM
Simple TCP Port Checker whit perl
#!/Perl/bin
use Tk;
use IO::Socket;
########### Port Checker GUI ####################
# Main Window For GUI
my $mw = MainWindow -> new;
$mw -> title("Port Checker by w3tw0rk");
$mw -> minsize(qw(250 250));
# Menu In Main Window For GUI
my $menu = $mw -> Frame(-background => 'gray') -> pack(-fill => 'x', -side => 'top');
my $file = $menu -> Menubutton(-text => 'File', -background => 'gray') -> pack(-side => 'left');
my $quit = $file -> command(-label => 'Quit', -background => 'gray' , -command => \&quit);
$file -> separator;
my $help = $menu -> Menubutton(-text => 'Help', -background => 'gray') -> pack(-side => 'right');
my $about = $help -> command(-label => 'About', -background => 'gray' , -command => \&about);
$help -> separator;
#Frames
my $top = $mw -> Frame() ->pack(-fill => 'x', -side => 'top'); #Simple frame, at the top of the window
my $bottom = $mw->Frame() ->pack(-fill => 'x', -side => 'bottom');#Simple frame, at the BOTTOM of the window
$lbl_1 = $mw -> Label(-text => "Host:");
my $display = $bottom -> Label(-background => 'white', -width => 35, -height => 8, -borderwidth => 1, -relief => 'sunken', ) -> pack(-pady =>5);
$display->Label(-textvariable => \$done)->pack();
my $entry = $top->Label(-height => 25, -width => 25, -font => 'Verdana', -padx => 1) -> pack(-fill => 'x'); #A text widget
my $status = $bottom->Label(-bg => 'black', -fg => 'white', -text => 'Status: ') -> pack(-fill => 'x'); #A simple label
$IPLabel = $entry -> Menubutton(-text => ' Host') -> pack(-side => 'left');
$PortLABEl = $entry -> Menubutton(-text => 'Port ') -> pack(-side => 'right');
my $enterip = $top -> Entry(-width => 20, -background => 'white', -textvariable => \$hostip) -> pack(-pady => 1, -padx => 3, -side => 'left');
my $enterport = $top -> Entry(-width => 20, -background => 'white', -textvariable => \$port) -> pack(-pady => 1, -padx => 3, -side => 'right');
my $scan = $bottom->Button(-text => 'Scan', -command => \&start, -padx => 5, -pady => 5) -> pack(-fill=>'x'); #A simple button
MainLoop;
#################### Port Checker Main ##########################
while ($port = $portentry) {
sub start {
$sock = new IO::Socket::INET (PeerAddr => $hostip,
PeerPort => $port,
Proto => 'tcp',
timeout => 4);
if ($sock){
close $sock;
$done = "Open"
}
else{
$done = "Closed";
}
}
}
sub quit {
$confirm = $mw -> messageBox(-message => "Really Quit?", -type => "yesno", -icon => "question");
if ($confirm =~ /^[Yy]+/){
sub about {
$confirm = $mw -> messageBox(-message => "Infections Port Checker 2007-2008");
}
exit 0;
}
}
.
#!/Perl/bin
use Tk;
use IO::Socket;
########### Port Checker GUI ####################
# Main Window For GUI
my $mw = MainWindow -> new;
$mw -> title("Port Checker by w3tw0rk");
$mw -> minsize(qw(250 250));
# Menu In Main Window For GUI
my $menu = $mw -> Frame(-background => 'gray') -> pack(-fill => 'x', -side => 'top');
my $file = $menu -> Menubutton(-text => 'File', -background => 'gray') -> pack(-side => 'left');
my $quit = $file -> command(-label => 'Quit', -background => 'gray' , -command => \&quit);
$file -> separator;
my $help = $menu -> Menubutton(-text => 'Help', -background => 'gray') -> pack(-side => 'right');
my $about = $help -> command(-label => 'About', -background => 'gray' , -command => \&about);
$help -> separator;
#Frames
my $top = $mw -> Frame() ->pack(-fill => 'x', -side => 'top'); #Simple frame, at the top of the window
my $bottom = $mw->Frame() ->pack(-fill => 'x', -side => 'bottom');#Simple frame, at the BOTTOM of the window
$lbl_1 = $mw -> Label(-text => "Host:");
my $display = $bottom -> Label(-background => 'white', -width => 35, -height => 8, -borderwidth => 1, -relief => 'sunken', ) -> pack(-pady =>5);
$display->Label(-textvariable => \$done)->pack();
my $entry = $top->Label(-height => 25, -width => 25, -font => 'Verdana', -padx => 1) -> pack(-fill => 'x'); #A text widget
my $status = $bottom->Label(-bg => 'black', -fg => 'white', -text => 'Status: ') -> pack(-fill => 'x'); #A simple label
$IPLabel = $entry -> Menubutton(-text => ' Host') -> pack(-side => 'left');
$PortLABEl = $entry -> Menubutton(-text => 'Port ') -> pack(-side => 'right');
my $enterip = $top -> Entry(-width => 20, -background => 'white', -textvariable => \$hostip) -> pack(-pady => 1, -padx => 3, -side => 'left');
my $enterport = $top -> Entry(-width => 20, -background => 'white', -textvariable => \$port) -> pack(-pady => 1, -padx => 3, -side => 'right');
my $scan = $bottom->Button(-text => 'Scan', -command => \&start, -padx => 5, -pady => 5) -> pack(-fill=>'x'); #A simple button
MainLoop;
#################### Port Checker Main ##########################
while ($port = $portentry) {
sub start {
$sock = new IO::Socket::INET (PeerAddr => $hostip,
PeerPort => $port,
Proto => 'tcp',
timeout => 4);
if ($sock){
close $sock;
$done = "Open"
}
else{
$done = "Closed";
}
}
}
sub quit {
$confirm = $mw -> messageBox(-message => "Really Quit?", -type => "yesno", -icon => "question");
if ($confirm =~ /^[Yy]+/){
sub about {
$confirm = $mw -> messageBox(-message => "Infections Port Checker 2007-2008");
}
exit 0;
}
}
.
