Mass Hunting and exploitation with powershell

Slides:



Advertisements
Similar presentations
Chapter Five Users, Groups, Profiles, and Policies.
Advertisements

UAG Authentication and Authorization- part1
IP ADDRESS MANAGEMENT [IPAM]
Week 6: Chapter 6 Agenda Automation of SQL Server tasks using: SQL Server Agent Scheduling Scripting Technologies.
NETOP REMOTE CONTROL What’s new in version 9.5? DECEMBER 09 NETOP REMOTE CONTROL1.
Abusing Windows Remote Management with Metasploit David Maloney Metasploit Software Engineer Rapid7.
DEV450 Visual Studio: Best Practices For Debugging Managed Applications Habib Heydarian Scott Nonnenberg Program Managers Microsoft Corporation.
MCTS Guide to Microsoft Windows Server 2008 Network Infrastructure Configuration Chapter 7 Configuring File Services in Windows Server 2008.
Jeffrey Snover Distinguished Engineer Microsoft Session Code: SRV312.
CN1176 Computer Support Kemtis Kunanuraksapong MSIS with Distinction MCT, MCTS, MCDST, MCP, A+
Remote Desktop Services Remote Desktop Connection Remote Desktop Protocol Remote Assistance Remote Server Administration T0ols.
Remote Administration Remote Desktop Remote Assistance Remote Server Administration Tools.
Microsoft ® Official Course Module XA Using Windows PowerShell ®
Appendix A Starting Out with Windows PowerShell™ 2.0.
Module 10: Monitoring ISA Server Overview Monitoring Overview Configuring Alerts Configuring Session Monitoring Configuring Logging Configuring.
Managing Groups, Folders, Files and Security Local Domain local Global Universal Objects Folders Permissions Inheritance Access Control List NTFS Permissions.
The Professional Open Source™ Company CLI Shell JBossNetwork Enterprise Manager Command Line Interface.
Tool Names: 1. VISION 2. PASCO 3. GALLETA. Tool 1 VISION.
Good Morning and Thank You!.  Have some Fun!  Learn at least one thing new!  Make myself available to you So please …  Ask questions and enjoy!
Reinsel Kuntz Lesher, LLP.  Outline Overview  netstat -an (-ano will give the PID)  ftp  bin  mget  mput  telnet  telnet bobm.us 25  helo  mail.
POWERSHELL SHENANIGANS KIERAN JACOBSEN HP ENTERPRISE SERVICES.
Remote Administration Remote Desktop Remote Desktop Gateway Remote Assistance Windows Remote Management Service Remote Server Administration Tools.
Troubleshooting Security Issues Lesson 6. Skills Matrix Technology SkillObjective Domain SkillDomain # Monitoring and Troubleshooting with Event Viewer.
Module 5: Creating and Configuring Group Policies.
Ed Wilson, MCSE, MCSD Microsoft Scripting Guy Microsoft Session Code: WCL314.
Windows XP Service Pack 2 Customer Awareness Workshop XP SP2 Technical Drilldown – Part 1 Craig Schofield Microsoft Ltd. UK September.
Lesson 12: Configuring Remote Management
Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some.
Msdevcon.ru#msdevcon. ИЗ ПЕРВЫХ РУК: ДИАГНОСТИКА ПРИЛОЖЕНИЙ С ПОМОЩЮ ИНСТРУМЕНТОВ VISUAL STUDIO 2012 MAXIM GOLDIN Senior Developer, Microsoft.
 It is Microsoft's new task-based command- line shell and scripting language designed especially for system administration.  It helps Information Technology.
Module 6: Administering Reporting Services. Overview Server Administration Performance and Reliability Monitoring Database Administration Security Administration.
Module 14: Advanced Topics and Troubleshooting. Microsoft ® Windows ® Small Business Server (SBS) 2008 Management Console (Advanced Mode) Managing Windows.
1 BCS 4 th Semester. Step 1: Download SQL Server 2005 Express Edition Version Feature SQL Server 2005 Express Edition SP1 SQL Server 2005 Express Edition.
Pass Microsoft Installing and Configuring Windows Server 2012 exam in just 24 HOURS! 100% REAL EXAM QUESTIONS ANSWERS Microsoft Installing.
Windows Server 2003 { First Steps and Administration} Benedikt Riedel MCSE + Messaging
Common System Exploits Tom Chothia Computer Security, Lecture 17.
Start-SPPowerShell – Introduction to PowerShell for SharePoint Admins and Developers Paul BAker.
ArcGIS for Server Security: Advanced
Stress Free Deployments with Octopus Deploy
Office PowerShell administration
Preparing for the Windows 8.1 MCSA
Lesson 6: Configuring Servers for Remote Management
PowerShell Introduction Copyright © 2016 – Curt Hill.
Windows Server 8 beta og Windows PowerShell 3.0
Exam In The First Attempt?
PowerShell 2.0 Remoting Ravikanth C.
70-293: MCSE Guide to Planning a Microsoft Windows Server 2003 Network, Enhanced Chapter 6: Planning, Configuring, And Troubleshooting WINS.
Securing the Network Perimeter with ISA 2004
Logo here Module 3 Microsoft Azure Web App. Logo here Module Overview Introduction to App Service Overview of Web Apps Hosting Web Applications in Azure.
Azure CLI Deep Dive Neil Peterson Content Developer Microsoft.
SQL Server & PowerShell
Excel Services Deployment and Administration
Getting Started with the Data ONTAP PowerShell Toolkit
Pentesting with Powershell
Lesson #8 MCTS Cert Guide Microsoft Windows 7, Configuring Chapter 8 Configuring Applications and Internet Explorer.
Download dumps - Microsoft Real Exam Questions Dumps4download
SharePoint Saturday Omaha April 2016
IIS.
Windows PowerShell Remoting: Definitely NOT Just for Servers
Making PowerShell Useful
Using PowerShell Magic to Manage Microsoft Office 365
Manage Your Enterprise from a Single Seat: Windows PowerShell Remoting
System Admin Best Practices for NAV 2013 R2
Cmdlets “Command-lets”
Service Template Creation from the Ground Up
Creating and Managing Folders
Windows Name Resolution
Microsoft Virtual Academy
Windows without windows...
Slide Summary: Perpetual Reality, who we are, and why we exist
Presentation transcript:

Mass Hunting and exploitation with powershell Jordan Abernathy Director of Defensive Operations @ CompSec Direct

Agenda Brief Powershell info Example usage Demo 1 (Enable Winrm via psexec) Demo 2 (Mass DNS Cache retrieval) Demo 3 (Mass Remote Command Execution) Demo 4 (Mass File Contains Search) Demo 5 (Mass File Search)

Powershell Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework (1) Incorporated into major Windows releases around October 2009 http://en.wikipedia.org/wiki/Windows_PowerShell 3

What can I do with pshell here? Run multiple commands on multiple boxes. Aggregate collected information Schedule recurring collection Find malicious activity (Hunt) Exploit numerous boxes Evade AV (2) What? Yep,PowerSploit among others 2. https://www.sans.org/webcasts/fail-pen-test-98647/success 4

I see a lot of versions and pshell types, does it matter? Yes XP 2003 can only run Ver 2.0 Vista,7,8 2008/2012 use Ver 3.0 8.1 and 2012 R2 use Ver 4.0 Each revision adds features and deprecates others Don’t be surprised if scripts don’t work across multiple versions. There are 4 different pshell script forms: cmdlets, which are .NET programs designed to interact with PowerShell PowerShell scripts (files suffixed by .ps1) PowerShell functions Standalone executable programs

Enough slides, Demo Time Network Description Us – Windows Xp-SP3 Them – 5 Win XP Hosts, 5 Windows 7 Domain Joined Needs Kerberos authentication by defaults Task Retrieve multiple entries from multiple system with Pshell scripts Parse, sort, output to csv and other formats Find Anomalies Push Malware and malicious commands Undetected Signature evasion Delivery evasion Abusing trusted applications Poor Configs

But Pshell does nothing remotely yet :-( Need to start WinRM (Remote Management) Use psexec to make this happen Psexec @listofboxes –accepteula –s cmd /c “winrm quickconfig -q” Psexec used admin$ by default It also needs file and sharing to be enabled This command also makes firewall exceptions Your AV may or may not allow psexec and winrm to function But my customer said no new services Fine, get permission It’s in the scope, if not, insist you can disable this with two commands sc stop WinRM sc config WinRM start= disabled

Enable WinRM via psexec Demo 1 Enable WinRM via psexec Starts WinRM (unencrypted http over TCP 5986) Adds Windows Firewall Exceptions Adds WinRM service in Auto Mode

Enable WinRM via psexec Demo 1 Enable WinRM via psexec Starts WinRM (unencrypted http over TCP 5986) Adds Windows Firewall Exceptions Adds WinRM service in Auto Mode

Demo 2 Get cached DNS Entries for beaconing remnants $computernames = Get-Content -Path c:\sysint\comps.txt (Read all the hostnames in file) $session = New-PSSession -cn $computernames -cred boobooware\administrator (Make WinRM sessions from list into memory) (Have to use names or use https for ip's or WinRM) Invoke-Command -Session $session -ScriptBlock {ipconfig /displaydns} | select-string “Record Name . . . . . :” | Export-Csv -Path "c:\sysint\dnsrecords.csv“ |format-table –property * -autosize | out-string –width 4096 http://social.technet.microsoft.com/Forums/windowsserver/en-US/47ab4058-9ae5-4924-9e34-2627eb5ab15d/beginner-powershell-getting-machine-names-from-a-text-file-and-run-queries-functions-and?forum=winserverpowershell http://technet.microsoft.com/en-us/library/dd819505.aspx 10

Demo 2 Cached DNS Entries Dumps dns cache from 10 different hosts into csv file for further analysis Any command can be substituted for ipconfig command used for intel gathering

Demo 3 Get EventLogs related to Last 10 Security Log entries computernames = Get-Content -Path c:\scripts\comps.txt $session = New-PSSession -cn $computernames -cred boobooware\administrator Invoke-Command -Session $session {Get-EventLog -ComputerName $computernames -LogName Security -Newest 10| Export-Csv -Path "c:\sysint\secevents.csv“} | format-table –property * -autosize | out-string –width 4096 12

Demo 3 Event Log Retrieval Pulls the latest 10 entries for all the hosts Requires further parsing, but delivery is almost immediate

Demo 4 Find files across all machines containing text Invoke-Command -Session $session {Get-ChildItem “C:\temp\” -recurse -ea 0 | Select-String -pattern “administrator” | group path | select name} | |format-table –property * -autosize

Demo 5 Find file across all machines with filename equals Invoke-Command -Session $session {Get-ChildItem “C:\windows\system32\drivers\” – recurse -ea 0 –Filter booms.sys.txt | group path | select name} |format- table – property * -autosize

QA on Pshell