18
19th October 2016 www.oneconsult.com badGPO Using GPOs for Persistence and Lateral Movement Speakers: Yves Kraft (@nrx_ch), Immanuel Willi e oneconsult®

badGPO ÃÆââ ... - Hack.luarchive.hack.lu/2016/161019_hacklu_badgpo_kraft-willi_oneconsult.pdf19th October 2016 badGPO Using GPOs for Persistence and

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: badGPO ÃÆââ ... - Hack.luarchive.hack.lu/2016/161019_hacklu_badgpo_kraft-willi_oneconsult.pdf19th October 2016 badGPO Using GPOs for Persistence and

19th October 2016

www.oneconsult.com

badGPOUsing GPOs for Persistence and Lateral Movement

Speakers: Yves Kraft (@nrx_ch), Immanuel Willi

e oneconsult®

Page 2: badGPO ÃÆââ ... - Hack.luarchive.hack.lu/2016/161019_hacklu_badgpo_kraft-willi_oneconsult.pdf19th October 2016 badGPO Using GPOs for Persistence and

2 © 2016 Oneconsult AG

To create awareness

or…

to give you neat ideas!

GOAL

"" oneconsult®

Page 3: badGPO ÃÆââ ... - Hack.luarchive.hack.lu/2016/161019_hacklu_badgpo_kraft-willi_oneconsult.pdf19th October 2016 badGPO Using GPOs for Persistence and

3 © 2016 Oneconsult AG

‣ Introduction

‣ Malicious Group Policies

‣ Countermeasures

‣ Future Work

AGENDA

"" oneconsult®

Page 4: badGPO ÃÆââ ... - Hack.luarchive.hack.lu/2016/161019_hacklu_badgpo_kraft-willi_oneconsult.pdf19th October 2016 badGPO Using GPOs for Persistence and

4 © 2016 Oneconsult AG

‣ Remote Management [Line 565][…]

5) GPO

If all those protocols are disabled or blocked by the

firewall, once you're Domain Admin, you can use GPO to give

users a login script, install an msi, execute a scheduled

task [13], or, like we'll see with the computer of Mauro

Romeo (one of Hacking Team's sysadmins), use GPO to enable

WMI and open the firewall.

‣ Persistence [Line 726]To hack companies, persistence isn't needed since companies

never sleep. I always use Duqu 2 style "persistence",

executing in RAM on a couple high-uptime servers.

HOW IT STARTED

Source: https://ghostbin.com/paste/6kho7

"" oneconsult®

Page 5: badGPO ÃÆââ ... - Hack.luarchive.hack.lu/2016/161019_hacklu_badgpo_kraft-willi_oneconsult.pdf19th October 2016 badGPO Using GPOs for Persistence and

5 © 2016 Oneconsult AG

‣ Initial idea

▹ Create a POC that uses group policies (GPOs) to distribute malware in a sneaky way to gain persistence in an automated manner.

‣ Initial goal

▹ Infect (a subset of) domain joined systems using a backdoor in memory of high uptime servers.

‣ Steps to take

▹ Create or inject into an existing GPO

› Set Run/RunOnce registry key

▹ Link GPO to domain/organizational unit

▹ Wait for incoming connections

THOUGHTS ABOUT PHINEAS FISHERS WRITE-UP

"" oneconsult®

Page 6: badGPO ÃÆââ ... - Hack.luarchive.hack.lu/2016/161019_hacklu_badgpo_kraft-willi_oneconsult.pdf19th October 2016 badGPO Using GPOs for Persistence and

6 © 2016 Oneconsult AG

‣ Group Policy provides the centralized management and configuration of operating systems, applications, and users' settings in an Active Directory environment:

▹ Administrative templates

▹ Security settings

▹ Software installation

▹ Scripts

▹ Remote Installation Services

▹ Internet Explorer maintenance

▹ Folder redirection

INTRODUCTION TO GROUP POLICIES

"" oneconsult®

Page 7: badGPO ÃÆââ ... - Hack.luarchive.hack.lu/2016/161019_hacklu_badgpo_kraft-willi_oneconsult.pdf19th October 2016 badGPO Using GPOs for Persistence and

7 © 2016 Oneconsult AG

‣ GPOs tend to get messy

▹ Stored all over the place

▹ Naming conventions

▹ Grown historically

▹ Not decommissioned

‣ Hard to read

‣ Problems with privileges

INTRODUCTION TO GROUP POLICIES

"" oneconsult®

Page 8: badGPO ÃÆââ ... - Hack.luarchive.hack.lu/2016/161019_hacklu_badgpo_kraft-willi_oneconsult.pdf19th October 2016 badGPO Using GPOs for Persistence and

8 © 2016 Oneconsult AG

‣ Framework

▹ Pure PowerShell post-exploitation framework

▹ Cryptologically-secure communications

▹ Module based post-exploitation

‣ Small forensic footprint

▹ Runs in memory

▹ Runs on PowerShell (Windows standard application)

‣ Web:

▹ http://www.powershellempire.com

▹ https://github.com/adaptivethreat/Empire

POWERSHELL EMPIRE

... oneconsult®

Page 9: badGPO ÃÆââ ... - Hack.luarchive.hack.lu/2016/161019_hacklu_badgpo_kraft-willi_oneconsult.pdf19th October 2016 badGPO Using GPOs for Persistence and

9 © 2016 Oneconsult AG

MALICIOUS GROUP POLICY ATTACK SCENARIO

7

"" oneconsult®

Page 10: badGPO ÃÆââ ... - Hack.luarchive.hack.lu/2016/161019_hacklu_badgpo_kraft-willi_oneconsult.pdf19th October 2016 badGPO Using GPOs for Persistence and

10 © 2016 Oneconsult AG

‣ Goal

▹ Get persistence

‣ Approach

▹ Create a new GPO (Module: set_GpRegistryValue)

› Set a “run once” registry key

▹ Link GPO to domain corp.com

▹ Enjoy backdoor

MALICIOUS GROUP POLICY ATTACK SCENARIO - DEMO TIME

"" oneconsult®

Page 11: badGPO ÃÆââ ... - Hack.luarchive.hack.lu/2016/161019_hacklu_badgpo_kraft-willi_oneconsult.pdf19th October 2016 badGPO Using GPOs for Persistence and

11 © 2016 Oneconsult AG

MALICIOUS GROUP POLICY ATTACK SCENARIO

“Get the file called proof.txt on one of the servers. Good luck!”

7

L1r.�

"" oneconsult®

Page 12: badGPO ÃÆââ ... - Hack.luarchive.hack.lu/2016/161019_hacklu_badgpo_kraft-willi_oneconsult.pdf19th October 2016 badGPO Using GPOs for Persistence and

12 © 2016 Oneconsult AG

‣ Goal

▹ “Get the file called proof.txt on one of the servers. Good luck!”

‣ Approach

▹ Read existing Group Policies (Module: get_gpo)

▹ Create/inject malicious Group Policy

› Open FW port for WMI (Module: set_gpo_fw)

› Start WMI service (Module: set_gpo_servicestatus)

▹ Remotely apply Group Policy (Module: invoke_gpo_update)

▹ Search for proof.txt

MALICIOUS GROUP POLICY ATTACK SCENARIO - DEMO TIME

"" oneconsult®

Page 13: badGPO ÃÆââ ... - Hack.luarchive.hack.lu/2016/161019_hacklu_badgpo_kraft-willi_oneconsult.pdf19th October 2016 badGPO Using GPOs for Persistence and

13 © 2016 Oneconsult AG

‣ Advantages

▹ Using non intrusive Microsoft standard procedures

▹ Flying under the radar of monitoring (SIEM)

▹ Defeating physical and logical barriers

▹ Reaching out to every domain joined system

▹ Comfortable way to gain persistence and move laterally

MALICIOUS GROUP POLICY ATTACK SCENARIO - SUMMARY

"" oneconsult®

Page 14: badGPO ÃÆââ ... - Hack.luarchive.hack.lu/2016/161019_hacklu_badgpo_kraft-willi_oneconsult.pdf19th October 2016 badGPO Using GPOs for Persistence and

14 © 2016 Oneconsult AG

COUNTERMEASURES

Hack.lu 2016: Infosec Crossroads (Saumil Shah)

"" oneconsult®

@thereal$aumm1�� SEVEN AXIOMS

of Security

Page 15: badGPO ÃÆââ ... - Hack.luarchive.hack.lu/2016/161019_hacklu_badgpo_kraft-willi_oneconsult.pdf19th October 2016 badGPO Using GPOs for Persistence and

15 © 2016 Oneconsult AG

‣ There is no all-in-one solution!

‣ But… Things you can do:

▹ Review your GPOs

▹ Limit admin privileges (least privilege principle)

▹ Restrict application usage

▹ Monitoring & IDS (intrusion detection)

▹ Healthy information security ecosystem

▹ …

COUNTERMEASURES

egg-laying, wool and milk yielding pig

"" oneconsult®

Page 16: badGPO ÃÆââ ... - Hack.luarchive.hack.lu/2016/161019_hacklu_badgpo_kraft-willi_oneconsult.pdf19th October 2016 badGPO Using GPOs for Persistence and

16 © 2016 Oneconsult AG

‣ Cover more attack vectors and implement more GPO related PowerShell Empire modules

▹ Registry Settings (Run/RunOnce, Autostart)

▹ Firewall manipulations

▹ Start/stop services

▹ Invoke GPO update remotely

▹ Login script

▹ Task scheduler

▹ Install MSI package

▹ File search

▹ Bridging an airgap

▹ …?

‣ Preserve timestamp of manipulated GPOs

FUTURE WORK

"" oneconsult®

Page 17: badGPO ÃÆââ ... - Hack.luarchive.hack.lu/2016/161019_hacklu_badgpo_kraft-willi_oneconsult.pdf19th October 2016 badGPO Using GPOs for Persistence and

17 © 2016 Oneconsult AG

THANKYOU.PS1

Enter-PSSession –Session $currentTalkWrite-Host “Thank you for your attention!”Write-Host “If there are any questions, we would be happy to answer them”

$questions = Get-Questions

foreach ($question in $questions) {Get-Item $question | Write-Host $answer

}

# Note: Now it’s time to clap! # Either if you want us to leave or it was an inspiring talk

{ Get-Feedback } until (audienceClaps –eq False)Exit-PSSession

Get-Beer | Invoke-PraiseDemoGods

"" oneconsult®

Page 18: badGPO ÃÆââ ... - Hack.luarchive.hack.lu/2016/161019_hacklu_badgpo_kraft-willi_oneconsult.pdf19th October 2016 badGPO Using GPOs for Persistence and

18 © 2016 Oneconsult AG

CONTACT US

Yves Kraft (@nrx_ch)[email protected]

Immanuel [email protected]

:5 oneconsult®

Switzerland

Tel +49 89 452 35 25 25 [email protected]

Subsidiary of Oneconsult AG Karlstrasse 35 80333 Munich

Oneconsult AG Barenplatz 7 3011 Bern

Tel +41 31 3271515 [email protected]

Germany

Oneconsult AG Schutzenstrasse 1 8800 Thalwil

Tel +41 43 377 22 22 [email protected]