def connect(ne_addr, ne_username, ne_password):

	# check to see if ne_addr is a valid IP(v6) address
	if not (HostIpCheck(ne_addr).is_ipv4() or HostIpCheck(ne_addr).is_ipv6()):
		raise ValueError('%s is not a valid IP address' % ne_addr)	

	# TLS Connection (This is the TLS Pinning Handler)  
	class PinningHandler(tlspinning.TLSUnverifiedElementHandler):  
	   def __init__(self, pinning_file):  
	       self.pinning_file = pinning_file  
	   def handle_verify(self, host, hashtype, finger_print, changed):  
	       return tlspinning.DecisionType.ACCEPT_ONCE  
	  
	# Connection to my onePK enabled Network Element  
	config = SessionConfig(None)  
	config.set_tls_pinning('', PinningHandler(''))  
	config.transportMode = SessionConfig.SessionTransportMode.TLS  
	network_element = NetworkElement(ne_addr)

	# Try authenticating, raise error if unsuccessful  
	try:
		network_element.connect(ne_username, ne_password, config)  
	except OnepConnectionException:
		raise ValueError('Invalid Credentials or unable to reach %s.' % network_element)  

	return network_element
def connect(ne_addr, ne_username, ne_password):

    # check to see if ne_addr is a valid IP(v6) address
    if not (HostIpCheck(ne_addr).is_ipv4() or HostIpCheck(ne_addr).is_ipv6()):
        raise ValueError('%s is not a valid IP address' % ne_addr)

    # TLS Connection (This is the TLS Pinning Handler)
    class PinningHandler(tlspinning.TLSUnverifiedElementHandler):
        def __init__(self, pinning_file):
            self.pinning_file = pinning_file

        def handle_verify(self, host, hashtype, finger_print, changed):
            return tlspinning.DecisionType.ACCEPT_ONCE

    # Connection to my onePK enabled Network Element
    config = SessionConfig(None)
    config.set_tls_pinning('', PinningHandler(''))
    config.transportMode = SessionConfig.SessionTransportMode.TLS
    network_element = NetworkElement(ne_addr)

    # Try authenticating, raise error if unsuccessful
    try:
        network_element.connect(ne_username, ne_password, config)
    except OnepConnectionException:
        raise ValueError('Invalid Credentials or unable to reach %s.' %
                         network_element)

    return network_element
Ejemplo n.º 3
0
def ConnectNE():
    global frame
    global connect_attempt
    global ne
    global username
    global password

    ne = NetworkElement(router_ip, connection_name)
    config = SessionConfig(None)
    config.set_tls_pinning("", PinningHandler(""))
    config.transportMode = SessionConfig.SessionTransportMode.TLS
    if ne.is_connected() != 1:
        try:
            ne.connect(username, password, config)
        except:
            connect_attempt = connect_attempt + 1
            ConnectNE()
Ejemplo n.º 4
0
                          help="[Mandatory] Account Username for Login")
    parser.add_option('-p', '--password',dest="password",
                          help="[Mandatory] Account Password for Login")

    (options, args) = parser.parse_args()

    if not options.ip:
        parser.print_help()
        parser.error("Provide IP Address")
    if not options.userName:
        parser.print_help()
        parser.error("Provide UserName")
    if not options.password:
        options.password=getpassword("Password:")

        
    # Setup a connection config with TLS pinning handler
    config = SessionConfig(None)  
    config.set_tls_pinning('', PinningHandler(''))  
    config.transportMode = SessionConfig.SessionTransportMode.TLS  
     
    # Connection to my onePK enabled Network Element  
    ne = NetworkElement(options.ip, 'App_Name')  
    ne.connect(options.userName, options.password, config)  
     
    # Print the information of the Network Element  
    print ne
     
    # Finally have the application disconnect from the Network Element  
    ne.disconnect()
Ejemplo n.º 5
0
    parser.add_option('-p',
                      '--password',
                      dest="password",
                      help="[Mandatory] Account Password for Login")

    (options, args) = parser.parse_args()

    if not options.ip:
        parser.print_help()
        parser.error("Provide IP Address")
    if not options.userName:
        parser.print_help()
        parser.error("Provide UserName")
    if not options.password:
        options.password = getpassword("Password:")

    # Setup a connection config with TLS pinning handler
    config = SessionConfig(None)
    config.set_tls_pinning('', PinningHandler(''))
    config.transportMode = SessionConfig.SessionTransportMode.TLS

    # Connection to my onePK enabled Network Element
    ne = NetworkElement(options.ip, 'App_Name')
    ne.connect(options.userName, options.password, config)

    # Print the information of the Network Element
    print ne

    # Finally have the application disconnect from the Network Element
    ne.disconnect()
Ejemplo n.º 6
0
if args.c:
    command = args.c
else:
    print "You have to specify a command (-c)"
    sys.exit()

if args.v:
    victim = args.v
else:
    print "You have to specify a victim (-u)"
    sys.exit()

password = getpass.getpass("Please enter your password: "******"Prank Listener")
cliFilter = CLIFilter(command)
clientData = None
eventHandle = router.add_cli_listener(cliListener, cliFilter, clientData)

print "-----"
print router
print "-----"
print "Waiting for command: " + command

try: