Land #10949, ForceExploit for Linux local exploits

This commit is contained in:
William Vu
2018-11-27 11:23:03 -06:00
11 changed files with 103 additions and 33 deletions
@@ -73,6 +73,7 @@ class MetasploitModule < Msf::Exploit::Local
OptEnum.new('COMPILE', [ true, 'Compile on target', 'Auto', %w(Auto True False) ])
]
register_advanced_options [
OptBool.new('ForceExploit', [ false, 'Override check result', false ]),
OptString.new('WritableDir', [ true, 'A directory where we can write files', '/tmp' ])
]
end
@@ -168,12 +169,17 @@ class MetasploitModule < Msf::Exploit::Local
end
def exploit
if check != CheckCode::Appears
fail_with Failure::NotVulnerable, 'Target is not vulnerable'
unless check == CheckCode::Appears
unless datastore['ForceExploit']
fail_with Failure::NotVulnerable, 'Target is not vulnerable. Set ForceExploit to override.'
end
print_warning 'Target does not appear to be vulnerable'
end
if is_root?
fail_with Failure::BadConfig, 'Session already has root privileges'
unless datastore['ForceExploit']
fail_with Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.'
end
end
unless writable? base_dir
@@ -71,6 +71,7 @@ class MetasploitModule < Msf::Exploit::Local
OptEnum.new('COMPILE', [ true, 'Compile on target', 'Auto', %w(Auto True False) ])
]
register_advanced_options [
OptBool.new('ForceExploit', [ false, 'Override check result', false ]),
OptString.new('WritableDir', [ true, 'A directory where we can write files', '/tmp' ])
]
end
@@ -164,12 +165,17 @@ class MetasploitModule < Msf::Exploit::Local
end
def exploit
if check != CheckCode::Appears
fail_with Failure::NotVulnerable, 'Target is not vulnerable'
unless check == CheckCode::Appears
unless datastore['ForceExploit']
fail_with Failure::NotVulnerable, 'Target is not vulnerable. Set ForceExploit to override.'
end
print_warning 'Target does not appear to be vulnerable'
end
if is_root?
fail_with Failure::BadConfig, 'Session already has root privileges'
unless datastore['ForceExploit']
fail_with Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.'
end
end
unless writable? base_dir
@@ -93,6 +93,7 @@ class MetasploitModule < Msf::Exploit::Local
OptEnum.new('COMPILE', [ true, 'Compile on target', 'Auto', %w[Auto True False] ])
]
register_advanced_options [
OptBool.new('ForceExploit', [ false, 'Override check result', false ]),
OptString.new('WritableDir', [ true, 'A directory where we can write files', '/tmp' ])
]
end
@@ -178,11 +179,16 @@ class MetasploitModule < Msf::Exploit::Local
def exploit
unless check == CheckCode::Appears
fail_with Failure::NotVulnerable, 'Target not vulnerable! punt!'
unless datastore['ForceExploit']
fail_with Failure::NotVulnerable, 'Target is not vulnerable. Set ForceExploit to override.'
end
print_warning 'Target does not appear to be vulnerable'
end
if is_root?
fail_with Failure::BadConfig, 'Session already has root privileges'
unless datastore['ForceExploit']
fail_with Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.'
end
end
unless writable? base_dir
@@ -64,6 +64,7 @@ class MetasploitModule < Msf::Exploit::Local
OptEnum.new('COMPILE', [ true, 'Compile on target', 'Auto', %w(Auto True False) ])
]
register_advanced_options [
OptBool.new('ForceExploit', [ false, 'Override check result', false ]),
OptString.new('WritableDir', [ true, 'A directory where we can write files', '/tmp' ])
]
end
@@ -161,12 +162,21 @@ class MetasploitModule < Msf::Exploit::Local
end
def exploit
if is_root?
fail_with Failure::BadConfig, 'Session already has root privileges'
unless check == CheckCode::Appears
unless datastore['ForceExploit']
fail_with Failure::NotVulnerable, 'Target is not vulnerable. Set ForceExploit to override.'
end
print_warning 'Target does not appear to be vulnerable'
end
if check != CheckCode::Appears
fail_with Failure::NotVulnerable, 'Target is not vulnerable'
if is_root?
unless datastore['ForceExploit']
fail_with Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.'
end
end
unless writable? base_dir
fail_with Failure::BadConfig, "#{base_dir} is not writable"
end
unless writable? base_dir
@@ -45,6 +45,7 @@ class MetasploitModule < Msf::Exploit::Local
'Targets' => [[ 'Auto', {} ]],
'DefaultTarget' => 0))
register_advanced_options [
OptBool.new('ForceExploit', [ false, 'Override check result', false ]),
OptString.new('WritableDir', [ true, 'A directory where we can write files', '/tmp' ])
]
end
@@ -119,12 +120,17 @@ class MetasploitModule < Msf::Exploit::Local
end
def exploit
if is_root?
fail_with Failure::BadConfig, 'Session already has root privileges'
unless check == CheckCode::Appears
unless datastore['ForceExploit']
fail_with Failure::NotVulnerable, 'Target is not vulnerable. Set ForceExploit to override.'
end
print_warning 'Target does not appear to be vulnerable'
end
if check != CheckCode::Appears
fail_with Failure::NotVulnerable, 'Target is not vulnerable'
if is_root?
unless datastore['ForceExploit']
fail_with Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.'
end
end
print_status 'Building package...'
@@ -78,6 +78,7 @@ class MetasploitModule < Msf::Exploit::Local
OptString.new('PASSWORD', [ true, 'Password for the current user', '' ])
]
register_advanced_options [
OptBool.new('ForceExploit', [ false, 'Override check result', false ]),
OptString.new('WritableDir', [ true, 'A directory where we can write files', '/tmp' ])
]
end
@@ -158,11 +159,16 @@ class MetasploitModule < Msf::Exploit::Local
def exploit
if check == CheckCode::Safe
fail_with Failure::NotVulnerable, 'Target is not vulnerable'
unless datastore['ForceExploit']
fail_with Failure::NotVulnerable, 'Target is not vulnerable. Set ForceExploit to override.'
end
print_warning 'Target does not appear to be vulnerable'
end
if is_root?
fail_with Failure::BadConfig, 'Session already has root privileges'
unless datastore['ForceExploit']
fail_with Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.'
end
end
unless writable? base_dir
@@ -64,6 +64,7 @@ class MetasploitModule < Msf::Exploit::Local
},
'DefaultTarget' => 0))
register_advanced_options [
OptBool.new('ForceExploit', [ false, 'Override check result', false ]),
OptString.new('WritableDir', [true, 'A directory where we can write files', '/tmp'])
]
end
@@ -95,12 +96,17 @@ class MetasploitModule < Msf::Exploit::Local
end
def exploit
if is_root?
fail_with Failure::BadConfig, 'Session already has root privileges'
unless check == CheckCode::Detected
unless datastore['ForceExploit']
fail_with Failure::NotVulnerable, 'Target is not vulnerable. Set ForceExploit to override.'
end
print_warning 'Target does not appear to be vulnerable'
end
if check != CheckCode::Detected
fail_with Failure::NotVulnerable, 'Target is not vulnerable'
if is_root?
unless datastore['ForceExploit']
fail_with Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.'
end
end
@payload_name = ".#{rand_text_alphanumeric rand(10..15)}"
+8 -2
View File
@@ -64,6 +64,7 @@ class MetasploitModule < Msf::Exploit::Local
OptEnum.new('COMPILE', [ true, 'Compile on target', 'Auto', %w(Auto True False) ])
]
register_advanced_options [
OptBool.new('ForceExploit', [ false, 'Override check result', false ]),
OptString.new('WritableDir', [ true, 'A directory where we can write files', '/tmp' ])
]
end
@@ -151,11 +152,16 @@ class MetasploitModule < Msf::Exploit::Local
def exploit
unless check == CheckCode::Appears
fail_with Failure::NotVulnerable, 'Target is not vulnerable'
unless datastore['ForceExploit']
fail_with Failure::NotVulnerable, 'Target is not vulnerable. Set ForceExploit to override.'
end
print_warning 'Target does not appear to be vulnerable'
end
if is_root?
fail_with Failure::BadConfig, 'Session already has root privileges'
unless datastore['ForceExploit']
fail_with Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.'
end
end
unless writable? base_dir
@@ -54,6 +54,7 @@ class MetasploitModule < Msf::Exploit::Local
OptEnum.new('COMPILE', [ true, 'Compile on target', 'Auto', %w(Auto True False) ])
]
register_advanced_options [
OptBool.new('ForceExploit', [ false, 'Override check result', false ]),
OptString.new('WritableDir', [ true, 'A directory where we can write files (must not be mounted noexec)', '/tmp' ])
]
end
@@ -132,7 +133,7 @@ class MetasploitModule < Msf::Exploit::Local
release = kernel_release
unless release =~ /^3\.11\.0-(12|15)-generic/ || release.eql?('3.8.0-19-generic')
print_error "Kernel #{release} #{version} is not exploitable"
vprint_error "Kernel #{release} #{version} is not exploitable"
return CheckCode::Safe
end
vprint_good "Kernel #{release} #{version} is exploitable"
@@ -141,12 +142,17 @@ class MetasploitModule < Msf::Exploit::Local
end
def exploit
if is_root?
fail_with Failure::BadConfig, 'Session already has root privileges'
unless check == CheckCode::Appears
unless datastore['ForceExploit']
fail_with Failure::NotVulnerable, 'Target is not vulnerable. Set ForceExploit to override.'
end
print_warning 'Target does not appear to be vulnerable'
end
if check != CheckCode::Appears
fail_with Failure::NotVulnerable, 'Target not vulnerable! punt!'
if is_root?
unless datastore['ForceExploit']
fail_with Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.'
end
end
unless writable? base_dir
@@ -69,6 +69,7 @@ class MetasploitModule < Msf::Exploit::Local
OptBool.new('DEBUG_EXPLOIT', [ true, "Make the exploit executable be verbose about what it's doing", false ])
]
register_advanced_options [
OptBool.new('ForceExploit', [ false, 'Override check result', false ]),
OptString.new('WritableDir', [ true, 'A directory where we can write files (must not be mounted noexec)', '/tmp' ])
]
end
@@ -133,11 +134,16 @@ class MetasploitModule < Msf::Exploit::Local
def exploit
if check == CheckCode::Safe
fail_with Failure::NotVulnerable, 'Target is not vulnerable'
unless datastore['ForceExploit']
fail_with Failure::NotVulnerable, 'Target is not vulnerable. Set ForceExploit to override.'
end
print_warning 'Target does not appear to be vulnerable'
end
if is_root?
fail_with Failure::BadConfig, 'Session already has root privileges'
unless datastore['ForceExploit']
fail_with Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.'
end
end
unless writable? base_dir
@@ -70,6 +70,7 @@ class MetasploitModule < Msf::Exploit::Local
OptEnum.new('COMPILE', [ true, 'Compile on target', 'Auto', %w[Auto True False] ])
]
register_advanced_options [
OptBool.new('ForceExploit', [ false, 'Override check result', false ]),
OptString.new('WritableDir', [ true, 'A directory where we can write files', '/tmp' ])
]
end
@@ -162,11 +163,16 @@ class MetasploitModule < Msf::Exploit::Local
def exploit
unless check == CheckCode::Appears
fail_with Failure::NotVulnerable, 'Target not vulnerable! punt!'
unless datastore['ForceExploit']
fail_with Failure::NotVulnerable, 'Target is not vulnerable. Set ForceExploit to override.'
end
print_warning 'Target does not appear to be vulnerable'
end
if is_root?
fail_with Failure::BadConfig, 'Session already has root privileges'
unless datastore['ForceExploit']
fail_with Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.'
end
end
unless writable? base_dir