惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
The Exploit Database - CXSecurity.com
WordPress大学
WordPress大学
L
LangChain Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 聂微东
J
Java Code Geeks
T
Tailwind CSS Blog
大猫的无限游戏
大猫的无限游戏
博客园 - 【当耐特】
阮一峰的网络日志
阮一峰的网络日志
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Engineering at Meta
Engineering at Meta
M
MIT News - Artificial intelligence
A
About on SuperTechFans
Simon Willison's Weblog
Simon Willison's Weblog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 叶小钗
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Threatpost
T
Threat Research - Cisco Blogs
GbyAI
GbyAI
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
AWS News Blog
AWS News Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
S
Securelist
I
InfoQ
N
News and Events Feed by Topic
I
Intezer
A
Arctic Wolf
P
Proofpoint News Feed
Martin Fowler
Martin Fowler
L
Lohrmann on Cybersecurity
S
Secure Thoughts
P
Privacy & Cybersecurity Law Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
SecWiki News
SecWiki News
P
Palo Alto Networks Blog
MongoDB | Blog
MongoDB | Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
H
Help Net Security
B
Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
V2EX - 技术
V2EX - 技术
S
SegmentFault 最新的问题
Application and Cybersecurity Blog
Application and Cybersecurity Blog
人人都是产品经理
人人都是产品经理
PCI Perspectives
PCI Perspectives
F
Fortinet All Blogs

Posts on Noah Bailey

How to turn anything into a router Deploy to Cloudfront from GitHub using OpenID Connect Backup Postgres databases with Kubernetes CronJobs The spelling error made 200 billion times a day Restarting Kubernetes pods using a CronJob You've just bought a new domain. Now what? Who Sawed My Motherboard??? Linux on the P8 Aliexpress Mini Laptop Recovering Mysql/Mariadb after a nasty crash Using EXIF data to pick my next lens Converting and developing RAW photos on Linux automatically Thank you, 2016 iPhone Don't Make It Work Self-hosted Surveillance with ZoneMinder Backups, Monitoring, and Security for small Mastodon servers Block web scanners with ipset & iptables Executing commands over SSH with GitHub Actions Debian Sid on encrypted ZFS Protect your dangerously insecure redis server Debian: the luxurious boring lifestyle Monitor radiation with a Raspberry Pi Simple Linux server alerts: Know your performance, errors, security, syslog, and security NUC crashes on debian 11 - How I fixed it Basic Linux server security with fail2ban, ossec, and firewall Windows 11 will create heaps of needless trash Domesticated Kubernetes Networking The Cursed Certificate Our mostly disposable and entirely stupid world Trying out OpenBSD (as a Linux geek) Making VoIP Calls with Antique Rotary Phones Monitoring WAN speed with speedtest-cli and ElasticSearch Monitoring WAN latency with InfluxDB The Zeroshell botnet returns Installing Gentoo on a vintage Thinkpad T60 Malware emails 2: Russian boogaloo TP-Link Device Weirdness ElasticSearch broke all my nice things (a story of cascading failure) A New Botnet is Targeting Network Infrastructure Malware on the Wire: Monitoring Network Traffic with Suricata and ClamAV Cloud Threat Protection with OSSEC and Suricata Malware Emails From Jerks Surviving the Apocalypse with an Offline Wikipedia Server Being Attacked by Bots Linux Router, Firewall and IDS Appliance You Probably Don't Need a VPN Fix an Oversharded Elasticsearch Cluster Automating KVM Virtualization Update all your linux servers as fast as possible Cleanup Systemd Journald Storage Stop Putting Your SSH Keys on Github! Clustering KVM with Ceph Storage FreeRadius Active Directory Integration Retrieving WPA2 Keys on Windows Deploy MDT Litetouch on Linux with TFTPD and Syslinux Generating MSI transform files with Orca The Inflatable Dinghy Generating Cisco IOS config files with Python Homebrew SAN Getting Cloudy
Stealing Windows Sessions
2019-02-02 · via Posts on Noah Bailey

Editor’s note (2021-01): This particular hacking method no longer works after 2019-11 windows update. I had this article on ice for a very long time and feel confident that it won’t be abused at this time.

Preface

I feel like I shouldn’t have to say this, but please use your powers for good and not evil. The methods I’ll reveal here have quite impressive post-exploit abilities for lateral movement. If you’re thinking about getting arrested for something dumb, please don’t bring up my website at your trial. I don’t like lawyers very much (no offense lawyers).

This is an interesting technique where a priviledged user on a Windows system can take control of other user’s sessions. To be clear, this is not a vulnerability or exploit for the following reasons:

  • Requires elevated priviledges
  • Requires physical access to the system, or a sophisticated remote access toolkit

Either way, it’s a fun way to learn more about the inner workings of Windows, and how to use and abuse it’s quirks and features.

The Windows Display Manager

Before we get too far ahead of ourselves, let’s start with what the Windows DM is and briefly how it works. This is a quick rundown at best; if you’re looking for full blown documentation you’ll want to get a job at Microsoft. Or read Mark Russonivich’s book, that might be the closest you’ll get…

There are three primary components of the Windows Display Manager that you should know about. For more information about these, go visit the the Windows Performance Team on Technet.

  • Desktops
    • Contains userspace processes, applications, runtimes, and background tasks
    • Generally one desktop per user, though that can be changed in more recent versions.
  • Sessions
    • Sessions >0 act as containers for userspace desktops
    • Session 0 contains interactive services, usermode drivers, and other vestigial leftovers from the pre-vista age. In most recent versions of Windows it is locked away, difficult to tamper with, and isolated in many ways from sensitive processes.
  • Window Stations
    • Represent connections to a session. Most commonly this is the physical keyboard, mouse, and monitor attached to a PC, however it can also represent RDP connections.

Inspecting Sessions

The first part of the puzzle is figuring out which session contains useful information. There are generally two things to look for, processes and user accounts. From here on out, Admin access is needed to do anything useful.

Users

Getting a list of logged in users is quite simple, and probably familiar to most admins:

net session 

Put a screenshot here?

Then, compare that to the list of window stations active:

qwinsta

Another one here?

Processes

Getting a process list is also quite straightforward. It requires an administrative powershell session:

Get-Process *[filter-keyword]* -IncludeUserName

Once a valuable session has been found, a priviledged user can then take control of the Display Manager to seize that session.

Switching Sessions

Because of the heavily ACL-integrated nature of the NT operating system, all objects including sessions and desktops have a set of securables. In most cases, the “owner” of a desktop is the user that created it with all other users having no access at all, other than being able to see that it exists (think about the login screen, that’s a desktop too!).

Fortunately, as with most securables, the NT AUTHORITY\SYSTEM account has full access to desktops and sessions. And this makes sense, since the operating system itself needs a way to manipulate the session manager to allow non-logged-in users to start their own sessions. However, it also means that those with more nefarious intent can seize control of sessions by elevating to SYSTEM level.

With both methods, it is required to already have a shell as Administrator; the difference is in the tools used.

Method 1: PSEXEC

This method requires the ability to download and run executables. In many cases this is not possible (for good reason), but most of the time it works just fine.

First, using the methods above locate the target session.

Then, execute tscon as system to link the target session ID to the console window station:

.\psexec.exe -s tscon /dest:CONSOLE <ID>

Within a second, the display will blank then connect to the target session. Easy!

Method 2: Scheduled Tasks

This method requires no additional binaries! Just register a scheduled task on the sytem that will trigger a tscon operation. For extra sneak factor, this task can be buried deep in the library with an inconspicuous name… Think “xbox-service-updater” or something along those lines.

schtasks.exe /create /tn sessionswap /ru "SYSTEM" /Z /tr "tscon" "/dest:CONSOLE <ID>"

schtasks.exe /run /tn sessionswap

Method 3: Service Manager

This method is my favourite, simply for the absurdity of it. There’s something delightful about creating a service that will immediately crash and land you in somebody else’s desktop. Of all these methonds, this is the least likely to work in the future, as Microsoft is actively working on securing the service control manager, and increasing the auditing ability of the system to detect tampering with services. So don’t try this if you don’t want to get caught… Hypothetically of course.

sc create sessionswap type= own type= interact start= demand binpath= C:\Windows\System32\tscon.exe /dest:CONSOLE <ID>

sc start sessionswap

Depending on the log level of the system, this service exiting will likely leave warn or error messages in the system event log.

Conclusion

With a bit of tinkering and poking, one can fairly easily traverse logged on sessions on a Windows PC or Server. If nothing else, this highlights the need to physically secure any endpoints, and secure the virtual console of any virtual machines. Though it may be possile to accomplish the same thing over RDP, I have not been able to do so (And of course please tell me if you can!).

And most importantly, always remember that admin=full control. It’s trivial to elevate to system, especially for a single task. If nothing else, this highlights the importance of the “Principal of Least Priviledge” approach to delegation.

Happy hacking!