Class: Ronin::PHP::LFI::File

Inherits:
StringIO
  • Object
show all
Defined in:
lib/ronin/php/lfi/file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, body) ⇒ File

Creates a new Inclusion with the specified path and response body.



36
37
38
39
40
# File 'lib/ronin/php/lfi/file.rb', line 36

def initialize(path,body)
  super(body)

  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Path to the file



30
31
32
# File 'lib/ronin/php/lfi/file.rb', line 30

def path
  @path
end

Instance Method Details

#contentsObject

Returns the contents of the File in String form.



45
46
47
# File 'lib/ronin/php/lfi/file.rb', line 45

def contents
  string
end

#inspectObject



56
57
58
# File 'lib/ronin/php/lfi/file.rb', line 56

def inspect
  "#<#{self.class}:#{@path}>"
end

#mirror(base) ⇒ Object



72
73
74
75
76
77
78
79
80
81
# File 'lib/ronin/php/lfi/file.rb', line 72

def mirror(base)
  dest = File.join(base,@path)
  dest_dir = File.dirname(dest)

  unless File.directory?(dest_dir)
    FileUtils.mkdir_p(dest_dir)
  end

  return save(dest)
end

#save(destination) ⇒ Object

Saves the body to specified destination, returns the destination.



64
65
66
67
68
69
70
# File 'lib/ronin/php/lfi/file.rb', line 64

def save(destination)
  File.open(destination,'w') do |dest|
    dest.write(string)
  end

  return destination
end

#to_sObject

See contents.



52
53
54
# File 'lib/ronin/php/lfi/file.rb', line 52

def to_s
  contents
end