Uname:Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64

Base Dir : /var/www/html

User : gavin


403WebShell
403Webshell
Server IP : 68.183.124.220  /  Your IP : 216.73.217.137
Web Server : Apache/2.4.18 (Ubuntu)
System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64
User : gavin ( 1000)
PHP Version : 7.0.33-0ubuntu0.16.04.16
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/gavin/workspace/happymandarin/node_modules/node-inspector/lib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/gavin/workspace/happymandarin/node_modules/node-inspector/lib/InjectorClient.js
var EventEmitter = require('events').EventEmitter,
    inherits = require('util').inherits,
    async = require('async'),
    debug = require('debug')('node-inspector:injector');

// NM is NativeModule
var FN_WITH_SCOPED_NM = 'Object.getOwnPropertyDescriptor(global, "console").get';

/**
 * @param {{inject}} config
 * @param {DebuggerClient} debuggerClient
 * @constructor
 */
function InjectorClient(config, session) {
  this._noInject = config.inject === false;
  this._injected = false;
  this._appPausedByInjector = false;

  this._debuggerClient = session.debuggerClient;
  this._frontendClient = session.frontendClient;
  this._debuggerClient.on('close', this.close.bind(this));
}

inherits(InjectorClient, EventEmitter);

Object.defineProperties(InjectorClient.prototype, {
  /** @type {boolean} */
  needsInject: {
    get: function() {
      return !this._noInject && !this._injected;
    }
  }
});

/**
 * @param {string} sourceLine
 * @type {boolean}
 */
InjectorClient.prototype.tryHandleDebuggerBreak = function(sourceLine, done) {
  return done(this._appPausedByInjector);
};

/**
 */
InjectorClient.prototype.inject = function(cb) {
  if (typeof cb !== 'function')
    cb = function(error, result) {};

  var _water = [];

  if (this.needsInject) {
    _water.unshift(
      this._getFuncWithNMInScope.bind(this),
      this._findNMInScope.bind(this),
      this._inject.bind(this),
      this._onInjection.bind(this)
    );
  }

  if (this.needsInject && this._debuggerClient.isRunning) {
    _water.unshift(this._pause.bind(this));
    _water.push(this._resume.bind(this));
  }

  async.waterfall(_water, function(error) {
    if (error)
      this._frontendClient.sendLogToConsole('error', error.toString());

    cb(error);
  }.bind(this));
};

InjectorClient.prototype._pause = function(cb) {
  this._appPausedByInjector = true;
  this._debuggerClient.request('suspend', {}, function() {
    cb();
  });
};

InjectorClient.prototype._resume = function(cb) {
  this._debuggerClient.request('continue', undefined, function() {
    this._appPausedByInjector = false;
    cb();
  }.bind(this));
};

InjectorClient.prototype._getFuncWithNMInScope = function(cb) {
    this._debuggerClient.request('evaluate', {
      global: true,
      expression: FN_WITH_SCOPED_NM
    }, function(error, result) {
      if (error) return cb(error);

      cb(null, result.handle);
    }.bind(this));
};

InjectorClient.prototype._findNMInScope = function(funcHandle, cb) {
    this._debuggerClient.request('scope', {
      functionHandle: funcHandle
    }, function(error, result, refs) {
      if (error) return cb(error);

      var NM = refs[result.object.ref].properties.filter(function(prop) {
        return prop.name == 'NativeModule';
      });

      if (!NM.length)
        error = new Error('No NativeModule in target scope');

      cb(error, NM[0].ref);
    }.bind(this));
};

/**
 * @param {Number} NM - handle of NativeModule object
 */
InjectorClient.prototype._inject = function(NM, cb) {
  var injectorServerPath = JSON.stringify(require.resolve('./InjectorServer'));
  var options = {
    'v8-debug': require.resolve('v8-debug'),
    'convert': require.resolve('./convert')
  };
  var injection = '(function (NM) {' +
    'NM.require("module")._load(' + injectorServerPath + ')' +
    '(' + JSON.stringify(options) + ')' +
  '})(NM)';

  this._debuggerClient.request(
    'evaluate',
    {
      expression: injection,
      global: true,
      additional_context: [
        { name: 'NM', handle: NM }
      ]
    },
    function(error) {
      cb(error);
    }
  );
};

/**
 */
InjectorClient.prototype._onInjection = function(cb) {
  this._injected = true;
  this.emit('inject');
  cb();
};

InjectorClient.prototype.close = function() {
  this._injected = false;
  this._appPausedByInjector = false;
  this.emit('close');
};

InjectorClient.prototype.injection = function(injection, options, callback) {
  this._debuggerClient.request(
    'evaluate',
    {
      expression: '(' + injection.toString() + ')' +
                  '(process._require, process._debugObject, ' + JSON.stringify(options) + ')',
      global: true
    },
    callback
  );
};

module.exports.InjectorClient = InjectorClient;

Youez - 2016 - github.com/yon3zu
LinuXploit