Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Usage:
- You should allow telnet in modem settings beforehand (might be allowed already)
- You should set opts according to your modem settings
- loginText = When you try `telnet 192.168.2.1` in terminal
- it asks you login name for the modem. Change
- this text to something you see on that line.
- I saw my modem name and used that.
- routerDefaultIP = might be different for different modems,
- 192.168.1.1 is also common AFAIK
- username = username for access to modem interface,
- 'root' or 'admin' is common
- password = password for access to modem interface
- commandDelimiter = you probably do not have to change this,
- either '#' or '>' should work
- */
- var opts = {
- loginText: 'Air5750',
- routerDefaultIP: '192.168.2.1',
- username: 'root',
- password: 'thisisyourpass',
- commandDelimiter: '#'
- };
- var spawn = require('child_process').spawn,
- child = spawn('telnet', [opts.routerDefaultIP]);
- child.stdout.on('data', function (data) {
- if(data.toString('utf8').indexOf(opts.loginText)>-1) {
- child.stdin.write(opts.username + '\n');
- } else if(data.toString('utf8').indexOf('Password')>-1) {
- child.stdin.write(opts.password + '\n');
- } else if(data.toString('utf8').indexOf(opts.commandDelimiter)>-1) {
- child.stdin.write('reboot\n');
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement