This change automatically sets +x permissions for cpuinfo and jtr if the install did not set them.

git-svn-id: file:///home/svn/framework3/trunk@14202 4d416f70-5f16-0410-b530-b9f4589650da
unstable
HD Moore 2011-11-09 16:44:07 +00:00
parent 9ff5eabb4b
commit 80652126b0
1 changed files with 30 additions and 14 deletions

View File

@ -1,6 +1,9 @@
require 'open3' require 'open3'
require 'fileutils'
require 'rex/proto/ntlm/crypt' require 'rex/proto/ntlm/crypt'
module Msf module Msf
### ###
@ -33,37 +36,43 @@ module Auxiliary::JohnTheRipper
def autodetect_platform def autodetect_platform
cpuinfo_base = ::File.join(Msf::Config.install_root, "data", "cpuinfo") cpuinfo_base = ::File.join(Msf::Config.install_root, "data", "cpuinfo")
return @run_path if @run_path
case ::RUBY_PLATFORM case ::RUBY_PLATFORM
when /mingw|cygwin|mswin/ when /mingw|cygwin|mswin/
data = `"#{cpuinfo_base}/cpuinfo.exe"` data = `"#{cpuinfo_base}/cpuinfo.exe"` rescue nil
case data case data
when /sse2/ when /sse2/
@run_path = "run.win32.sse2/john.exe" @run_path ||= "run.win32.sse2/john.exe"
when /mmx/ when /mmx/
@run_path = "run.win32.mmx/john.exe" @run_path ||= "run.win32.mmx/john.exe"
else else
@run_path = "run.win32.any/john.exe" @run_path ||= "run.win32.any/john.exe"
end end
when /x86_64-linux/ when /x86_64-linux/
data = `#{cpuinfo_base}/cpuinfo.ia64.bin` ::FileUtils.chmod(755, "#{cpuinfo_base}/cpuinfo.ia64.bin") rescue nil
data = `#{cpuinfo_base}/cpuinfo.ia64.bin` rescue nil
case data case data
when /mmx/ when /mmx/
@run_path = "run.linux.x64.mmx/john" @run_path ||= "run.linux.x64.mmx/john"
else else
@run_path = "run.linux.x86.any/john" @run_path ||= "run.linux.x86.any/john"
end end
when /i[\d]86-linux/ when /i[\d]86-linux/
data = `#{cpuinfo_base}/cpuinfo.ia32.bin` ::FileUtils.chmod(755, "#{cpuinfo_base}/cpuinfo.ia32.bin") rescue nil
data = `#{cpuinfo_base}/cpuinfo.ia32.bin` rescue nil
case data case data
when /sse2/ when /sse2/
@run_path = "run.linux.x86.sse2/john" @run_path ||= "run.linux.x86.sse2/john"
when /mmx/ when /mmx/
@run_path = "run.linux.x86.mmx/john" @run_path ||= "run.linux.x86.mmx/john"
else else
@run_path = "run.linux.x86.any/john" @run_path ||= "run.linux.x86.any/john"
end end
end end
@run_path
end end
def john_session_id def john_session_id
@ -160,16 +169,23 @@ module Auxiliary::JohnTheRipper
def john_binary_path def john_binary_path
if datastore['JOHN_PATH'] and ::File.file?(datastore['JOHN_PATH']) if datastore['JOHN_PATH'] and ::File.file?(datastore['JOHN_PATH'])
return datastore['JOHN_PATH'] path = datastore['JOHN_PATH']
::FileUtils.chmod(755, path) rescue nil
path
end end
if not @run_path if not @run_path
if ::RUBY_PLATFORM =~ /mingw|cygwin|mswin/ if ::RUBY_PLATFORM =~ /mingw|cygwin|mswin/
::File.join(john_base_path, "john.exe") ::File.join(john_base_path, "john.exe")
else else
::File.join(john_base_path, "john") path = ::File.join(john_base_path, "john")
::FileUtils.chmod(755, path) rescue nil
path
end end
else else
::File.join(john_base_path, @run_path) path = ::File.join(john_base_path, @run_path)
::FileUtils.chmod(755, path) rescue nil
path
end end
end end