Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added BHCE support #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 57 additions & 17 deletions crackhound.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def banner():
MMMMMMMMMMMMMMMMMMMMMMMMMMXl....'..'.,kWMMMMMMMMMMMMMMMMMMMMMMMMMMMXl.........'dWMMMM0:.',,,,,,,,,,'':OWXc..,,;;,;,,;,':O00NMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMWXKKXKKKKKNWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWXXXXXXXXXXWMMMMMMNXXXXXXXXXXXXXXWMMMNXXXXXXXXXXXXXWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
CRACKHOUND - jfmaes
updated for BHCE by m4lwhere
""")


Expand Down Expand Up @@ -83,7 +84,7 @@ def format_compromised_users(compromised_users, domain, type):
if "\\" in user["username"]:
split = user["username"].split("\\")
if domain:
user["username"] = split[1] + "@" + domain
user["username"] = split[1] + "@" + domain.upper()
else:
user["username"] = split[1] + "@" + split[0]
else:
Expand Down Expand Up @@ -112,12 +113,26 @@ def update_database(compromised_users, url, username, password, plaintext, verbo
try:
with db_conn.session() as session:

# If plaintext not specified, simply mark user as owned in BH
# If plaintext not specified, simply mark user as owned in BHCE.
# Check if user is marked with owned property first to prevent accidental tag deletion. BHCE stores this as a string in the system_tags property (along with admin_tier_0) and not as a bool.
if type.upper() == "NTDS":
tx = session.run("match (u:User) where u.name=\"{0}\" set u.nthash=\"{1}\" set u.plaintext=False set u.owned=True".format(
user["username"], user["NT"]
)
)
query = """
MATCH (u:User) where u.name= $username
set u.nthash= $nthash,
u.plaintext=False,
u.system_tags = CASE
WHEN u.system_tags IS NULL or u.system_tags = '' THEN 'owned'
WHEN NOT 'owned' IN split(u.system_tags, ' ') THEN u.system_tags + ' owned'
ELSE u.system_tags
END
"""
parameters = {
"username":user["username"],
"nthash":user["NT"]
}

tx = session.run(query, parameters)

if verbose:
print("added NT hash of {0} and marked as owned.".format(
user["username"]
Expand All @@ -126,21 +141,40 @@ def update_database(compromised_users, url, username, password, plaintext, verbo
#this could be optional?
elif type == "plaintext":
if not plaintext:
tx = session.run(
"match (u:User) where u.name=\"{0}\" set u.owned=True set u.plaintext=False".format(
user["username"]
)
)
query = """
MATCH (u:User) where u.name= $username
set u.plaintext=False,
u.system_tags = CASE
WHEN u.system_tags IS NULL or u.system_tags = '' THEN 'owned'
WHEN NOT 'owned' IN split(u.system_tags, ' ') THEN u.system_tags + ' owned'
ELSE u.system_tags
END
"""
parameters = {
"username":user["username"]
}


tx = session.run(query, parameters)
result = tx.single()

if verbose:
print("{0} successfully marked as owned!".format(
tx.single()[0]
user["username"]
)
)
#till here?
elif add_password:
if user["password"]:
tx = session.run(
"match (u:User) where u.name=\"{0}\" set u.plaintextpassword=\"{1}\" set u.owned=True set u.plaintext=True".format(
"""match (u:User) where u.name=\"{0}\"
set u.plaintextpassword=\"{1}\"
set u.plaintext=True
set u.system_tags = CASE
WHEN u.system_tags IS NULL or u.system_tags = '' THEN 'owned'
WHEN NOT 'owned' IN split(u.system_tags, ' ') THEN u.system_tags + ' owned'
ELSE u.system_tags
END""".format(
user["username"], user["password"]
)
)
Expand All @@ -153,13 +187,19 @@ def update_database(compromised_users, url, username, password, plaintext, verbo
continue
else:
tx = session.run(
"match (u:User) where u.name=\"{0}\" set u.owned=True set u.plaintext=True".format(
"""match (u:User) where u.name=\"{0}\"
set u.plaintext=True
set u.system_tags = CASE
WHEN u.system_tags IS NULL or u.system_tags = '' THEN 'owned'
WHEN NOT 'owned' IN split(u.system_tags, ' ') THEN u.system_tags + ' owned'
ELSE u.system_tags
END""".format(
user["username"]
)
)
if verbose:
print("{0} successfully marked as owned and marked as plaintext!".format(
tx.single()[0]
user["username"]
)
)
except Exception as e:
Expand Down Expand Up @@ -205,8 +245,8 @@ def main():
"-p",
"--password",
required=False,
help="Password to login to neo4j (defaults to bloodhound)",
default="bloodhound",
help="Password to login to neo4j (defaults to bloodhoundcommunityedition)",
default="bloodhoundcommunityedition",
)
parser.add_argument(
"-plaintext",
Expand Down