homepage
Menu
Open menu
  • Training
    Go one level top Back

    Training

    • Courses

      Build cyber prowess with training from renowned experts

    • Hands-On Simulations

      Hands-on learning exercises keep you at the top of your cyber game

    • Certifications

      Demonstrate cybersecurity expertise with GIAC certifications

    • Ways to Train

      Multiple training options to best fit your schedule and preferred learning style

    • Training Events & Summits

      Expert-led training at locations around the world

    • Free Training Events

      Upcoming workshops, webinars and local events

    • Security Awareness

      Harden enterprise security with end-user and role-based training

    Featured: Solutions for Emerging Risks

    Discover tailored resources that translate emerging threats into actionable strategies

    Risk-Based Solutions

    Can't find what you are looking for?

    Let us help.
    Contact us
  • Learning Paths
    Go one level top Back

    Learning Paths

    • By Focus Area

      Chart your path to job-specific training courses

    • By NICE Framework

      Navigate cybersecurity training through NICE framework roles

    • DoDD 8140 Work Roles

      US DoD 8140 Directive Frameworks

    • By European Skills Framework

      Align your enterprise cyber skills with ECSF profiles

    • By Skills Roadmap

      Find the right training path based on critical skills

    • New to Cyber

      Give your cybersecurity career the right foundation for success

    • Leadership

      Training designed to help security leaders reduce organizational risk

    • Degree and Certificate Programs

      Gain the skills, certifications, and confidence to launch or advance your cybersecurity career.

    Featured

    New to Cyber resources

    Start your career
  • Community Resources
    Go one level top Back

    Community Resources

    Watch & Listen

    • Webinars
    • Live Streams
    • Podcasts

    Read

    • Blog
    • Newsletters
    • White Papers
    • Internet Storm Center

    Download

    • Open Source Tools
    • Posters & Cheat Sheets
    • Policy Templates
    • Summit Presentations
    • SANS Community Benefits

      Connect, learn, and share with other cybersecurity professionals

    • CISO Network

      Engage, challenge, and network with fellow CISOs in this exclusive community of security leaders

  • For Organizations
    Go one level top Back

    For Organizations

    Team Development

    • Why Partner with SANS
    • Group Purchasing
    • Skills & Talent Assessments
    • Private & Custom Training

    Leadership Development

    • Leadership Courses & Accreditation
    • Executive Cybersecurity Exercises
    • CISO Network

    Security Awareness

    • End-User Training
    • Phishing Simulation
    • Specialized Role-Based Training
    • Risk Assessments
    • Public Sector Partnerships

      Explore industry-specific programming and customized training solutions

    • Sponsorship Opportunities

      Sponsor a SANS event or research paper

    Interested in developing a training plan to fit your organization’s needs?

    We're here to help.
    Contact us
  • Talk with an expert
  • Log In
  • Join - it's free
  • Account
    • Account Dashboard
    • Log Out
  1. Home >
  2. Blog >
  3. Protecting Privileged Domain Accounts: PsExec Deep-Dive
370x370_Mike-Pilkington.jpg
Mike Pilkington

Protecting Privileged Domain Accounts: PsExec Deep-Dive

December 17, 2012

[Author's Note: This is the 6th in a multi-part series on the topic of "Protecting Privileged Domain Accounts". My primary goal is to help incident responders protect their privileged accounts when interacting with comprised hosts, though I also believe this information will be useful to anyone administering and defending a Windows environment.]

PsExec is an extremely powerful tool and is used commonly in enterprise networks, for both good and evil. Systems administrators and incident responders use it for its flexibility in interacting with remote machines, including a telnet-like ability to run command-line tools on remote machines and receive the output on their local console. Attackers utilize it for the same reasons, providing a convenient way to move laterally and interact with remote machines using compromised credentials.

Given its power, you might wonder what the ramifications are of using this tool on a compromised machine. In other words, could it lead to your credentials being compromised? In this article, I'll discuss the two "native" methods of logging onto a remote machine with PsExec and why you should always avoid one of the two. I'll also discuss possible workarounds to the second, more dangerous logon. Finally, since attackers have been known to use this tool for lateral movement, I'll follow up the logon discussion with a brief forensic analysis of the artifacts you will typically find from PsExec usage.

2 Types of Logons with PsExec

It's easy to overlook that fact that there are two distinct ways to logon to a remote host with PsExec. The first method is to run PsExec under the context of the currently logged-on user. This requires no special switches or specification of an account. It simply uses the logged-on account to authenticate to the remote machine. As we'll see in a moment, this results in a network logon to the remote machine.

The second method is to specify an alternate account using the "-u" switch and optionally the "-p" switch (if you don't supply "-p", it behaves the same but will prompt you for the password). This allows you to authenticate to the remote machine as a different user. This would commonly be a user with higher privileges than your currently logged-on account. While this is often convenient, it provides more than just convenience?it also provides a full interactive logon, which loads all the user's credentials on the remote host. This has the benefit of allowing a user to authenticate to another system from the remote host, but it also carries the significant drawback of exposing NT & LM hashes, Kerberos Ticket Granting Ticket (TGT), and clear-text passwords to malware on the remote host. We clearly don't want to do this on an untrusted host!

An important side note here is to be aware that both logon methods for PsExec have the potential of creating the delegate-level access token, if the remote system is trusted for delegation. This is also a significant risk, though not as commonly exploited. As discussed in my article on access tokens, we fortunately have a simple fix available by enabling the setting "Account is sensitive and cannot be delegated", which is recommended by Microsoft for sensitive accounts. Please refer to the access token article for complete details.

Ok, so let's have a look at these two logon methods in action.

Testing: PsExec with logged-on user account

In the following screenshot, I'm logged onto machine IR-XP-PC as MSAD2-RESPONDER1. I've initiated a PsExec logon from the local host to the remote host named USER-XP-PC. Since I did not specify "-u", the currently logged-on user will use standard Kerberos or NTLM integrated authentication to connect to the remote host. Once connected, I ran a couple of commands to show that I am still MSAD2-RESPONDER1 and am now executing commands on USER-XP-PC.

pc-cmd-prompt.png

The following screenshot shows the relevant Event Log from the PsExec logon. This connection created only a Type 3 network logon, which is the safe way to connect to a remote host, as discussed in my previous article on password hashes.

PsExec.png

To confirm the logon type and the fact that password hashes are not revealed, here's the relevant output from Sysinternals' logonsessions tool?again showing a network logon for MSAD2-RESPONDER1. The screenshot also shows the output of Windows Credentials Editor (WCE), which verifies the hash is not in memory for the MSAD2-RESPONDER1 account.

msad2-responder1.png

So the good news is that we've seen that a standard connection with PsExec, using the currently logged-on user's credentials, results in only a network logon. This is the safe way to execute PsExec remotely.

Now let's look at the other authentication method with PsExec.

Testing: PsExec with Alternate Credentials "-u" option

This time I'm logged on locally with a non-privileged account and will then log on remotely using a privileged account, MSAD2-RESPONDER1.

alternative-credentials.png

Examining the logs on the remote machine, we initially see a network logon (Type 3), but then 1 second later we see an interactive logon (Type 2) for our alternate credentials user, MSAD2-RESPONDER1.

alternative-credentials-user.png alternative-credentials-user-2.png

This interactive logon causes the credentials of the responder account to be loaded and available for an attacker to steal. The following screenshot shows the currently logged on sessions for MSAD2-RESPONDER1 (two of them), and as expected, WCE shows us the password hashes for MSAD2-RESPONDER1.

wce.png

To make matters worse, an additional concern with the "-u" option is that it sends the password in clear-text in order to generate the interactive logon. Microsoft Sysinternals warns us of this issue on their PsExec download page. Here is a screenshot of Wireshark showing the password being sent over the network in the clear (password = responder1-pw1):

wireshark.png

Conclusions on PsExec Logon Methods, with Workarounds

It is clearly not safe to use PsExec's "-u" option on an untrusted remote host. On the other hand, using PsExec without "-u" and therefore authenticating as the currently logged-on user is much safer and does not expose the account to theft of password hashes, the Kerberos TGT, or the plain-text password itself. As mentioned earlier, there is still the possibility of the account's delegation token being stolen, as discussed in my article on access tokens. The simple fix for this risk is to enable the setting "Account is sensitive and cannot be delegated", as discussed in the article.

The ability to specify alternate credentials is a useful one, and fortunately, there are a couple of ways we can still make this work without divulging credentials on the remote host.

One possibility is the use of RunAs. For example, I logon to my machine as a standard user, but will often need to connect to a remote machine with a privileged account. For me, the easiest way to do this, while still being safe assuming my local machine is not compromised, is to spawn a new CMD command shell as the privileged account, using the command "RunAs.exe /user:domain\user cmd.exe". As I discussed in my article on hashes, using RunAs will still result in an interactive logon, but at least I'm doing it on my trusted workstation rather than the untrusted remote host.

RunAs is a good option in many cases, but there are situations where using RunAs is not feasible. For example, if the machine you are using is not a part of the privileged account's domain. It turns out there is another workaround that can allow you to specify alternate credentials but not create an interactive logon. The workaround is described in another PsExec article I wrote a couple of years ago. The suggested workaround is to first connect to the IPC$ share of the remote host using the alternate account, and then use PsExec without "-u". The process looks like this for my current test setup:

command-prompt.png

When performed this way, my tests show that only a network logon is created (no interactive logon) and also the password is not sent in clear-text (presumably since there is no interactive logon). I'd recommend you confirm this in your own environment before using it in production. The main thing to check for is that there is no Type 2 interactive logon in the logs of the remote host.

A Forensic Overview of PsExec

Since we sometimes see attackers use PsExec for lateral movement, let's take the discussion a step further and look at some artifacts that could reside from PsExec usage. The artifacts presented here are the direct result of using PsExec in my tests above. Of course there are other ways of utilizing PsExec, so the resulting artifacts may vary.

When PsExec executes on a remote machine, the local machine sends a service executable named PSEXESVC.EXE to the remote machine and that executable is installed as a service. Here's a look at that service running on the remote host. Notice the service executable resides in C:\WINDOWS.

psexec-properties.png

Once the user has cleanly logged off (exited) PsExec, the service is removed and PSEXESVC.EXE is deleted. Although PsExec is deleted (as indicated by the red X icon), the screenshot below shows the file and its metadata. Notice the UTC creation and modification times correspond to the second logon time in my tests above (12/15/12 9:43:20 PM Central time).

access-data-ftk-imager.png

Also notice that the owner of this file is the user who connected remotely to run PsExec.

access-data-ftk-image-2.png command-prompt-2.png

A profile is created for this user at the time of first login, if it didn't already exist. This is regardless of whether an interactive logon occurred or not. Here are the timestamps for the MSAD2-RESPONDER1 account's profile folder. Notice the UTC creation timestamp is the same time of the first logon in the tests above (12/12/12 9:52:27 PM Central time).

timestamps.png

Prefetch shows both the first time the service executable was run (Prefetch file creation time minus 10 seconds) and last time run (Prefetch file modification time minus 10 seconds).

prefetch.png

The Application Compatibility Cache shows this as well, with an entry for both times run.

app-compatibility-cache.png

Since PsExec is typically run remotely, these run times can be used to examine the Event Logs and look for network logons at the same time. The corresponding Event Logs for these PsExec executions are shown in the screenshots at the beginning of this article.

yaru.png

When PsExec is exited, the PsExec service is removed, but you may find the deleted service key still in the Registry. Here is the deleted key shown by YARU. Note that the last write time of the key corresponds to the time the responder account logged out and exited PsExec the second time (12/15/12 9:49:13 PM Central time)

yaru-2.png

Final Thoughts

I've found that there are safe ways to use PsExec, but unfortunately it is not obvious how to do so. Hopefully this discussion has provided a deeper understanding of the tool and how you can use it safely, as well as analyze the forensic artifacts it can leave behind.

Share:
TwitterLinkedInFacebook
Copy url Url was copied to clipboard
Subscribe to SANS Newsletters
Receive curated news, vulnerabilities, & security awareness tips
United States
Canada
United Kingdom
Spain
Belgium
Denmark
Norway
Netherlands
Australia
India
Japan
Singapore
Afghanistan
Aland Islands
Albania
Algeria
American Samoa
Andorra
Angola
Anguilla
Antarctica
Antigua and Barbuda
Argentina
Armenia
Aruba
Austria
Azerbaijan
Bahamas
Bahrain
Bangladesh
Barbados
Belarus
Belize
Benin
Bermuda
Bhutan
Bolivia
Bonaire, Sint Eustatius, and Saba
Bosnia And Herzegovina
Botswana
Bouvet Island
Brazil
British Indian Ocean Territory
Brunei Darussalam
Bulgaria
Burkina Faso
Burundi
Cambodia
Cameroon
Cape Verde
Cayman Islands
Central African Republic
Chad
Chile
China
Christmas Island
Cocos (Keeling) Islands
Colombia
Comoros
Cook Islands
Costa Rica
Cote D'ivoire
Croatia (Local Name: Hrvatska)
Curacao
Cyprus
Czech Republic
Democratic Republic of the Congo
Djibouti
Dominica
Dominican Republic
East Timor
Ecuador
Egypt
El Salvador
Equatorial Guinea
Eritrea
Estonia
Eswatini
Ethiopia
Falkland Islands (Malvinas)
Faroe Islands
Fiji
Finland
France
French Guiana
French Polynesia
French Southern Territories
Gabon
Gambia
Georgia
Germany
Ghana
Gibraltar
Greece
Greenland
Grenada
Guadeloupe
Guam
Guatemala
Guernsey
Guinea
Guinea-Bissau
Guyana
Haiti
Heard And McDonald Islands
Honduras
Hong Kong
Hungary
Iceland
Indonesia
Iraq
Ireland
Isle of Man
Israel
Italy
Jamaica
Jersey
Jordan
Kazakhstan
Kenya
Kiribati
Korea, Republic Of
Kosovo
Kuwait
Kyrgyzstan
Lao People's Democratic Republic
Latvia
Lebanon
Lesotho
Liberia
Liechtenstein
Lithuania
Luxembourg
Macau
Madagascar
Malawi
Malaysia
Maldives
Mali
Malta
Marshall Islands
Martinique
Mauritania
Mauritius
Mayotte
Mexico
Micronesia, Federated States Of
Moldova, Republic Of
Monaco
Mongolia
Montenegro
Montserrat
Morocco
Mozambique
Myanmar
Namibia
Nauru
Nepal
Netherlands Antilles
New Caledonia
New Zealand
Nicaragua
Niger
Nigeria
Niue
Norfolk Island
North Macedonia
Northern Mariana Islands
Oman
Pakistan
Palau
Palestine
Panama
Papua New Guinea
Paraguay
Peru
Philippines
Pitcairn
Poland
Portugal
Puerto Rico
Qatar
Reunion
Romania
Russian Federation
Rwanda
Saint Bartholemy
Saint Kitts And Nevis
Saint Lucia
Saint Martin
Saint Vincent And The Grenadines
Samoa
San Marino
Sao Tome And Principe
Saudi Arabia
Senegal
Serbia
Seychelles
Sierra Leone
Sint Maarten
Slovakia
Slovenia
Solomon Islands
South Africa
South Georgia and the South Sandwich Islands
South Sudan
Sri Lanka
St. Helena
St. Pierre And Miquelon
Suriname
Svalbard And Jan Mayen Islands
Sweden
Switzerland
Taiwan
Tajikistan
Tanzania, United Republic Of
Thailand
Togo
Tokelau
Tonga
Trinidad And Tobago
Tunisia
Turkey
Turkmenistan
Turks And Caicos Islands
Tuvalu
Uganda
Ukraine
United Arab Emirates
United States Minor Outlying Islands
Uruguay
Uzbekistan
Vanuatu
Vatican City State
Venezuela
Vietnam
Virgin Islands (British)
Virgin Islands (U.S.)
Wallis And Futuna Islands
Western Sahara
Yemen
Zambia
Zimbabwe

By providing this information, you agree to the processing of your personal data by SANS as described in our Privacy Policy.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Tags:
  • Digital Forensics, Incident Response & Threat Hunting

Related Content

Blog
emerging threats summit 340x340.png
Digital Forensics, Incident Response & Threat Hunting, Offensive Operations, Pen Testing, and Red Teaming, Cyber Defense, Industrial Control Systems Security, Cybersecurity Leadership
May 14, 2025
Visual Summary of SANS Emerging Threats Summit 2025
Check out these graphic recordings created in real-time throughout the event for SANS Emerging Threats Summit 2025
No Headshot Available
Alison Kim
read more
Blog
DFIR - Blog - Running EZ Tools Natively on Linux_340 x 340.jpg
Digital Forensics, Incident Response & Threat Hunting
April 23, 2025
Running EZ Tools Natively on Linux: A Step-by-Step Guide
Developed by Eric Zimmerman, the EZ Tools suite is a collection of utilities written to assist with multiple aspects of forensic analysis.
Seth_Enoka_370x370.png
Seth Enoka
read more
Blog
powershell_option_340x340.jpg
Cyber Defense, Digital Forensics, Incident Response & Threat Hunting, Cybersecurity and IT Essentials, Offensive Operations, Pen Testing, and Red Teaming
July 12, 2022
Month of PowerShell - Windows File Server Enumeration
In this Month of PowerShell article we look at several commands to interrogate Windows SMB servers as part of our incident response toolkit.
Josh Wright - Headshot - 370x370 2025.jpg
Joshua Wright
read more
  • Company
  • Mission
  • Instructors
  • About
  • FAQ
  • Press
  • Contact Us
  • Careers
  • Policies
  • Training Programs
  • Work Study
  • Academies & Scholarships
  • Public Sector Partnerships
  • Law Enforcement
  • SkillsFuture Singapore
  • Degree Programs
  • Get Involved
  • Join the Community
  • Become an Instructor
  • Become a Sponsor
  • Speak at a Summit
  • Join the CISO Network
  • Award Programs
  • Partner Portal
Subscribe to SANS Newsletters
Receive curated news, vulnerabilities, & security awareness tips
United States
Canada
United Kingdom
Spain
Belgium
Denmark
Norway
Netherlands
Australia
India
Japan
Singapore
Afghanistan
Aland Islands
Albania
Algeria
American Samoa
Andorra
Angola
Anguilla
Antarctica
Antigua and Barbuda
Argentina
Armenia
Aruba
Austria
Azerbaijan
Bahamas
Bahrain
Bangladesh
Barbados
Belarus
Belize
Benin
Bermuda
Bhutan
Bolivia
Bonaire, Sint Eustatius, and Saba
Bosnia And Herzegovina
Botswana
Bouvet Island
Brazil
British Indian Ocean Territory
Brunei Darussalam
Bulgaria
Burkina Faso
Burundi
Cambodia
Cameroon
Cape Verde
Cayman Islands
Central African Republic
Chad
Chile
China
Christmas Island
Cocos (Keeling) Islands
Colombia
Comoros
Cook Islands
Costa Rica
Cote D'ivoire
Croatia (Local Name: Hrvatska)
Curacao
Cyprus
Czech Republic
Democratic Republic of the Congo
Djibouti
Dominica
Dominican Republic
East Timor
Ecuador
Egypt
El Salvador
Equatorial Guinea
Eritrea
Estonia
Eswatini
Ethiopia
Falkland Islands (Malvinas)
Faroe Islands
Fiji
Finland
France
French Guiana
French Polynesia
French Southern Territories
Gabon
Gambia
Georgia
Germany
Ghana
Gibraltar
Greece
Greenland
Grenada
Guadeloupe
Guam
Guatemala
Guernsey
Guinea
Guinea-Bissau
Guyana
Haiti
Heard And McDonald Islands
Honduras
Hong Kong
Hungary
Iceland
Indonesia
Iraq
Ireland
Isle of Man
Israel
Italy
Jamaica
Jersey
Jordan
Kazakhstan
Kenya
Kiribati
Korea, Republic Of
Kosovo
Kuwait
Kyrgyzstan
Lao People's Democratic Republic
Latvia
Lebanon
Lesotho
Liberia
Liechtenstein
Lithuania
Luxembourg
Macau
Madagascar
Malawi
Malaysia
Maldives
Mali
Malta
Marshall Islands
Martinique
Mauritania
Mauritius
Mayotte
Mexico
Micronesia, Federated States Of
Moldova, Republic Of
Monaco
Mongolia
Montenegro
Montserrat
Morocco
Mozambique
Myanmar
Namibia
Nauru
Nepal
Netherlands Antilles
New Caledonia
New Zealand
Nicaragua
Niger
Nigeria
Niue
Norfolk Island
North Macedonia
Northern Mariana Islands
Oman
Pakistan
Palau
Palestine
Panama
Papua New Guinea
Paraguay
Peru
Philippines
Pitcairn
Poland
Portugal
Puerto Rico
Qatar
Reunion
Romania
Russian Federation
Rwanda
Saint Bartholemy
Saint Kitts And Nevis
Saint Lucia
Saint Martin
Saint Vincent And The Grenadines
Samoa
San Marino
Sao Tome And Principe
Saudi Arabia
Senegal
Serbia
Seychelles
Sierra Leone
Sint Maarten
Slovakia
Slovenia
Solomon Islands
South Africa
South Georgia and the South Sandwich Islands
South Sudan
Sri Lanka
St. Helena
St. Pierre And Miquelon
Suriname
Svalbard And Jan Mayen Islands
Sweden
Switzerland
Taiwan
Tajikistan
Tanzania, United Republic Of
Thailand
Togo
Tokelau
Tonga
Trinidad And Tobago
Tunisia
Turkey
Turkmenistan
Turks And Caicos Islands
Tuvalu
Uganda
Ukraine
United Arab Emirates
United States Minor Outlying Islands
Uruguay
Uzbekistan
Vanuatu
Vatican City State
Venezuela
Vietnam
Virgin Islands (British)
Virgin Islands (U.S.)
Wallis And Futuna Islands
Western Sahara
Yemen
Zambia
Zimbabwe

By providing this information, you agree to the processing of your personal data by SANS as described in our Privacy Policy.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
  • Privacy Policy
  • Terms and Conditions
  • Do Not Sell/Share My Personal Information
  • Contact
  • Careers
© 2025 The Escal Institute of Advanced Technologies, Inc. d/b/a SANS Institute. Our Terms and Conditions detail our trademark and copyright rights. Any unauthorized use is expressly prohibited.
  • Twitter
  • Facebook
  • Youtube
  • LinkedIn