LVS
lvs-users
Google
 
Web LinuxVirtualServer.org

[lvs-users] Checking SSH with ldirectord.-

To: lvs-users@xxxxxxxxxxxxxxxxxxxxxx
Subject: [lvs-users] Checking SSH with ldirectord.-
From: "Ariel Liguori" <ariel.security@xxxxxxxxx>
Date: Tue, 25 Nov 2008 11:57:34 -0200
Hi friends, i've attached a new functionality to my ldirectord, the
capability of test if an SSH port is listening and based on that redirect
the trafic or not.
Basically i create a new sub called check_ssh, look up the code and feel
free to correct me if something is worng :)

sub check_ssh {

  use IO::Socket;
  use IO::Select;
  my ($v, $r) = @_;
  my $sock;
  my $s;
  my $buf;
  my $port=(defined $$v{checkport}?$$v{checkport}:$$r{port});
  my $status = 1;

  &ld_debug(2, "Checking ssh server=$$r{server} port=$port");

  unless ($sock = new
IO::Socket::INET(PeerAddr=>$$r{server},PeerPort=>$port,Proto=>'tcp') ){
     service_set($v, $r, "down");
     return 1;
  }

  if($sock)
  {
     service_set($v, $r, "up");
     $status = 0;
  }
  else
  {
     service_set($v, $r, "down");
  }

  $s = IO::Select->new();
  $s->add($sock);
  $s->remove($sock);
  $sock->close;


  return $status;
}

Regards,
---
Ariel M. Liguori
Buenos Aires, Argentina.
http://hacksecurity.com.ar

<Prev in Thread] Current Thread [Next in Thread>