forked from francisco-monserrat/level0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
level0.pl
executable file
·71 lines (48 loc) · 1.32 KB
/
level0.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/perl
use strict;
use warnings;
use Scalar::Util qw(looks_like_number);
use Error qw(:try);
use RT::Client::REST;
use RT::Client::REST::Ticket;
use Term::ReadKey;
use Term::ReadPassword;
use Term::ReadLine ;
use Net::IP ;
use Cmd ;
use Actions ;
# Variables globales, etc
my $server="http://rt.rediris.es" ;
my $username ;
my $password ;
# Funciones locales
sub input {
my $txt=$_[0] ;
print "$txt" ;
my $lin = <STDIN> ;
if (($lin eq "\n") && (defined $_[1] ) ) {
$lin=$_[1] ; }
else { chomp $lin ; }
return $lin ;
}
## Inicio del código
my $cmd_parser=Cmd->new() ;
my $prompt =" Command ?> " ;
my $term = Term::ReadLine->new('Level 0 for Incident Response') ;
my $linea ;
$server= input ("Servidor RT (defaults to $server )",$server) ;
$username= input ( "introduce el usuario: " ) ;
$password= read_password (' password : ') ;
Actions::load_rules() ;
Actions::login($server,$username,$password) ;
$main::fin=0 ;
while ( $main::fin ==0 ) {
# $linea = $term->readline ($prompt ) ;
# $cmd_parser->YYData->{DATA} = $linea ;
# $cmd_parser->YYParse(yylex=> \&lex) ;
# $cmd_parser->YYData->{DATA} = <STDIN> ;
$linea= $term->readline ($prompt) ;
$cmd_parser->YYData->{DATA} = $linea ;
# $cmd_parser->YYParse(yydebug => 0x1F, YYlex => \&Cmd::cmdlex) ;
$cmd_parser->YYParse( YYlex => \&Cmd::cmdlex) ;
}