Why you should be using Azure and move on premise infrastructure to cloud ?

Microsoft Azure cloud computing services for deploying managing application and service through ta global network of Microsoft managed data centres. T provide software as a service , platform as service and infrastructure as service with large number of services , tools and framework including both Microsoft specific and third party software systems .

But really why should you move to cloud? Well next couple of paragraph explains,

After my introduction to Azure cloud implementing azure infrastructure solution decided to look at the one of the core Azure cloud service Azure Security centre Prevent, detect and to threats with increased visibility and control over resource groups , essentially Virtual machines,  NSG Network security groups, network anomalies e.g. external/network attacks especially windows attack vector.

What did I really found.. Next step is to test the underlying Security operation centre security identify how it respond to determined sophisticated PowerShell based on memory/disk attack ,

We created a resource group under the name of securesystem.co.uk and deployed a windows server 2012 R2 with domain active directory installed and a SQL Server 2016 as joined server to the domain.

The new ARM template when deploy a VM by default doesn’t allow any incoming connection, in another word port 3389 Remote Desktop Protocol is not allowed. We created a new NSG Network security group and allowed port 3389 for remote management. Of course you should never allow direct access to RDP over the public network but still very common very mistake administrator make.

Next we enabled Security centre and added a policy to monitor our resource group containing the Domain controller active directory and domain joined SQL Server 2016. Now that we have configured virtual machines and security centre monitoring.. You probably figured out our next step… The attack

In this scenario I use the following attacks and tools,

  1. RDP Remote Protocol attack using a dictionary attack with most common used passwords
  2. –         Custom designed PowerShell/Python command and control framework
  3. –         Persistence and lateral movement using pass the hash attack
  4. –         Forensic network analysis and anomaly detection

On our kail attacking host we used medusa with dictionary file containing the password attacked the 51.140.123.240 which is the SRV01 domain controller listening on port 3389. Of course for sake of demonstration we added the correct password to the list as highlighted the password found “ReallySecure$$” Success .

1

Figure 1 Medusa conducted controlled dictionary attack from Kali Linux attacking machine

Next we logged on to the SRV01 using Rdesktop from kali machine using the credentials we found in previous initial RDP attack

2

Figure 2 RDP session with the target SRV01 domain controller server

Custom powershell agent created and base64 encoded to copy over the target machine in order to maintain a persistence on target machine and ensure the agent payload lives in memory only after self-destruct.

3

Figure 3 powershell agent runs and on target machine and self-destruct itself and lives in memory

Custom Namlook framework python/powershell command control uses public key infrastructure for command and control so the idea is to encrypt the traffic between the target victim machine and my attacking command and control machine

4Figure 4 we have connection back from the target azure SRV01 to our python powershell command and control the payload. The payload as you see it spawn the powershell on PID 3632 and we also have internal IP address, machine name, user logged on, ad the last seen is based on 5 second interval to check if the server still sending the heartbeats .

Next step we decided to deploy a persistence stager to our target machine the idea is to force the target SRV01 server to send cmd.exe shell back to our command control every day at 8:00am or simply at startup. So whenever a use logins we get nice shell back from the SRV01

5

Figure 5 Stager but with high detection ratio as this would touch the disk and lives in HKLM:\Software\Microsoft\Network\debug registry . we encode the payload to be base64

The agent now lives inside registry debug file whenever the user logins to the SRV01 server the persistence module trigger happens and sends encrypted shell back to the command  control

6

Figure 6 debug embedded with base64 encoded powershell agent.

Next step we decided to conduct situational awareness to check what other host is reachable within from compromised target, this module simply uses nmap network mapper to identify hosts and the port numbers

7

Figure 7 SQLSRV01 10.0.0.4 identified with the open ports 445 SMB , 3389 ?

Next we used another module to extract password hashes directly from SYSTEM/SAM file. System file is required as it contains the windows secret bootkey to extract the password hashes from SAM file

8

Figure 8 USER Private and RID 500 indicates the user is local administrator account and user Guest RID 501 is guest but disabled by default.

Another fantastic we used is the mimikatz by benjamin DEPLY a.k.a gentilkiwi written in C but ported to powershell to make the use of extracted password hashes and use that as way gaining access to the connecting SQLSRV2 host with the PTH Pass the hash attack, which essentially is to inject the NTLMv2 hash into the process PID 1240 and call the cmd.exe on target server.

9

Figure 9 now is just a matter of running another PS module to steal the token to give us full administrative access on target SQLSRV02 box.

One last demo was to check how security centre identify malicious executables land on the disk with up to date AV. Of course it’s simple to bypass AV. As you see I recompiled the mimikatz simply by replacing all mimimkatz strings in code with Kikitaz to bypass Anti-virus..

10

Figure 10 extracted password hashes from SRV01 Server 2012 KIKTAZZZ

Azure Security centre and on disk analysis

process explore is one of the top windows system internal tool we use for security/troubleshooting investigations , it lists all the process and one can easily identify malicious process, schedule tasks, TCP/IP connections and most importantly file signature and many more ..

Process explore identified the PID 3632 Powershell v.1.0 and command line containing the agent PowerShell code runs under the user private context. Base64 encoded code to send the shell back to the command and control.

11

Figure 10 Process explore identifies the PowerShell malicious code

Closer dynamic analysis we can see winhttp.dll dynamic link library establishes makes 5 minutes interval to our command and control

12

Figure 11 winhttp.dll used for establishing the C2 connection

Azure security centre main dashboard resource security health with recommendations on vulnerabilities such as open NSG network security  groups, Patching as well as container encryption

13

Figure 12 azure security centre

Azure Security Centre Security Alert with description of each suspicious activities and severity level

14

Figure 13 dates and individual attack type with severity level Medium to High

Closer analysis shows our dictionary attack from my attacking machine 82.32.182.245 against SRV01 Server 2012 has been identified as network anomaly, good indication of brute force attack

15

Figure 14 RDP network anomaly brute force  detection

Powershell agent identified as malicious with decoded script showing the command and control IP address

16

Figure 15 Agent identified as malicious powershell

In conclusion it’s clear how Microsoft raised security bar against the sophisticated attacks especially identifying network anomaly and memory based attacks as we demonstrated using PowerShell as command and control. As these types of attacks on premises difficult to identify almost impossible but with Azure the response time is almost 2 ~ 3 hours

The future is here, so time to accept and adopt to cloud services  🙂

Hit me up for security related projects or 5 minutes of CLI ? 🙂

—–BEGIN PGP PUBLIC KEY BLOCK—–
Version: GnuPG v2.0.22 (GNU/Linux)

mQENBFkl+OwBCAC555CkUnv94N2ZG3M9LrGj4WdrQ98PxwhDaZ/SQ/M126hp/VhE
Pk/3BTXuoTjGrmMANU7MidKeoWwflwFsnW8m0W3+yxnkBUv/V+q6gQHDPpWoxhMw
NrDSlud4ybTVq4q/Coo1Eapt2cb3kVUIDzVYegMOKwXN2ch+S5HF/64935Us61GS
0jH2CLaF43P9apPoz7DbyOyl+bAQlzoylW1khB/1fQ8Qv6533IAvGoNted9XITBB
L7mlWZ03AuhDNbYgpKrsuuAnjl7a/5qGdr6GwWbJr4e21uycAUOGUnOpf6Lb+Z3N
aKLo5c7KHm3M0FyM7pycb/0PatI/ZYqLe0QpABEBAAG0KWFtYmllbnRjcnlwdG8g
KHRvcikgPHNhZGkuemFuZUBnbWFpbC5jb20+iQE5BBMBAgAjBQJZJfjsAhsDBwsJ
CA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xAoyAmdBynWk3MbR4avd1A2
2oKJkb76DrJQ7aB8mYyB7inPWtssiSIgs+j3TWx+RKDuMBMf+gDht0w=
=SNCP
—–END PGP PUBLIC KEY BLOCK—–

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s