Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Node script utility for Cisco equipment. (Unstable)
var settings = {
host: 'switch1',
port: 22,
protocol: 'ssh',
username: 'cisco',
password: 'cisco',
autoEnable: true,
enablePassword: 'cisco'
}
To connect to a device with telnet set the protocol to raw
and port number to 23
.
.connect() - Connects to the remote host.
.end() - Closes the connection to the remote host.
A connection was made to the remote host. The session variable is the expectly session for this connection.
Emitted after the session is logged in and the enable command is issued if requested.
var Expectly = require('expectly').Expectly;
var Patterns = require('expectly').Patterns;
var settings = {
host: 'switch1',
port: 22,
protocol: 'ssh',
username: 'cisco',
password: 'cisco',
autoEnable: true,
enablePassword: 'cisco'
}
// These regexs are used to grab the content between the begin and start of a config.
var START_CONFIG = Patterns['RANGE START RUNNING-CONFIG'];
var END_CONFIG = Patterns['RANGE STOP RUNNING-CONFIG'];
var expectly = new Expectly(settings);
// Show errors...
expectly.on('error', function(err){
console.log('Error', err)
});
expectly.on('ready', function(session){
// At this point you should be logged in. The session object is an expectly-stream session.
// Here we execute a 'show run' command to see
session.sync()
.send("show run\n")
.between(BEGIN_CONFIG, END_CONFIG, function(err, results, done) {
// Store the configuration in the sessions config variable.
session.set('config', results);
done();
})
.end(function(err){
// Get the configuration from the sessions config variable
var deviceConfig = session.get('config');
console.log(deviceConfig);
expectly.end();
})
})
expectly.connect();
These tricks assume
var START_CONFIG = Patterns['RANGE_START_RUNNING-CONFIG'];
var END_CONFIG = Patterns['RANGE_STOP_RUNNING-CONFIG'];
session.sync()
.send("show running-config\n")
.between(START_CONFIG, END_CONFIG, function(err, results, done) {
// Store the configuration in the sessions config variable.
session.set('config', results);
done();
})
.end(function(err){
// Get the configuration from the sessions config variable
var deviceConfig = session.get('config');
console.log(deviceConfig);
expectly.end();
})
var expectly = new Expectly(settings);
expectly.on('connect', function(session) {
// Use the connection object to listen for data.
expectly.connection.on('data', function(data) {
console.log('>>>', data.toString())
});
});
There is a patterns object included in the module which contains some cisco related regexes. These can be used with the expect, match and between functions of the expectly-stream object.
var Patterns = require('expectly').Patterns;
var PATTERN_PROMPT = Patterns['PROMPT_CLI'];
Alias | Purpose | Example |
---|---|---|
PROMPT_USERNAME | Match user name prompts. | Username: |
PROMPT_PASSWORD | Match password prompts. | Password: |
PROMPT_CLI | Match the host> or host# prompts. | switch1> |
RANGE_START_RUNNING-CONFIG | Match the begining of a running-config. | Building configuration... |
RANGE_STOP_RUNNING-CONFIG | Match the begining of a running-config. | end ... switch |
FAQs
Remote CLI for Cisco IOS and Adtran AOS.
We found that expectly demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.