Class: Ronin::PostExploitation::Shells::FS

Inherits:
UI::Shell
  • Object
show all
Defined in:
lib/ronin/post_exploitation/shells/fs.rb

Overview

A shell for Resources::FS.

Since:

  • 1.0.0

Instance Method Summary collapse

Constructor Details

#initialize(fs) ⇒ FS

Initializes the file-system shell.

Since:

  • 1.0.0


41
42
43
44
45
# File 'lib/ronin/post_exploitation/shells/fs.rb', line 41

def initialize(fs)
  super(name: 'fs')

  @fs = fs
end

Instance Method Details

#chdir(path) ⇒ Object (protected) Also known as: cd

Changes the working directory.

See Also:

Since:

  • 1.0.0


57
58
59
60
# File 'lib/ronin/post_exploitation/shells/fs.rb', line 57

def chdir(path)
  @fs.chdir(path)
  print_info "Current working directory is now: #{@fs.pwd}"
end

#chgrp(*args) ⇒ Object (protected)

Changes group ownership of a file or directory.

See Also:

Since:

  • 1.0.0


230
231
232
233
234
# File 'lib/ronin/post_exploitation/shells/fs.rb', line 230

def chgrp(*args)
  @fs.chgrp(*args)

  print_info "Changed group ownership of #{@fs.join(args.first)}"
end

#chmod(*args) ⇒ Object (protected)

Changes the permissions of a file or directory.

See Also:

Since:

  • 1.0.0


244
245
246
247
248
# File 'lib/ronin/post_exploitation/shells/fs.rb', line 244

def chmod(*args)
  @fs.chmod(*args)

  print_info "Changed permissions on #{@fs.join(args.first)}"
end

#chown(*args) ⇒ Object (protected)

Changes ownership of a file or directory.

See Also:

Since:

  • 1.0.0


216
217
218
219
220
# File 'lib/ronin/post_exploitation/shells/fs.rb', line 216

def chown(*args)
  @fs.chown(*args)

  print_info "Changed ownership of #{@fs.join(args.first)}"
end

#copy(src, dest) ⇒ Object (protected) Also known as: cp

Copies a file to a destination.

See Also:

Since:

  • 1.0.0


136
137
138
139
140
# File 'lib/ronin/post_exploitation/shells/fs.rb', line 136

def copy(src,dest)
  @fs.copy(src,dest)

  print_info "Copied #{@fs.join(src)} -> #{@fs.join(dest)}"
end

#cwdObject (protected) Also known as: pwd

Prints the current working directory.

See Also:

Since:

  • 1.0.0


68
69
70
# File 'lib/ronin/post_exploitation/shells/fs.rb', line 68

def cwd
  print_info "Current working directory: #{@fs.getcwd}"
end

#hexdump(path) ⇒ Object (protected)

Hexdumps a file.

See Also:

Since:

  • 1.0.0


121
122
123
# File 'lib/ronin/post_exploitation/shells/fs.rb', line 121

def hexdump(path)
  @fs.hexdump(path,self)
end

Creates a link to a file or directory.

See Also:

Since:

  • 1.0.0


201
202
203
204
205
# File 'lib/ronin/post_exploitation/shells/fs.rb', line 201

def link(src,dest)
  @fs.link(src,dest)

  print_info "Linked #{@fs.join(src)} -> #{@fs.join(dest)}"
end

#move(src, dest) ⇒ Object (protected) Also known as: mv

Moves a file or directory.

See Also:

Since:

  • 1.0.0


183
184
185
186
187
# File 'lib/ronin/post_exploitation/shells/fs.rb', line 183

def move(src,dest)
  @fs.move(src,dest)

  print_info "Moved #{@fs.join(src)} -> #{@fs.join(dest)}"
end

#read(path) ⇒ Object (protected) Also known as: cat

Reads data from a file.

See Also:

Since:

  • 1.0.0


81
82
83
# File 'lib/ronin/post_exploitation/shells/fs.rb', line 81

def read(path)
  write(@fs.read(path))
end

#readdir(path) ⇒ Object (protected) Also known as: dir

Reads the entries of a directory.

See Also:

Since:

  • 1.0.0


106
107
108
109
110
# File 'lib/ronin/post_exploitation/shells/fs.rb', line 106

def readdir(path)
  @fs.readdir(path).each do |entry|
    puts entry
  end
end

Reads the destination of a link.

See Also:

Since:

  • 1.0.0


94
95
96
# File 'lib/ronin/post_exploitation/shells/fs.rb', line 94

def readlink(path)
  puts @fs.readlink(path)
end

#rmdir(path) ⇒ Object (protected)

Removes an empty directory.

See Also:

Since:

  • 1.0.0


166
167
168
169
170
# File 'lib/ronin/post_exploitation/shells/fs.rb', line 166

def rmdir(path)
  @fs.rmdir(path)

  print_info "Removed directory #{@fs.join(path)}"
end

#stat(path) ⇒ Object (protected)

Stats a file or directory.

See Also:

Since:

  • 1.0.0


258
259
260
# File 'lib/ronin/post_exploitation/shells/fs.rb', line 258

def stat(path)
  @fs.stat(path)
end

Removes a file.

See Also:

Since:

  • 1.0.0


151
152
153
154
155
# File 'lib/ronin/post_exploitation/shells/fs.rb', line 151

def unlink(path)
  @fs.unlink(path)

  print_info "Removed #{@fs.join(path)}"
end