Skip to content

Instantly share code, notes, and snippets.

@AnshumanSrivastavaGit
Forked from m8sec/aduser_lookup.sh
Created July 27, 2024 10:43
Show Gist options
  • Save AnshumanSrivastavaGit/eba0400e4c91362ca99f7f934edebbd1 to your computer and use it in GitHub Desktop.
Save AnshumanSrivastavaGit/eba0400e4c91362ca99f7f934edebbd1 to your computer and use it in GitHub Desktop.

Revisions

  1. @m8sec m8sec revised this gist Jul 12, 2018. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion aduser_lookup.sh
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,7 @@

    # Author: m8r0wn
    # Description: Uses the Linux net commands to lookup a user in Active Directory
    # This is the Linux equivalent of: net user [Username] /domain
    # Usage: ./aduser_lookup.sh [username] [password] [DC-Server] [Lookup-User]

    if [ ! $1 ];
    @@ -10,7 +11,7 @@ then
    exit 0
    fi

    #Get info about single user in ad
    #Get info about single user in AD
    printf "\nAD User Lookup:\n"
    printf '%s\n' '-----------------------'
    printf "user edit fullname '$4'"| net rpc shell -U "$1"%"$2" -S $3|tail -n +2
  2. @m8sec m8sec revised this gist Jun 8, 2018. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions aduser_lookup.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,8 @@
    #!/usr/bin/env bash

    #Author: m8r0wn
    #Description: Uses the Linux net commands to lookup a user in Active Directory
    # Author: m8r0wn
    # Description: Uses the Linux net commands to lookup a user in Active Directory
    # Usage: ./aduser_lookup.sh [username] [password] [DC-Server] [Lookup-User]

    if [ ! $1 ];
    then
  3. @m8sec m8sec revised this gist Jun 8, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions aduser_lookup.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    #!/usr/bin/env bash

    #Author: m8r0wn
    #Description: Uses the Linux net commands to lookup a user in Active Directory

  4. @m8sec m8sec revised this gist Jun 8, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion aduser_lookup.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #!/usr/bin/env bash
    #Author: m8r0wn
    #Description: Lookup AD domain user info on Linux
    #Description: Uses the Linux net commands to lookup a user in Active Directory

    if [ ! $1 ];
    then
  5. @m8sec m8sec created this gist Jun 8, 2018.
    35 changes: 35 additions & 0 deletions aduser_lookup.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    #!/usr/bin/env bash
    #Author: m8r0wn
    #Description: Lookup AD domain user info on Linux

    if [ ! $1 ];
    then
    printf "[-] Usage: $0 Username Password DC_Server username_to_lookup\n"
    exit 0
    fi

    #Get info about single user in ad
    printf "\nAD User Lookup:\n"
    printf '%s\n' '-----------------------'
    printf "user edit fullname '$4'"| net rpc shell -U "$1"%"$2" -S $3|tail -n +2
    printf "user edit homedir '$4'" | net rpc shell -U "$1"%"$2" -S $3|tail -n +2
    printf "user edit homedrive '$4'" | net rpc shell -U "$1"%"$2" -S $3|tail -n +2
    printf "user edit logonscript '$4'" | net rpc shell -U "$1"%"$2" -S $3|tail -n +2
    printf "user edit profilepath '$4'" | net rpc shell -U "$1"%"$2" -S $3|tail -n +2
    printf "user edit description '$4'" | net rpc shell -U "$1"%"$2" -S $3|tail -n +2
    printf "user edit disabled '$4'" | net rpc shell -U "$1"%"$2" -S $3|tail -n +2

    output="$(printf "user edit autolock '$4'" | net rpc shell -U "$1"%"$2" -S $3|tail -n +2)"
    printf "${output} (Currently locked out)\n"

    #find users with password not set to change or no expiration
    output="$(printf "user edit pwnotreq '$4'" | net rpc shell -U "$1"%"$2" -S $3|tail -n +2)"
    printf "${output} (Password not required)\n"

    output="$(printf "user edit pwnoexp '$4'" | net rpc shell -U "$1"%"$2" -S $3|tail -n +2)"
    printf "${output} (Password never expire?)\n"

    printf "\nGroup Memberships:\n"
    printf '%s\n' '-----------------------'
    printf "user info '$4'" | net rpc shell -U "$1"%"$2" -S $3|tail -n +2
    printf "\n"