5 # Copyright (C) 2009 Trend Micro Inc.
8 # This program is a free software; you can redistribute it
9 # and/or modify it under the terms of the GNU General Public
10 # License (version 2) as published by the FSF - Free Software
14 send_user "\nERROR: ssh_integrity_check <hostname> <arguments>\n";
18 # NOTE: this script must be called from within /var/ossec for it to work
19 set passlist "agentless/.passlist"
20 set sshsrc "agentless/ssh.exp"
21 set susrc "agentless/su.exp"
22 set sshloginsrc "agentless/sshlogin.exp"
23 set sshnopasssrc "agentless/ssh_nopass.exp"
24 set hostname [lindex $argv 0]
25 set args [lrange $argv 1 end]
33 if {[string compare $hostname "test"] == 0} {
34 if {[string compare $args "test"] == 0} {
39 # Check if the hostname (first argument) is an option
40 if {[string compare $hostname "use_su"] == 0} {
42 set hostname [lindex $argv 1]
43 set args [lrange $argv 2 end]
45 # Check if the hostname (first argument) is an option
46 if {[string compare $hostname "use_sudo"] == 0} {
47 set use_sudo "sudo sh;"
48 set hostname [lindex $argv 1]
49 set args [lrange $argv 2 end]
52 # Read the password list
54 set in [open "$passlist" r]
56 send_user "\nERROR: Password list not present (use \"register_host\" first).\n"
60 while {[gets $in line] != -1} {
61 set me [string first "|" $line]
62 set me2 [string last "|" $line]
63 set length [string length $line]
78 set host_list [string range $line 0 $me]
80 set pass_list [string range $line $me $me2]
82 set addpass_list [string range $line $me2 $length]
84 if {[string compare $host_list $hostname] == 0} {
86 set addpass "$addpass_list"
93 if {[string compare $pass "x"] == 0} {
94 send_user "\nERROR: Password for '$hostname' not found.\n"