Hi all,
I am having two problems:
1. I can't get the output of the scan to my right text frame :S Have no clue how to do this
2. Everything is quite slow, can I make this faster?
Here is my code:
use IO::Socket;
# DCP Log Analyser GUI t
#use strict;
use Tk;
use Tk::OptionMenu;
use Tk::Frame;
use Tk::TextUndo;
use Tk::Text;
use Tk::Scrollbar;
use Tk::Menu;
use Tk::Menubutton;
use Tk::Adjuster;
use Tk:
ialogbox;
my $main;
my $menubar;
my $file_menu;
$main = MainWindow->new();
$main->geometry('400x300');
$main->title( "DCP Portscanner"
;
$main->Label( - text=>"Version 1.0 by Patrick de Kok",
- relief => "raised"
# Create label and pack bottom
->pack ( - side => 'bottom',
- fill => "x"
;
$menubar = $main->Frame( - relief => "raised",
- borderwidth => 2)
->pack ( - anchor => "nw",
- fill => "x"
;
$file_menu = $menubar->Menubutton( - text => "File",
- underline => 1,
- menuitems => [
[ Button => "Scan!", -command => \&onScan ],
[ Button => "Quit", -command => \&onQuit ]
]
)
-> pack( - side => "left"
;
$file_menu = $menubar->Menubutton( - text => "Help",
- underline => 1,
- menuitems => [
[ Button => "About", -command => \&onAbout ],
[ Button => "Helpfile", -command => \&Print ],
]
)
-> pack( - side => "left",
- fill => "x"
;
#This is the main frame for the program
my $mainframe = $main->Frame
->pack( - side => "left",
- fill => "both"
;
my $first = $mainframe->Frame( - relief =>'groove',
- borderwidth => 2,
)
->pack
->Label(-text => " Input Target IP:",
-width => "20"
)->pack(-side => 'left');
my $second = $mainframe->Entry( - relief =>'groove',
- borderwidth => 2
)
->pack;
$mainframe->Button( - text => 'Execute!',
- command => sub { my $input = $second->get;
&onScan($input);
}
)
->pack;
my $rf = $main->Frame( - relief =>'groove',
- borderwidth => 2,
)
->pack
->Label(-text => " Scan result",
-width => "20"
)->pack(-side => 'left');
my $OutputText = $rf->Text( -height => '100',
-width => '100',
-background=>'white',
-borderwidth => 2,
- relief =>'groove',
);
MainLoop;
# Functions
sub onQuit
{
exit;
}
sub onScan
{
$| = 1; # auto buffer flush
$host = shift;
@ports = (21..25,79,80,110,113,119,135,139,143,389,443,445,1002,1024..1030,1720,5000); # a list of ports
tie *STDOUT, $OutputText;
print "Attemping to connect to ports on host: $host\n";
foreach my $port (@ports)
{
if(my $sock = new IO::Socket::INET (
PeerAddr => $host,
PeerPort => $port,
Proto => 'tcp',
Timeout => '1')) # or die print "Socket Error: $!"
{
print "Succesfully connected to port: $port\n";
}
else
{
print "Could not connect to port: $port\n";
}
}
}
"Free will...is an illusion"
I am having two problems:
1. I can't get the output of the scan to my right text frame :S Have no clue how to do this
2. Everything is quite slow, can I make this faster?
Here is my code:
use IO::Socket;
# DCP Log Analyser GUI t
#use strict;
use Tk;
use Tk::OptionMenu;
use Tk::Frame;
use Tk::TextUndo;
use Tk::Text;
use Tk::Scrollbar;
use Tk::Menu;
use Tk::Menubutton;
use Tk::Adjuster;
use Tk:
my $main;
my $menubar;
my $file_menu;
$main = MainWindow->new();
$main->geometry('400x300');
$main->title( "DCP Portscanner"
$main->Label( - text=>"Version 1.0 by Patrick de Kok",
- relief => "raised"
->pack ( - side => 'bottom',
- fill => "x"
$menubar = $main->Frame( - relief => "raised",
- borderwidth => 2)
->pack ( - anchor => "nw",
- fill => "x"
$file_menu = $menubar->Menubutton( - text => "File",
- underline => 1,
- menuitems => [
[ Button => "Scan!", -command => \&onScan ],
[ Button => "Quit", -command => \&onQuit ]
]
)
-> pack( - side => "left"
$file_menu = $menubar->Menubutton( - text => "Help",
- underline => 1,
- menuitems => [
[ Button => "About", -command => \&onAbout ],
[ Button => "Helpfile", -command => \&Print ],
]
)
-> pack( - side => "left",
- fill => "x"
#This is the main frame for the program
my $mainframe = $main->Frame
->pack( - side => "left",
- fill => "both"
my $first = $mainframe->Frame( - relief =>'groove',
- borderwidth => 2,
)
->pack
->Label(-text => " Input Target IP:",
-width => "20"
)->pack(-side => 'left');
my $second = $mainframe->Entry( - relief =>'groove',
- borderwidth => 2
)
->pack;
$mainframe->Button( - text => 'Execute!',
- command => sub { my $input = $second->get;
&onScan($input);
}
)
->pack;
my $rf = $main->Frame( - relief =>'groove',
- borderwidth => 2,
)
->pack
->Label(-text => " Scan result",
-width => "20"
)->pack(-side => 'left');
my $OutputText = $rf->Text( -height => '100',
-width => '100',
-background=>'white',
-borderwidth => 2,
- relief =>'groove',
);
MainLoop;
# Functions
sub onQuit
{
exit;
}
sub onScan
{
$| = 1; # auto buffer flush
$host = shift;
@ports = (21..25,79,80,110,113,119,135,139,143,389,443,445,1002,1024..1030,1720,5000); # a list of ports
tie *STDOUT, $OutputText;
print "Attemping to connect to ports on host: $host\n";
foreach my $port (@ports)
{
if(my $sock = new IO::Socket::INET (
PeerAddr => $host,
PeerPort => $port,
Proto => 'tcp',
Timeout => '1')) # or die print "Socket Error: $!"
{
print "Succesfully connected to port: $port\n";
}
else
{
print "Could not connect to port: $port\n";
}
}
}
"Free will...is an illusion"