Skip to content

Commit

Permalink
onStart container apitoken fix and slight UI tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
its-a-feature committed Nov 18, 2024
1 parent 688b2ca commit 99f1e7a
Show file tree
Hide file tree
Showing 21 changed files with 293 additions and 264 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.3.1-rc24] - 2024-11-18

### Changed

- Fixed a bug with onStart messages getting the wrong value for temporary APITokens
- Increased the timeouts for gRPC messages from 1s to 10s

## [3.3.1-rc23] - 2024-11-14

### Changed
Expand Down
6 changes: 6 additions & 0 deletions MythicReactUI/CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.2.58] - 2024-11-18

### Changed

- Fixed some of the alignment formatting for string cells in creating payloads/tasking

## [0.2.57] - 2024-11-15

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ class MythicTextField extends React.Component {
helperText={this.checkError() ? this.props.errorText : this.props.helperText}
style={{
padding:0,
paddingLeft: "5px",
marginBottom: this.props.marginBottom ? this.props.marginBottom : "10px",
display: this.props.inline ? "inline-block": "",
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,7 @@ export function TaskParametersDialogRow(props){
<MythicTextField required={props.required} fullWidth={true} placeholder={""} value={a} multiline={true} autoFocus={props.autoFocus || i > 0}
onChange={(n,v,e) => onChangeArrayText(v, e, i)} display="inline-block" maxRows={5}
validate={testParameterValues} errorText={"Must match: " + props.verifier_regex}
marginBottom={"0px"}
/>
</MythicStyledTableCell>
</TableRow>
Expand Down Expand Up @@ -663,6 +664,7 @@ export function TaskParametersDialogRow(props){
<MythicTextField required={props.required} fullWidth={true} placeholder={""} value={a[1]} multiline={true} autoFocus={props.autoFocus || i > 0}
onChange={(n,v,e) => onChangeTypedArrayText(v, e, i)} display="inline-block" maxRows={5}
validate={testParameterValues} errorText={"Must match: " + props.verifier_regex}
marginBottom={"0px"}
/>
</div>

Expand All @@ -684,13 +686,15 @@ export function TaskParametersDialogRow(props){
<MythicTextField required={props.required} placeholder={props.default_value} value={value} multiline={true} maxRows={5}
onChange={onChangeText} display="inline-block" onEnter={props.onSubmit} autoFocus={props.autoFocus}
validate={testParameterValues} errorText={"Must match: " + props.verifier_regex}
marginBottom={"0px"}
/>
)
case "Number":
return (
<MythicTextField required={props.required} placeholder={props.default_value} value={value} multiline={false} type="number"
onChange={onChangeNumber} display="inline-block" onEnter={props.onSubmit} autoFocus={props.autoFocus}
validate={testParameterValues} errorText={"Must match: " + props.verifier_regex}
marginBottom={"0px"}
/>
)
case "Boolean":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ export function CreatePayloadParameter({onChange, parameter_type, default_value,
<MythicStyledTableCell>
<MythicTextField required={required} fullWidth={true} placeholder={""} value={a} multiline={true}
onChange={(n,v,e) => onChangeArrayText(v, e, i)} display="inline-block" autoFocus={a === ""}
validate={testParameterValues} errorText={"Must match: " + verifier_regex}
validate={testParameterValues} errorText={"Must match: " + verifier_regex} marginBottom={"0px"}
/>
</MythicStyledTableCell>
</TableRow>
Expand Down Expand Up @@ -524,6 +524,7 @@ export function CreatePayloadParameter({onChange, parameter_type, default_value,
<MythicTextField required={required} value={valueNum} type={"number"}
onChange={onChangeNumber} display="inline-block" name={name} showLabel={false}
validate={testParameterValues} errorText={"Must match: " + verifier_regex}
marginBottom={"0px"}
/>
);
case "Boolean":
Expand Down
2 changes: 1 addition & 1 deletion MythicReactUI/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {snackActions} from './components/utilities/Snackbar';
import jwt_decode from 'jwt-decode';
import {meState} from './cache';

export const mythicUIVersion = "0.2.57";
export const mythicUIVersion = "0.2.58";

let fetchingNewToken = false;

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.1-rc23
3.3.1-rc24
2 changes: 1 addition & 1 deletion mythic-docker/src/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.1-rc23
3.3.1-rc24
145 changes: 74 additions & 71 deletions mythic-docker/src/grpc/generate_encryption_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,83 +12,86 @@ import (
func (t *translationContainerServer) GenerateEncryptionKeys(stream services.TranslationContainer_GenerateEncryptionKeysServer) error {
clientName := ""
// initially wait for a request from the other side with blank data to indicate who is talking to us
if initial, err := stream.Recv(); err == io.EOF {
initial, err := stream.Recv()
if err == io.EOF {
logging.LogDebug("Client closed before ever sending anything, err is EOF")
return nil // the client closed before ever sending anything
} else if err != nil {
}
if err != nil {
logging.LogError(err, "Client ran into an error before sending anything")
return err
} else {
clientName = initial.GetTranslationContainerName()
if getMessageToSend, sendBackMessageResponse, err := t.addNewGenerateKeysClient(clientName); err != nil {
logging.LogError(err, "Failed to add new channels to listen for connection")
return err
} else {
logging.LogDebug("Got translation container name from remote connection", "name", clientName)
for {
}
clientName = initial.GetTranslationContainerName()
getMessageToSend, sendBackMessageResponse, err := t.addNewGenerateKeysClient(clientName)
if err != nil {
logging.LogError(err, "Failed to add new channels to listen for connection")
return err
}
logging.LogDebug("Got translation container name from remote connection", "name", clientName)
for {
select {
case <-stream.Context().Done():
logging.LogError(stream.Context().Err(), fmt.Sprintf("client disconnected: %s", clientName))
t.SetGenerateKeysChannelExited(clientName)
return errors.New(fmt.Sprintf("client disconnected: %s", clientName))
case msgToSend, ok := <-getMessageToSend:
if !ok {
logging.LogError(nil, "got !ok from messageToSend, channel was closed")
t.SetGenerateKeysChannelExited(clientName)
return nil
}
err = stream.Send(&msgToSend)
if err != nil {
logging.LogError(err, "Failed to send message through stream to translation container")
select {
case sendBackMessageResponse <- services.TrGenerateEncryptionKeysMessageResponse{
Success: false,
Error: err.Error(),
TranslationContainerName: clientName,
}:
case <-time.After(t.GetChannelTimeout()):
logging.LogError(errors.New("timeout sending to channel"), "gRPC stream connection needs to exit due to timeouts")
}
t.SetGenerateKeysChannelExited(clientName)
return err
}
resp, err := stream.Recv()
if err == io.EOF {
// cleanup the connection channels first before returning
logging.LogError(err, "connection closed in stream.Rev after sending message")
select {
case sendBackMessageResponse <- services.TrGenerateEncryptionKeysMessageResponse{
Success: false,
Error: err.Error(),
TranslationContainerName: clientName,
}:
case <-time.After(t.GetChannelTimeout()):
logging.LogError(errors.New("timeout sending to channel"), "gRPC stream connection needs to exit due to timeouts")
}
t.SetGenerateKeysChannelExited(clientName)
return nil
}
if err != nil {
// cleanup the connection channels first before returning
logging.LogError(err, "Failed to read from translation container")
select {
case <-stream.Context().Done():
logging.LogError(stream.Context().Err(), fmt.Sprintf("client disconnected: %s", clientName))
t.SetGenerateKeysChannelExited(clientName)
return errors.New(fmt.Sprintf("client disconnected: %s", clientName))
case msgToSend, ok := <-getMessageToSend:
if !ok {
logging.LogError(nil, "got !ok from messageToSend, channel was closed")
t.SetGenerateKeysChannelExited(clientName)
return nil
} else {
if err = stream.Send(&msgToSend); err != nil {
logging.LogError(err, "Failed to send message through stream to translation container")
select {
case sendBackMessageResponse <- services.TrGenerateEncryptionKeysMessageResponse{
Success: false,
Error: err.Error(),
TranslationContainerName: clientName,
}:
case <-time.After(t.GetChannelTimeout()):
logging.LogError(errors.New("timeout sending to channel"), "gRPC stream connection needs to exit due to timeouts")
}
t.SetGenerateKeysChannelExited(clientName)
return err
} else if resp, err := stream.Recv(); err == io.EOF {
// cleanup the connection channels first before returning
logging.LogError(err, "connection closed in stream.Rev after sending message")
select {
case sendBackMessageResponse <- services.TrGenerateEncryptionKeysMessageResponse{
Success: false,
Error: err.Error(),
TranslationContainerName: clientName,
}:
case <-time.After(t.GetChannelTimeout()):
logging.LogError(errors.New("timeout sending to channel"), "gRPC stream connection needs to exit due to timeouts")
}
t.SetGenerateKeysChannelExited(clientName)
return nil
} else if err != nil {
// cleanup the connection channels first before returning
logging.LogError(err, "Failed to read from translation container")
select {
case sendBackMessageResponse <- services.TrGenerateEncryptionKeysMessageResponse{
Success: false,
Error: err.Error(),
TranslationContainerName: clientName,
}:
case <-time.After(t.GetChannelTimeout()):
logging.LogError(errors.New("timeout sending to channel"), "gRPC stream connection needs to exit due to timeouts")
}
t.SetGenerateKeysChannelExited(clientName)
return err
} else {
select {
case sendBackMessageResponse <- *resp:
case <-time.After(t.GetChannelTimeout()):
logging.LogError(errors.New("timeout sending to channel"), "gRPC stream connection needs to exit due to timeouts")
t.SetGenerateKeysChannelExited(clientName)
return err
}
}
}
case sendBackMessageResponse <- services.TrGenerateEncryptionKeysMessageResponse{
Success: false,
Error: err.Error(),
TranslationContainerName: clientName,
}:
case <-time.After(t.GetChannelTimeout()):
logging.LogError(errors.New("timeout sending to channel"), "gRPC stream connection needs to exit due to timeouts")
}
t.SetGenerateKeysChannelExited(clientName)
return err
}
select {
case sendBackMessageResponse <- *resp:
case <-time.After(t.GetChannelTimeout()):
logging.LogError(errors.New("timeout sending to channel"), "gRPC stream connection needs to exit due to timeouts")
t.SetGenerateKeysChannelExited(clientName)
return err
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions mythic-docker/src/grpc/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
)

const (
connectionTimeoutSeconds = 3
channelSendTimeoutSeconds = 1
connectionTimeoutSeconds = 10
channelSendTimeoutSeconds = 10
)

type translationContainerServer struct {
Expand Down
6 changes: 4 additions & 2 deletions mythic-docker/src/grpc/push_c2_stream_one_to_one.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ func (t *pushC2Server) StartPushC2Streaming(stream services.PushC2_StartPushC2St
if err == io.EOF {
logging.LogError(err, "Client closed before ever sending anything, err is EOF")
return nil // the client closed before ever sending anything
} else if err != nil {
}
if err != nil {
logging.LogError(err, "Client ran into an error before sending anything")
return err
}
Expand Down Expand Up @@ -172,7 +173,8 @@ func (t *pushC2Server) StartPushC2Streaming(stream services.PushC2_StartPushC2St
logging.LogDebug("Client closed before ever sending anything, err is EOF")
failedReadFromAgent <- true // the client closed before ever sending anything
return
} else if err != nil {
}
if err != nil {
logging.LogError(err, "Client ran into an error before sending anything")
failedReadFromAgent <- true
return
Expand Down
Loading

0 comments on commit 99f1e7a

Please sign in to comment.