Namespace: microsoft.graph
Wichtig
Die APIs unter der /beta Version in Microsoft Graph können sich ändern. Die Verwendung dieser APIs in Produktionsanwendungen wird nicht unterstützt. Um festzustellen, ob eine API in v1.0 verfügbar ist, verwenden Sie die Version Selektor.
Aktualisieren einer Angriffssimulationskampagne für einen Mandanten.
Diese API ist in den folgenden nationalen Cloudbereitstellungen verfügbar.
| Weltweiter Service |
US Government L4 |
US Government L5 (DOD) |
China, betrieben von 21Vianet |
| ✅ |
❌ |
❌ |
❌ |
Berechtigungen
Wählen Sie die Berechtigungen aus, die für diese API als am wenigsten privilegiert markiert sind. Verwenden Sie eine höhere Berechtigung oder Berechtigungen nur, wenn Ihre App dies erfordert. Ausführliche Informationen zu delegierten Berechtigungen und Anwendungsberechtigungen finden Sie unter Berechtigungstypen. Weitere Informationen zu diesen Berechtigungen finden Sie in der Berechtigungsreferenz.
| Berechtigungstyp |
Berechtigungen mit den geringsten Berechtigungen |
Berechtigungen mit höheren Berechtigungen |
| Delegiert (Geschäfts-, Schul- oder Unikonto) |
AttackSimulation.ReadWrite.All |
Nicht verfügbar. |
| Delegiert (persönliches Microsoft-Konto) |
Nicht unterstützt |
Nicht unterstützt |
| Application |
AttackSimulation.ReadWrite.All |
Nicht verfügbar. |
HTTP-Anforderung
PATCH /security/attackSimulation/simulations/{simulationId}
Anforderungstext
Geben Sie im Anforderungstext nur die Werte für zu aktualisierende Eigenschaften an. Vorhandene Eigenschaften, die nicht im Anforderungstext enthalten sind, behalten ihre vorherigen Werte bei oder werden basierend auf Änderungen an anderen Eigenschaftswerten neu berechnet.
In der folgenden Tabelle sind die Eigenschaften angegeben, die aktualisiert werden können.
| Eigenschaft |
Typ |
Beschreibung |
| attackTechnique |
simulationAttackTechnique |
Die Social-Engineering-Technik, die in der Angriffssimulations- und Trainingskampagne verwendet wird. Unterstützt $filter und $orderby. Die möglichen Werte sind: unknown, credentialHarvesting, attachmentMalware, driveByUrl, linkInAttachment, linkToMalwareFile, unknownFutureValue, oAuthConsentGrant, . phishTraining Verwenden Sie den Anforderungsheader Prefer: include-unknown-enum-members , um die folgenden Werte aus dieser verteilbaren Enumeration abzurufen: oAuthConsentGrant, phishTraining. Weitere Informationen zu den Arten von Social Engineering-Angriffstechniken finden Sie unter Simulationen. |
| attackType |
simulationAttackType |
Angriffstyp der Angriffssimulation und -trainingskampagne. Unterstützt $filter und $orderby. Mögliche Werte sind: unknown, social, cloud, endpoint, unknownFutureValue. |
| displayName |
Zeichenfolge |
Anzeigename der Angriffssimulation und -trainingskampagne. Unterstützt $filter und $orderby. |
| durationInDays |
Int32 |
Simulationsdauer in Tagen. |
| excludedAccountTarget |
accountTargetContent |
Benutzer, die von der Simulation ausgeschlossen sind. |
| includedAccountTarget |
accountTargetContent |
Benutzer, die in der Simulation als Ziel verwendet werden. |
| payload |
Nutzlast |
Nutzlast, die der Simulation zugeordnet ist. |
| status |
simulationStatus |
Status der Angriffssimulation und -trainingskampagne. Unterstützt $filter und $orderby. Die möglichen Werte sind: unknown, draft, running, scheduled, succeeded, failed, cancelled, excluded, . unknownFutureValue |
Antwort
Bei erfolgreicher Ausführung gibt die Methode einen 202 Accepted Antwortcode und einen Nachverfolgungsheader mit dem Namen location in der Antwort zurück.
Beispiele
Beispiel 1: Aktualisieren einer Angriffssimulationskampagne
Das folgende Beispiel zeigt, wie Sie eine Angriffssimulationskampagne für einen Mandanten aktualisieren.
Anforderung
Das folgende Beispiel zeigt eine Anfrage.
PATCH https://graph.microsoft.com/beta/security/attackSimulation/simulations/2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc
Content-type: application/json
{
"@odata.etag": "\"0100aa9b-0000-0100-0000-6396fa270000\"",
"displayName": "Graph Simulation",
"payload@odata.bind":"https://graph.microsoft.com/beta/security/attacksimulation/payloads/12345678-9abc-def0-123456789a",
"durationInDays": 7,
"attackTechnique": "credentialHarvesting",
"attackType": "social",
"status": "scheduled",
"includedAccountTarget": {
"@odata.type": "#microsoft.graph.addressBookAccountTargetContent",
"type" : "addressBook",
"accountTargetEmails" : [
"faiza@contoso.com"
]
},
"excludedAccountTarget": {
"@odata.type": "#microsoft.graph.addressBookAccountTargetContent",
"type" : "addressBook",
"accountTargetEmails" : [
"sam@contoso.com"
]
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new Simulation
{
DisplayName = "Graph Simulation",
DurationInDays = 7,
AttackTechnique = SimulationAttackTechnique.CredentialHarvesting,
AttackType = SimulationAttackType.Social,
Status = SimulationStatus.Scheduled,
IncludedAccountTarget = new AddressBookAccountTargetContent
{
OdataType = "#microsoft.graph.addressBookAccountTargetContent",
Type = AccountTargetContentType.AddressBook,
AccountTargetEmails = new List<string>
{
"faiza@contoso.com",
},
},
ExcludedAccountTarget = new AddressBookAccountTargetContent
{
OdataType = "#microsoft.graph.addressBookAccountTargetContent",
Type = AccountTargetContentType.AddressBook,
AccountTargetEmails = new List<string>
{
"sam@contoso.com",
},
},
AdditionalData = new Dictionary<string, object>
{
{
"@odata.etag" , "\"0100aa9b-0000-0100-0000-6396fa270000\""
},
{
"payload@odata.bind" , "https://graph.microsoft.com/beta/security/attacksimulation/payloads/12345678-9abc-def0-123456789a"
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Security.AttackSimulation.Simulations["{simulation-id}"].PatchAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewSimulation()
displayName := "Graph Simulation"
requestBody.SetDisplayName(&displayName)
durationInDays := int32(7)
requestBody.SetDurationInDays(&durationInDays)
attackTechnique := graphmodels.CREDENTIALHARVESTING_SIMULATIONATTACKTECHNIQUE
requestBody.SetAttackTechnique(&attackTechnique)
attackType := graphmodels.SOCIAL_SIMULATIONATTACKTYPE
requestBody.SetAttackType(&attackType)
status := graphmodels.SCHEDULED_SIMULATIONSTATUS
requestBody.SetStatus(&status)
includedAccountTarget := graphmodels.NewAddressBookAccountTargetContent()
type := graphmodels.ADDRESSBOOK_ACCOUNTTARGETCONTENTTYPE
includedAccountTarget.SetType(&type)
accountTargetEmails := []string {
"faiza@contoso.com",
}
includedAccountTarget.SetAccountTargetEmails(accountTargetEmails)
requestBody.SetIncludedAccountTarget(includedAccountTarget)
excludedAccountTarget := graphmodels.NewAddressBookAccountTargetContent()
type := graphmodels.ADDRESSBOOK_ACCOUNTTARGETCONTENTTYPE
excludedAccountTarget.SetType(&type)
accountTargetEmails := []string {
"sam@contoso.com",
}
excludedAccountTarget.SetAccountTargetEmails(accountTargetEmails)
requestBody.SetExcludedAccountTarget(excludedAccountTarget)
additionalData := map[string]interface{}{
"@odata.etag" : "\"0100aa9b-0000-0100-0000-6396fa270000\"",
"payload@odata.bind" : "https://graph.microsoft.com/beta/security/attacksimulation/payloads/12345678-9abc-def0-123456789a",
}
requestBody.SetAdditionalData(additionalData)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
simulations, err := graphClient.Security().AttackSimulation().Simulations().BySimulationId("simulation-id").Patch(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Simulation simulation = new Simulation();
simulation.setDisplayName("Graph Simulation");
simulation.setDurationInDays(7);
simulation.setAttackTechnique(SimulationAttackTechnique.CredentialHarvesting);
simulation.setAttackType(SimulationAttackType.Social);
simulation.setStatus(SimulationStatus.Scheduled);
AddressBookAccountTargetContent includedAccountTarget = new AddressBookAccountTargetContent();
includedAccountTarget.setOdataType("#microsoft.graph.addressBookAccountTargetContent");
includedAccountTarget.setType(AccountTargetContentType.AddressBook);
LinkedList<String> accountTargetEmails = new LinkedList<String>();
accountTargetEmails.add("faiza@contoso.com");
includedAccountTarget.setAccountTargetEmails(accountTargetEmails);
simulation.setIncludedAccountTarget(includedAccountTarget);
AddressBookAccountTargetContent excludedAccountTarget = new AddressBookAccountTargetContent();
excludedAccountTarget.setOdataType("#microsoft.graph.addressBookAccountTargetContent");
excludedAccountTarget.setType(AccountTargetContentType.AddressBook);
LinkedList<String> accountTargetEmails1 = new LinkedList<String>();
accountTargetEmails1.add("sam@contoso.com");
excludedAccountTarget.setAccountTargetEmails(accountTargetEmails1);
simulation.setExcludedAccountTarget(excludedAccountTarget);
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("@odata.etag", "\"0100aa9b-0000-0100-0000-6396fa270000\"");
additionalData.put("payload@odata.bind", "https://graph.microsoft.com/beta/security/attacksimulation/payloads/12345678-9abc-def0-123456789a");
simulation.setAdditionalData(additionalData);
Simulation result = graphClient.security().attackSimulation().simulations().bySimulationId("{simulation-id}").patch(simulation);
const options = {
authProvider,
};
const client = Client.init(options);
const simulation = {
'@odata.etag': '\"0100aa9b-0000-0100-0000-6396fa270000\"',
displayName: 'Graph Simulation',
'payload@odata.bind':'https://graph.microsoft.com/beta/security/attacksimulation/payloads/12345678-9abc-def0-123456789a',
durationInDays: 7,
attackTechnique: 'credentialHarvesting',
attackType: 'social',
status: 'scheduled',
includedAccountTarget: {
'@odata.type': '#microsoft.graph.addressBookAccountTargetContent',
type: 'addressBook',
accountTargetEmails: [
'faiza@contoso.com'
]
},
excludedAccountTarget: {
'@odata.type': '#microsoft.graph.addressBookAccountTargetContent',
type: 'addressBook',
accountTargetEmails: [
'sam@contoso.com'
]
}
};
await client.api('/security/attackSimulation/simulations/2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc')
.version('beta')
.update(simulation);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\Simulation;
use Microsoft\Graph\Beta\Generated\Models\SimulationAttackTechnique;
use Microsoft\Graph\Beta\Generated\Models\SimulationAttackType;
use Microsoft\Graph\Beta\Generated\Models\SimulationStatus;
use Microsoft\Graph\Beta\Generated\Models\AddressBookAccountTargetContent;
use Microsoft\Graph\Beta\Generated\Models\AccountTargetContentType;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Simulation();
$requestBody->setDisplayName('Graph Simulation');
$requestBody->setDurationInDays(7);
$requestBody->setAttackTechnique(new SimulationAttackTechnique('credentialHarvesting'));
$requestBody->setAttackType(new SimulationAttackType('social'));
$requestBody->setStatus(new SimulationStatus('scheduled'));
$includedAccountTarget = new AddressBookAccountTargetContent();
$includedAccountTarget->setOdataType('#microsoft.graph.addressBookAccountTargetContent');
$includedAccountTarget->setType(new AccountTargetContentType('addressBook'));
$includedAccountTarget->setAccountTargetEmails(['faiza@contoso.com', ]);
$requestBody->setIncludedAccountTarget($includedAccountTarget);
$excludedAccountTarget = new AddressBookAccountTargetContent();
$excludedAccountTarget->setOdataType('#microsoft.graph.addressBookAccountTargetContent');
$excludedAccountTarget->setType(new AccountTargetContentType('addressBook'));
$excludedAccountTarget->setAccountTargetEmails(['sam@contoso.com', ]);
$requestBody->setExcludedAccountTarget($excludedAccountTarget);
$additionalData = [
'@odata.etag' => '\"0100aa9b-0000-0100-0000-6396fa270000\"',
'payload@odata.bind' => 'https://graph.microsoft.com/beta/security/attacksimulation/payloads/12345678-9abc-def0-123456789a',
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->security()->attackSimulation()->simulations()->bySimulationId('simulation-id')->patch($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.simulation import Simulation
from msgraph_beta.generated.models.simulation_attack_technique import SimulationAttackTechnique
from msgraph_beta.generated.models.simulation_attack_type import SimulationAttackType
from msgraph_beta.generated.models.simulation_status import SimulationStatus
from msgraph_beta.generated.models.address_book_account_target_content import AddressBookAccountTargetContent
from msgraph_beta.generated.models.account_target_content_type import AccountTargetContentType
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Simulation(
display_name = "Graph Simulation",
duration_in_days = 7,
attack_technique = SimulationAttackTechnique.CredentialHarvesting,
attack_type = SimulationAttackType.Social,
status = SimulationStatus.Scheduled,
included_account_target = AddressBookAccountTargetContent(
odata_type = "#microsoft.graph.addressBookAccountTargetContent",
type = AccountTargetContentType.AddressBook,
account_target_emails = [
"faiza@contoso.com",
],
),
excluded_account_target = AddressBookAccountTargetContent(
odata_type = "#microsoft.graph.addressBookAccountTargetContent",
type = AccountTargetContentType.AddressBook,
account_target_emails = [
"sam@contoso.com",
],
),
additional_data = {
"@odata_etag" : "\"0100aa9b-0000-0100-0000-6396fa270000\"",
"payload@odata_bind" : "https://graph.microsoft.com/beta/security/attacksimulation/payloads/12345678-9abc-def0-123456789a",
}
)
result = await graph_client.security.attack_simulation.simulations.by_simulation_id('simulation-id').patch(request_body)
Antwort
Das folgende Beispiel zeigt die Antwort.
HTTP/1.1 202 Accepted
Beispiel 2: Aktualisieren einer Angriffssimulationskampagne vom Entwurf in den geplanten
Das folgende Beispiel zeigt, wie Sie eine Angriffssimulationskampagne planen. Die Simulationsanforderung wird beim Planen einer Simulation überprüft. Alle erforderlichen Parameter müssen in einer solchen Anforderung weitergegeben werden.
Anforderung
Das folgende Beispiel zeigt eine Anfrage.
PATCH https://graph.microsoft.com/beta/security/attackSimulation/simulations/2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc
Content-type: application/json
{
"@odata.etag": "\"0100aa9b-0000-0100-0000-6396fa270000\"",
"id": "2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc",
"displayName": "Graph Simulation",
"payload@odata.bind":"https://graph.microsoft.com/beta/security/attacksimulation/payloads/12345678-9abc-def0-123456789a",
"durationInDays": 7,
"attackTechnique": "credentialHarvesting",
"attackType": "social",
"status": "scheduled",
"includedAccountTarget": {
"@odata.type": "#microsoft.graph.addressBookAccountTargetContent",
"type" : "addressBook",
"accountTargetEmails" : [
"faiza@contoso.com"
]
},
"excludedAccountTarget": {
"@odata.type": "#microsoft.graph.addressBookAccountTargetContent",
"type" : "addressBook",
"accountTargetEmails" : [
"sam@contoso.com"
]
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new Simulation
{
Id = "2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc",
DisplayName = "Graph Simulation",
DurationInDays = 7,
AttackTechnique = SimulationAttackTechnique.CredentialHarvesting,
AttackType = SimulationAttackType.Social,
Status = SimulationStatus.Scheduled,
IncludedAccountTarget = new AddressBookAccountTargetContent
{
OdataType = "#microsoft.graph.addressBookAccountTargetContent",
Type = AccountTargetContentType.AddressBook,
AccountTargetEmails = new List<string>
{
"faiza@contoso.com",
},
},
ExcludedAccountTarget = new AddressBookAccountTargetContent
{
OdataType = "#microsoft.graph.addressBookAccountTargetContent",
Type = AccountTargetContentType.AddressBook,
AccountTargetEmails = new List<string>
{
"sam@contoso.com",
},
},
AdditionalData = new Dictionary<string, object>
{
{
"@odata.etag" , "\"0100aa9b-0000-0100-0000-6396fa270000\""
},
{
"payload@odata.bind" , "https://graph.microsoft.com/beta/security/attacksimulation/payloads/12345678-9abc-def0-123456789a"
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Security.AttackSimulation.Simulations["{simulation-id}"].PatchAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewSimulation()
id := "2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc"
requestBody.SetId(&id)
displayName := "Graph Simulation"
requestBody.SetDisplayName(&displayName)
durationInDays := int32(7)
requestBody.SetDurationInDays(&durationInDays)
attackTechnique := graphmodels.CREDENTIALHARVESTING_SIMULATIONATTACKTECHNIQUE
requestBody.SetAttackTechnique(&attackTechnique)
attackType := graphmodels.SOCIAL_SIMULATIONATTACKTYPE
requestBody.SetAttackType(&attackType)
status := graphmodels.SCHEDULED_SIMULATIONSTATUS
requestBody.SetStatus(&status)
includedAccountTarget := graphmodels.NewAddressBookAccountTargetContent()
type := graphmodels.ADDRESSBOOK_ACCOUNTTARGETCONTENTTYPE
includedAccountTarget.SetType(&type)
accountTargetEmails := []string {
"faiza@contoso.com",
}
includedAccountTarget.SetAccountTargetEmails(accountTargetEmails)
requestBody.SetIncludedAccountTarget(includedAccountTarget)
excludedAccountTarget := graphmodels.NewAddressBookAccountTargetContent()
type := graphmodels.ADDRESSBOOK_ACCOUNTTARGETCONTENTTYPE
excludedAccountTarget.SetType(&type)
accountTargetEmails := []string {
"sam@contoso.com",
}
excludedAccountTarget.SetAccountTargetEmails(accountTargetEmails)
requestBody.SetExcludedAccountTarget(excludedAccountTarget)
additionalData := map[string]interface{}{
"@odata.etag" : "\"0100aa9b-0000-0100-0000-6396fa270000\"",
"payload@odata.bind" : "https://graph.microsoft.com/beta/security/attacksimulation/payloads/12345678-9abc-def0-123456789a",
}
requestBody.SetAdditionalData(additionalData)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
simulations, err := graphClient.Security().AttackSimulation().Simulations().BySimulationId("simulation-id").Patch(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Simulation simulation = new Simulation();
simulation.setId("2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc");
simulation.setDisplayName("Graph Simulation");
simulation.setDurationInDays(7);
simulation.setAttackTechnique(SimulationAttackTechnique.CredentialHarvesting);
simulation.setAttackType(SimulationAttackType.Social);
simulation.setStatus(SimulationStatus.Scheduled);
AddressBookAccountTargetContent includedAccountTarget = new AddressBookAccountTargetContent();
includedAccountTarget.setOdataType("#microsoft.graph.addressBookAccountTargetContent");
includedAccountTarget.setType(AccountTargetContentType.AddressBook);
LinkedList<String> accountTargetEmails = new LinkedList<String>();
accountTargetEmails.add("faiza@contoso.com");
includedAccountTarget.setAccountTargetEmails(accountTargetEmails);
simulation.setIncludedAccountTarget(includedAccountTarget);
AddressBookAccountTargetContent excludedAccountTarget = new AddressBookAccountTargetContent();
excludedAccountTarget.setOdataType("#microsoft.graph.addressBookAccountTargetContent");
excludedAccountTarget.setType(AccountTargetContentType.AddressBook);
LinkedList<String> accountTargetEmails1 = new LinkedList<String>();
accountTargetEmails1.add("sam@contoso.com");
excludedAccountTarget.setAccountTargetEmails(accountTargetEmails1);
simulation.setExcludedAccountTarget(excludedAccountTarget);
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("@odata.etag", "\"0100aa9b-0000-0100-0000-6396fa270000\"");
additionalData.put("payload@odata.bind", "https://graph.microsoft.com/beta/security/attacksimulation/payloads/12345678-9abc-def0-123456789a");
simulation.setAdditionalData(additionalData);
Simulation result = graphClient.security().attackSimulation().simulations().bySimulationId("{simulation-id}").patch(simulation);
const options = {
authProvider,
};
const client = Client.init(options);
const simulation = {
'@odata.etag': '\"0100aa9b-0000-0100-0000-6396fa270000\"',
id: '2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc',
displayName: 'Graph Simulation',
'payload@odata.bind':'https://graph.microsoft.com/beta/security/attacksimulation/payloads/12345678-9abc-def0-123456789a',
durationInDays: 7,
attackTechnique: 'credentialHarvesting',
attackType: 'social',
status: 'scheduled',
includedAccountTarget: {
'@odata.type': '#microsoft.graph.addressBookAccountTargetContent',
type: 'addressBook',
accountTargetEmails: [
'faiza@contoso.com'
]
},
excludedAccountTarget: {
'@odata.type': '#microsoft.graph.addressBookAccountTargetContent',
type: 'addressBook',
accountTargetEmails: [
'sam@contoso.com'
]
}
};
await client.api('/security/attackSimulation/simulations/2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc')
.version('beta')
.update(simulation);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\Simulation;
use Microsoft\Graph\Beta\Generated\Models\SimulationAttackTechnique;
use Microsoft\Graph\Beta\Generated\Models\SimulationAttackType;
use Microsoft\Graph\Beta\Generated\Models\SimulationStatus;
use Microsoft\Graph\Beta\Generated\Models\AddressBookAccountTargetContent;
use Microsoft\Graph\Beta\Generated\Models\AccountTargetContentType;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Simulation();
$requestBody->setId('2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc');
$requestBody->setDisplayName('Graph Simulation');
$requestBody->setDurationInDays(7);
$requestBody->setAttackTechnique(new SimulationAttackTechnique('credentialHarvesting'));
$requestBody->setAttackType(new SimulationAttackType('social'));
$requestBody->setStatus(new SimulationStatus('scheduled'));
$includedAccountTarget = new AddressBookAccountTargetContent();
$includedAccountTarget->setOdataType('#microsoft.graph.addressBookAccountTargetContent');
$includedAccountTarget->setType(new AccountTargetContentType('addressBook'));
$includedAccountTarget->setAccountTargetEmails(['faiza@contoso.com', ]);
$requestBody->setIncludedAccountTarget($includedAccountTarget);
$excludedAccountTarget = new AddressBookAccountTargetContent();
$excludedAccountTarget->setOdataType('#microsoft.graph.addressBookAccountTargetContent');
$excludedAccountTarget->setType(new AccountTargetContentType('addressBook'));
$excludedAccountTarget->setAccountTargetEmails(['sam@contoso.com', ]);
$requestBody->setExcludedAccountTarget($excludedAccountTarget);
$additionalData = [
'@odata.etag' => '\"0100aa9b-0000-0100-0000-6396fa270000\"',
'payload@odata.bind' => 'https://graph.microsoft.com/beta/security/attacksimulation/payloads/12345678-9abc-def0-123456789a',
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->security()->attackSimulation()->simulations()->bySimulationId('simulation-id')->patch($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.simulation import Simulation
from msgraph_beta.generated.models.simulation_attack_technique import SimulationAttackTechnique
from msgraph_beta.generated.models.simulation_attack_type import SimulationAttackType
from msgraph_beta.generated.models.simulation_status import SimulationStatus
from msgraph_beta.generated.models.address_book_account_target_content import AddressBookAccountTargetContent
from msgraph_beta.generated.models.account_target_content_type import AccountTargetContentType
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Simulation(
id = "2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc",
display_name = "Graph Simulation",
duration_in_days = 7,
attack_technique = SimulationAttackTechnique.CredentialHarvesting,
attack_type = SimulationAttackType.Social,
status = SimulationStatus.Scheduled,
included_account_target = AddressBookAccountTargetContent(
odata_type = "#microsoft.graph.addressBookAccountTargetContent",
type = AccountTargetContentType.AddressBook,
account_target_emails = [
"faiza@contoso.com",
],
),
excluded_account_target = AddressBookAccountTargetContent(
odata_type = "#microsoft.graph.addressBookAccountTargetContent",
type = AccountTargetContentType.AddressBook,
account_target_emails = [
"sam@contoso.com",
],
),
additional_data = {
"@odata_etag" : "\"0100aa9b-0000-0100-0000-6396fa270000\"",
"payload@odata_bind" : "https://graph.microsoft.com/beta/security/attacksimulation/payloads/12345678-9abc-def0-123456789a",
}
)
result = await graph_client.security.attack_simulation.simulations.by_simulation_id('simulation-id').patch(request_body)
Antwort
Das folgende Beispiel zeigt die Antwort.
HTTP/1.1 202 Accepted
Beispiel 3: Abbrechen einer Angriffssimulationskampagne
Das folgende Beispiel zeigt, wie Sie eine Angriffssimulationskampagne für einen Mandanten abbrechen. Sie können eine Simulation abbrechen, wenn ihr Zustand entweder scheduled oder runningist.
Anforderung
Das folgende Beispiel zeigt eine Anfrage.
PATCH https://graph.microsoft.com/beta/security/attackSimulation/simulations/2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc
Content-type: application/json
{
"@odata.etag": "\"0100aa9b-0000-0100-0000-6396fa270000\"",
"id": "2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc",
"status": "cancelled"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new Simulation
{
Id = "2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc",
Status = SimulationStatus.Cancelled,
AdditionalData = new Dictionary<string, object>
{
{
"@odata.etag" , "\"0100aa9b-0000-0100-0000-6396fa270000\""
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Security.AttackSimulation.Simulations["{simulation-id}"].PatchAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewSimulation()
id := "2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc"
requestBody.SetId(&id)
status := graphmodels.CANCELLED_SIMULATIONSTATUS
requestBody.SetStatus(&status)
additionalData := map[string]interface{}{
"@odata.etag" : "\"0100aa9b-0000-0100-0000-6396fa270000\"",
}
requestBody.SetAdditionalData(additionalData)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
simulations, err := graphClient.Security().AttackSimulation().Simulations().BySimulationId("simulation-id").Patch(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Simulation simulation = new Simulation();
simulation.setId("2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc");
simulation.setStatus(SimulationStatus.Cancelled);
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("@odata.etag", "\"0100aa9b-0000-0100-0000-6396fa270000\"");
simulation.setAdditionalData(additionalData);
Simulation result = graphClient.security().attackSimulation().simulations().bySimulationId("{simulation-id}").patch(simulation);
const options = {
authProvider,
};
const client = Client.init(options);
const simulation = {
'@odata.etag': '\"0100aa9b-0000-0100-0000-6396fa270000\"',
id: '2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc',
status: 'cancelled'
};
await client.api('/security/attackSimulation/simulations/2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc')
.version('beta')
.update(simulation);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\Simulation;
use Microsoft\Graph\Beta\Generated\Models\SimulationStatus;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Simulation();
$requestBody->setId('2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc');
$requestBody->setStatus(new SimulationStatus('cancelled'));
$additionalData = [
'@odata.etag' => '\"0100aa9b-0000-0100-0000-6396fa270000\"',
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->security()->attackSimulation()->simulations()->bySimulationId('simulation-id')->patch($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.simulation import Simulation
from msgraph_beta.generated.models.simulation_status import SimulationStatus
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Simulation(
id = "2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc",
status = SimulationStatus.Cancelled,
additional_data = {
"@odata_etag" : "\"0100aa9b-0000-0100-0000-6396fa270000\"",
}
)
result = await graph_client.security.attack_simulation.simulations.by_simulation_id('simulation-id').patch(request_body)
Antwort
Das folgende Beispiel zeigt die Antwort.
HTTP/1.1 202 Accepted
Beispiel 4: Ausschließen einer Angriffssimulationskampagne
Das folgende Beispiel zeigt, wie eine Angriffssimulationskampagne für einen Mandanten ausgeschlossen wird. Sie können eine Simulation nur dann von der Berichterstellung ausschließen, wenn ihr Zustand ist cancelled.
Anforderung
Das folgende Beispiel zeigt eine Anfrage.
PATCH https://graph.microsoft.com/beta/security/attackSimulation/simulations/2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc
Content-type: application/json
{
"@odata.etag": "\"0100aa9b-0000-0100-0000-6396fa270000\"",
"id": "2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc",
"status": "excluded"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new Simulation
{
Id = "2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc",
Status = SimulationStatus.Excluded,
AdditionalData = new Dictionary<string, object>
{
{
"@odata.etag" , "\"0100aa9b-0000-0100-0000-6396fa270000\""
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Security.AttackSimulation.Simulations["{simulation-id}"].PatchAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewSimulation()
id := "2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc"
requestBody.SetId(&id)
status := graphmodels.EXCLUDED_SIMULATIONSTATUS
requestBody.SetStatus(&status)
additionalData := map[string]interface{}{
"@odata.etag" : "\"0100aa9b-0000-0100-0000-6396fa270000\"",
}
requestBody.SetAdditionalData(additionalData)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
simulations, err := graphClient.Security().AttackSimulation().Simulations().BySimulationId("simulation-id").Patch(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Simulation simulation = new Simulation();
simulation.setId("2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc");
simulation.setStatus(SimulationStatus.Excluded);
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("@odata.etag", "\"0100aa9b-0000-0100-0000-6396fa270000\"");
simulation.setAdditionalData(additionalData);
Simulation result = graphClient.security().attackSimulation().simulations().bySimulationId("{simulation-id}").patch(simulation);
const options = {
authProvider,
};
const client = Client.init(options);
const simulation = {
'@odata.etag': '\"0100aa9b-0000-0100-0000-6396fa270000\"',
id: '2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc',
status: 'excluded'
};
await client.api('/security/attackSimulation/simulations/2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc')
.version('beta')
.update(simulation);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\Simulation;
use Microsoft\Graph\Beta\Generated\Models\SimulationStatus;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Simulation();
$requestBody->setId('2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc');
$requestBody->setStatus(new SimulationStatus('excluded'));
$additionalData = [
'@odata.etag' => '\"0100aa9b-0000-0100-0000-6396fa270000\"',
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->security()->attackSimulation()->simulations()->bySimulationId('simulation-id')->patch($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.simulation import Simulation
from msgraph_beta.generated.models.simulation_status import SimulationStatus
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Simulation(
id = "2f5548d1-0dd8-4cc8-9de0-e0d6ec7ea3dc",
status = SimulationStatus.Excluded,
additional_data = {
"@odata_etag" : "\"0100aa9b-0000-0100-0000-6396fa270000\"",
}
)
result = await graph_client.security.attack_simulation.simulations.by_simulation_id('simulation-id').patch(request_body)
Antwort
Das folgende Beispiel zeigt die Antwort.
HTTP/1.1 202 Accepted