Save data to ~/.beef - Fix #1254

This commit is contained in:
Brendan Coles
2017-04-15 09:56:01 +00:00
parent 55797a7b17
commit 4edab3e961
3 changed files with 13 additions and 4 deletions

8
beef
View File

@@ -19,6 +19,7 @@ end
$:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), '.'))
$root_dir = File.expand_path('..', __FILE__)
$home_dir = File.expand_path('~/.beef', __FILE__).freeze
# @note Require core loader's
require 'core/loader'
@@ -123,6 +124,13 @@ if config.get("beef.credentials.user").eql?('beef') && config.get("beef.credenti
print_warning "Warning: Default username and password in use!"
end
# @note create ~/.beef/
begin
FileUtils.mkdir_p($home_dir) unless File.directory?($home_dir)
rescue => e
print_error "Could not create '#{$home_dir}': #{e.message}"
end
#@note Prints the API key needed to use the RESTful API
print_info "RESTful API key: #{BeEF::Core::Crypto::api_token}"

View File

@@ -25,7 +25,7 @@ class Spyder_eye < BeEF::Core::Command
begin
timestamp = Time.now.localtime.strftime("%Y-%m-%d_%H-%M-%S")
ip = BeEF::Core::Models::BrowserDetails.get(session_id, 'IP')
filename = "screenshot_#{ip}_-_#{timestamp}_#{@datastore['cid']}.png"
filename = "#{$home_dir}/screenshot_#{ip}_-_#{timestamp}_#{@datastore['cid']}.png"
File.open(filename, 'wb') do |file|
data = @datastore['results'].gsub(/^image=data:image\/(png|jpg);base64,/, "")
file.write(Base64.decode64(data))

View File

@@ -13,10 +13,11 @@ class Get_wireless_keys < BeEF::Core::Command
content = {}
content['result'] = @datastore['result'].to_s
save content
f = File.open("exported_wlan_profiles.xml","w+")
filename = "#{$home_dir}/exported_wlan_profiles_#{ip}_-_#{timestamp}_#{@datastore['cid']}.xml"
f = File.open(filename,"w+")
f.write((@datastore['results']).sub("result=",""))
writeToResults = Hash.new
writeToResults['data'] = "Please import "+Dir.pwd+"/exported_wlan_profiles.xml into your windows machine"
writeToResults = Hash.new
writeToResults['data'] = "Please import #{filename} into your windows machine"
BeEF::Core::Models::Command.save_result(@datastore['beefhook'], @datastore['cid'] , @friendlyname, writeToResults, 0)
BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.unbind('/wirelessZeroConfig.jar')
end