Class: Ronin::PostEx::Sessions::RPCSession
- Defined in:
- lib/ronin/post_ex/sessions/rpc_session.rb
Overview
Provides a post-exploitation session which wraps around an RPC client.
Instance Attribute Summary collapse
-
#client ⇒ #call
readonly
private
The RPC client object.
System Methods collapse
-
#sys_hostname ⇒ String
Gets the system's hostname.
-
#sys_time ⇒ Integer
Gets the current time and returns the UNIX timestamp.
File Methods collapse
-
#file_close(fd) ⇒ Object
Closes an opened remote file-descriptor.
-
#file_fcntl(fd, command, argument) ⇒ Integer
Performs a
fcntl()
operation on the file-descriptor. -
#file_ioctl(fd, command, argument) ⇒ Integer
Performs a
ioctl()
operation on the file-descriptor. -
#file_open(path, mode = 'r') ⇒ Integer
Opens a file and returns the file-descriptor number.
-
#file_read(fd, length) ⇒ String?
Reads from an opened file-descriptor and returns the read data.
-
#file_seek(fd, new_pos, whence) ⇒ Object
Seeks to a position within the file.
-
#file_stat(fd) ⇒ Hash{Symbol => Object}?
Queries file information from the given file-descriptor and returns a Hash of file metadata.
-
#file_tell(fd) ⇒ Integer
Queries the current position within the file.
-
#file_write(fd, pos, data) ⇒ Integer
Writes data to the opened file-descriptor.
File-System methods collapse
-
#fs_chdir(path) ⇒ Object
Changes the current working directory.
-
#fs_chgrp(group, path) ⇒ Object
Changes the group ownership of a remote file or directory.
-
#fs_chmod(mode, path) ⇒ Object
Changes the permissions on a remote file or directory.
-
#fs_chown(user, path) ⇒ Object
Changes the user ownership of remote a file or directory.
-
#fs_copy(src, dest) ⇒ Object
Copies a source file to the destination path.
-
#fs_getcwd ⇒ String
Gets the current working directory and returns the directory path.
-
#fs_glob(pattern) ⇒ Array<String>
Evaluates a directory glob pattern and returns all matching paths.
-
#fs_link(src, dest) ⇒ Object
Creates a remote symbolic link at the destination path pointing to the source path.
-
#fs_mkdir(new_path) ⇒ Object
Creates a new remote directory at the given path.
-
#fs_mktemp(basename) ⇒ String
Creates a remote temporary file with the given file basename.
-
#fs_move(src, dest) ⇒ Object
Moves or renames a remote source file to a new destination path.
-
#fs_readdir(path) ⇒ Array<String>
Reads the contents of a remote directory and returns an Array of directory entry names.
-
#fs_readfile(path) ⇒ String?
Reads the entire file at the given path and returns the full file's contents.
-
#fs_readlink(path) ⇒ String?
Reads the destination path of a remote symbolic link.
-
#fs_rmdir(path) ⇒ Object
Removes an empty directory at the given path.
-
#fs_stat(path) ⇒ Hash{Symbol => Object}?
Queries file information for the given remote path and returns a Hash of file metadata.
-
#fs_unlink(path) ⇒ Object
Removes a file at the given path.
Process methods collapse
-
#process_environ ⇒ Hash{String => String}
Queries all environment variables of the current process.
-
#process_exit ⇒ Object
Exits the current process.
-
#process_getegid ⇒ Integer
Gets the current process's effective group ID (EGID).
-
#process_getenv(name) ⇒ String?
Gets an individual environment variable.
-
#process_geteuid ⇒ Integer
Gets the current process's effective UID (EUID).
-
#process_getgid ⇒ Integer
Gets the current process's group ID (GID).
-
#process_getpid ⇒ Integer
Gets the current process's Process ID (PID).
-
#process_getppid ⇒ Integer
Gets the current process's parent Process ID (PPID).
-
#process_getsid ⇒ Integer
Gets the current process's session ID (SID).
-
#process_getuid ⇒ Integer
Gets the current process's user ID (UID).
-
#process_kill(pid, signal) ⇒ Object
Kills another process using the given Process ID (POD) and the signal number.
-
#process_setegid(egid) ⇒ Object
Sets the current process's effective group ID (EGID) to the given Integer.
-
#process_setenv(name, value) ⇒ Object
Sets an environment variable to the given value.
-
#process_seteuid(euid) ⇒ Object
Sets the current process's effective UID (EUID) to the given Integer.
-
#process_setgid(gid) ⇒ Object
Sets the current process's group ID (GID) to the given Integer.
-
#process_setsid(sid) ⇒ Object
Sets the current process's session ID (SID).
-
#process_setuid(uid) ⇒ Object
Sets the current process's user ID (UID) to the given Integer.
-
#process_spawn(program, *arguments) ⇒ Integer
Spawns a new process using the given program and additional arguments.
-
#process_unsetenv(name) ⇒ Object
Un-sets an environment variable.
Shell Methods collapse
-
#shell_exec(command) ⇒ Object
Executes a new shell command using the given program name and additional arguments.
Instance Method Summary collapse
-
#call(method, *arguments) ⇒ Object
Calls the RPC method.
-
#initialize(client) ⇒ RPCSession
constructor
Initializes the RPC session.
Methods inherited from Session
Constructor Details
#initialize(client) ⇒ RPCSession
Initializes the RPC session.
44 45 46 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 44 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ #call (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The RPC client object.
36 37 38 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 36 def client @client end |
Instance Method Details
#call(method, *arguments) ⇒ Object
Calls the RPC method.
60 61 62 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 60 def call(method,*arguments) @client.call(method,*arguments) end |
#file_close(fd) ⇒ Object
calls the file.close
RPC function.
Closes an opened remote file-descriptor.
257 258 259 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 257 def file_close(fd) call('file.close',fd) end |
#file_fcntl(fd, command, argument) ⇒ Integer
calls the file.fcntl
RPC function.
Performs a fcntl()
operation on the file-descriptor.
228 229 230 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 228 def file_fcntl(fd,command,argument) call('file.fcntl',fd,command,argument) end |
#file_ioctl(fd, command, argument) ⇒ Integer
calls the file.ioctl
RPC function.
Performs a ioctl()
operation on the file-descriptor.
207 208 209 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 207 def file_ioctl(fd,command,argument) call('file.ioctl',fd,command,argument) end |
#file_open(path, mode = 'r') ⇒ Integer
calls the file.open
RPC function.
Opens a file and returns the file-descriptor number.
109 110 111 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 109 def file_open(path,mode='r') call('file.open',path,mode) end |
#file_read(fd, length) ⇒ String?
calls the file.read
RPC function.
Reads from an opened file-descriptor and returns the read data.
127 128 129 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 127 def file_read(fd,length) call('file.read',fd,length) end |
#file_seek(fd, new_pos, whence) ⇒ Object
calls the file.seek
RPC function.
Seeks to a position within the file.
171 172 173 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 171 def file_seek(fd,new_pos,whence) call('file.seek',fd,new_pos,whence) end |
#file_stat(fd) ⇒ Hash{Symbol => Object}?
calls the file.stat
RPC function.
Queries file information from the given file-descriptor and returns a Hash of file metadata.
245 246 247 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 245 def file_stat(fd) call('file.stat',fd) end |
#file_tell(fd) ⇒ Integer
calls the file.tell
RPC function.
Queries the current position within the file.
186 187 188 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 186 def file_tell(fd) call('file.tell',fd) end |
#file_write(fd, pos, data) ⇒ Integer
calls the file.write
RPC function.
Writes data to the opened file-descriptor.
147 148 149 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 147 def file_write(fd,pos,data) call('file.write',fd,pos,data) end |
#fs_chdir(path) ⇒ Object
calls the fs.chdir
RPC function.
Changes the current working directory.
285 286 287 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 285 def fs_chdir(path) call('fs.chdir',path) end |
#fs_chgrp(group, path) ⇒ Object
calls the fs.chgrp
RPC function.
Changes the group ownership of a remote file or directory.
461 462 463 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 461 def fs_chgrp(group,path) call('fs.chgrp',group,path) end |
#fs_chmod(mode, path) ⇒ Object
calls the fs.chmod
RPC function.
Changes the permissions on a remote file or directory.
491 492 493 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 491 def fs_chmod(mode,path) call('fs.chmod',mode,path) end |
#fs_chown(user, path) ⇒ Object
calls the fs.chown
RPC function.
Changes the user ownership of remote a file or directory.
476 477 478 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 476 def fs_chown(user,path) call('fs.chown',user,path) end |
#fs_copy(src, dest) ⇒ Object
calls the fs.copy
RPC function.
Copies a source file to the destination path.
391 392 393 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 391 def fs_copy(src,dest) call('fs.copy',src,dest) end |
#fs_getcwd ⇒ String
calls the fs.getcwd
RPC function.
Gets the current working directory and returns the directory path.
273 274 275 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 273 def fs_getcwd call('fs.getcwd') end |
#fs_glob(pattern) ⇒ Array<String>
calls the fs.glob
RPC function.
Evaluates a directory glob pattern and returns all matching paths.
349 350 351 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 349 def fs_glob(pattern) call('fs.glob',pattern) end |
#fs_link(src, dest) ⇒ Object
calls the fs.link
RPC function.
Creates a remote symbolic link at the destination path pointing to the source path.
446 447 448 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 446 def fs_link(src,dest) call('fs.link',src,dest) end |
#fs_mkdir(new_path) ⇒ Object
calls the fs.mkdir
RPC function.
Creates a new remote directory at the given path.
376 377 378 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 376 def fs_mkdir(new_path) call('fs.mkdir',new_path) end |
#fs_mktemp(basename) ⇒ String
calls the fs.mktemp
RPC function.
Creates a remote temporary file with the given file basename.
364 365 366 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 364 def fs_mktemp(basename) call('fs.mktemp',basename) end |
#fs_move(src, dest) ⇒ Object
calls the fs.move
RPC function.
Moves or renames a remote source file to a new destination path.
430 431 432 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 430 def fs_move(src,dest) call('fs.move',src,dest) end |
#fs_readdir(path) ⇒ Array<String>
calls the fs.readdir
RPC function.
Reads the contents of a remote directory and returns an Array of directory entry names.
334 335 336 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 334 def fs_readdir(path) call('fs.readdir',path) end |
#fs_readfile(path) ⇒ String?
calls the fs.readfile
RPC function.
Reads the entire file at the given path and returns the full file's contents.
302 303 304 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 302 def fs_readfile(path) call('fs.readfile',path) end |
#fs_readlink(path) ⇒ String?
calls the fs.readlink
RPC function.
Reads the destination path of a remote symbolic link.
318 319 320 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 318 def fs_readlink(path) call('fs.readlink',path) end |
#fs_rmdir(path) ⇒ Object
calls the fs.rmdir
RPC function.
Removes an empty directory at the given path.
415 416 417 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 415 def fs_rmdir(path) call('fs.rmdir',path) end |
#fs_stat(path) ⇒ Hash{Symbol => Object}?
calls the fs.stat
RPC function.
Queries file information for the given remote path and returns a Hash of file metadata.
507 508 509 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 507 def fs_stat(path) call('fs.stat',path) end |
#fs_unlink(path) ⇒ Object
calls the fs.unlink
RPC function.
Removes a file at the given path.
403 404 405 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 403 def fs_unlink(path) call('fs.unlink',path) end |
#process_environ ⇒ Hash{String => String}
calls the process.environ
RPC function.
Queries all environment variables of the current process. Returns a Hash of the env variable names and values.
669 670 671 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 669 def process_environ call('process.environ') end |
#process_exit ⇒ Object
calls the process.exit
RPC function.
Exits the current process.
755 756 757 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 755 def process_exit call('process.exit') end |
#process_getegid ⇒ Integer
calls the process_getegid
RPC function.
Gets the current process's effective group ID (EGID).
619 620 621 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 619 def process_getegid call('process.getegid') end |
#process_getenv(name) ⇒ String?
calls the process.getenv
RPC function.
Gets an individual environment variable. If the environment variable
has not been set, nil
will be returned.
685 686 687 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 685 def process_getenv(name) call('process.getenv',name) end |
#process_geteuid ⇒ Integer
calls the process.geteuid
RPC function.
Gets the current process's effective UID (EUID).
571 572 573 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 571 def process_geteuid call('process.geteuid') end |
#process_getgid ⇒ Integer
calls the process_getgid
RPC function.
Gets the current process's group ID (GID).
595 596 597 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 595 def process_getgid call('process.getgid') end |
#process_getpid ⇒ Integer
calls the process.getpid
RPC function.
Gets the current process's Process ID (PID).
523 524 525 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 523 def process_getpid call('process.getpid') end |
#process_getppid ⇒ Integer
calls the process.getppid
RPC function.
Gets the current process's parent Process ID (PPID).
535 536 537 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 535 def process_getppid call('process.getppid') end |
#process_getsid ⇒ Integer
calls the process.getsid
RPC function.
Gets the current process's session ID (SID).
644 645 646 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 644 def process_getsid call('process.getsid') end |
#process_getuid ⇒ Integer
calls the process.getuid
RPC function.
Gets the current process's user ID (UID).
547 548 549 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 547 def process_getuid call('process.getuid') end |
#process_kill(pid, signal) ⇒ Object
calls the process.kill
RPC function.
Kills another process using the given Process ID (POD) and the signal number.
728 729 730 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 728 def process_kill(pid,signal) call('process.kill',pid,signal) end |
#process_setegid(egid) ⇒ Object
calls the process_setegid
RPC function.
Sets the current process's effective group ID (EGID) to the given Integer.
632 633 634 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 632 def process_setegid(egid) call('process.setegid',egid) end |
#process_setenv(name, value) ⇒ Object
calls the process.setenv
RPC function.
Sets an environment variable to the given value.
700 701 702 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 700 def process_setenv(name,value) call('process.setenv',name,value) end |
#process_seteuid(euid) ⇒ Object
calls the process_seteuid
RPC function.
Sets the current process's effective UID (EUID) to the given Integer.
583 584 585 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 583 def process_seteuid(euid) call('process.seteuid',euid) end |
#process_setgid(gid) ⇒ Object
calls the process_setgid
RPC function.
Sets the current process's group ID (GID) to the given Integer.
607 608 609 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 607 def process_setgid(gid) call('process.setgid',gid) end |
#process_setsid(sid) ⇒ Object
calls the process.setsid
RPC function.
Sets the current process's session ID (SID).
656 657 658 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 656 def process_setsid(sid) call('process.setsid',sid) end |
#process_setuid(uid) ⇒ Object
calls the process.setuid
RPC function.
Sets the current process's user ID (UID) to the given Integer.
559 560 561 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 559 def process_setuid(uid) call('process.setuid',uid) end |
#process_spawn(program, *arguments) ⇒ Integer
calls the process.spawn
RPC function.
Spawns a new process using the given program and additional arguments.
746 747 748 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 746 def process_spawn(program,*arguments) call('process.spawn',program,*arguments) end |
#process_unsetenv(name) ⇒ Object
calls the process.unsetenv
RPC function.
Un-sets an environment variable.
712 713 714 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 712 def process_unsetenv(name) call('process.unsetenv',name) end |
#shell_exec(command) ⇒ Object
calls the shell.exec
RPC function.
Executes a new shell command using the given program name and additional arguments.
772 773 774 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 772 def shell_exec(command) call('shell.exec',command) end |
#sys_hostname ⇒ String
calls the sys.hostname
RPC function.
Gets the system's hostname.
87 88 89 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 87 def sys_hostname call('sys.hostname') end |
#sys_time ⇒ Integer
calls the sys.time
RPC function.
Gets the current time and returns the UNIX timestamp.
76 77 78 |
# File 'lib/ronin/post_ex/sessions/rpc_session.rb', line 76 def sys_time call('sys.time') end |