Exemplo n.º 1
0
def switch_main_cisco_to_primary():
    hostname = crassh.connect(config.main_cisco, config.username, config.password)
    crassh.send_command("conf t", hostname)
    output = crassh.send_command("hostname CSR-TEST1-Primary", hostname, 1)
    crassh.disconnect()
Exemplo n.º 2
0
username = "******"
password = "******"
cmd01 = "show running-config"

# user need Enablepass, Not work in this lab because default enable=False
""" 
username = "******"
password = "******"
cmd01 = "show running-config"
** need to set option `enable=True` see pyw32.py 
"""

try:
    hostname = crassh.connect(router, username, password)
    print("Connected device %s [%s]" % (hostname, router))
    output = crassh.send_command(cmd01, hostname)
    print(output)
    crassh.disconnect()

except:
    print("Can not connect to [%s]" % router)
""" Output
Connecting to 10.0.1.22 ...
Connected device MNR-RT2 [10.0.1.22]
show running-config
Building configuration...

Current configuration : 1348 bytes
!
version 12.4
service timestamps debug datetime msec
Exemplo n.º 3
0
import crassh

routers = ["10.0.1.11"]
youraddress = "5.5.5.5"
username = "******"
password = "******"
enablepass = "******"
cmd01 = "configure terminal"
cmd02 = "access-list 1 permit host " + youraddress

for device in routers:
   try:
       hostname = crassh.connect(device, username, password, enable=True , enable_password = enablepass)
       print("Connected device %s [%s]" %(hostname,device))
       crassh.send_command(cmd01, hostname)
       crassh.send_command(cmd02, hostname)
       crassh.disconnect()
   except:
       print("Can not connect to [%s]" %device)
       pass



	
logger.setLevel(logging.DEBUG)
handler = logging.FileHandler('ConfAuditor.log')
handler.setFormatter(formatter)
logger.addHandler(handler)

routers = ["10.1.0.11", "10.1.0.12", "10.1.0.13"]
username = "******"
password = "******"

logger.info("Configuration Auditor Scaning ...")
print("Configuration Auditor Scaning...")

for device in routers:
    try:
        hostname = crassh.connect(device, username, password)
        output = crassh.send_command("show run | include snmp-server", hostname)
        crassh.disconnect()

        # Split the output by spaces 
        words = output.split()
        logger.info("Scan Configuration on %s [%s]" % (hostname, device))

        # Look for "public"
        for word in words:
            if word == "public":
                logger.warning("Found Default SNMP Community!! on %s [%s]" %(hostname, device))
    except:
        logger.error("Cannot connect to %s" %device)
        pass  # If connect fails, move onto next router in the list.

logger.info("Configuration Auditor Program Stop.")
Exemplo n.º 5
0
#Date and Time
time = datetime.datetime.now()

filename = raw_input("Introduce the Report file name :  ")
print filename

#wipe the file to have it clean files :)

open(filename, 'w').close()

# Loop
for device in routers:
    try:
        f = open(filename, "a+")
        hostname = crassh.connect(device, username, password)
        output = crassh.send_command("sh int status | in connected ", hostname)

        crassh.disconnect()

        # Split the output by spaces so we can search the response -- to be released in v2.0
        words = output.split()

        var2 -= 1

        print hostname, "Information gathered, writting to file --> ", filename, " remaining: ", var2, "of: ", var1

        #to write output in the report file

        f.write(
            "\r\n\r\n ------>>Hostname: %s<<-----report time: %s-------------------- \r\n\r\n %s "
            % (hostname, time, output))
Exemplo n.º 6
0
#!/usr/bin/env python
# coding=utf-8
import crassh
import datetime
import time
import sys

# Variables
routers = ["10.236.58.66", "10.237.179.66", "10.237.180.66 "]
username = "******"
password = "******"
# Loop
for device in routers:
    try:
        hostname = crassh.connect(device, username, password)
        output = crassh.send_command("conf t", hostname)
        output1 = crassh.send_command("ip access-list standard 89", hostname)
        output2 = crassh.send_command("no 10", hostname)
        output3 = crassh.send_command("no 20", hostname)
        output4 = crassh.send_command("exit", hostname)
        output5 = crassh.send_command(
            "no snmp-server host 10.193.135.12 version 2c Wr7j4p3vi9pe9eth",
            hostname)
        output6 = crassh.send_command(
            "no snmp-server host 10.193.135.13 version 2c Wr7j4p3vi9pe9eth",
            hostname)
        # commented or disabled output7 = crassh.send_command("do show run | in snmp", hostname)
        #output8 = crassh.send_command("do write", hostname)
        #output9 = crassh.send_command("write", hostname)

        #output5 * crassh.send_command("write", hostname)