App-Hack-Exe
view release on metacpan or search on metacpan
lib/App/Hack/Exe.pm view on Meta::CPAN
print $knocked[-1];
if (@ports) {
print $";
}
$self->_sleep(0.2);
}
say '';
return;
}
sub _prompt {
my $self = shift;
my $hostname = shift;
$self->_sleep(0.5);
my $prompt = "root\@$hostname:~# ";
print $prompt;
# Wait for the user to press Ctrl-d
while (-t STDIN && <STDIN>) {
print $prompt;
}
return;
}
sub _sleep {
my ($self, @args) = @_;
if ($self->{no_delay}) {
@args = (0);
}
return sleep @args;
lib/App/Hack/Exe.pm view on Meta::CPAN
croak('No targets specified.');
}
local $| = 1;
print _colored_demon();
$self->_get_ip($hostname);
$self->_launchproxy;
$self->_chainproxies;
$self->_portknock;
$self->_w00tw00t;
$self->_prompt($hostname);
say 'Done';
return;
}
=head1 AUTHOR
Dan Church (h3xx<attyzatzat>gmx<dottydot>com)
=head1 LICENSE AND COPYRIGHT
use Symbol qw/ gensym /;
# Control for this env being set
local $ENV{NO_COLOR};
require App::Hack::Exe;
my $he = App::Hack::Exe->new(no_delay => 1);
my ($errout) = capture_merged {
# Close prompt immediately
local *STDIN = gensym();
$he->run('localhost');
};
like($errout, qr/^\e\[31m/,
q{Demon should be colorized red}
);
like($errout, qr/\e\[33mDIE\e\[31m/,
q{Demon's eyes should be colored yellow}
);
like($errout, qr/\e\[33mHUMAN\e\[31m/,
t/feature-ports.t view on Meta::CPAN
use Symbol qw/ gensym /;
require App::Hack::Exe;
my $he = App::Hack::Exe->new(
no_delay => 1,
ports => [ 999, 888 ],
);
my ($errout) = capture_merged {
# Close prompt immediately
local *STDIN = gensym();
$he->run('localhost');
};
like($errout, qr/999,888/,
'port numbers from constructor should be used'
);
$he = App::Hack::Exe->new(
no_delay => 1,
ports => [ qw/ foo bar / ],
);
($errout) = capture_merged {
# Close prompt immediately
local *STDIN = gensym();
$he->run('localhost');
};
like($errout, qr/foo,bar/,
'port numbers should be arbitrary strings'
);
t/feature-proxies.t view on Meta::CPAN
use Symbol qw/ gensym /;
require App::Hack::Exe;
my $he = App::Hack::Exe->new(
no_delay => 1,
proxies => [qw/ MOO OOM /],
);
my ($errout) = capture_merged {
# Close prompt immediately
local *STDIN = gensym();
$he->run('localhost');
};
like($errout, qr/MOO>OOM/,
'proxies from constructor should be used'
);
t/no-color.t view on Meta::CPAN
plan('no_plan');
use Capture::Tiny 'capture_merged';
use Symbol qw/ gensym /;
require App::Hack::Exe;
my $he = App::Hack::Exe->new(no_delay => 1);
local $ENV{NO_COLOR};
my ($errout) = capture_merged {
# Close prompt immediately
local *STDIN = gensym();
$he->run('localhost');
};
like($errout, qr/\e\[/,
'Color escapes should output when NO_COLOR is unset'
);
local $ENV{NO_COLOR} = 1;
($errout) = capture_merged {
# Close prompt immediately
local *STDIN = gensym();
$he->run('localhost');
};
unlike($errout, qr/\e\[/,
'No color escapes should output when NO_COLOR is unset'
);
# Test simulating one host
@args = ('localhost');
($stdout, $stderr, $ret) = _run_script(@args);
is($ret, 0,
"script (@args) should exit 0"
);
like($stdout, qr/COMPLETE/,
"script output (@args) should contain COMPLETE"
);
like($stdout, qr/root\@localhost/,
"script output (@args) should show a prompt"
);
like($stdout, qr/\n$/,
"script output (@args) should end with a newline"
);
is($stderr, '',
"script (@args) should not output on stderr"
);
# Help message tests
@args = ('--help');
( run in 1.492 second using v1.01-cache-2.11-cpan-6aa56a78535 )