3 # @(#) $Id: ./src/agentlessd/scripts/main.exp, 2011/09/08 dcid Exp $
7 # Copyright (C) 2009 Trend Micro Inc.
10 # This program is a free software; you can redistribute it
11 # and/or modify it under the terms of the GNU General Public
12 # License (version 2) as published by the FSF - Free Software
17 send_user "\nERROR: ssh_integrity_check <hostname> <arguments>\n";
22 # NOTE: this script must be called from within /var/ossec for it to work.
23 set passlist "agentless/.passlist"
24 set sshsrc "agentless/ssh.exp"
25 set susrc "agentless/su.exp"
26 set sshloginsrc "agentless/sshlogin.exp"
27 set sshnopasssrc "agentless/ssh_nopass.exp"
28 set hostname [lindex $argv 0]
29 set args [lrange $argv 1 end]
38 if {[string compare $hostname "test"] == 0} {
39 if {[string compare $args "test"] == 0} {
44 # Checking if the hostname (first argument) is an option.
45 if {[string compare $hostname "use_su"] == 0} {
47 set hostname [lindex $argv 1]
48 set args [lrange $argv 2 end]
50 # Checking if the hostname (first argument) is an option.
51 if {[string compare $hostname "use_sudo"] == 0} {
52 set use_sudo "sudo sh;"
53 set hostname [lindex $argv 1]
54 set args [lrange $argv 2 end]
58 # Reading the password list.
60 set in [open "$passlist" r]
62 send_user "\nERROR: Password list not present (use \"register_host\" first).\n"
66 while {[gets $in line] != -1} {
67 set me [string first "|" $line]
68 set me2 [string last "|" $line]
69 set length [string length $line]
84 set host_list [string range $line 0 $me]
86 set pass_list [string range $line $me $me2]
88 set addpass_list [string range $line $me2 $length]
90 if {[string compare $host_list $hostname] == 0} {
92 set addpass "$addpass_list"
99 if {[string compare $pass "x"] == 0} {
100 send_user "\nERROR: Password for '$hostname' not found.\n"