Skip to content

Commit

Permalink
Cp list beacons on host (#544)
Browse files Browse the repository at this point in the history
* feat(hostview): Add beacon table to host view

* fix(hostview): Add quest button to beacons list

* fix(build): Rebuild UI
  • Loading branch information
cmp5987 authored Feb 4, 2024
1 parent 481c586 commit c55d414
Show file tree
Hide file tree
Showing 21 changed files with 263 additions and 194 deletions.
12 changes: 6 additions & 6 deletions tavern/internal/www/build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"files": {
"main.css": "/static/css/main.15b8222e.css",
"main.js": "/static/js/main.1b7bbb76.js",
"main.css": "/static/css/main.01f32014.css",
"main.js": "/static/js/main.3fe7b832.js",
"react-syntax-highlighter/refractor-core-import.js": "/static/js/react-syntax-highlighter/refractor-core-import.d0cd1e85.chunk.js",
"react-syntax-highlighter_languages_refractor_abap.js": "/static/js/react-syntax-highlighter_languages_refractor_abap.a2bf84e3.chunk.js",
"react-syntax-highlighter_languages_refractor_actionscript.js": "/static/js/react-syntax-highlighter_languages_refractor_actionscript.fff5a604.chunk.js",
Expand Down Expand Up @@ -157,8 +157,8 @@
"static/js/787.4af0fb89.chunk.js": "/static/js/787.4af0fb89.chunk.js",
"static/media/eldrich.png": "/static/media/eldrich.a80c74e8249d2461e174.png",
"index.html": "/index.html",
"main.15b8222e.css.map": "/static/css/main.15b8222e.css.map",
"main.1b7bbb76.js.map": "/static/js/main.1b7bbb76.js.map",
"main.01f32014.css.map": "/static/css/main.01f32014.css.map",
"main.3fe7b832.js.map": "/static/js/main.3fe7b832.js.map",
"refractor-core-import.d0cd1e85.chunk.js.map": "/static/js/react-syntax-highlighter/refractor-core-import.d0cd1e85.chunk.js.map",
"react-syntax-highlighter_languages_refractor_abap.a2bf84e3.chunk.js.map": "/static/js/react-syntax-highlighter_languages_refractor_abap.a2bf84e3.chunk.js.map",
"react-syntax-highlighter_languages_refractor_actionscript.fff5a604.chunk.js.map": "/static/js/react-syntax-highlighter_languages_refractor_actionscript.fff5a604.chunk.js.map",
Expand Down Expand Up @@ -314,7 +314,7 @@
"787.4af0fb89.chunk.js.map": "/static/js/787.4af0fb89.chunk.js.map"
},
"entrypoints": [
"static/css/main.15b8222e.css",
"static/js/main.1b7bbb76.js"
"static/css/main.01f32014.css",
"static/js/main.3fe7b832.js"
]
}
2 changes: 1 addition & 1 deletion tavern/internal/www/build/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="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"><link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"><link rel="manifest" href="/site.webmanifest"><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>Realm - Red Team Engagement Platform</title><script defer="defer" src="/static/js/main.1b7bbb76.js"></script><link href="/static/css/main.15b8222e.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="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"><link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"><link rel="manifest" href="/site.webmanifest"><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>Realm - Red Team Engagement Platform</title><script defer="defer" src="/static/js/main.3fe7b832.js"></script><link href="/static/css/main.01f32014.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
4 changes: 4 additions & 0 deletions tavern/internal/www/build/static/css/main.01f32014.css

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions tavern/internal/www/build/static/css/main.15b8222e.css

This file was deleted.

3 changes: 0 additions & 3 deletions tavern/internal/www/build/static/js/main.11e06a01.js

This file was deleted.

1 change: 0 additions & 1 deletion tavern/internal/www/build/static/js/main.11e06a01.js.map

This file was deleted.

123 changes: 0 additions & 123 deletions tavern/internal/www/build/static/js/main.1b7bbb76.js.LICENSE.txt

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tavern/internal/www/src/components/BeaconTile.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Badge } from "@chakra-ui/react";
import { checkIfBeaconOnline } from "../utils/utils";
import { checkIfBeaconOffline } from "../utils/utils";

type Props = {
beaconData: {
Expand All @@ -18,7 +18,7 @@ type Props = {
}
const BeaconTile = (props: Props) => {
const { beaconData } = props;
const beaconOffline = checkIfBeaconOnline(beaconData);
const beaconOffline = checkIfBeaconOffline(beaconData);
return (
<div className="flex flex-col gap-1">
<div className="flex flex-row gap-4">{beaconData.name}</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { EmptyState, EmptyStateType } from "../tavern-base-ui/EmptyState";

const EmptyStateNoBeacon = () => {
return (
<EmptyState type={EmptyStateType.noData} label="No beacons found" details="Get started by deploying an imix agent on your target system.">
<button
type="button"
className="inline-flex items-center rounded-md bg-purple-700 px-4 py-2 text-sm font-semibold text-white shadow-sm hover:bg-purple-600 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-purple-700"
onClick={() => window.open("https://docs.realm.pub/user-guide/getting-started#start-the-agent", '_blank')}
>
See imix docs
</button>
</EmptyState>
);
}
export default EmptyStateNoBeacon;
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ type Props = {

export const TaskOutput = (props: Props) => {
const { isOpen, setOpen, selectedTask } = props;
console.log(selectedTask);
const createdTime = new Date(selectedTask?.createdAt || "");
const finishTime = new Date(selectedTask?.execFinishedAt || "");
const startTime = new Date(selectedTask?.execStartedAt || "");
Expand Down
11 changes: 2 additions & 9 deletions tavern/internal/www/src/pages/create-quest/CreateQuest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { PageNavItem } from "../../utils/enums";
import { TagContext } from "../../context/TagContext";
import { EmptyState, EmptyStateType } from "../../components/tavern-base-ui/EmptyState";
import QuestForm from "./components/QuestForm";
import EmptyStateNoBeacon from "../../components/empty-states/EmptyStateNoBeacon";

export const CreateQuest = () => {
const { data, isLoading, error } = useContext(TagContext);
Expand All @@ -20,15 +21,7 @@ export const CreateQuest = () => {
) : data?.beacons && data?.beacons?.length > 0 ? (
<QuestForm />
) : (
<EmptyState type={EmptyStateType.noData} label="No beacons found" details="Get started by deploying an imix agent on your target system.">
<button
type="button"
className="inline-flex items-center rounded-md bg-purple-700 px-4 py-2 text-sm font-semibold text-white shadow-sm hover:bg-purple-600 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-purple-700"
onClick={() => window.open("https://docs.realm.pub/user-guide/getting-started#start-the-agent", '_blank')}
>
See imix docs
</button>
</EmptyState>
<EmptyStateNoBeacon />
)}
</PageWrapper>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ import FinalizeStep from "./FinalizeStep";
import BeaconStepWrapper from "./BeaconStepWrapper";
import { useSubmitQuest } from "../hooks/useSubmitQuest";
import { getRandomQuestName } from "../../../utils/questNames";
import { useLocation } from "react-router-dom";

const QuestForm = () => {
const [currStep, setCurrStep] = useState<number>(0);
const location = useLocation();
//the data here will be an object since an object was
const data = location.state;
const [currStep, setCurrStep] = useState<number>(data?.step || 0);
const { submitQuest } = useSubmitQuest();
const placeholderTitle = getRandomQuestName();

Expand All @@ -25,7 +29,7 @@ const QuestForm = () => {
name: placeholderTitle,
tome: null,
params: [],
beacons: [],
beacons: data?.beacons || [],
},
onSubmit: (values: any) => submitQuest(values),
});
Expand All @@ -49,10 +53,10 @@ const QuestForm = () => {
className="py-6"
>
<div className="grid grid-cols-12">
<div className=" col-span-3">
<div className="hidden md:flex col-span-3">
<FormSteps currStep={currStep} steps={steps} />
</div>
<div className="col-span-9">
<div className="col-span-12 md:col-span-9">
{getStepView(currStep)}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { ApolloError } from "@apollo/client";
import { Accordion, AccordionButton, AccordionIcon, AccordionItem, AccordionPanel, Box } from "@chakra-ui/react";
import EmptyStateNoBeacon from "../../../components/empty-states/EmptyStateNoBeacon";
import { EmptyState, EmptyStateType } from "../../../components/tavern-base-ui/EmptyState";
import { HostType } from "../../../utils/consts";
import BeaconTable from "./BeaconTable";

type Props = {
loading: boolean;
error: ApolloError | undefined;
host: HostType | null;
}
const BeaconAccordion = (props: Props) => {
const { loading, error, host } = props;
return (
<Accordion allowToggle className='w-full'>
<AccordionItem>
<AccordionButton>
<Box as="span" flex='1' textAlign='left'>
<h2 className="text-lg font-semibold text-gray-900">Beacons</h2>
</Box>
<AccordionIcon />
</AccordionButton>
<AccordionPanel>
{loading ? (
<EmptyState type={EmptyStateType.loading} label="Loading beacons..." />
) : error ? (
<EmptyState type={EmptyStateType.error} label="Error loading beacons..." />
) : (
<div>
{host?.beacons && host?.beacons?.length > 0 ? (
<BeaconTable beacons={host.beacons} />
)
: (
<EmptyStateNoBeacon />
)}
</div>
)}
</AccordionPanel>
</AccordionItem>
</Accordion>
);
}
export default BeaconAccordion;
Loading

0 comments on commit c55d414

Please sign in to comment.