mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-22 03:10:42 +08:00
fix ms17010 legacy packet decoding
This commit is contained in:
@@ -184,10 +184,7 @@ func aesDecrypt(crypted string, key string) (string, error) {
|
||||
return "", fmt.Errorf("密文长度过短")
|
||||
}
|
||||
|
||||
iv := cryptedBytes[:aes.BlockSize]
|
||||
cryptedBytes = cryptedBytes[aes.BlockSize:]
|
||||
|
||||
mode := cipher.NewCBCDecrypter(block, iv)
|
||||
mode := cipher.NewCBCDecrypter(block, keyBytes[:aes.BlockSize])
|
||||
mode.CryptBlocks(cryptedBytes, cryptedBytes)
|
||||
|
||||
// 移除PKCS7填充
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"net"
|
||||
"testing"
|
||||
@@ -11,6 +12,34 @@ import (
|
||||
"github.com/shadow1ng/fscan/common"
|
||||
)
|
||||
|
||||
func TestMS17010LegacyRequestsDecodeToSMB1Packets(t *testing.T) {
|
||||
requests := map[string][]byte{
|
||||
"negotiate": negotiateProtocolRequest,
|
||||
"sessionSetup": sessionSetupRequest,
|
||||
"treeConnect": treeConnectRequest,
|
||||
"transNamedPipe": transNamedPipeRequest,
|
||||
"trans2SessionSetup": trans2SessionSetupRequest,
|
||||
}
|
||||
|
||||
for name, request := range requests {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
if len(request) < 36 {
|
||||
t.Fatalf("request length = %d, want at least 36", len(request))
|
||||
}
|
||||
if request[0] != 0x00 {
|
||||
t.Fatalf("NetBIOS message type = 0x%02x, want 0x00", request[0])
|
||||
}
|
||||
payloadLen := int(request[1])<<16 | int(request[2])<<8 | int(request[3])
|
||||
if payloadLen != len(request)-4 {
|
||||
t.Fatalf("NetBIOS payload length = %d, want %d", payloadLen, len(request)-4)
|
||||
}
|
||||
if !bytes.Equal(request[4:8], []byte{0xff, 0x53, 0x4d, 0x42}) {
|
||||
t.Fatalf("SMB signature = % x, want ff 53 4d 42", request[4:8])
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMS17010CheckDetectsVulnerableStatus(t *testing.T) {
|
||||
addr, cleanup := startMS17010FakeServer(t, true, 45)
|
||||
defer cleanup()
|
||||
|
||||
Reference in New Issue
Block a user