Path: blob/main/notebooks/random_active_directory.py
597 views
# ---1# jupyter:2# jupytext:3# formats: ipynb,py:percent4# text_representation:5# extension: .py6# format_name: percent7# format_version: '1.3'8# jupytext_version: 1.16.49# kernelspec:10# display_name: Python 3 (ipykernel)11# language: python12# name: python313# ---1415# %% [markdown]16# Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License.17#18# # Randomly generated CyberBattle network environment for Active Directory1920# %%21import cyberbattle.samples.active_directory.generate_ad as ad22import cyberbattle.simulation.commandcontrol as commandcontrol23import logging, sys, random2425random.seed(1)26logging.basicConfig(stream=sys.stdout, level=logging.INFO, format="%(levelname)s: %(message)s")27# %matplotlib inline2829# %%30env = ad.new_random_environment(42)31env.plot_environment_graph()3233# %%34c2 = commandcontrol.CommandControl(env)35dbg = commandcontrol.EnvironmentDebugging(c2)3637# 1 - Start from client38dbg.plot_discovered_network()39c2.print_all_attacks()4041# %%42outcome = c2.run_attack("workstation_0", "FindDomainControllers")43dbg.plot_discovered_network()44c2.print_all_attacks()4546# %%47outcome = c2.run_attack("workstation_0", "EnumerateFileShares")48dbg.plot_discovered_network()49c2.print_all_attacks()5051# %%52outcome = c2.run_attack("workstation_0", "AuthorizationSpoofAndCrack")53dbg.plot_discovered_network()54c2.print_all_attacks()5556# %%57c2.connect_and_infect("workstation_0", "workstation_4", "SHELL", "user_28")58dbg.plot_discovered_network()59c2.print_all_attacks()6061# %%62c2.run_attack("workstation_4", "ScanForCreds")63dbg.plot_discovered_network()64c2.print_all_attacks()6566# %%67c2.connect_and_infect("workstation_0", "domain_controller_1", "AD", "dc_1")68dbg.plot_discovered_network()69c2.print_all_attacks()7071# %%72c2.run_attack("domain_controller_1", "DumpNTDS")73dbg.plot_discovered_network()74c2.print_all_attacks()757677