Skip to content

Commit 39f518e

Browse files
committed
Conditionally validate only when session type is enabled
1 parent 355d5c2 commit 39f518e

File tree

5 files changed

+19
-21
lines changed

5 files changed

+19
-21
lines changed

lib/msf/core/optional_session.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module OptionalSession
1111
# Validates options depending on whether we are using SESSION or an RHOST for our connection
1212
def validate
1313
super
14-
return unless framework.features.enabled?(Msf::FeatureManager::SMB_SESSION_TYPE)
14+
return unless optional_session_enabled?
1515

1616
# If the session is set use that by default regardless of rhost being (un)set
1717
if session
@@ -23,6 +23,12 @@ def validate
2323
end
2424
end
2525

26+
def session
27+
return nil unless optional_session_enabled?
28+
29+
super
30+
end
31+
2632
protected
2733

2834
# Used to validate options when RHOST has been set

lib/msf/core/optional_session/mssql.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def initialize(info = {})
1515
)
1616
)
1717

18-
if framework.features.enabled?(Msf::FeatureManager::MSSQL_SESSION_TYPE)
18+
if optional_session_enabled?
1919
register_option_group(name: 'SESSION',
2020
description: 'Used when connecting via an existing SESSION',
2121
option_names: ['SESSION'])
@@ -37,10 +37,8 @@ def initialize(info = {})
3737
end
3838
end
3939

40-
def session
41-
return nil unless framework.features.enabled?(Msf::FeatureManager::MSSQL_SESSION_TYPE)
42-
43-
super
40+
def optional_session_enabled?
41+
framework.features.enabled?(Msf::FeatureManager::MSSQL_SESSION_TYPE)
4442
end
4543
end
4644
end

lib/msf/core/optional_session/mysql.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def initialize(info = {})
1515
)
1616
)
1717

18-
if framework.features.enabled?(Msf::FeatureManager::MYSQL_SESSION_TYPE)
18+
if optional_session_enabled?
1919
register_option_group(name: 'SESSION',
2020
description: 'Used when connecting via an existing SESSION',
2121
option_names: ['SESSION'])
@@ -35,10 +35,8 @@ def initialize(info = {})
3535
end
3636
end
3737

38-
def session
39-
return nil unless framework.features.enabled?(Msf::FeatureManager::MYSQL_SESSION_TYPE)
40-
41-
super
38+
def optional_session_enabled?
39+
framework.features.enabled?(Msf::FeatureManager::MYSQL_SESSION_TYPE)
4240
end
4341
end
4442
end

lib/msf/core/optional_session/postgresql.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def initialize(info = {})
1515
)
1616
)
1717

18-
if framework.features.enabled?(Msf::FeatureManager::POSTGRESQL_SESSION_TYPE)
18+
if optional_session_enabled?
1919
register_option_group(name: 'SESSION',
2020
description: 'Used when connecting via an existing SESSION',
2121
option_names: ['SESSION'])
@@ -37,10 +37,8 @@ def initialize(info = {})
3737
end
3838
end
3939

40-
def session
41-
return nil unless framework.features.enabled?(Msf::FeatureManager::POSTGRESQL_SESSION_TYPE)
42-
43-
super
40+
def optional_session_enabled?
41+
framework.features.enabled?(Msf::FeatureManager::POSTGRESQL_SESSION_TYPE)
4442
end
4543
end
4644
end

lib/msf/core/optional_session/smb.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def initialize(info = {})
1515
)
1616
)
1717

18-
if framework.features.enabled?(Msf::FeatureManager::SMB_SESSION_TYPE)
18+
if optional_session_enabled?
1919
register_option_group(name: 'SESSION',
2020
description: 'Used when connecting via an existing SESSION',
2121
option_names: ['SESSION'])
@@ -35,10 +35,8 @@ def initialize(info = {})
3535
end
3636
end
3737

38-
def session
39-
return nil unless framework.features.enabled?(Msf::FeatureManager::SMB_SESSION_TYPE)
40-
41-
super
38+
def optional_session_enabled?
39+
framework.features.enabled?(Msf::FeatureManager::SMB_SESSION_TYPE)
4240
end
4341
end
4442
end

0 commit comments

Comments
 (0)