The Penguin Could Read the Batcave

Gotham AD Masterclass, episode 3. AD groups, AGDLP and file share permissions, in a home lab.

I signed in to Dick Grayson’s PC as Oswald Cobblepot, the catering contractor. Win + R, \\GOTHAM-DC01\Batcave, and R&D’s prototype folder opened. Then I made a new file in it and it saved.

Nobody hacked anything. Somebody shared the folder to Domain Users, and every account in the domain is a Domain User. It’s every account’s primary group, contractors included. “Shared to Domain Users” really means shared to everyone who has a login.

If you’re new to the series: I’m building a real company’s IT department in my home lab. The company is Wayne Enterprises, the domain is gotham.lab, and the Joker’s account was disabled in episode one. He keeps getting in anyway, the way real attackers do. This time it’s his crew, through an over-shared folder.

By the end of this one, the Batcave lives on a proper file server, R&D can write to it, the executives can read it, and the Penguin can’t even see that it exists.

Two problems, not one

The share was open, but that was only half of it. The folder’s NTFS permissions also gave Domain Users Modify. And the share was on the domain controller: the server holding every password in the company had every user in Gotham poking around in its folders.

The tempting fix is to take Domain Users off and add the R&D people by name. Don’t. That’s how every file server ends up a mess. Dick on this folder, Barbara on that one, and when Dick changes teams, nobody remembers where he was.

Permissions go on groups. Never on people.

AGDLP, in plain English

Think about building access cards.

  • Your badge says who you are: R&D. In AD that’s a Global group: GG-RD.
  • The door has a list of which badges it opens for. In AD that’s a Domain Local group: DL-Batcave-Share-RW.
  • People go in the badge group. The badge group goes in the door group. The permission goes on the door group, and only there.

Accounts → Global → Domain Local → Permissions. AGDLP.

It’s two groups per folder, and that sounds like double the work. It’s double the work once. After that:

Something changesWhat you touch
Dick leaves R&Done group membership
The executives need to read the Batcaveput GG-Executive in DL-Batcave-Share-RO
“Who can get into the Batcave?”Get-ADGroupMember DL-Batcave-Share-RW -Recursive

Scopes, briefly: Global groups hold members from their own domain and can be used anywhere. Domain Local groups can hold members from almost anywhere, but only grant access in their own domain, which is why the permissions live on them. Universal is for forests with more than one domain. Gotham has one, so it doesn’t need them yet. And it’s always a Security group. Distribution groups are email lists and can’t hold permissions.

A file server, and a trap I’d set for myself

GOTHAM-FS01 is a second Windows Server 2025 VM: a second disk for data (Windows on C:, shares on D:), and a static address, 192.168.20.20, outside the DHCP range.

Before joining it, I remembered the previous episode. I’d pointed every new computer at the Workstations OU with redircmp, and Workstations has a GPO that denies Domain Admins local sign-in. A plain domain join would have put the file server there, and I’d have locked myself out of it.

So I made a Servers OU at the top of the domain, beside Wayne Enterprises (where none of the workstation policies reach), and pre-staged the computer account in it before the join:

New-ADOrganizationalUnit -Name Servers -Path 'DC=gotham,DC=lab'
New-ADComputer -Name GOTHAM-FS01 -SamAccountName 'GOTHAM-FS01$' -Path 'OU=Servers,DC=gotham,DC=lab'

The server joined, found its account waiting, and stayed out of Workstations.

Twenty groups, one script

.\New-GothamGroups.ps1 -WhatIf   # look first
.\New-GothamGroups.ps1           # then for real

It builds a Groups OU (role groups and resource groups), nests the badge groups into the door groups, and puts everyone in their badge group from the roster CSV. Two details I like:

  • It skips disabled accounts. Tim Drake left in episode one, but he’s still in the spreadsheet as R&D. The script won’t put a disabled account back in a group. Disabled, not deleted, and not let back in by an old CSV.
  • Contractors are never in GG-AllStaff. GG-Contractors is in exactly one door group: read-only on the public share. That one line keeps the Penguin out of everything else.

Carrie Kelley, the intern who joined in episode one, isn’t in the CSV, so she got added to GG-RD by hand. A new starter is a group change, not a permissions change.

The front door and the lock

Windows checks two sets of permissions on a shared folder:

  • Share permissions are the building’s front door. They only apply over the network.
  • NTFS permissions are the lock on each room. They always apply, even when you’re sitting at the server.

Over the network you need to get through both, and the stricter one wins. So most admins leave the front door open to every signed-in user (Authenticated Users, Full Control) and do all the real work in NTFS, so there’s one place to look.

Two more rules for the locks: allows add up (read from one group plus modify from another gets you modify), and a Deny beats an Allow. That’s why the quick fix of “Deny Domain Users on the Batcave” is a disaster: R&D are Domain Users too. Don’t Deny. Just don’t give the Allow.

The hidden way in

This is the part most AGDLP explanations skip.

I made a new folder, D:\Wayne, and it picked up its permissions from the drive. Among them was Users: Read & execute. Then I opened the local Users group on the file server:

Get-LocalGroupMember -Group Users

GOTHAM\Domain Users is in it. Windows adds it when a server joins the domain. So every new folder on every member server starts out readable by the whole domain, the Penguin included, before you’ve shared anything to anyone.

The fix is to break inheritance once, at the top:

icacls D:\Wayne /inheritance:r /grant:r '*S-1-5-32-544:(OI)(CI)F' '*S-1-5-18:(OI)(CI)F' '*S-1-5-11:(RX)'

That leaves Administrators and SYSTEM with Full Control, plus Authenticated Users with Read & execute on that folder only. Everyone can open the top of the share. Every room underneath gets its own lock. I took off CREATOR OWNER too, because it gives whoever creates a file full control of it, which undoes the next step.

The Batcave folder then gets its two door groups:

icacls D:\Wayne\Batcave /grant 'GOTHAM\DL-Batcave-Share-RW:(OI)(CI)M' 'GOTHAM\DL-Batcave-Share-RO:(OI)(CI)RX'

Modify, not Full Control. Full Control lets users change the permissions and take ownership, and only IT should be able to do that. The other six company folders were built by New-GothamShares.ps1, the same pattern each time.

Then one share, \\GOTHAM-FS01\Wayne, with access-based enumeration on. ABE hides any folder you can’t open, so the Penguin doesn’t get a locked door with “Batcave” written on it. He just doesn’t see one. It’s why everything sits under one share: ABE filters the folders inside a share, not the share names on a server. (And a $ on the end of a share name isn’t security either. It’s hidden from the list, not locked.)

Moving in without dragging the mess along

robocopy \\GOTHAM-DC01\C$\Batcave D:\Wayne\Batcave /E /COPY:DAT /DCOPY:DAT /R:1 /W:1 /L    # list only
robocopy \\GOTHAM-DC01\C$\Batcave D:\Wayne\Batcave /E /COPY:DAT /DCOPY:DAT /R:1 /W:1 /LOG:C:\Logs\batcave-move.log /TEE

/L first, always: it shows what would be copied and copies nothing. /COPY:DAT copies data, attributes and timestamps, and no security, so the old “Domain Users” entries don’t come across and the files take the new Batcave’s permissions instead. Then I stopped sharing the old folder on the DC and renamed it with a delete-by date rather than deleting it on the spot.

The Batcave drive

Last episode promised a drive map with Group Policy Preferences. WE-U-Drive-Maps is linked to Wayne Enterprises, in the user half:

  • W: → \\GOTHAM-FS01\Wayne for all staff
  • B: → \\GOTHAM-FS01\Wayne\Batcave, with item-level targeting on GG-RD, so it’s R&D’s drive. The executives read the Batcave through W:

Action Update (not Replace), and always the server name, never an IP: a name gets Kerberos, an IP quietly falls back to NTLM. The drives target the badge groups (who you are). The permissions sit on the door groups (what you can touch). Contractors live outside Wayne Enterprises, so the GPO never reaches them at all.

Who gets in

WhoWhat happened
Dick (R&D)W: and B:. Saves in the Batcave. W: shows him only Batcave and Public
Bruce (Executive)W: only. ABE shows him five rooms (the vault, Batcave, board papers, HR reports, public). Opens every Batcave file, can’t save anything
The PenguinNo drives. \\GOTHAM-FS01\Wayne shows only Public. The Batcave by path: access denied. The old DC share: gone
Carrie (added while signed in)Access denied, until she signed out and back in

That last one is the most common “it’s not working” ticket there is. Your groups are stamped on you when you sign in. Change them afterwards, and nothing happens until the next sign-in. whoami /groups shows what you’re actually carrying.

And when you’re not sure what someone can do, don’t test it as yourself. Folder → Properties → Security → Advanced → Effective Access, pick the person, and Windows tells you.

Three habits

  1. Permissions go on door groups. Never on people.
  2. Break inheritance once, at the top, and don’t copy old permissions across.
  3. Check access as the person (Effective Access), not as you.

Where Gotham stands

  • A file server that isn’t the domain controller, in an OU the workstation policies can’t reach
  • Twenty groups: badges for who you are, door lists for what you can touch
  • A share with the front door open and a real lock on every room
  • A Batcave drive for R&D, read-only for the bosses, and nothing at all for the contractors
  • The old share on the DC, shut

One more thing, though. I did every step of this as Domain Admin, including signing in to a file server that every user in Gotham connects to. That’s the next episode: why Bruce Wayne doesn’t get Domain Admin, and neither do I.

📺 Watch the episode: https://youtu.be/Jd-pYnrHmcg
🧰 Every command, plus New-GothamGroups.ps1 and New-GothamShares.ps1: https://github.com/TrevTech-IT/gotham-ad-masterclass
⬅ Episode 2, Group Policy: https://trevtech.blog/gotham-group-policy
🗂 The whole series: https://www.youtube.com/watch?v=0T5iN290njQ&list=PLfmRIg23g1uw&pp=0gcJCZAGa94AFGB0sAgC

— Trev | I broke it. Fixed it.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top