Class: Ronin::PostExploitation::Resources::Process

Inherits:
Ronin::PostExploitation::Resource show all
Defined in:
lib/ronin/post_exploitation/resources/process.rb

Overview

Controls the Process resource.

Supported Control Methods

The Process resource uses the following control methods, defined by the controller object.

  • process_getpid # => Integer
  • process_getppid # => Integer
  • process_getuid # => Integer
  • process_setuid(uid)
  • process_geteuid # => Integer
  • process_seteuid(euid)
  • process_getgid # => Integer
  • process_setgid(gid)
  • process_getegid # => Integer
  • process_setegid(egid)
  • process_getsid # => Integer
  • process_setsid(sid) # => Integer
  • process_environ # => Hash{String => String}
  • process_getenv(name) # => String
  • process_setenv(name,value)
  • process_unsetenv(name)
  • process_kill(pid,signal)
  • process_getcwd # => String
  • process_chdir(path)
  • process_time => Integer
  • process_spawn(program,*arguments) # => Integer
  • process_exit

Since:

  • 1.0.0

Instance Attribute Summary

Attributes inherited from Ronin::PostExploitation::Resource

#controller

Instance Method Summary collapse

Methods inherited from Ronin::PostExploitation::Resource

#console, #initialize, #requires_method!, resource_method, resource_methods, #supports, #supports?

Constructor Details

This class inherits a constructor from Ronin::PostExploitation::Resource

Instance Method Details

#chdir(path) ⇒ String Also known as: cwd=

Note:

Requires the process_chdir method be defined by the controller object.

Changes the working directory of the current process.

Parameters:

  • path (String)

    The new working directory.

Returns:

  • (String)

    The new current working directory.

Since:

  • 1.0.0


394
395
396
# File 'lib/ronin/post_exploitation/resources/process.rb', line 394

def chdir(path)
  @controller.process_chdir(path)
end

#environHash{String => String}

Note:

Requires the process_environ method be defined by the controller object.

Retrieves the whole environment Hash.

Returns:

  • (Hash{String => String})

    The Hash of environment variables.

Since:

  • 1.0.0


278
279
280
# File 'lib/ronin/post_exploitation/resources/process.rb', line 278

def environ
  @controller.process_environ
end

#exitObject

Note:

Requires the process_exit method be defined by the controller object.

Exits the current running process.

Since:

  • 1.0.0


446
447
448
# File 'lib/ronin/post_exploitation/resources/process.rb', line 446

def exit
  @controller.process_exit
end

#getcwdString Also known as: cwd

Note:

Requires the process_getcwd method be defined by the controller object.

Gets the working directory of the current process.

Returns:

  • (String)

    The current working directory.

Since:

  • 1.0.0


374
375
376
# File 'lib/ronin/post_exploitation/resources/process.rb', line 374

def getcwd
  @controller.process_getcwd
end

#getegidInteger Also known as: egid

Note:

Requires the process_getegid method be defined by the controller object.

Gets the effective GID that the current process is running under.

Returns:

  • (Integer)

    The effective GID.

Since:

  • 1.0.0


211
212
213
# File 'lib/ronin/post_exploitation/resources/process.rb', line 211

def getegid
  @controller.process_getegid
end

#getenv(name) ⇒ String?

Note:

Requires process_getenv or process_environ methods be defined by the controller object.

Retrieves the value of a environment variable.

Parameters:

  • name (String)

    The name of the environment variable.

Returns:

  • (String, nil)

    The value of the environment variable.

Since:

  • 1.0.0


298
299
300
301
302
303
304
305
306
# File 'lib/ronin/post_exploitation/resources/process.rb', line 298

def getenv(name)
  if @controller.respond_to?(:process_getenv)
    @controller.process_getenv(name)
  elsif @controller.respond_to?(:process_environ)
    @controller.process_environ[name]
  else
    raise(NoMethodError,"#{@controller} does not define process_getenv or process_environ")
  end
end

#geteuidInteger Also known as: euid

Note:

Requires the process_geteuid method be defined by the controller object.

Gets the effective UID that the current process is running under.

Returns:

  • (Integer)

    The effective UID.

Since:

  • 1.0.0


143
144
145
# File 'lib/ronin/post_exploitation/resources/process.rb', line 143

def geteuid
  @controller.process_geteuid
end

#getgidInteger Also known as: gid

Note:

Requires the process_getgid method be defined by the controller object.

Gets the GID that the current process is running under.

Returns:

  • (Integer)

    The current GID.

Since:

  • 1.0.0


177
178
179
# File 'lib/ronin/post_exploitation/resources/process.rb', line 177

def getgid
  @controller.process_getgid
end

#getpidInteger Also known as: pid

Note:

Requires the process_getpid method be defined by the controller object.

Gets the pid of the current process.

Returns:

  • (Integer)

    The current PID.

Since:

  • 1.0.0


75
76
77
# File 'lib/ronin/post_exploitation/resources/process.rb', line 75

def getpid
  @controller.process_getpid
end

#getppidInteger Also known as: ppid

Note:

Requires the process_getppid method be defined by the controller object.

Gets the pid of the parent process.

Returns:

  • (Integer)

    The parent PID.

Since:

  • 1.0.0


92
93
94
# File 'lib/ronin/post_exploitation/resources/process.rb', line 92

def getppid
  @controller.process_getppid
end

#getsidInteger Also known as: sid

Note:

Requires the process_getsid method be defined by the controller object.

Gets the SID of the current process.

Returns:

  • (Integer)

    The current SID.

Since:

  • 1.0.0


245
246
247
# File 'lib/ronin/post_exploitation/resources/process.rb', line 245

def getsid
  @controller.process_getsid
end

#getuidInteger Also known as: uid

Note:

Requires the process_getuid method be defined by the controller object.

Gets the UID that the current process is running under.

Returns:

  • (Integer)

    The current UID.

Since:

  • 1.0.0


109
110
111
# File 'lib/ronin/post_exploitation/resources/process.rb', line 109

def getuid
  @controller.process_getuid
end

#kill(pid, signal = 'KILL') ⇒ Object

Note:

Requires the process_kill method be defined by the controller object.

Kills a process.

Parameters:

  • pid (Integer)

    The PID of the process to kill.

  • signal (String) (defaults to: 'KILL')

    The POSIX signal name to send to the process.

Since:

  • 1.0.0


359
360
361
# File 'lib/ronin/post_exploitation/resources/process.rb', line 359

def kill(pid,signal='KILL')
  @controller.process_kill(pid,signal)
end

#setegid(new_egid) ⇒ Object Also known as: egid=

Note:

Requires the process_setegid method be defined by the controller object.

Attempts to set the effective GID of the current process.

Parameters:

  • new_egid (Integer)

    The new effective GID.

Since:

  • 1.0.0


228
229
230
# File 'lib/ronin/post_exploitation/resources/process.rb', line 228

def setegid(new_egid)
  @controller.process_setegid(new_egid)
end

#setenv(name, value) ⇒ Object

Note:

Requires the process_setenv method be defined by the controller object.

Sets the value of a environment variable.

Parameters:

  • name (String)

    The name of the environment variable.

  • value (String)

    The new value for the environment variable.

Since:

  • 1.0.0


324
325
326
# File 'lib/ronin/post_exploitation/resources/process.rb', line 324

def setenv(name,value)
  @controller.process_setenv(name,value)
end

#seteuid(new_euid) ⇒ Object Also known as: euid=

Note:

Requires the process_seteuid method be defined by the controller object.

Attempts to set the effective UID of the current process.

Parameters:

  • new_euid (Integer)

    The new effective UID.

Since:

  • 1.0.0


160
161
162
# File 'lib/ronin/post_exploitation/resources/process.rb', line 160

def seteuid(new_euid)
  @controller.process_seteuid(new_euid)
end

#setgid(new_gid) ⇒ Object Also known as: gid=

Note:

Requires the process_setgid method be defined by the controller object.

Attempts to set the GID of the current process.

Parameters:

  • new_gid (Integer)

    The new GID.

Since:

  • 1.0.0


194
195
196
# File 'lib/ronin/post_exploitation/resources/process.rb', line 194

def setgid(new_gid)
  @controller.process_setgid(new_gid)
end

#setsidObject Also known as: sid!

Note:

Requires the process_setsid method be defined by the controller object.

Sets the SID of the current process.

Since:

  • 1.0.0


259
260
261
# File 'lib/ronin/post_exploitation/resources/process.rb', line 259

def setsid
  @controller.process_setsid
end

#setuid(new_uid) ⇒ Object Also known as: uid=

Note:

Requires the process_setuid method be defined by the controller object.

Attempts to set the UID of the current process.

Parameters:

  • new_uid (Integer)

    The new UID.

Since:

  • 1.0.0


126
127
128
# File 'lib/ronin/post_exploitation/resources/process.rb', line 126

def setuid(new_uid)
  @controller.process_setuid(new_uid)
end

#spawn(program, *arguments) ⇒ Integer

Note:

Requires the process_spawn method be defined by the controller object.

Executes a program as a separate child process.

Parameters:

  • program (String)

    The name or path of the program.

  • arguments (Array<String>)

    Additional arguments to execute the program with.

Returns:

  • (Integer)

    The pid of the new process.

Since:

  • 1.0.0


434
435
436
# File 'lib/ronin/post_exploitation/resources/process.rb', line 434

def spawn(program,*arguments)
  @controller.process_spawn(program,*arguments)
end

#timeTime

Note:

Requires the process_time method be defined by the controller object.

Gets the current time.

Returns:

  • (Time)

    The current time.

Since:

  • 1.0.0


411
412
413
# File 'lib/ronin/post_exploitation/resources/process.rb', line 411

def time
  Time.at(@controller.process_time.to_i)
end

#unsetenv(name) ⇒ Object

Note:

Requires the process_unsetenv method be defined by the controller object.

Unsets an environment variable.

Parameters:

  • name (String)

    The name of the environment variable.

Since:

  • 1.0.0


341
342
343
# File 'lib/ronin/post_exploitation/resources/process.rb', line 341

def unsetenv(name)
  @controller.process_unsetenv(name)
end