Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/expect -f
- # This script needs 5 arguments to connect to remote ASA:
- # username = asa username
- # password = Password of ASA
- # ipaddr = IP Addreess of ASA
- # ipshun = ip being shunned on the ASA
- # firewallpass = the password to enable on the ASA
- #------------------------------
- # SET VARIABLES
- set username USERNAME
- set password PASSWORD
- set ipaddr IP
- set ipshun [lindex $argv 1]
- set no [lindex $argv 2]
- set timeout -1
- set firewallpass ENABLE
- # CONNECTION ATTEMPT
- spawn ssh $username@$ipaddr
- match_max 100000
- # LOOK FOR PASSWORD PROMPT
- expect "*?assword:*"
- # SEND PASSWORD $password
- send -- "$password\r"
- #LOOK FOR PROMPT
- expect "ASA-FW>"
- #GO INTO ENABLE MODE
- send -- "enable\r"
- #GET ENABLE PASSWORD PROMPT
- expect "*?assword:*"
- #SEND ENABLE PASSWORD
- send -- "$firewallpass\r"
- #LOOK FOR PROMPT
- expect "ASA-FW#"
- #GO INTO CONFIG MODE
- send -- "config t\r"
- #LOOK FOR PROMPT
- expect "ASA-FW"
- #SHUN IP ADDRESS DECLARED OR UNSHUNNED
- send -- "$no $ipshun\r"
- #LOOK FOR PROMPT
- expect "ASA-FW"
- #WRITE CONFIG
- send -- "wr mem\r"
- #LOOK FOR PROMPT
- expect "ASA-FW"
- #WRITE TO BACKUP
- send -- "wr net\r"
- #LOOK FOR PROMPT
- expect "ASA-FW#"
- #EXIT
- send -- "exit\r"
- #LOOK FOR PROMPT
- expect "ASA-FW"
- #EXIT
- send -- "exit\r"
- #SHUNNING IS COMPLETE
- expect eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement