fix ms17010 legacy packet decoding
测试构建 / 代码检查 (push) Has been cancelled
测试构建 / 单元测试和构建 (push) Has been cancelled
测试构建 / 构建验证 (push) Has been cancelled

This commit is contained in:
ZacharyZcR
2026-05-09 11:08:32 +08:00
parent ad32568857
commit 63c899f465
2 changed files with 30 additions and 4 deletions
+1 -4
View File
@@ -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填充
+29
View File
@@ -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()