-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The SMTP module was matching on "STMP" when verifying the contents of the scan response. This PR fixes the typo and adds a test for the VerifySMTPContents() function.
- Loading branch information
1 parent
d9ed4f1
commit d25b7ad
Showing
2 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package smtp | ||
|
||
import ( | ||
"github.com/zmap/zgrab2" | ||
"testing" | ||
) | ||
|
||
func TestVerifySMTPContents(t *testing.T) { | ||
type Test struct { | ||
Banner string | ||
ExpectedStatus zgrab2.ScanStatus | ||
ExpectedCode int | ||
} | ||
testTable := map[string]Test{ | ||
"success with code": { | ||
Banner: `220-some.host.com ESMTP Exim 4.93 #2 Thu, 04 Feb 2021 13:34:12 -0500 | ||
220-We do not authorize the use of this system to transport unsolicited, | ||
220 and/or bulk e-mail.`, | ||
ExpectedStatus: zgrab2.SCAN_SUCCESS, | ||
ExpectedCode: 0, | ||
}, | ||
"success without code": { | ||
Banner: `ESMTP Exim 4.93 #2 Thu, 04 Feb 2021 13:34:12 -0500 | ||
220-We do not authorize the use of this system to transport unsolicited, | ||
220 and/or bulk e-mail.`, | ||
ExpectedStatus: zgrab2.SCAN_SUCCESS, | ||
ExpectedCode: 0, | ||
}, | ||
"invalid protocol": { | ||
Banner: "gibberish that doesnt match expected response", | ||
ExpectedStatus: zgrab2.SCAN_PROTOCOL_ERROR, | ||
ExpectedCode: 0, | ||
}, | ||
"error response": { | ||
Banner: "500-some.host.com ESMTP something went horribly wrong.", | ||
ExpectedStatus: zgrab2.SCAN_APPLICATION_ERROR, | ||
ExpectedCode: 500, | ||
}, | ||
} | ||
|
||
for name, test := range testTable { | ||
t.Run(name, func(t *testing.T) { | ||
status, code := VerifySMTPContents(test.Banner) | ||
if status != test.ExpectedStatus { | ||
t.Errorf("recieved unexpected status: %s, wanted: %s", status, test.ExpectedStatus) | ||
} | ||
if code != test.ExpectedCode { | ||
t.Errorf("recieved unexpected code: %d, wanted: %d", code, test.ExpectedCode) | ||
} | ||
}) | ||
} | ||
|
||
} |