mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-25 20:51:52 +08:00
fix ms17010 legacy packet decoding (#574)
This commit is contained in:
@@ -184,10 +184,7 @@ func aesDecrypt(crypted string, key string) (string, error) {
|
|||||||
return "", fmt.Errorf("密文长度过短")
|
return "", fmt.Errorf("密文长度过短")
|
||||||
}
|
}
|
||||||
|
|
||||||
iv := cryptedBytes[:aes.BlockSize]
|
mode := cipher.NewCBCDecrypter(block, keyBytes[:aes.BlockSize])
|
||||||
cryptedBytes = cryptedBytes[aes.BlockSize:]
|
|
||||||
|
|
||||||
mode := cipher.NewCBCDecrypter(block, iv)
|
|
||||||
mode.CryptBlocks(cryptedBytes, cryptedBytes)
|
mode.CryptBlocks(cryptedBytes, cryptedBytes)
|
||||||
|
|
||||||
// 移除PKCS7填充
|
// 移除PKCS7填充
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -11,6 +12,34 @@ import (
|
|||||||
"github.com/shadow1ng/fscan/common"
|
"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) {
|
func TestMS17010CheckDetectsVulnerableStatus(t *testing.T) {
|
||||||
addr, cleanup := startMS17010FakeServer(t, true, 45)
|
addr, cleanup := startMS17010FakeServer(t, true, 45)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|||||||
Reference in New Issue
Block a user