Skip to content

[Query Issue]: Users with logon scripts stored in a trusted domain #58

Closed

Description

@johnmccash

Query GUID

8d94d3f3-3d53-4939-a206-3c0a4dd3f646

Query content

MATCH (n:User)
WHERE n.logonscript IS NOT NULL
MATCH (d:Domain)<-[:SameForestTrust|CrossForestTrust]-(:Domain)-[:Contains*1..]->(n)
WITH n,last(split(d.name, '@')) AS domain
WHERE toUpper(n.logonscript) STARTS WITH ("\\" + domain + "\")
RETURN n

Issue description

Unknown Cypher function: last

BloodHound version

BHE

BloodHound DB

Postgres

Activity

  1. added a commit that references this issue on Jun 9, 2026
  2. martinsohn commented on Jun 9, 2026

    @martinsohn
    Collaborator

    Thank you for reporting! I am fixing this in an upcomig release.

    This query has been bugging me for a long time, so I will reduce it to simply Users with logon scripts.

    • The check for logon script WITHIN a trusted domain is equally important, if not less important, than a logon script OUTSIDE a trusted domain.

    • The query itself is complex and brittle

      This is my current best iteration:

      MATCH (n:User)
      WHERE n.logonscript IS NOT NULL
      MATCH (d:Domain)<-[:SameForestTrust|CrossForestTrust]-(:Domain)-[:Contains*1..]->(n)
      WHERE toUpper(n.logonscript) STARTS WITH ("\\\\" + toUpper(d.name) + "\\")
      RETURN n
      

      However, it can still return false-negagives due to possible variations of the network path: FQDN, short domain name, explicit server/DC hostnames, IP addresses, ...

  3. martinsohn commented on Aug 5, 2026

    @martinsohn
    Collaborator

    Fixed in the latest release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions