Guest User

Untitled

a guest
Jul 23rd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. /********* Server-side JS ************/
  2.  
  3. Ape.addEvent("init", function() {
  4. include("framework/mootools.js");
  5. include("utils/utils.js");
  6.  
  7. Ape.addEvent('deluser', function(user) {
  8. if (user.ssh != null) {
  9. Ape.log('Connection closed');
  10. user.ssh.close();
  11. }
  12. });
  13.  
  14. Ape.registerCmd('ssh', true, function(params, cmd) {
  15.  
  16. params.cmd = params.cmd || '';
  17. params.data = params.data || '';
  18.  
  19. switch(params.cmd) {
  20. case 'data':
  21. if (cmd.user.ssh != null) {
  22. cmd.user.ssh.send(Ape.base64.decode(unescape(params.data)));
  23. }
  24. break;
  25. case 'connect':
  26. params.ip = params.ip || '';
  27. params.login = params.login || '';
  28. params.pass = params.pass || '';
  29.  
  30. cmd.user.ssh = new Ape.SSH(params.ip, params.login, params.pass);
  31.  
  32. cmd.user.ssh.onShell = function() {
  33. Ape.log('New connection');
  34. cmd.user.pipe.sendRaw('ssh', {'state':'connected'});
  35. }
  36. cmd.user.ssh.onError = function(err) {
  37. cmd.user.pipe.sendRaw('ssh', {'state':'error','value':err});
  38. delete cmd.user.ssh;
  39. }
  40. cmd.user.ssh.onRead = function(data) {
  41. cmd.user.pipe.sendRaw('ssh', {'state':'data', 'value':Ape.base64.encode(data)});
  42. }
  43.  
  44.  
  45. break;
  46. }
  47. });
  48. });
Add Comment
Please, Sign In to add comment