MCPcopy
hub / github.com/ph4ntonn/Stowaway / NormalActive

Function NormalActive

agent/initial/method.go:46–124  ·  view source on GitHub ↗
(userOptions *Options, proxy share.Proxy)

Source from the content-addressed store, hash-verified

44}
45
46func NormalActive(userOptions *Options, proxy share.Proxy) (net.Conn, string) {
47 var sMessage, rMessage protocol.Message
48 // just say hi!
49 hiMess := &protocol.HIMess{
50 GreetingLen: uint16(len("Shhh...")),
51 Greeting: "Shhh...",
52 UUIDLen: uint16(len(protocol.TEMP_UUID)),
53 UUID: protocol.TEMP_UUID,
54 IsAdmin: 0,
55 IsReconnect: 0,
56 }
57
58 header := &protocol.Header{
59 Sender: protocol.TEMP_UUID,
60 Accepter: protocol.ADMIN_UUID,
61 MessageType: protocol.HI,
62 RouteLen: uint32(len([]byte(protocol.TEMP_ROUTE))),
63 Route: protocol.TEMP_ROUTE,
64 }
65
66 for {
67 var (
68 conn net.Conn
69 err error
70 )
71
72 if proxy == nil {
73 conn, err = net.Dial("tcp", userOptions.Connect)
74 } else {
75 conn, err = proxy.Dial()
76 }
77
78 if err != nil {
79 log.Fatalf("[*] Error occurred: %s", err.Error())
80 }
81
82 if err := share.ActivePreAuth(conn); err != nil {
83 log.Fatalf("[*] Error occurred: %s", err.Error())
84 }
85
86 if userOptions.TlsEnable {
87 var tlsConfig *tls.Config
88 tlsConfig, err = transport.NewClientTLSConfig(userOptions.Domain)
89 if err != nil {
90 log.Printf("[*] Error occured: %s", err.Error())
91 conn.Close()
92 continue
93 }
94 conn = transport.WrapTLSClientConn(conn, tlsConfig)
95 // As we have already used TLS, we don't need to use aes inside
96 // Set userOptions.Secret as null to disable aes
97 userOptions.Secret = ""
98 }
99
100 sMessage = protocol.PrepareAndDecideWhichSProtoToUpper(conn, userOptions.Secret, protocol.TEMP_UUID)
101
102 protocol.ConstructMessage(sMessage, header, hiMess, false)
103 sMessage.SendMessage()

Callers 1

mainFunction · 0.92

Calls 10

SendMessageMethod · 0.95
ActivePreAuthFunction · 0.92
NewClientTLSConfigFunction · 0.92
WrapTLSClientConnFunction · 0.92
ConstructMessageFunction · 0.92
DestructMessageFunction · 0.92
achieveUUIDFunction · 0.85
DialMethod · 0.65

Tested by

no test coverage detected