From ef6dad2bc3c70b052d1e932fa1945e4200ccab33 Mon Sep 17 00:00:00 2001 From: Luke Imhoff Date: Mon, 8 Oct 2012 09:12:23 -0500 Subject: [PATCH] Fix loading binary modules on Windows [#36737359, #36401509] Failed to follow HACKING guideline #5, open files in binary mode, so Pro modules were being truncated on Windows installs. --- lib/msf/core/modules/loader/directory.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/msf/core/modules/loader/directory.rb b/lib/msf/core/modules/loader/directory.rb index 5ac977b730..0dbde7f014 100644 --- a/lib/msf/core/modules/loader/directory.rb +++ b/lib/msf/core/modules/loader/directory.rb @@ -73,6 +73,13 @@ class Msf::Modules::Loader::Directory < Msf::Modules::Loader::Base def read_module_content(parent_path, type, module_reference_name) full_path = module_path(parent_path, type, module_reference_name) - ::File.read(full_path) + module_content = '' + + # force to read in binary mode so Pro modules won't be truncated on Windows + File.open(full_path, 'rb') do |f| + module_content = f.read + end + + module_content end end