6 # Copyright (C) 2009 Trend Micro Inc.
9 # This program is a free software; you can redistribute it
10 # and/or modify it under the terms of the GNU General Public
11 # License (version 2) as published by the FSF - Free Software
16 send_user "ERROR: ssh_pixconfig_diff <hostname> <commands>\n";
21 # NOTE: this script must be called from within /var/ossec for it to work.
22 set passlist "agentless/.passlist"
23 set hostname [lindex $argv 0]
24 set commands [lrange $argv 1 end]
29 if {[string compare $hostname "test"] == 0} {
30 if {[string compare $commands "test"] == 0} {
35 # Reading the password list.
37 set in [open "$passlist" r]
39 send_user "ERROR: Password list not present (use \"register_host\" first).\n"
43 while {[gets $in line] != -1} {
44 set me [string first "|" $line]
45 set me2 [string last "|" $line]
46 set length [string length $line]
61 set host_list [string range $line 0 $me]
63 set pass_list [string range $line $me $me2]
65 set addpass_list [string range $line $me2 $length]
67 if {[string compare $host_list $hostname] == 0} {
69 set addpass "$addpass_list"
76 if {[string compare $pass "x"] == 0} {
77 send_user "ERROR: Password for '$hostname' not found.\n"
82 # SSHing to the box and passing the directories to check.
86 send_user "ERROR: Opening connection: $loc_error.\n"
91 "WARNING: REMOTE HOST" {
92 send_user "ERROR: RSA host key for '$hostname' has changed. Unable to access.\n"
95 "*sure you want to continue connecting*" {
97 expect "* password:*" {
101 "Permission denied" {
102 send_user "ERROR: Incorrect password to remote host: $hostname .\n"
106 send_user "ERROR: Timeout while running on host (too long to finish): $hostname .\n"
110 send_user "\nINFO: Starting.\n"
115 "ssh: connect to host*" {
116 send_user "ERROR: Unable to connect to remote host: $hostname .\n"
119 "no address associated with name" {
120 send_user "ERROR: Unable to connect to remote host: $hostname .\n"
123 "*Connection refused*" {
124 send_user "ERROR: Unable to connect to remote host: $hostname .\n"
127 "*Connection closed by remote host*" {
128 send_user "ERROR: Unable to connect to remote host: $hostname .\n"
135 "Permission denied" {
136 send_user "ERROR: Incorrect password to remote host: $hostname .\n"
140 send_user "ERROR: Timeout while running on host (too long to finish): $hostname .\n"
144 send_user "INFO: Starting.\n"
149 send_user "ERROR: Timeout while connecting to host: $hostname . \n"
155 if {[string compare $addpass ""] != 0} {
156 # Going into enable mode.
164 send_user "ERROR: Incorrect enable password to remote host: $hostname .\n"
167 "*rror - incorrect password*" {
168 send_user "ERROR: Incorrect enable password to remote host: $hostname .\n"
172 send_user "ERROR: Timeout while going to enable mode on host: $hostname .\n"
176 send_user "ok on enable pass\n"
181 send_user "ERROR: Timeout while running enable on host: $hostname .\n"
190 send_user "\nSTORE: now\n"
192 send "skip-page-display\r"
195 # Excluding uptime from the output
202 send_user "ERROR: Timeout while running commands on host: $hostname .\n"
206 send_user "\nINFO: Finished.\n"
211 send_user "ERROR: Unable to finish properly.\n"