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 "ERROR: ssh_asa-fwsmconfig_diff <hostname> <commands>\n";
15 send_user "ERROR: Must be run from /var/ossec\n";
19 # NOTE: this script must be called from within /var/ossec for it to work
20 set passlist "agentless/.passlist"
21 set hostname [lindex $argv 0]
22 set commands [lrange $argv 1 end]
27 if {[string compare $hostname "test"] == 0} {
28 if {[string compare $commands "test"] == 0} {
33 # Read the password list
35 set in [open "$passlist" r]
37 send_user "ERROR: Password list not present (use \"register_host\" first).\n"
41 while {[gets $in line] != -1} {
42 set me [string first "|" $line]
43 set me2 [string last "|" $line]
44 set length [string length $line]
59 set host_list [string range $line 0 $me]
61 set pass_list [string range $line $me $me2]
63 set addpass_list [string range $line $me2 $length]
65 if {[string compare $host_list $hostname] == 0} {
67 set addpass "$addpass_list"
73 if {[string compare $pass "x"] == 0} {
74 send_user "ERROR: Password for '$hostname' not found.\n"
78 # SSH to the box and pass the directories to check
80 spawn ssh -c des $hostname
82 send_user "ERROR: Opening connection: $loc_error.\n"
87 "WARNING: REMOTE HOST" {
88 send_user "ERROR: RSA host key for '$hostname' has changed. Unable to access.\n"
91 "*sure you want to continue connecting*" {
93 expect "* password:*" {
98 send_user "ERROR: Incorrect password to remote host: $hostname .\n"
102 send_user "ERROR: Timeout while running on host (too long to finish): $hostname .\n"
106 send_user "\nINFO: Starting.\n"
111 "ssh: connect to host*" {
112 send_user "ERROR: Unable to connect to remote host: $hostname .\n"
115 "no address associated with name" {
116 send_user "ERROR: Unable to connect to remote host: $hostname .\n"
119 "*Connection refused*" {
120 send_user "ERROR: Unable to connect to remote host: $hostname .\n"
123 "*Connection closed by remote host*" {
124 send_user "ERROR: Unable to connect to remote host: $hostname .\n"
131 "Permission denied" {
132 send_user "ERROR: Incorrect password to remote host: $hostname .\n"
136 send_user "ERROR: Timeout while running on host (too long to finish): $hostname .\n"
140 send_user "INFO: Starting.\n"
145 send_user "ERROR: Timeout while connecting to host: $hostname . \n"
150 # Go into enable mode
158 send_user "ERROR: Incorrect enable password to remote host: $hostname .\n"
161 "*rror in authenticatio*" {
162 send_user "ERROR: Incorrect enable password to remote host: $hostname .\n"
166 send_user "ERROR: Timeout while going to enable mode on host: $hostname .\n"
170 send_user "ok on enable pass\n"
175 send_user "ERROR: Timeout while running enable on host: $hostname .\n"
182 send_user "\nSTORE: now\n"
184 send "term pager 0\r"
186 # Exclude uptime from the output
187 send "show version | grep -v Configuration last| up\r"
188 send "show running-config\r"
194 send_user "ERROR: Timeout while running commands on host: $hostname .\n"
198 send_user "\nINFO: Finished.\n"
203 send_user "ERROR: Unable to finish properly.\n"