diff --git a/openbas-api/src/main/java/io/openbas/injectors/caldera/CalderaExecutor.java b/openbas-api/src/main/java/io/openbas/injectors/caldera/CalderaExecutor.java index 8ee2447e08..9400ba8b29 100644 --- a/openbas-api/src/main/java/io/openbas/injectors/caldera/CalderaExecutor.java +++ b/openbas-api/src/main/java/io/openbas/injectors/caldera/CalderaExecutor.java @@ -62,13 +62,17 @@ public ExecutionProcess process(@NotNull final Execution execution, @NotNull fin try { Endpoint executionEndpoint = this.findAndRegisterAssetForExecution(injection.getInjection().getInject(), asset); if (executionEndpoint != null) { - this.calderaService.exploit(obfuscator, executionEndpoint.getExternalReference(), contract); - ExploitResult exploitResult = this.calderaService.exploitResult(executionEndpoint.getExternalReference(), contract); - asyncIds.add(exploitResult.getLinkId()); - execution.addTrace(traceInfo(EXECUTION_TYPE_COMMAND, exploitResult.getCommand())); - // Compute expectations - boolean isInGroup = assets.get(executionEndpoint.getParent()); - computeExpectationsForAsset(expectations, content, executionEndpoint.getParent(), isInGroup); + String result = this.calderaService.exploit(obfuscator, executionEndpoint.getExternalReference(), contract); + if (result.contains("complete")) { + ExploitResult exploitResult = this.calderaService.exploitResult(executionEndpoint.getExternalReference(), contract); + asyncIds.add(exploitResult.getLinkId()); + execution.addTrace(traceInfo(EXECUTION_TYPE_COMMAND, exploitResult.getCommand())); + // Compute expectations + boolean isInGroup = assets.get(executionEndpoint.getParent()); + computeExpectationsForAsset(expectations, content, executionEndpoint.getParent(), isInGroup); + } else { + execution.addTrace(traceError("Caldera failed to execute ability on asset " + asset.getName() + " (" + result + ")")); + } } else { execution.addTrace(traceError("Caldera failed to execute the ability because execution endpoint was not found for endpoint " + asset.getName())); } diff --git a/openbas-api/src/main/java/io/openbas/injectors/caldera/client/CalderaInjectorClient.java b/openbas-api/src/main/java/io/openbas/injectors/caldera/client/CalderaInjectorClient.java index 9745d77358..54bcf2a33b 100644 --- a/openbas-api/src/main/java/io/openbas/injectors/caldera/client/CalderaInjectorClient.java +++ b/openbas-api/src/main/java/io/openbas/injectors/caldera/client/CalderaInjectorClient.java @@ -156,7 +156,7 @@ public Result results(@NotBlank final String linkId) { private final static String EXPLOIT_URI = "/exploit"; - public void exploit( + public String exploit( @NotBlank final String obfuscator, @NotBlank final String paw, @NotBlank final String abilityId) { @@ -165,11 +165,10 @@ public void exploit( body.put("obfuscator", obfuscator); body.put("paw", paw); body.put("ability_id", abilityId); - String result = this.post( - this.config.getPluginAccessApiUrl() + EXPLOIT_URI, - body - ); - assert result.contains("complete"); // the exploit is well taken into account + return this.post( + this.config.getPluginAccessApiUrl() + EXPLOIT_URI, + body + ); } catch (ClientProtocolException e) { throw new RuntimeException(e); } diff --git a/openbas-api/src/main/java/io/openbas/injectors/caldera/service/CalderaInjectorService.java b/openbas-api/src/main/java/io/openbas/injectors/caldera/service/CalderaInjectorService.java index 0627dfb244..5720381fc5 100644 --- a/openbas-api/src/main/java/io/openbas/injectors/caldera/service/CalderaInjectorService.java +++ b/openbas-api/src/main/java/io/openbas/injectors/caldera/service/CalderaInjectorService.java @@ -29,11 +29,11 @@ public List abilities() { return this.client.abilities(); } - public void exploit( + public String exploit( @NotBlank final String obfuscator, @NotBlank final String paw, @NotBlank final String abilityId) { - this.client.exploit(obfuscator, paw, abilityId); + return this.client.exploit(obfuscator, paw, abilityId); } public List obfuscators() { diff --git a/openbas-framework/src/main/java/io/openbas/executors/caldera/service/CalderaExecutorService.java b/openbas-framework/src/main/java/io/openbas/executors/caldera/service/CalderaExecutorService.java index d9072dd85a..a53bb7e3df 100644 --- a/openbas-framework/src/main/java/io/openbas/executors/caldera/service/CalderaExecutorService.java +++ b/openbas-framework/src/main/java/io/openbas/executors/caldera/service/CalderaExecutorService.java @@ -146,6 +146,7 @@ private void updateEndpoint(@NotNull final Endpoint external, @NotNull final Lis matchingExistingEndpoint.setName(external.getName()); matchingExistingEndpoint.setIps(external.getIps()); matchingExistingEndpoint.setHostname(external.getHostname()); + matchingExistingEndpoint.setPlatform(external.getPlatform()); matchingExistingEndpoint.setExecutor(this.executor); if ((now().toEpochMilli() - matchingExistingEndpoint.getClearedAt().toEpochMilli()) > CLEAR_TTL) { try { diff --git a/openbas-framework/src/main/java/io/openbas/executors/tanium/service/TaniumExecutorService.java b/openbas-framework/src/main/java/io/openbas/executors/tanium/service/TaniumExecutorService.java index 0ccfbbb999..c717f6d3b3 100644 --- a/openbas-framework/src/main/java/io/openbas/executors/tanium/service/TaniumExecutorService.java +++ b/openbas-framework/src/main/java/io/openbas/executors/tanium/service/TaniumExecutorService.java @@ -138,6 +138,7 @@ private void updateEndpoint(@NotNull final Endpoint external, @NotNull final Lis matchingExistingEndpoint.setIps(external.getIps()); matchingExistingEndpoint.setHostname(external.getHostname()); matchingExistingEndpoint.setExternalReference(external.getExternalReference()); + matchingExistingEndpoint.setPlatform(external.getPlatform()); matchingExistingEndpoint.setExecutor(this.executor); if ((now().toEpochMilli() - matchingExistingEndpoint.getClearedAt().toEpochMilli()) > CLEAR_TTL) { try { diff --git a/openbas-front/src/admin/components/assets/endpoints/EndpointsDialogAdding.tsx b/openbas-front/src/admin/components/assets/endpoints/EndpointsDialogAdding.tsx index 91c29750a8..66e071fcd8 100644 --- a/openbas-front/src/admin/components/assets/endpoints/EndpointsDialogAdding.tsx +++ b/openbas-front/src/admin/components/assets/endpoints/EndpointsDialogAdding.tsx @@ -16,7 +16,7 @@ import { Switch, Tooltip, } from '@mui/material'; -import { ComputerOutlined } from '@mui/icons-material'; +import { DevicesOtherOutlined } from '@mui/icons-material'; import * as R from 'ramda'; import { makeStyles } from '@mui/styles'; import Transition from '../../../../components/common/Transition'; @@ -32,6 +32,7 @@ import type { EndpointHelper } from '../../../../actions/assets/asset-helper'; import useDataLoader from '../../../../utils/hooks/useDataLoader'; import { fetchEndpoints } from '../../../../actions/assets/endpoint-actions'; import useSearchAnFilter from '../../../../utils/SortingFiltering'; +import PlatformIcon from '../../../../components/PlatformIcon'; const useStyles = makeStyles(() => ({ box: { @@ -43,6 +44,13 @@ const useStyles = makeStyles(() => ({ chip: { margin: '0 10px 10px 0', }, + bodyItem: { + fontSize: 13, + whiteSpace: 'nowrap', + overflow: 'hidden', + textOverflow: 'ellipsis', + paddingRight: 10, + }, })); interface Props { @@ -163,13 +171,23 @@ const EndpointsDialogAdding: FunctionComponent = ({ onClick={() => addEndpoint(endpoint.asset_id)} > - + +
+ {endpoint.asset_name} +
+
+ {endpoint.endpoint_platform} +
+
+ +
+ + } /> - ); })} diff --git a/openbas-front/src/admin/components/assets/endpoints/EndpointsList.tsx b/openbas-front/src/admin/components/assets/endpoints/EndpointsList.tsx index 7cfdd9d24b..5f81ceab09 100644 --- a/openbas-front/src/admin/components/assets/endpoints/EndpointsList.tsx +++ b/openbas-front/src/admin/components/assets/endpoints/EndpointsList.tsx @@ -4,6 +4,7 @@ import { DevicesOtherOutlined } from '@mui/icons-material'; import { makeStyles } from '@mui/styles'; import type { EndpointStore } from './Endpoint'; import ItemTags from '../../../../components/ItemTags'; +import PlatformIcon from '../../../../components/PlatformIcon'; const useStyles = makeStyles(() => ({ item: { @@ -29,11 +30,16 @@ const inlineStyles: Record = { asset_name: { width: '40%', }, + asset_platform: { + width: '20%', + display: 'flex', + alignItems: 'center', + }, asset_tags: { - width: '40%', + width: '25%', }, asset_type: { - width: '20%', + width: '10%', }, }; @@ -81,6 +87,12 @@ const EndpointsList: FunctionComponent = ({ > {endpoint.asset_name} +
+ {endpoint.endpoint_platform} +
= ({