3 # @(#) $Id: ./src/agentlessd/scripts/ssh_asa-fwsmconfig_diff, 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 "ERROR: ssh_asa-fwsmconfig_diff <hostname> <commands>\n";
18 send_user "ERROR: Must be run from /var/ossec\n";
23 # NOTE: this script must be called from within /var/ossec for it to work.
24 set passlist "agentless/.passlist"
25 set hostname [lindex $argv 0]
26 set commands [lrange $argv 1 end]
31 if {[string compare $hostname "test"] == 0} {
32 if {[string compare $commands "test"] == 0} {
37 # Reading the password list.
39 set in [open "$passlist" r]
41 send_user "ERROR: Password list not present (use \"register_host\" first).\n"
45 while {[gets $in line] != -1} {
46 set me [string first "|" $line]
47 set me2 [string last "|" $line]
48 set length [string length $line]
63 set host_list [string range $line 0 $me]
65 set pass_list [string range $line $me $me2]
67 set addpass_list [string range $line $me2 $length]
69 if {[string compare $host_list $hostname] == 0} {
71 set addpass "$addpass_list"
78 if {[string compare $pass "x"] == 0} {
79 send_user "ERROR: Password for '$hostname' not found.\n"
84 # SSHing to the box and passing the directories to check.
86 spawn ssh -c des $hostname
88 send_user "ERROR: Opening connection: $loc_error.\n"
93 "WARNING: REMOTE HOST" {
94 send_user "ERROR: RSA host key for '$hostname' has changed. Unable to access.\n"
97 "*sure you want to continue connecting*" {
99 expect "* password:*" {
103 "Permission denied" {
104 send_user "ERROR: Incorrect password to remote host: $hostname .\n"
108 send_user "ERROR: Timeout while running on host (too long to finish): $hostname .\n"
112 send_user "\nINFO: Starting.\n"
117 "ssh: connect to host*" {
118 send_user "ERROR: Unable to connect to remote host: $hostname .\n"
121 "no address associated with name" {
122 send_user "ERROR: Unable to connect to remote host: $hostname .\n"
125 "*Connection refused*" {
126 send_user "ERROR: Unable to connect to remote host: $hostname .\n"
129 "*Connection closed by remote host*" {
130 send_user "ERROR: Unable to connect to remote host: $hostname .\n"
137 "Permission denied" {
138 send_user "ERROR: Incorrect password to remote host: $hostname .\n"
142 send_user "ERROR: Timeout while running on host (too long to finish): $hostname .\n"
146 send_user "INFO: Starting.\n"
151 send_user "ERROR: Timeout while connecting to host: $hostname . \n"
156 # Going into enable mode.
164 send_user "ERROR: Incorrect enable password to remote host: $hostname .\n"
167 "*rror in authenticatio*" {
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 "term pager 0\r"
194 # Excluding uptime from the output
195 send "show version | grep -v Configuration last| up\r"
196 send "show running-config\r"
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"