From 47bb57a1fedbcf998e3212c73810ccbcdb5a4243 Mon Sep 17 00:00:00 2001 From: ErikWynter Date: Mon, 18 Sep 2023 12:31:13 +0300 Subject: [PATCH 1/3] add support for HELO in case EHLO is not supported --- modules/auxiliary/scanner/smtp/smtp_relay.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/auxiliary/scanner/smtp/smtp_relay.rb b/modules/auxiliary/scanner/smtp/smtp_relay.rb index 287316508f13..47ebe9a31363 100644 --- a/modules/auxiliary/scanner/smtp/smtp_relay.rb +++ b/modules/auxiliary/scanner/smtp/smtp_relay.rb @@ -84,6 +84,11 @@ def do_test_relay(testnumber, mailfrom, mailto) res = raw_send_recv("EHLO X\r\n") vprint_status("#{res.inspect}") + # check if the EHLO is actually supported. In case it's not, try the HELO command instead + if res.inspect&.include?('Command EHLO not known') + res = raw_send_recv("HELO X\r\n") + vprint_status("#{res.inspect}") + end res = raw_send_recv("#{mailfrom}\r\n") vprint_status("#{res.inspect}") From 75d2d20a049147e85c6e549fe3366c591c05cadc Mon Sep 17 00:00:00 2001 From: ErikWynter Date: Mon, 18 Sep 2023 17:25:04 +0300 Subject: [PATCH 2/3] check response code instead of text for downgrade to HELO --- modules/auxiliary/scanner/smtp/smtp_relay.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/auxiliary/scanner/smtp/smtp_relay.rb b/modules/auxiliary/scanner/smtp/smtp_relay.rb index 47ebe9a31363..7fa1c55e77f8 100644 --- a/modules/auxiliary/scanner/smtp/smtp_relay.rb +++ b/modules/auxiliary/scanner/smtp/smtp_relay.rb @@ -85,7 +85,7 @@ def do_test_relay(testnumber, mailfrom, mailto) res = raw_send_recv("EHLO X\r\n") vprint_status("#{res.inspect}") # check if the EHLO is actually supported. In case it's not, try the HELO command instead - if res.inspect&.include?('Command EHLO not known') + if res.inspect =~ /^"5\d\d/ res = raw_send_recv("HELO X\r\n") vprint_status("#{res.inspect}") end From e5c922619b1dd1b95595fa82da3892b6ea291d4e Mon Sep 17 00:00:00 2001 From: ErikWynter Date: Mon, 18 Sep 2023 19:33:07 +0300 Subject: [PATCH 3/3] use res for check response code instead of res.inspect --- modules/auxiliary/scanner/smtp/smtp_relay.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/auxiliary/scanner/smtp/smtp_relay.rb b/modules/auxiliary/scanner/smtp/smtp_relay.rb index 7fa1c55e77f8..141eca030c72 100644 --- a/modules/auxiliary/scanner/smtp/smtp_relay.rb +++ b/modules/auxiliary/scanner/smtp/smtp_relay.rb @@ -85,7 +85,7 @@ def do_test_relay(testnumber, mailfrom, mailto) res = raw_send_recv("EHLO X\r\n") vprint_status("#{res.inspect}") # check if the EHLO is actually supported. In case it's not, try the HELO command instead - if res.inspect =~ /^"5\d\d/ + if res.to_s =~ /^5\d\d/ res = raw_send_recv("HELO X\r\n") vprint_status("#{res.inspect}") end