2016-04-25 04:46:28 +02:00
|
|
|
package protocol
|
|
|
|
|
|
|
|
import (
|
2016-06-05 20:54:01 +02:00
|
|
|
"bufio"
|
|
|
|
"crypto/sha1"
|
|
|
|
"encoding/hex"
|
2016-07-31 02:00:42 +02:00
|
|
|
"fmt"
|
2016-05-03 16:31:56 +02:00
|
|
|
"github.com/s-rah/onionscan/config"
|
2016-04-25 04:46:28 +02:00
|
|
|
"github.com/s-rah/onionscan/report"
|
2016-06-07 08:29:29 +02:00
|
|
|
"github.com/s-rah/onionscan/utils"
|
2016-04-25 04:46:28 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type SMTPProtocolScanner struct {
|
|
|
|
}
|
|
|
|
|
2016-07-31 02:00:42 +02:00
|
|
|
func (sps *SMTPProtocolScanner) ScanProtocol(hiddenService string, osc *config.OnionscanConfig, report *report.OnionScanReport) {
|
2016-04-25 04:46:28 +02:00
|
|
|
// SMTP
|
2016-07-31 02:00:42 +02:00
|
|
|
osc.LogInfo(fmt.Sprintf("Checking %s SMTP(25)\n", hiddenService))
|
|
|
|
conn, err := utils.GetNetworkConnection(hiddenService, 25, osc.TorProxyAddress, osc.Timeout)
|
2016-04-25 04:46:28 +02:00
|
|
|
if err != nil {
|
2016-07-31 02:00:42 +02:00
|
|
|
osc.LogInfo("Failed to connect to service on port 25\n")
|
2016-05-23 10:38:10 +02:00
|
|
|
report.SMTPDetected = false
|
2016-04-25 04:46:28 +02:00
|
|
|
} else {
|
|
|
|
// TODO SMTP Checking
|
|
|
|
report.SMTPDetected = true
|
2016-06-05 20:54:01 +02:00
|
|
|
reader := bufio.NewReader(conn)
|
|
|
|
banner, err := reader.ReadString('\n')
|
|
|
|
if err == nil {
|
|
|
|
report.SMTPBanner = banner
|
|
|
|
hash := sha1.Sum([]byte(banner))
|
|
|
|
report.SMTPFingerprint = hex.EncodeToString(hash[:])
|
2016-07-31 02:00:42 +02:00
|
|
|
osc.LogInfo(fmt.Sprintf("Found SMTP Banner: %s (%s)", banner, report.SMTPFingerprint))
|
2016-06-05 20:54:01 +02:00
|
|
|
}
|
2016-04-25 04:46:28 +02:00
|
|
|
}
|
2016-07-31 21:05:42 +02:00
|
|
|
if conn != nil {
|
|
|
|
conn.Close()
|
|
|
|
}
|
2016-04-25 04:46:28 +02:00
|
|
|
}
|