Skip to content

Commit 99f1e7a

Browse files
committed
onStart container apitoken fix and slight UI tweak
1 parent 688b2ca commit 99f1e7a

21 files changed

+293
-264
lines changed

CHANGELOG.MD

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [3.3.1-rc24] - 2024-11-18
8+
9+
### Changed
10+
11+
- Fixed a bug with onStart messages getting the wrong value for temporary APITokens
12+
- Increased the timeouts for gRPC messages from 1s to 10s
13+
714
## [3.3.1-rc23] - 2024-11-14
815

916
### Changed

MythicReactUI/CHANGELOG.MD

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.2.58] - 2024-11-18
8+
9+
### Changed
10+
11+
- Fixed some of the alignment formatting for string cells in creating payloads/tasking
12+
713
## [0.2.57] - 2024-11-15
814

915
### Changed

MythicReactUI/src/components/MythicComponents/MythicTextField.js

-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ class MythicTextField extends React.Component {
9797
helperText={this.checkError() ? this.props.errorText : this.props.helperText}
9898
style={{
9999
padding:0,
100-
paddingLeft: "5px",
101100
marginBottom: this.props.marginBottom ? this.props.marginBottom : "10px",
102101
display: this.props.inline ? "inline-block": "",
103102
}}

MythicReactUI/src/components/pages/Callbacks/TaskParametersDialogRow.js

+4
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@ export function TaskParametersDialogRow(props){
617617
<MythicTextField required={props.required} fullWidth={true} placeholder={""} value={a} multiline={true} autoFocus={props.autoFocus || i > 0}
618618
onChange={(n,v,e) => onChangeArrayText(v, e, i)} display="inline-block" maxRows={5}
619619
validate={testParameterValues} errorText={"Must match: " + props.verifier_regex}
620+
marginBottom={"0px"}
620621
/>
621622
</MythicStyledTableCell>
622623
</TableRow>
@@ -663,6 +664,7 @@ export function TaskParametersDialogRow(props){
663664
<MythicTextField required={props.required} fullWidth={true} placeholder={""} value={a[1]} multiline={true} autoFocus={props.autoFocus || i > 0}
664665
onChange={(n,v,e) => onChangeTypedArrayText(v, e, i)} display="inline-block" maxRows={5}
665666
validate={testParameterValues} errorText={"Must match: " + props.verifier_regex}
667+
marginBottom={"0px"}
666668
/>
667669
</div>
668670

@@ -684,13 +686,15 @@ export function TaskParametersDialogRow(props){
684686
<MythicTextField required={props.required} placeholder={props.default_value} value={value} multiline={true} maxRows={5}
685687
onChange={onChangeText} display="inline-block" onEnter={props.onSubmit} autoFocus={props.autoFocus}
686688
validate={testParameterValues} errorText={"Must match: " + props.verifier_regex}
689+
marginBottom={"0px"}
687690
/>
688691
)
689692
case "Number":
690693
return (
691694
<MythicTextField required={props.required} placeholder={props.default_value} value={value} multiline={false} type="number"
692695
onChange={onChangeNumber} display="inline-block" onEnter={props.onSubmit} autoFocus={props.autoFocus}
693696
validate={testParameterValues} errorText={"Must match: " + props.verifier_regex}
697+
marginBottom={"0px"}
694698
/>
695699
)
696700
case "Boolean":

MythicReactUI/src/components/pages/CreatePayload/CreatePayloadParameter.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ export function CreatePayloadParameter({onChange, parameter_type, default_value,
427427
<MythicStyledTableCell>
428428
<MythicTextField required={required} fullWidth={true} placeholder={""} value={a} multiline={true}
429429
onChange={(n,v,e) => onChangeArrayText(v, e, i)} display="inline-block" autoFocus={a === ""}
430-
validate={testParameterValues} errorText={"Must match: " + verifier_regex}
430+
validate={testParameterValues} errorText={"Must match: " + verifier_regex} marginBottom={"0px"}
431431
/>
432432
</MythicStyledTableCell>
433433
</TableRow>
@@ -524,6 +524,7 @@ export function CreatePayloadParameter({onChange, parameter_type, default_value,
524524
<MythicTextField required={required} value={valueNum} type={"number"}
525525
onChange={onChangeNumber} display="inline-block" name={name} showLabel={false}
526526
validate={testParameterValues} errorText={"Must match: " + verifier_regex}
527+
marginBottom={"0px"}
527528
/>
528529
);
529530
case "Boolean":

MythicReactUI/src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {snackActions} from './components/utilities/Snackbar';
1414
import jwt_decode from 'jwt-decode';
1515
import {meState} from './cache';
1616

17-
export const mythicUIVersion = "0.2.57";
17+
export const mythicUIVersion = "0.2.58";
1818

1919
let fetchingNewToken = false;
2020

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.3.1-rc23
1+
3.3.1-rc24

mythic-docker/src/VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.3.1-rc23
1+
3.3.1-rc24

mythic-docker/src/grpc/generate_encryption_keys.go

+74-71
Original file line numberDiff line numberDiff line change
@@ -12,83 +12,86 @@ import (
1212
func (t *translationContainerServer) GenerateEncryptionKeys(stream services.TranslationContainer_GenerateEncryptionKeysServer) error {
1313
clientName := ""
1414
// initially wait for a request from the other side with blank data to indicate who is talking to us
15-
if initial, err := stream.Recv(); err == io.EOF {
15+
initial, err := stream.Recv()
16+
if err == io.EOF {
1617
logging.LogDebug("Client closed before ever sending anything, err is EOF")
1718
return nil // the client closed before ever sending anything
18-
} else if err != nil {
19+
}
20+
if err != nil {
1921
logging.LogError(err, "Client ran into an error before sending anything")
2022
return err
21-
} else {
22-
clientName = initial.GetTranslationContainerName()
23-
if getMessageToSend, sendBackMessageResponse, err := t.addNewGenerateKeysClient(clientName); err != nil {
24-
logging.LogError(err, "Failed to add new channels to listen for connection")
25-
return err
26-
} else {
27-
logging.LogDebug("Got translation container name from remote connection", "name", clientName)
28-
for {
23+
}
24+
clientName = initial.GetTranslationContainerName()
25+
getMessageToSend, sendBackMessageResponse, err := t.addNewGenerateKeysClient(clientName)
26+
if err != nil {
27+
logging.LogError(err, "Failed to add new channels to listen for connection")
28+
return err
29+
}
30+
logging.LogDebug("Got translation container name from remote connection", "name", clientName)
31+
for {
32+
select {
33+
case <-stream.Context().Done():
34+
logging.LogError(stream.Context().Err(), fmt.Sprintf("client disconnected: %s", clientName))
35+
t.SetGenerateKeysChannelExited(clientName)
36+
return errors.New(fmt.Sprintf("client disconnected: %s", clientName))
37+
case msgToSend, ok := <-getMessageToSend:
38+
if !ok {
39+
logging.LogError(nil, "got !ok from messageToSend, channel was closed")
40+
t.SetGenerateKeysChannelExited(clientName)
41+
return nil
42+
}
43+
err = stream.Send(&msgToSend)
44+
if err != nil {
45+
logging.LogError(err, "Failed to send message through stream to translation container")
46+
select {
47+
case sendBackMessageResponse <- services.TrGenerateEncryptionKeysMessageResponse{
48+
Success: false,
49+
Error: err.Error(),
50+
TranslationContainerName: clientName,
51+
}:
52+
case <-time.After(t.GetChannelTimeout()):
53+
logging.LogError(errors.New("timeout sending to channel"), "gRPC stream connection needs to exit due to timeouts")
54+
}
55+
t.SetGenerateKeysChannelExited(clientName)
56+
return err
57+
}
58+
resp, err := stream.Recv()
59+
if err == io.EOF {
60+
// cleanup the connection channels first before returning
61+
logging.LogError(err, "connection closed in stream.Rev after sending message")
62+
select {
63+
case sendBackMessageResponse <- services.TrGenerateEncryptionKeysMessageResponse{
64+
Success: false,
65+
Error: err.Error(),
66+
TranslationContainerName: clientName,
67+
}:
68+
case <-time.After(t.GetChannelTimeout()):
69+
logging.LogError(errors.New("timeout sending to channel"), "gRPC stream connection needs to exit due to timeouts")
70+
}
71+
t.SetGenerateKeysChannelExited(clientName)
72+
return nil
73+
}
74+
if err != nil {
75+
// cleanup the connection channels first before returning
76+
logging.LogError(err, "Failed to read from translation container")
2977
select {
30-
case <-stream.Context().Done():
31-
logging.LogError(stream.Context().Err(), fmt.Sprintf("client disconnected: %s", clientName))
32-
t.SetGenerateKeysChannelExited(clientName)
33-
return errors.New(fmt.Sprintf("client disconnected: %s", clientName))
34-
case msgToSend, ok := <-getMessageToSend:
35-
if !ok {
36-
logging.LogError(nil, "got !ok from messageToSend, channel was closed")
37-
t.SetGenerateKeysChannelExited(clientName)
38-
return nil
39-
} else {
40-
if err = stream.Send(&msgToSend); err != nil {
41-
logging.LogError(err, "Failed to send message through stream to translation container")
42-
select {
43-
case sendBackMessageResponse <- services.TrGenerateEncryptionKeysMessageResponse{
44-
Success: false,
45-
Error: err.Error(),
46-
TranslationContainerName: clientName,
47-
}:
48-
case <-time.After(t.GetChannelTimeout()):
49-
logging.LogError(errors.New("timeout sending to channel"), "gRPC stream connection needs to exit due to timeouts")
50-
}
51-
t.SetGenerateKeysChannelExited(clientName)
52-
return err
53-
} else if resp, err := stream.Recv(); err == io.EOF {
54-
// cleanup the connection channels first before returning
55-
logging.LogError(err, "connection closed in stream.Rev after sending message")
56-
select {
57-
case sendBackMessageResponse <- services.TrGenerateEncryptionKeysMessageResponse{
58-
Success: false,
59-
Error: err.Error(),
60-
TranslationContainerName: clientName,
61-
}:
62-
case <-time.After(t.GetChannelTimeout()):
63-
logging.LogError(errors.New("timeout sending to channel"), "gRPC stream connection needs to exit due to timeouts")
64-
}
65-
t.SetGenerateKeysChannelExited(clientName)
66-
return nil
67-
} else if err != nil {
68-
// cleanup the connection channels first before returning
69-
logging.LogError(err, "Failed to read from translation container")
70-
select {
71-
case sendBackMessageResponse <- services.TrGenerateEncryptionKeysMessageResponse{
72-
Success: false,
73-
Error: err.Error(),
74-
TranslationContainerName: clientName,
75-
}:
76-
case <-time.After(t.GetChannelTimeout()):
77-
logging.LogError(errors.New("timeout sending to channel"), "gRPC stream connection needs to exit due to timeouts")
78-
}
79-
t.SetGenerateKeysChannelExited(clientName)
80-
return err
81-
} else {
82-
select {
83-
case sendBackMessageResponse <- *resp:
84-
case <-time.After(t.GetChannelTimeout()):
85-
logging.LogError(errors.New("timeout sending to channel"), "gRPC stream connection needs to exit due to timeouts")
86-
t.SetGenerateKeysChannelExited(clientName)
87-
return err
88-
}
89-
}
90-
}
78+
case sendBackMessageResponse <- services.TrGenerateEncryptionKeysMessageResponse{
79+
Success: false,
80+
Error: err.Error(),
81+
TranslationContainerName: clientName,
82+
}:
83+
case <-time.After(t.GetChannelTimeout()):
84+
logging.LogError(errors.New("timeout sending to channel"), "gRPC stream connection needs to exit due to timeouts")
9185
}
86+
t.SetGenerateKeysChannelExited(clientName)
87+
return err
88+
}
89+
select {
90+
case sendBackMessageResponse <- *resp:
91+
case <-time.After(t.GetChannelTimeout()):
92+
logging.LogError(errors.New("timeout sending to channel"), "gRPC stream connection needs to exit due to timeouts")
93+
t.SetGenerateKeysChannelExited(clientName)
94+
return err
9295
}
9396
}
9497
}

mythic-docker/src/grpc/initialize.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import (
1515
)
1616

1717
const (
18-
connectionTimeoutSeconds = 3
19-
channelSendTimeoutSeconds = 1
18+
connectionTimeoutSeconds = 10
19+
channelSendTimeoutSeconds = 10
2020
)
2121

2222
type translationContainerServer struct {

mythic-docker/src/grpc/push_c2_stream_one_to_one.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ func (t *pushC2Server) StartPushC2Streaming(stream services.PushC2_StartPushC2St
5555
if err == io.EOF {
5656
logging.LogError(err, "Client closed before ever sending anything, err is EOF")
5757
return nil // the client closed before ever sending anything
58-
} else if err != nil {
58+
}
59+
if err != nil {
5960
logging.LogError(err, "Client ran into an error before sending anything")
6061
return err
6162
}
@@ -172,7 +173,8 @@ func (t *pushC2Server) StartPushC2Streaming(stream services.PushC2_StartPushC2St
172173
logging.LogDebug("Client closed before ever sending anything, err is EOF")
173174
failedReadFromAgent <- true // the client closed before ever sending anything
174175
return
175-
} else if err != nil {
176+
}
177+
if err != nil {
176178
logging.LogError(err, "Client ran into an error before sending anything")
177179
failedReadFromAgent <- true
178180
return

0 commit comments

Comments
 (0)