Advertisement
Guest User

Untitled

a guest
Jul 28th, 2015
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. /*
  2. Usage:
  3. You should allow telnet in modem settings beforehand (might be allowed already)
  4. You should set opts according to your modem settings
  5.  
  6. loginText = When you try `telnet 192.168.2.1` in terminal
  7. it asks you login name for the modem. Change
  8. this text to something you see on that line.
  9. I saw my modem name and used that.
  10.  
  11. routerDefaultIP = might be different for different modems,
  12. 192.168.1.1 is also common AFAIK
  13.  
  14. username = username for access to modem interface,
  15. 'root' or 'admin' is common
  16.  
  17. password = password for access to modem interface
  18.  
  19. commandDelimiter = you probably do not have to change this,
  20. either '#' or '>' should work
  21. */
  22.  
  23. var opts = {
  24. loginText: 'Air5750',
  25. routerDefaultIP: '192.168.2.1',
  26. username: 'root',
  27. password: 'thisisyourpass',
  28. commandDelimiter: '#'
  29. };
  30.  
  31. var spawn = require('child_process').spawn,
  32. child = spawn('telnet', [opts.routerDefaultIP]);
  33.  
  34. child.stdout.on('data', function (data) {
  35. if(data.toString('utf8').indexOf(opts.loginText)>-1) {
  36. child.stdin.write(opts.username + '\n');
  37. } else if(data.toString('utf8').indexOf('Password')>-1) {
  38. child.stdin.write(opts.password + '\n');
  39. } else if(data.toString('utf8').indexOf(opts.commandDelimiter)>-1) {
  40. child.stdin.write('reboot\n');
  41. }
  42. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement