Skip to content

Commit

Permalink
azure crowdstrike remediation
Browse files Browse the repository at this point in the history
Signed-off-by: Rahul Jadhav <[email protected]>
  • Loading branch information
nyrahul committed Jul 21, 2024
1 parent 8fe1d90 commit 4362982
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion crowdstrike-bsod-fix/csp_aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import glob

logging.basicConfig(level=logging.INFO)
log = logging.getLogger("main")
log = logging.getLogger("aws")

def detach_volumes(ec2, inst_id, dry_run=False):
try:
Expand Down
25 changes: 20 additions & 5 deletions crowdstrike-bsod-fix/csp_azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,33 @@
# Copyright 2024 XCitium

# Import the needed credential and management objects from the libraries.
import logging
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
logging.basicConfig(level=logging.INFO)
log = logging.getLogger("azure")

def handle_azure(args):
if args.az_res_grp:
log.info(f"using azure resource group {args.az_res_grp}")
else:
log.error("CSP azure needs --az_res_grp <resource group> to be specified")
return
# Acquire a credential object.
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="{subscription-id}",
)

response = client.virtual_machines.get(
resource_group_name="myResourceGroup",
vm_name="myVM",
)
print(response)
instances=args.instances.split(",")
for inst_id in instances:
log.info(f"checking {inst_id}")
try:
response = client.virtual_machines.get(
resource_group_name=args.az_res_grp,
vm_name=inst_id,
)
print(response)
except Exception as err:
log.error(f"instance get failed {inst_id}: {err}")
continue
1 change: 1 addition & 0 deletions crowdstrike-bsod-fix/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def main() -> None:
argp = argparse.ArgumentParser()
argp.add_argument("--csp", required=True, help="Cloud Service Provider name [aws/gcp/azure]")
argp.add_argument("--instances", required=True, help="Instance list separated by comma")
argp.add_argument("--az_res_grp", required=False, help="Azure resource group")
argp.add_argument("--dry-run", action="store_true")
args = argp.parse_args()

Expand Down

0 comments on commit 4362982

Please sign in to comment.