{"id":13609911,"url":"https://github.com/secureworks/chaosbernie","last_synced_at":"2026-01-14T19:07:43.360Z","repository":{"id":90547129,"uuid":"564379663","full_name":"secureworks/chaosbernie","owner":"secureworks","description":"Azure as an external process source for psDoom-ng","archived":false,"fork":false,"pushed_at":"2022-11-11T00:14:34.000Z","size":202,"stargazers_count":85,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-12T22:36:04.904Z","etag":null,"topics":["psdoom"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/secureworks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-11-10T15:38:12.000Z","updated_at":"2024-08-06T05:50:48.000Z","dependencies_parsed_at":"2023-07-19T09:15:52.764Z","dependency_job_id":null,"html_url":"https://github.com/secureworks/chaosbernie","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/secureworks/chaosbernie","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/secureworks%2Fchaosbernie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/secureworks%2Fchaosbernie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/secureworks%2Fchaosbernie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/secureworks%2Fchaosbernie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/secureworks","download_url":"https://codeload.github.com/secureworks/chaosbernie/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/secureworks%2Fchaosbernie/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28431418,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T18:57:19.464Z","status":"ssl_error","status_checked_at":"2026-01-14T18:52:48.501Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["psdoom"],"created_at":"2024-08-01T19:01:39.211Z","updated_at":"2026-01-14T19:07:43.345Z","avatar_url":"https://github.com/secureworks.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"![chaosbernie](docs/chaosbernie.png)\n\nChaos Bernie implements Azure as an external process source for [psDoom-ng](https://github.com/yeoldegrove/psdoom-ng1). \n\n\n\u003e **Warning** \n\u003e **Azure resources will be permanently and irrevocably destroyed: use at your own risk!**\n\n# Background\n\n* 1997: [id Software release source code to DOOM](https://github.com/id-Software/DOOM)\n* 1999: psDoom origins and proof of concept - [Doom as a tool for system administration](https://www.cs.unm.edu/~dlchao/flake/doom/)\n* 2000: [psDoom](https://psdoom.sourceforge.net/) released\n  \u003e  psDooM is a process monitor and manager for *nix systems. It could be considered a graphical interface to the 'ps', 'renice', and 'kill' commands. psDooM is based on XDoom, which is based on id Software's 'Doom'. \n* 2016: [psDoom-ng](https://github.com/yeoldegrove/psdoom-ng1) released, updating psDoom for modern operating systems and support for external process source\n  \u003e psdoom-ng is a First Person Shooter operating system process killer based on psDooM and Chocolate Doom.\n* 2022: Chaos Bernie written to add Azure virtual machines and resource groups as external processes\n\n# Chaos Bernie\n\nChaos Bernie was written during an internal hackathon as a fun way to clean up Azure resources. Users are great at spinning up compute resources but often require nagging to deallocate or destroy them. As Bernie would say \"Once again I'm asking for you to clean up your compute resources\"\n\nChaos Bernie adds Azure virtual machines and resource groups as external process to psDoom-ng. \n\nAs per the psDoom-ng documentation, DOOM is a single threaded application so any blocking on external scripts makes the game unplayable. Azure resources take a while to delete so golang was chosen for concurrency and unix domain sockets for a simple queue for client to communicate with backend.\n\nThis could easily be adapted to other cloud providers (AWS, GCP)\n\n## Architecture\n\n![Chaos Bernie architecture diagram](docs/chaosbernie-architecture.png)\n\n\nInteraction with psDoom via external process sources\nhttps://github.com/yeoldegrove/psdoom-ng1#support-for-external-process-source\n\nThree commands with their required inputs/outputs\n* PSDOOMPSCMD\n  * The command must print one space separated line per process with the format: \n    ```text\n    \u003cuser\u003e \u003cpid\u003e \u003cprocessname\u003e \u003cis_daemon=[1|0]\u003e\n    ```\n* PSDOOMRENICECMD\n  * input: PID\n* PSDOOMKILLCMD\n  * input: PID\n\nFor Azure, these values have the following definitions\n\n| Variable    | Azure Definition                                          |\n|-------------|-----------------------------------------------------------|\n| user        | resource group                                            |\n| pid         | unique integer generated from JSON array element ID + 100 |\n| processname | resource name                                             |\n| is_daemon   | deallocate (1), delete (0)                                |\n\nThe wrapper script `cb.sh` populates the environment variables for PSDOOM with `azure/bin/client` with the appropriate flags. \n\n```bash\nPSDOOMPSCMD=\"${SCRIPT_DIR}/azure/bin/client --action=ps\"\nPSDOOMRENICECMD=\"${SCRIPT_DIR}/azure/bin/client --action=renice\"\nPSDOOMKILLCMD=\"${SCRIPT_DIR}/azure/bin/client --action=kill\"\n```\n(It may be necessary to run `psd` in psdoom-ng's source directory once before chaos bernie will run)\n\n## Modes\nThere are two modes\n- `deallocate`: stops and deallocate the virtual machine resources (virtual machines only). In the process list, resources to be deallocated are represented as 'daemons' and killing them in game will trigger the 'renice' command\n- `destroy`: destroys the resource (resource groups, virtual machines). These are 'processes' aka zombie man in the process list and killing them in game runs the 'kill' command\n\n## Interaction with Azure APIs\nAzure APIs and the golang Azure SDK are a bit of a mess. The lazy option was chosen to just interface with the Azure CLI `az` over using SDKs\n\nA static JSON file generated from Azure Graph queries is used to provide input of 'processes'. The main reason for is it is called frequently by psDoom-ng and any blocking to list live resources won't be tolerated by the game. Doing this as a static file also allow sanity checking of resources before they are **permanently and irrevocably destroyed**\n\n## Visualisation\nTo help visualise the status of the Azure resources, the generation of graphviz DOT file was added. xdot can render this and will update display when file is changed on disk\n\n# Setup\n\nThe following has been tested on Ubuntu 20.04\n\n## Compile psDoom-ng\n\nif not already installed, packages required to compile everything\n\n```bash\napt install git build-essential autoconf golang python3-pip\n```\n\ninstall psdoom-ng specific requirements\n\n```bash\napt install libsdl1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev\n```\n\nclone psdoomr-ng repo\n\n```bash\ngit clone https://github.com/yeoldegrove/psdoom-ng1\n```\n\ncompile psdoom-ng\n\n```bash\n./autogen.sh\nmake\nsudo make install\n```\n\nSetup DOOM and remap keyboard to WASD\n\n```bash\npsdoom-setup\n```\n\n## Doom WAD\n\nFrom Wikipedia https://en.wikipedia.org/wiki/Doom_modding\n\u003e Doom WAD is the default format of package files for the video game Doom and its sequel Doom II: Hell on Earth, that contain sprites, levels, and game data. WAD stands for Where's All the Data?\n\nWAD files are not included with the released source code. If you own DOOM (available on Steam) you can use the WAD files distributed with the game. Alternatively you can use the shareware WAD\n\n```bash\napt install doom-wad-shareware\n```\n\n\n## Setup Chaos Bernie\ninstall Azure CLI\n\n```bash\npip3 install az-cli\nexport PATH=$PATH:~/.local/bin/\naz login --use-device-code\n```\n\nusing device code, you can login via host computer\n\n\nto render dot files for scoreboard\n\n```bash\napt install xdot\n```\n\ncompile client and server applications\n\n```bash\n(cd azure \u0026\u0026 make)\n```\n\n# Run Chaos Bernie\n## Generate resource/process list\n\nUsing Azure Graph we can generate JSON files with list of 'processes' to include in the game for **deallocation or deletion**. It's up to you what to include here but some sample queries. Only virtual machines and resource groups have been tested but likely other Azure resource types will work without any modification\n\n\u003e **Note**\n\u003e There is no concurrency limit or queuing beyond domain socket, if you attempt to kill too many monsters at once it may lock up the game/computer or make game unplayable** e.g. running Chaos Bernie with 120 VMs and using the rocket launcher on the monsters crashed the test VM running DOOM.\n\nRunning virtual machines:\n\n```bash\naz graph query -q \"Resources\n| where type =~ 'microsoft.compute/virtualmachines'\n| where properties.extended.instanceView.powerState.code has 'running'\n\" --query 'data' \u003e virtual-machines.json\n```\n\nResource groups:\n\n```bash\naz graph query -q 'resourcecontainers\n| where type == \"microsoft.resources/subscriptions/resourcegroups\"\n' --query 'data' \u003e resource-groups.json\n```\n\n## Server\n\nServer usage\n\n```bash\n./azure/bin/server --help\nUsage:\n  server [OPTIONS]\n\nApplication Options:\n  -f, --file=FILE                     JSON file with resources\n      --action=[deallocate|delete]\n      --socket=                       unix domain socket to create, defaults to\n                                      ~/.chaosbernie.sock\n  -d, --debug\n      --dry-run\n\nHelp Options:\n  -h, --help                          Show this help message\n```\n\nstart the server with minimum required options\n\n```bash\n./azure/bin/server -f ./virtual-machines.json\n```\n\n## Visualiser\n\nTo view visualisation while playing, you will need to use `psdoom-ng-setup` to configure DOOM to run in window mode\n\nstart xdot in background\n\n```bash\nxdot resources.gv \u0026 \n```\n\nLegend:\n\n| Colour | Meaning                                                                             |\n|--------|-------------------------------------------------------------------------------------|\n| Blue   | hierarchy/grouping (e.g. for virtual machines, which resource group they belong to) |\n| Green  | resource that is represented by monster in game                                     |\n| Orange | monster has been shot and azure operation has been triggered                        |\n| Red    | Azure operation complete, resource deleted/deallocated                              |\n\n## Client\n\nstart psdoom-ng\n\n```bash\n./cb.sh\n```\n\nadditional options can be passed through to psdoom-ng, e.g.\n\n```bash\n./cb.sh -godstart -telestartf 136310834 -257677815\n```\n\nwhich will start in god mode (iddqd) and teleport you directly to the steps outside the hidden area\n\n\n# Demo\n\nhttps://user-images.githubusercontent.com/31047013/201231011-65076c41-7b58-47da-9d11-87bf6cee8949.mp4\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsecureworks%2Fchaosbernie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsecureworks%2Fchaosbernie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsecureworks%2Fchaosbernie/lists"}