-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add: exploits now are clickable and give some more calculated stats
- Loading branch information
Showing
12 changed files
with
167 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import { exploitsQuery, statsQuery, useClientSolver, useServiceSolverByExploitId } from "@/utils/queries"; | ||
import { useGlobalStore } from "@/utils/stores"; | ||
import { Box, Modal, Space, Title } from "@mantine/core" | ||
import { showNotification } from "@mantine/notifications"; | ||
import { useEffect } from "react"; | ||
import { FaUser } from "react-icons/fa"; | ||
import { MdTimer } from "react-icons/md"; | ||
import { getDateFormatted } from "@/utils/time"; | ||
import { FaKeyboard } from "react-icons/fa"; | ||
import { FaGear } from "react-icons/fa6"; | ||
import { StatusPoint } from "./ExploitsBar"; | ||
import { attackStatusTable, flagStatusTable } from "./StatusIcon"; | ||
|
||
export const ExploitDetailModal = (props:{ opened:boolean, close:()=>void, exploitId:string }) => { | ||
|
||
if (!props.opened) return null | ||
|
||
const exploits = exploitsQuery() | ||
const exploit = exploits.data?.find((exploit) => exploit.id == props.exploitId)??null | ||
const stats = statsQuery() | ||
const setLoading = useGlobalStore((store) => store.setLoader) | ||
const clientSolver = useClientSolver() | ||
const serviceSolver = useServiceSolverByExploitId() | ||
|
||
useEffect(() => { | ||
if (exploits.isError){ | ||
showNotification({ title: "Error", message: "Failed to fetch attack details", color: "red" }) | ||
setLoading(false) | ||
}else if (exploits.isSuccess && exploit != null){ | ||
setLoading(false) | ||
}else{ | ||
setLoading(true) | ||
} | ||
}, [exploits.isLoading, exploit]) | ||
|
||
const boxWidth = 180 | ||
|
||
const okFlags = exploit?(stats.data?.ticks.reduce((a, b) => a+(b.exploits[exploit.id]?.flags?.ok??0), 0)??0):0 | ||
const invalidFlags = exploit?(stats.data?.ticks.reduce((a, b) => a+(b.exploits[exploit.id]?.flags?.invalid??0), 0)??0):0 | ||
const timeoutFlags = exploit?(stats.data?.ticks.reduce((a, b) => a+(b.exploits[exploit.id]?.flags?.timeout??0), 0)??0):0 | ||
const totFlags = exploit?(stats.data?.ticks.reduce((a, b) => a+(b.exploits[exploit.id]?.flags?.tot??0), 0)??0):0 | ||
|
||
const doneAttacks = exploit?(stats.data?.ticks.reduce((a, b) => a+(b.exploits[exploit.id]?.attacks?.done??0), 0)??0):0 | ||
const crashedAttacks = exploit?(stats.data?.ticks.reduce((a, b) => a+(b.exploits[exploit.id]?.attacks?.crashed??0), 0)??0):0 | ||
const noFlagsAttacks = exploit?(stats.data?.ticks.reduce((a, b) => a+(b.exploits[exploit.id]?.attacks?.noflags??0), 0)??0):0 | ||
const totAttacks = exploit?(stats.data?.ticks.reduce((a, b) => a+(b.exploits[exploit.id]?.attacks?.tot??0), 0)??0):0 | ||
|
||
return <Modal opened={props.opened} onClose={props.close} title={<Box className="center-flex"> | ||
<StatusPoint status={exploit?.status} /> | ||
<Space w="xs" /> | ||
<Title order={3}> Exploit '{exploit?.name}' 🚩</Title> | ||
</Box> | ||
} size="xl" centered> | ||
{exploit?<Box> | ||
<Box display="flex"> | ||
<Box display="flex" style={{alignItems: "center", width: boxWidth}}><FaGear /><Space w="xs" />Service<Space w="xs" /></Box> | ||
<b>{serviceSolver(exploit.id)}</b> | ||
</Box> | ||
<Box display="flex"> | ||
<Box display="flex" style={{alignItems: "center", width: boxWidth}}><FaUser /><Space w="xs" />Last execution<Space w="xs" /></Box> | ||
<Box>by <b>{exploit.last_execution_by?clientSolver(exploit.last_execution_by):"unknown"}</b> at <b>{exploit.last_update?getDateFormatted(exploit.last_update):"unknown"}</b> </Box> | ||
</Box> | ||
<Space h="xs" /> | ||
<Box display="flex"> | ||
<Box display="flex" style={{alignItems: "center", width: boxWidth}}><flagStatusTable.ok.icon /><Space w="xs" />Valid Flags<Space w="xs" /></Box> | ||
<b>{okFlags} / {totFlags} ({totFlags!=0?(okFlags*100/totFlags).toFixed(2):0}%)</b> | ||
</Box> | ||
<Box display="flex"> | ||
<Box display="flex" style={{alignItems: "center", width: boxWidth}}><flagStatusTable.invalid.icon /><Space w="xs" />Invalid Flags<Space w="xs" /></Box> | ||
<b>{invalidFlags} / {totFlags} ({totFlags!=0?(invalidFlags*100/totFlags).toFixed(2):0}%)</b> | ||
</Box> | ||
<Box display="flex"> | ||
<Box display="flex" style={{alignItems: "center", width: boxWidth}}><flagStatusTable.timeout.icon /><Space w="xs" />Timeouted Flags<Space w="xs" /></Box> | ||
<b>{timeoutFlags} / {totFlags} ({totFlags!=0?(timeoutFlags*100/totFlags).toFixed(2):0}%)</b> | ||
</Box> | ||
<Space h="xs" /> | ||
<Box display="flex"> | ||
<Box display="flex" style={{alignItems: "center", width: boxWidth}}><attackStatusTable.done.icon /><Space w="xs" />Done attacks<Space w="xs" /></Box> | ||
<b>{doneAttacks} / {totAttacks} ({totAttacks!=0?(doneAttacks*100/totAttacks).toFixed(2):0}%)</b> | ||
</Box> | ||
<Box display="flex"> | ||
<Box display="flex" style={{alignItems: "center", width: boxWidth}}><attackStatusTable.crashed.icon /><Space w="xs" />Crashed attacks<Space w="xs" /></Box> | ||
<b>{crashedAttacks} / {totAttacks} ({totAttacks!=0?(crashedAttacks*100/totAttacks).toFixed(2):0}%)</b> | ||
</Box> | ||
<Box display="flex"> | ||
<Box display="flex" style={{alignItems: "center", width: boxWidth}}><attackStatusTable.noflags.icon /><Space w="xs" />No flags attacks<Space w="xs" /></Box> | ||
<b>{noFlagsAttacks} / {totAttacks} ({totAttacks!=0?(noFlagsAttacks*100/totAttacks).toFixed(2):0}%)</b> | ||
</Box> | ||
<Space h="xs" /> | ||
<Box display="flex"> | ||
<Box display="flex" style={{alignItems: "center", width: boxWidth}}><MdTimer /><Space w="xs" />Exploit created<Space w="xs" /></Box> | ||
<Box>by <b>{clientSolver(exploit.created_by)}</b> at <b>{getDateFormatted(exploit.created_at)}</b></Box> | ||
</Box> | ||
<Box display="flex"> | ||
<Box display="flex" style={{alignItems: "center", width: boxWidth}}><FaKeyboard /><Space w="xs" />Language used<Space w="xs" /></Box> | ||
<b>{exploit.language}</b> | ||
</Box> | ||
<Space h="sm" /> | ||
</Box>:null} | ||
|
||
</Modal> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters