Class: Ronin::PostEx::System::Process
- Defined in:
- lib/ronin/post_ex/system/process.rb
Overview
Provides access to the current process and managing child processes.
Supported Control Methods
The Process resource uses the following post-exploitation API methods, defined by the Resource#session object.
process_getpid -> Integer
process_getppid -> Integer
process_getuid -> Integer
process_setuid(uid : Integer)
process_geteuid -> Integer
process_seteuid(euid : Integer)
process_getgid -> Integer
process_setgid(gid : Integer)
process_getegid -> Integer
process_setegid(egid : Integer)
process_getsid -> Integer
process_setsid(sid : Integer) -> Integer
process_environ -> Hash[String, String]
process_getenv(name : String) -> String | env
process_setenv(name : String, value : String)
process_unsetenv(name : String)
process_kill(pid : Integer, signal : Integer)
process_popen(command : String) -> Integer
process_read(fd : Integer, length : Integer) -> String
process_write(fd : Integer, data : String)
process_close(fd : Integer)
process_spawn(program : String, *arguments : Array[String]) -> Integer
process_exit
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
-
#environ ⇒ Hash{String => String}
(also: #env)
Retrieves the whole environment Hash.
-
#exit ⇒ Object
Exits the current running process.
-
#getegid ⇒ Integer
(also: #egid)
Gets the effective GID that the current process is running under.
-
#getenv(name) ⇒ String?
Retrieves the value of a environment variable.
-
#geteuid ⇒ Integer
(also: #euid)
Gets the effective UID that the current process is running under.
-
#getgid ⇒ Integer
(also: #gid)
Gets the GID that the current process is running under.
-
#getpid ⇒ Integer
(also: #pid)
Gets the pid of the current process.
-
#getppid ⇒ Integer
(also: #ppid)
Gets the pid of the parent process.
-
#getsid ⇒ Integer
(also: #sid)
Gets the SID of the current process.
-
#getuid ⇒ Integer
(also: #uid)
Gets the UID that the current process is running under.
-
#kill(pid, signal = 'KILL') ⇒ Object
Kills a process.
-
#popen(command) ⇒ RemoteProcess
Opens a new process.
-
#setegid(new_egid) ⇒ Object
(also: #egid=)
Attempts to set the effective GID of the current process.
-
#setenv(name, value) ⇒ Object
Sets the value of a environment variable.
-
#seteuid(new_euid) ⇒ Object
(also: #euid=)
Attempts to set the effective UID of the current process.
-
#setgid(new_gid) ⇒ Object
(also: #gid=)
Attempts to set the GID of the current process.
-
#setsid ⇒ Object
(also: #sid!)
Sets the SID of the current process.
-
#setuid(new_uid) ⇒ Object
(also: #uid=)
Attempts to set the UID of the current process.
-
#spawn(program, *arguments) ⇒ Integer
Executes a program as a separate child process.
-
#unsetenv(name) ⇒ Object
Unsets an environment variable.
Methods inherited from Resource
#initialize, #interact, #supports, #supports?
Constructor Details
This class inherits a constructor from Ronin::PostEx::Resource
Instance Method Details
#environ ⇒ Hash{String => String} Also known as: env
Requires the process_environ
method be defined by the Resource#session
object.
Retrieves the whole environment Hash.
276 277 278 |
# File 'lib/ronin/post_ex/system/process.rb', line 276 def environ @session.process_environ end |
#exit ⇒ Object
Requires the process_exit
method be defined by the Resource#session
object.
Exits the current running process.
414 415 416 |
# File 'lib/ronin/post_ex/system/process.rb', line 414 def exit @session.process_exit end |
#getegid ⇒ Integer Also known as: egid
Requires the process_getegid
method be defined by the Resource#session
object.
Gets the effective GID that the current process is running under.
209 210 211 |
# File 'lib/ronin/post_ex/system/process.rb', line 209 def getegid @session.process_getegid end |
#getenv(name) ⇒ String?
Requires process_getenv
or process_environ
methods be defined by
the Resource#session object.
Retrieves the value of a environment variable.
298 299 300 301 302 303 304 305 306 |
# File 'lib/ronin/post_ex/system/process.rb', line 298 def getenv(name) if @session.respond_to?(:process_getenv) @session.process_getenv(name) elsif @session.respond_to?(:process_environ) @session.process_environ[name] else raise(NoMethodError,"#{@session} does not define process_getenv or process_environ") end end |
#geteuid ⇒ Integer Also known as: euid
Requires the process_geteuid
method be defined by the Resource#session
object.
Gets the effective UID that the current process is running under.
141 142 143 |
# File 'lib/ronin/post_ex/system/process.rb', line 141 def geteuid @session.process_geteuid end |
#getgid ⇒ Integer Also known as: gid
Requires the process_getgid
method be defined by the Resource#session
object.
Gets the GID that the current process is running under.
175 176 177 |
# File 'lib/ronin/post_ex/system/process.rb', line 175 def getgid @session.process_getgid end |
#getpid ⇒ Integer Also known as: pid
Requires the process_getpid
method be defined by the Resource#session
object.
Gets the pid of the current process.
73 74 75 |
# File 'lib/ronin/post_ex/system/process.rb', line 73 def getpid @session.process_getpid end |
#getppid ⇒ Integer Also known as: ppid
Requires the process_getppid
method be defined by the Resource#session
object.
Gets the pid of the parent process.
90 91 92 |
# File 'lib/ronin/post_ex/system/process.rb', line 90 def getppid @session.process_getppid end |
#getsid ⇒ Integer Also known as: sid
Requires the process_getsid
method be defined by the Resource#session
object.
Gets the SID of the current process.
243 244 245 |
# File 'lib/ronin/post_ex/system/process.rb', line 243 def getsid @session.process_getsid end |
#getuid ⇒ Integer Also known as: uid
Requires the process_getuid
method be defined by the Resource#session
object.
Gets the UID that the current process is running under.
107 108 109 |
# File 'lib/ronin/post_ex/system/process.rb', line 107 def getuid @session.process_getuid end |
#kill(pid, signal = 'KILL') ⇒ Object
Requires the process_kill
method be defined by the Resource#session
object.
Kills a process.
359 360 361 |
# File 'lib/ronin/post_ex/system/process.rb', line 359 def kill(pid,signal='KILL') @session.process_kill(pid,signal) end |
#popen(command) ⇒ RemoteProcess
Requires the process_popen
method be defined by the Resource#session
object.
Opens a new process.
379 380 381 |
# File 'lib/ronin/post_ex/system/process.rb', line 379 def popen(command) RemoteProcess.new(@session,command) end |
#setegid(new_egid) ⇒ Object Also known as: egid=
Requires the process_setegid
method be defined by the Resource#session
object.
Attempts to set the effective GID of the current process.
226 227 228 |
# File 'lib/ronin/post_ex/system/process.rb', line 226 def setegid(new_egid) @session.process_setegid(new_egid) end |
#setenv(name, value) ⇒ Object
Requires the process_setenv
method be defined by the Resource#session
object.
Sets the value of a environment variable.
324 325 326 |
# File 'lib/ronin/post_ex/system/process.rb', line 324 def setenv(name,value) @session.process_setenv(name,value) end |
#seteuid(new_euid) ⇒ Object Also known as: euid=
Requires the process_seteuid
method be defined by the Resource#session
object.
Attempts to set the effective UID of the current process.
158 159 160 |
# File 'lib/ronin/post_ex/system/process.rb', line 158 def seteuid(new_euid) @session.process_seteuid(new_euid) end |
#setgid(new_gid) ⇒ Object Also known as: gid=
Requires the process_setgid
method be defined by the Resource#session
object.
Attempts to set the GID of the current process.
192 193 194 |
# File 'lib/ronin/post_ex/system/process.rb', line 192 def setgid(new_gid) @session.process_setgid(new_gid) end |
#setsid ⇒ Object Also known as: sid!
Requires the process_setsid
method be defined by the Resource#session
object.
Sets the SID of the current process.
257 258 259 |
# File 'lib/ronin/post_ex/system/process.rb', line 257 def setsid @session.process_setsid end |
#setuid(new_uid) ⇒ Object Also known as: uid=
Requires the process_setuid
method be defined by the Resource#session
object.
Attempts to set the UID of the current process.
124 125 126 |
# File 'lib/ronin/post_ex/system/process.rb', line 124 def setuid(new_uid) @session.process_setuid(new_uid) end |
#spawn(program, *arguments) ⇒ Integer
Requires the process_spawn
method be defined by the Resource#session
object.
Executes a program as a separate child process.
402 403 404 |
# File 'lib/ronin/post_ex/system/process.rb', line 402 def spawn(program,*arguments) @session.process_spawn(program,*arguments) end |
#unsetenv(name) ⇒ Object
Requires the process_unsetenv
method be defined by the Resource#session
object.
Unsets an environment variable.
341 342 343 |
# File 'lib/ronin/post_ex/system/process.rb', line 341 def unsetenv(name) @session.process_unsetenv(name) end |