Skip to content

Instantly share code, notes, and snippets.

@jmgunn87
Last active January 4, 2016 05:09
Show Gist options
  • Save jmgunn87/8573239 to your computer and use it in GitHub Desktop.
Save jmgunn87/8573239 to your computer and use it in GitHub Desktop.
TCP-32764.js
var bufferpack = require('bufferpack');
var net = require('net');
var commands = {
DUMP_CFG : 1,
GET_CFG : 2,
SET_CFG : 3,
COMMIT_NVRAM : 4,
BRIDGE_ON : 5,
SPEED_TEST : 6,
SHELL : 7,
WRITE_FS : 8,
VERSION : 9,
ROUTER_IP : 10,
RESTORE_CFG : 11,
READ_MTDBLOCK : 12,
DUMP_NVRAM : 13
};
function message(code, payload) {
payload = payload || "";
return bufferpack.pack('<III', [
1399016781, code, payload.length + 1
]) + payload + "\x00";
}
var client = net.connect({
host: "192.168.0.1",
port: 32764
}, function() {
console.log('client connected');
// some example commands
client.write(message(commands.DUMP_CFG));
client.write(message(commands.WRITE_FS, "blahblah.txt\0this is some content"));
client.write(message(commands.SHELL, "ls -la tmp"));
client.write(message(commands.SPEED_TEST));
});
client.on('data', function(data) {
console.log('client data');
console.log(data.toString());
client.end();
});
client.on('end', function() {
console.log('client disconnected');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment