Skip Ribbon Commands
Skip to main content

Ondrej Sevecek's Blog

:

Engineering and troubleshooting by Directory Master!
Ondrej Sevecek's Blog > Posts > Seznam všech loginů z Active Directory
září 29
Seznam všech loginů z Active Directory

Někde to tady mám, ale nemůžu to najít a docela často to potřebuju, takže znovu :-)

Úkol zní - vylistovat všechny loginy z Active Directory (ADDS) za použití minimálních oprávnění a tak, aby to pokud možno šlo kdykoliv. A ono to jde. Bez ohledu na oprávnění, která máte na objektech a organizačních jednotkách v AD, tahle metoda funguje pod jakýmkoliv ověřeným účtem vždy. Protože nepoužívá LDAP připojení, ale nechává si pomocí SAM rozhraní překládat SIDy na loginy. Takže stačí libovolný účet, který je Authenticated Users.

Jak to funguje? Každý účet, účet počítače, nebo skupina má SID. Všechny SIDy v jedné doméně jsou stejné, kromě koncovky (RID). RIDy vznikají tak, že se pouze inkrementují pro každý nový účet. Stačí tedy nechat si přeložit všechny SIDy od 1 do 2 miliard :-) Samozřejmě skončíte jakmile cítíte, že tam už žádné další nebudou.

function global:Get-PrimaryDomainSID ()
{
  # Note: this script obtains SID of the primary AD domain for the local computer. It works both
  #       if the local computer is a domain member (DomainRole = 1 or DomainRole = 3)
  #       or if the local computer is a domain controller (DomainRole = 4 or DomainRole = 4).
  #       The code works even under local user account and does not require calling user
  #       to be domain account. This should also work on any AD domain regardless of language
  #       mutation because, hopefully, the krbtgt account has always the same name

  [string] $domainSID = $null

  [int] $domainRole = gwmi Win32_ComputerSystem | Select -Expand DomainRole
  [bool] $isDomainMember = ($domainRole -ne 0) -and ($domainRole -ne 2)

  if ($isDomainMember) {

    [string] $domain = gwmi Win32_ComputerSystem | Select -Expand Domain
    [string] $krbtgtSID = (New-Object Security.Principal.NTAccount $domain\krbtgt).Translate([Security.Principal.SecurityIdentifier]).Value
    $domainSID = $krbtgtSID.SubString(0, $krbtgtSID.LastIndexOf('-'))
  }

  return $domainSID
}

$domainSID = Get-PrimaryDomainSID

(500..10000) | % { 

  $user = New-Object Security.Principal.SecurityIdentifier $domainSID-$_
  $errorActionPreference = 'SilentlyContinue'
  $user.Translate([Type]::GetType('System.Security.Principal.NTAccount')).Value
  $errorActionPreference = 'Continue'
}

Comments

Re: Seznam všech loginů z Active Directory

To se mi prave hodi, dekuji :)
Kubajs on 29.9.2017 13:16

Active Directory (ADDS) logins must be enumerated with minimal

Active Directory (ADDS) logins must be enumerated with minimal access and in a fashion that allows for this to be done at any time. Additionally, it does the job. This technique always operates under any authenticated account, <a href="https://phrazle.co">phrazle</a> regardless of the permissions the account has on objects and OUs in AD. Since it does not rely on an LDAP server, but rather makes use of the SAM interface to convert SID y to login y. It follows that any Authenticated Users account will do.
bikeskillet on 7.2.2023 3:49

grat

 PowerShell nabízí příkazový řádek a skriptovací prostředí, které umožňuje správcům získat seznam uživatelů z Active Directory. Můžete použít příkazy jako Get-ADUser nebo Get-ADGroupMember pro získání seznamu uživatelů a jejich přihlašovacích údajů. https://bitlifeonline.com/

great on 16.5.2023 6:56

 contexto unlimited

The word-finding puzzle game Contexto's objective is to identify the secret word with as many guesses as you like before giving up. https://contextogame.io
herrty on 2.6.2023 4:43

great

sam on 29.6.2023 14:45

Re: Seznam všech loginů z Active Directory


Thank you for taking the time to discuss this. I'm passionate about it and enjoy learning more about it https://drivingdirectionsroute.com

Mark Miller on 4.7.2023 9:55

good

Your article was well-structured https://theminicrossword.com and had a clear beginning, middle, and end.
abel1303 on 4.7.2023 10:58

Taylor 2048

There are specific dissertation websites that are online via the internet when you find definitely reported in your internet site. <a href="https://taylorswift2048.org/">Taylor 2048</a>
elyana on 19.9.2023 18:41

Taylor 2048

There are specific dissertation websites that are online via the internet when you find definitely reported in your internet site. [url=https://taylorswift2048.org/]Taylor 2048[/url]
elyana on 19.9.2023 18:42

Re: Seznam všech loginů z Active Directory

The real-world examples in this article https://unogame.io/ make it easy to relate to the topic. It adds depth to the content.
daisymaria on 5.10.2023 10:25

great

sam on 18.10.2023 7:07

thanks

When you notice something that is unquestionably reported on your website, there are particular dissertation websites that are accessible online. https://iogamesio.org
Harry on 31.10.2023 7:55

Add Comment

Title


Pole Title nemusíte vyplňovat, doplní se to samo na stejnou hodnotu jako je nadpis článku.

Author *


Pole Author nesmí být stejné jako pole Title! Mám to tu jako ochranu proti spamu. Roboti to nevyplní dobře :-)

Body *


Type number two as digit *


Semhle vyplňte číslici dvě. Předchozí antispemové pole nefunguje úplně dokonale, zdá se, že jsou i spamery, které pochopily, že je občas potřeba vyplnit autora :-)

Email


Emailová adresa, pokud na ni chcete ode mě dostat odpověď. Nikdo jiný než já vaši emailovou adresu neuvidí.

Attachments