整理代码

This commit is contained in:
2025-02-20 12:31:02 +08:00
parent 84362607c2
commit 71b5229198
17 changed files with 14 additions and 183 deletions

View File

@@ -1,17 +0,0 @@
package core
import (
"bytes"
"encoding/hex"
"testing"
)
func TestWriteUInt16LE(t *testing.T) {
buff := &bytes.Buffer{}
WriteUInt32LE(66538, buff)
result := hex.EncodeToString(buff.Bytes())
expected := "ea030100"
if result != expected {
t.Error(result, "not equals to", expected)
}
}

View File

@@ -1,15 +0,0 @@
// rle_test.go
package core
import (
"fmt"
"testing"
)
func TestSum(t *testing.T) {
input := []byte{
192, 44, 200, 8, 132, 200, 8, 200, 8, 200, 8, 200, 8, 0, 19, 132, 232, 8, 12, 50, 142, 66, 77, 58, 208, 59, 225, 25, 1, 0, 0, 0, 0, 0, 0, 0, 132, 139, 33, 142, 66, 142, 66, 142, 66, 208, 59, 4, 43, 1, 0, 0, 0, 0, 0, 0, 0, 132, 203, 41, 142, 66, 142, 66, 142, 66, 208, 59, 96, 0, 1, 0, 0, 0, 0, 0, 0, 0, 132, 9, 17, 142, 66, 142, 66, 142, 66, 208, 59, 230, 27, 1, 0, 0, 0, 0, 0, 0, 0, 132, 200, 8, 9, 17, 139, 33, 74, 25, 243, 133, 14, 200, 8, 132, 200, 8, 200, 8, 200, 8, 200, 8,
}
out := Decompress(input, 64, 64, 3)
fmt.Println(out)
}

View File

@@ -6,10 +6,9 @@ import (
"fmt"
"unsafe"
"ShotRDP/grdp/glog"
"ShotRDP/grdp/core"
"ShotRDP/grdp/emission"
"ShotRDP/grdp/glog"
)
const (

View File

@@ -1,22 +0,0 @@
// cliprdr_test.go
package cliprdr_test
import (
"fmt"
"testing"
"ShotRDP/grdp/plugin/cliprdr"
)
func TestClip(t *testing.T) {
//t1, _ := cliprdr.ReadAll()
//fmt.Printf("%s\n", t1)
ok := cliprdr.OpenClipboard(0)
fmt.Println(ok)
if ok {
name := cliprdr.GetClipboardData(13)
fmt.Printf("name=%s\n", name)
cliprdr.CloseClipboard()
}
}

View File

@@ -7,11 +7,10 @@ import (
"unicode/utf16"
"unsafe"
"ShotRDP/grdp/glog"
"github.com/shirou/w32"
"ShotRDP/grdp/core"
"ShotRDP/grdp/glog"
"ShotRDP/grdp/win"
)

View File

@@ -1,16 +0,0 @@
package nla_test
import (
"encoding/hex"
"testing"
"ShotRDP/grdp/protocol/nla"
)
func TestEncodeDERTRequest(t *testing.T) {
ntlm := nla.NewNTLMv2("", "", "")
result := nla.EncodeDERTRequest([]nla.Message{ntlm.GetNegotiateMessage()}, "", "")
if hex.EncodeToString(result) != "302fa003020102a12830263024a02204204e544c4d53535000010000003582086000000000000000000000000000000000" {
t.Error("not equal")
}
}

View File

@@ -1,32 +0,0 @@
package nla_test
import (
"encoding/hex"
"testing"
"ShotRDP/grdp/protocol/nla"
)
func TestNTOWFv2(t *testing.T) {
res := hex.EncodeToString(nla.NTOWFv2("", "", ""))
expected := "f4c1a15dd59d4da9bd595599220d971a"
if res != expected {
t.Error(res, "not equal to", expected)
}
res = hex.EncodeToString(nla.NTOWFv2("user", "pwd", "dom"))
expected = "652feb8208b3a8a6264c9c5d5b820979"
if res != expected {
t.Error(res, "not equal to", expected)
}
}
func TestRC4K(t *testing.T) {
key, _ := hex.DecodeString("55638e834ce774c100637f197bc0683f")
src, _ := hex.DecodeString("177d16086dd3f06fa8d594e3bad005b7")
res := hex.EncodeToString(nla.RC4K(key, src))
expected := "f5ab375222707a492bd5a90705d96d1d"
if res != expected {
t.Error(res, "not equal to", expected)
}
}

View File

@@ -10,6 +10,7 @@ import (
"ShotRDP/grdp/core"
"ShotRDP/grdp/glog"
"github.com/lunixbochs/struc"
)

View File

@@ -1,62 +0,0 @@
package nla_test
import (
"bytes"
"encoding/hex"
"testing"
"ShotRDP/grdp/protocol/nla"
"github.com/lunixbochs/struc"
)
func TestNewNegotiateMessage(t *testing.T) {
ntlm := nla.NewNTLMv2("", "", "")
negoMsg := ntlm.GetNegotiateMessage()
buff := &bytes.Buffer{}
struc.Pack(buff, negoMsg)
result := hex.EncodeToString(buff.Bytes())
expected := "4e544c4d535350000100000035820860000000000000000000000000000000000000000000000000"
if result != expected {
t.Error(result, " not equals to", expected)
}
}
func TestNTLMv2_ComputeResponse(t *testing.T) {
ntlm := nla.NewNTLMv2("", "", "")
ResponseKeyNT, _ := hex.DecodeString("39e32c766260586a9036f1ceb04c3007")
ResponseKeyLM, _ := hex.DecodeString("39e32c766260586a9036f1ceb04c3007")
ServerChallenge, _ := hex.DecodeString("adcb9d1c8d4a5ed8")
ClienChallenge, _ := hex.DecodeString("1a78bed8e5d5efa7")
Timestamp, _ := hex.DecodeString("a02f44f01267d501")
ServerName, _ := hex.DecodeString("02001e00570049004e002d00460037005200410041004d004100500034004a00430001001e00570049004e002d00460037005200410041004d004100500034004a00430004001e00570049004e002d00460037005200410041004d004100500034004a00430003001e00570049004e002d00460037005200410041004d004100500034004a00430007000800a02f44f01267d50100000000")
NtChallengeResponse, LmChallengeResponse, SessionBaseKey := ntlm.ComputeResponse(ResponseKeyNT, ResponseKeyLM, ServerChallenge, ClienChallenge, Timestamp, ServerName)
ntChallRespExpected := "4e7316531937d2fc91e7230853844b890101000000000000a02f44f01267d5011a78bed8e5d5efa70000000002001e00570049004e002d00460037005200410041004d004100500034004a00430001001e00570049004e002d00460037005200410041004d004100500034004a00430004001e00570049004e002d00460037005200410041004d004100500034004a00430003001e00570049004e002d00460037005200410041004d004100500034004a00430007000800a02f44f01267d50100000000"
lmChallRespExpected := "d4dc6edc0c37dd70f69b5c4f05a615661a78bed8e5d5efa7"
sessBaseKeyExpected := "034009be89a0507b2bd6d28e966e1dab"
if hex.EncodeToString(NtChallengeResponse) != ntChallRespExpected {
t.Error("NtChallengeResponse incorrect")
}
if hex.EncodeToString(LmChallengeResponse) != lmChallRespExpected {
t.Error("LmChallengeResponse incorrect")
}
if hex.EncodeToString(SessionBaseKey) != sessBaseKeyExpected {
t.Error("SessionBaseKey incorrect")
}
}
func TestSIGNKEY(t *testing.T) {
exportedSessionKey, _ := hex.DecodeString("be32c3c56ea6683200a35329d67880c3")
result := hex.EncodeToString(nla.SIGNKEY(exportedSessionKey, true))
expected := "79b4f9a4113230f378a0af99f784adae"
if result != expected {
t.Error(result, "not equal to", expected)
}
}

View File

@@ -8,9 +8,9 @@ import (
"io"
"ShotRDP/grdp/glog"
"ShotRDP/grdp/core"
"ShotRDP/grdp/protocol/t125/gcc"
"github.com/lunixbochs/struc"
)

View File

@@ -8,6 +8,7 @@ import (
"ShotRDP/grdp/core"
"ShotRDP/grdp/glog"
"github.com/lunixbochs/struc"
)

View File

@@ -6,9 +6,8 @@ import (
"fmt"
"io"
"ShotRDP/grdp/glog"
"ShotRDP/grdp/core"
"ShotRDP/grdp/glog"
)
type ControlFlag uint8

View File

@@ -14,12 +14,11 @@ import (
"github.com/lunixbochs/struc"
"ShotRDP/grdp/protocol/nla"
"ShotRDP/grdp/core"
"ShotRDP/grdp/emission"
"ShotRDP/grdp/glog"
"ShotRDP/grdp/protocol/lic"
"ShotRDP/grdp/protocol/nla"
"ShotRDP/grdp/protocol/t125"
"ShotRDP/grdp/protocol/t125/gcc"
)

View File

@@ -12,9 +12,9 @@ import (
"os"
"ShotRDP/grdp/glog"
"ShotRDP/grdp/core"
"ShotRDP/grdp/protocol/t125/per"
"github.com/lunixbochs/struc"
)

View File

@@ -8,14 +8,12 @@ import (
"io"
"reflect"
"ShotRDP/grdp/plugin/cliprdr"
"ShotRDP/grdp/plugin/rail"
"ShotRDP/grdp/plugin/drdynvc"
"ShotRDP/grdp/core"
"ShotRDP/grdp/emission"
"ShotRDP/grdp/glog"
"ShotRDP/grdp/plugin/cliprdr"
"ShotRDP/grdp/plugin/drdynvc"
"ShotRDP/grdp/plugin/rail"
"ShotRDP/grdp/protocol/t125/ber"
"ShotRDP/grdp/protocol/t125/gcc"
"ShotRDP/grdp/protocol/t125/per"

View File

@@ -4,9 +4,8 @@ import (
"bytes"
"io"
"ShotRDP/grdp/glog"
"ShotRDP/grdp/core"
"ShotRDP/grdp/glog"
)
func ReadEnumerates(r io.Reader) (uint8, error) {

View File

@@ -6,11 +6,11 @@ import (
"errors"
"fmt"
"ShotRDP/grdp/glog"
"ShotRDP/grdp/core"
"ShotRDP/grdp/emission"
"ShotRDP/grdp/glog"
"ShotRDP/grdp/protocol/tpkt"
"github.com/lunixbochs/struc"
)