Add spaces

bug/bundler_fix
jvazquez-r7 2015-08-28 11:47:50 -05:00
parent 132f5c6a20
commit 0a95a1543f
No known key found for this signature in database
GPG Key ID: 38D99152B9352D83
1 changed files with 18 additions and 26 deletions

View File

@ -5,16 +5,14 @@ require 'msf/core'
module Msf
class Post
module Linux
module Busybox
module BusyBox
include ::Msf::Post::File
#
#Checks if the target file exists
#@param file_path [String] the target file path
#@note file? doesnt work because test -f is not implemented in busybox
#@return [Boolean] True if files exists, otherwise false
#
# Checks if the target file exists
# @param file_path [String] the target file path
# @note file? doesnt work because test -f is not implemented in busybox
# @return [Boolean] True if files exists, otherwise false
def file_exists(file_path)
s = read_file(file_path)
if s and s.length
@ -23,11 +21,9 @@ module Busybox
return false
end
#
#Checks if the target directory is writable
#@param directory_path [String] the target directory path
#@return [Boolean] True if target directory is writable, otherwise false
#
# Checks if the target directory is writable
# @param directory_path [String] the target directory path
# @return [Boolean] True if target directory is writable, otherwise false
def is_writable_directory(directory_path)
retval = false
rand_str = ""; 16.times{rand_str << (65 + rand(25)).chr}
@ -41,17 +37,15 @@ module Busybox
return retval
end
#
#Checks if the target file is writable and writes or append to the file the data given as parameter
#@param file_path [String] the target file path
#@param data [String] the content to be written to the file
#@param append [Boolean] if true, append data to the target file. Otherwise, overwrite the target file
#@note BusyBox shell's commands are limited and Msf > Post > File > write_file function doesnt work here, for this reason it is necessary to implement an specific function
#@return [Boolean] True if target file is writable and it was written. Otherwise, false.
#
# Checks if the target file is writable and writes or append to the file the data given as parameter
# @param file_path [String] the target file path
# @param data [String] the content to be written to the file
# @param append [Boolean] if true, append data to the target file. Otherwise, overwrite the target file
# @note BusyBox shell's commands are limited and Msf > Post > File > write_file function doesnt work here, for this reason it is necessary to implement an specific function
# @return [Boolean] True if target file is writable and it was written. Otherwise, false.
def is_writable_and_write(file_path, data, append)
if append
writable_directory = get_writable_directory()
writable_directory = get_writable_directory
return false if not writable_directory
cmd_exec("cp -f #{file_path} #{writable_directory}tmp"); Rex::sleep(0.3)
end
@ -73,11 +67,9 @@ module Busybox
end
end
#
#Checks some directories that usually are writable in devices running busybox
#@return [String] If the function finds a writable directory, it returns the path. Else it returns nil
#
def get_writable_directory()
# Checks some directories that usually are writable in devices running busybox
# @return [String] If the function finds a writable directory, it returns the path. Else it returns nil
def get_writable_directory
writable_directory = nil
writable_directory = "/etc/" if is_writable_directory("/etc")
writable_directory = "/mnt/" if (!writable_directory && is_writable_directory("/mnt"))