Skip to content

Commit

Permalink
updating streaming of filebrowser data
Browse files Browse the repository at this point in the history
  • Loading branch information
its-a-feature committed Aug 2, 2024
1 parent 28d87c5 commit 7583b78
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 21 deletions.
6 changes: 6 additions & 0 deletions 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).

## [3.3.0-rc12] - 2024-08-02

### Changed

- Updated the logic when downloading files to also update the timestamp on the mythictree entries so that the data is streamed to the UI properly

## [3.3.0-rc11] - 2024-08-01

### 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.12] - 2024-08-02

### Changed

- Fixed the create credential dialog while issuing tasks using the old graphql mutation

## [0.2.11] - 2024-08-02

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import DeleteIcon from '@mui/icons-material/Delete';
import {useTheme} from '@mui/material/styles';
import CancelIcon from '@mui/icons-material/Cancel';
import {Typography} from '@mui/material';
import {useMutation, gql } from '@apollo/client';
import {useMutation, gql, useLazyQuery } from '@apollo/client';
import { snackActions } from '../../utilities/Snackbar';
import {CredentialTableNewCredentialDialog} from '../Search/CredentialTableNewCredentialDialog';
import { MythicDialog } from '../../MythicComponents/MythicDialog';
Expand Down Expand Up @@ -60,13 +60,22 @@ fragment credentialData on credential{
}
`;
const createCredentialMutation = gql`
${credentialFragment}
mutation createCredential($comment: String!, $account: String!, $realm: String!, $type: String!, $credential: bytea!) {
insert_credential_one(object: {account: $account, credential_raw: $credential, comment: $comment, realm: $realm, type: $type}) {
...credentialData
mutation createCredential($comment: String!, $account: String!, $realm: String!, $type: String!, $credential: String!) {
createCredential(account: $account, credential: $credential, comment: $comment, realm: $realm, credential_type: $type) {
id
status
error
}
}
`;
const getCredentialQuery = gql`
${credentialFragment}
query getCredential($id: Int!){
credential_by_pk(id: $id){
...credentialData
}
}
`;

export function TaskParametersDialogRow(props){
const [value, setValue] = React.useState('');
Expand Down Expand Up @@ -157,13 +166,25 @@ export function TaskParametersDialogRow(props){
console.log(data);
setBackdropOpen(false);
}
});
const [getCredential] = useLazyQuery(getCredentialQuery, {
onCompleted: (data) => {
updateToLatestCredential.current = true;
props.addedCredential(data.credential_by_pk);
},
onError: (data) => {
console.log(data);
}
})
const [createCredential] = useMutation(createCredentialMutation, {
fetchPolicy: "no-cache",
onCompleted: (data) => {
snackActions.success("Successfully created new credential");
updateToLatestCredential.current = true;
props.addedCredential(data.insert_credential_one);
if(data.createCredential.status === "success"){
getCredential({variables: {id: data.createCredential.id}});
} else {
snackActions.error(data.createCredential.error);
}
},
onError: (data) => {
snackActions.error("Failed to create credential");
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.11";
export const mythicUIVersion = "0.2.12";

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.0-rc11
3.3.0-rc12
2 changes: 1 addition & 1 deletion mythic-docker/src/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.0-rc11
3.3.0-rc12
Original file line number Diff line number Diff line change
Expand Up @@ -1354,7 +1354,7 @@ func associateFileMetaWithMythicTree(pathData utils.AnalyzedPath, fileMeta datab
fileMetaData := map[string]interface{}{
"access_time": time.Now().Unix(),
"modify_time": time.Now().Unix(),
"size": fileMeta.ChunkSize * fileMeta.TotalChunks,
"size": fileMeta.Size,
"permissions": map[string]interface{}{},
}
newTree.Metadata = GetMythicJSONTextFromStruct(fileMetaData)
Expand All @@ -1368,9 +1368,15 @@ func associateFileMetaWithMythicTree(pathData utils.AnalyzedPath, fileMeta datab
// now that we know the mythictree entry exists, associate this filemeta with it
fileMeta.MythicTreeID.Valid = true
fileMeta.MythicTreeID.Int64 = int64(newTree.ID)
if _, err := database.DB.NamedExec(`UPDATE filemeta SET mythictree_id=:mythictree_id WHERE id=:id`, fileMeta); err != nil {
_, err := database.DB.NamedExec(`UPDATE filemeta SET mythictree_id=:mythictree_id WHERE id=:id`, fileMeta)
if err != nil {
logging.LogError(err, "Failed to associate filemeta with mythictree ")
go SendAllOperationsMessage(fmt.Sprintf("Failed to associate file with file browser: %s\n", fileMeta.AgentFileID), task.OperationID, "", database.MESSAGE_LEVEL_WARNING)
return
}
_, err = database.DB.Exec(`UPDATE mythictree SET "timestamp"=now() WHERE id=$1`, newTree.ID)
if err != nil {
logging.LogError(err, "failed to update timestamp on mythictree to indicate new file association happened")
}
}
func addFilePermissions(fileBrowser *agentMessagePostResponseFileBrowser) map[string]interface{} {
Expand Down Expand Up @@ -2000,8 +2006,14 @@ func addFileMetaToMythicTree(task databaseStructs.Task, newFile databaseStructs.
} else if err == nil {
newFile.MythicTreeID.Int64 = int64(fileBrowser.ID)
newFile.MythicTreeID.Valid = true
if _, err := database.DB.NamedExec(`UPDATE filemeta SET mythictree_id=:mythictree_id WHERE id=:id`, newFile); err != nil {
_, err = database.DB.NamedExec(`UPDATE filemeta SET mythictree_id=:mythictree_id WHERE id=:id`, newFile)
if err != nil {
logging.LogError(err, "Failed to update file meta with mythic tree id")
return
}
_, err = database.DB.Exec(`UPDATE mythictree SET "timestamp"=now() WHERE id=$1`, fileBrowser.ID)
if err != nil {
logging.LogError(err, "failed to update timestamp on mythictree to indicate new file association happened")
}

} else {
Expand Down
6 changes: 3 additions & 3 deletions mythic-react-docker/mythic/public/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"files": {
"main.css": "/new/static/css/main.7e143bf2.css",
"main.js": "/new/static/js/main.220682dd.js",
"main.js": "/new/static/js/main.e6eb2feb.js",
"static/media/mythic-red.png": "/new/static/media/mythic-red.203468a4e5240d239aa0.png",
"static/media/mythic_red_small.svg": "/new/static/media/mythic_red_small.793b41cc7135cdede246661ec232976b.svg",
"index.html": "/new/index.html",
"main.7e143bf2.css.map": "/new/static/css/main.7e143bf2.css.map",
"main.220682dd.js.map": "/new/static/js/main.220682dd.js.map"
"main.e6eb2feb.js.map": "/new/static/js/main.e6eb2feb.js.map"
},
"entrypoints": [
"static/css/main.7e143bf2.css",
"static/js/main.220682dd.js"
"static/js/main.e6eb2feb.js"
]
}
2 changes: 1 addition & 1 deletion mythic-react-docker/mythic/public/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/new/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><link rel="apple-touch-icon" href="/new/logo192.png"/><link rel="manifest" href="/new/manifest.json"/><title>Mythic</title><script defer="defer" src="/new/static/js/main.220682dd.js"></script><link href="/new/static/css/main.7e143bf2.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/new/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><link rel="apple-touch-icon" href="/new/logo192.png"/><link rel="manifest" href="/new/manifest.json"/><title>Mythic</title><script defer="defer" src="/new/static/js/main.e6eb2feb.js"></script><link href="/new/static/css/main.7e143bf2.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit 7583b78

Please sign in to comment.