tuiHoneyPot

front and back end of my TUI honeypot
Log | Files | Refs | README

whoami.js (1172B)


      1 /**
      2  * The "whoami" command
      3  * @param  {window.FakeTerminal} instance The instance of FakeTerminal
      4  * @return {Object}
      5  */
      6 window.FakeTerminal.command.whoami = function (instance) {
      7 
      8     //  Extend the base command
      9     window.FakeTerminal.command.apply(this, arguments);
     10 
     11     /**
     12      * Avoid scope issues by using `base` instead of `this`
     13      * @type {Object}
     14      */
     15     const base = this;
     16 
     17     // --------------------------------------------------------------------------
     18 
     19     /**
     20      * Describes the command
     21      * @return {Object}
     22      */
     23     base.info = function () {
     24         return {
     25             description: 'Prints the user\'s username to standard output'
     26         };
     27     };
     28 
     29     // --------------------------------------------------------------------------
     30 
     31     /**
     32      * Executes the command
     33      * @return {Object} A promise which will be resolved when the command completes
     34      */
     35     base.execute = function () {
     36         instance.output.write(instance.options.username);
     37         base.deferred.resolve();
     38         return base.deferred.promise();
     39     };
     40 
     41     // --------------------------------------------------------------------------
     42 
     43     return base;
     44 };