ThreatDetector

 view release on metacpan or  search on metacpan

utils/remote_detect_launcher.pl  view on Meta::CPAN

use warnings;
use File::Path qw(make_path);
use File::Slurp;
use IPC::System::Simple qw(system);
use Term::ANSIColor;
use JSON;

# NOT finished

my $key_path     = "$ENV{HOME}/.ssh/id_rsa.pub";
my $private_key  = "$ENV{HOME}/.ssh/id_rsa";

# Local folders
my $log_dir      = "../remote_logs";
my $output_dir   = "../logs";
make_path($log_dir)  unless -d $log_dir;
make_path($output_dir) unless -d $output_dir;

my @targets = (
    { ip => 'ipAddr',  user => 'username' },
 
);

# Step 1: Ensure SSH key exists
unless (-e $key_path) {
    print colored("No SSH key found, generating...\n", 'yellow');
    system("ssh-keygen -t rsa -b 4096 -f $private_key -N ''");
}

# Step 2: Loop over each target
for my $host (@targets) {
    my ($ip, $user) = ($host->{ip}, $host->{user});
    my $remote      = "$user\@$ip";
    my $remote_path = "/var/log/apache2/access_log";
    my $local_log   = "$log_dir/${ip}_access.log";

    print colored("\nConnecting to $remote...\n", 'cyan');



( run in 0.381 second using v1.01-cache-2.11-cpan-2b1a40005be )