lab:stack_of_nucs:ansible_playbook_-_fah_removal
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
lab:stack_of_nucs:ansible_playbook_-_fah_removal [2023/05/03 18:12] – [Create a Task to Crack the Hashes] user | lab:stack_of_nucs:ansible_playbook_-_fah_removal [2024/05/06 02:11] (current) – removed user | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | clie====== Ansible Playbook - FAH Removal ====== | ||
- | In our previous step we [[ansible playbook - fah installation|set up FAH]] on our [[start|Stack of NUCs]]. | ||
- | Now we are going to disable the service and uninstall it. In the last step there was an optional step to " | ||
- | |||
- | Purpose: | ||
- | * Demonstrate stopping and removing an installed service workload | ||
- | |||
- | ====== Step 1 - Connect to the Ansible Control Node ====== | ||
- | From [[NUC 1]], log in to the Ansible control node, [[NUC 2]]. | ||
- | |||
- | ====== Step 2 - Create the Playbook ====== | ||
- | Create the file / | ||
- | |||
- | <file yaml removefah.yml> | ||
- | --- | ||
- | - hosts: all | ||
- | become: true | ||
- | become_user: | ||
- | tasks: | ||
- | - name: Stop and disable FAHClient.service | ||
- | ansible.builtin.service: | ||
- | name: FAHClient.service | ||
- | state: stopped | ||
- | enabled: false | ||
- | - name: Remove fahclient package | ||
- | apt: | ||
- | name: fahclient | ||
- | state: absent | ||
- | clean: true | ||
- | purge: true | ||
- | - name: Reboot | ||
- | reboot: | ||
- | </ | ||
- | ====== Step 3 - Test the Playbook ====== | ||
- | '' | ||
- | |||
- | ====== Next Step ====== | ||
- | Now that we have removed the CPU-hungry FAH service, we go next to [[Ansible Playbeook - Install Kubernetes|installing Kubernetes]]. | ||
- | |||
- | ====== Optional ====== | ||
- | Cyber security students may want to deploy hashtopolis in the Lab. This deploys a distributed hashcat cluster for brute forcing password hashes. | ||
- | |||
- | ===== Hashtopolis ===== | ||
- | References: | ||
- | * [[https:// | ||
- | * [[https:// | ||
- | |||
- | There are two pieces to set up: | ||
- | * server - central server distributes the keyspace of a task, aggregates jobs, and collects results in MySQL database | ||
- | * communicates over HTTPS with client machines | ||
- | * passes over files, binaries and task commands | ||
- | * agents - act on the commands, execute the hash cracking application, | ||
- | |||
- | ==== Start a Folder for hashtopolis ==== | ||
- | - Log in to the Ansible control node ([[NUC 2]]) | ||
- | - Create directory ''/ | ||
- | * '' | ||
- | * '' | ||
- | - Create the inventory, putting one of the worker nodes in the '' | ||
- | * ''/ | ||
- | * <file yaml inventory> | ||
- | [all:vars] | ||
- | ansible_python_interpreter=/ | ||
- | ansible_user=' | ||
- | ansible_become=true | ||
- | ansible_become_method=sudo | ||
- | [server] | ||
- | |||
- | [agents] | ||
- | </ | ||
- | - Create the '' | ||
- | * ''/ | ||
- | * <file yaml ansible.cfg> | ||
- | [defaults] | ||
- | inventory = inventory | ||
- | </ | ||
- | |||
- | ==== Server Setup ==== | ||
- | Server runs on a LAMP stack | ||
- | |||
- | <file yaml testing-server-build.yml> | ||
- | --- | ||
- | - hosts: server | ||
- | become: true | ||
- | vars: | ||
- | mysql_root_password: | ||
- | app_user: " | ||
- | http_host: " | ||
- | http_conf: " | ||
- | http_port: " | ||
- | disable_default: | ||
- | hashtopolis_password: | ||
- | tasks: | ||
- | - name: Install prerequisites | ||
- | apt: | ||
- | pkg: | ||
- | - aptitude | ||
- | - git | ||
- | - phpmyadmin | ||
- | |||
- | # Apache Configuration | ||
- | - name: Install LAMP Packages | ||
- | apt: | ||
- | pkg: | ||
- | - apache2 | ||
- | - mysql-server | ||
- | - python3-pymysql | ||
- | - php | ||
- | - php-pear | ||
- | - php-mysql | ||
- | - libapache2-mod-php | ||
- | - name: Create document root | ||
- | file: | ||
- | path: "/ | ||
- | state: directory | ||
- | owner: "{{ app_user }}" | ||
- | mode: ' | ||
- | - name: Set up Apache virtualhost | ||
- | template: | ||
- | src: " | ||
- | dest: "/ | ||
- | notify: Reload Apache | ||
- | - name: Enable new site | ||
- | shell: / | ||
- | notify: Reload Apache | ||
- | - name: Disable default Apache site | ||
- | shell: / | ||
- | when: disable_default | ||
- | notify: Reload Apache | ||
- | |||
- | # MySQL Configuration | ||
- | - name: start and enable mysql service | ||
- | service: | ||
- | name: mysql | ||
- | state: started | ||
- | enabled: yes | ||
- | - name: manage MySQL root password | ||
- | become: true | ||
- | mysql_user: | ||
- | login_user: root | ||
- | login_password: | ||
- | name: root | ||
- | password: "{{ mysql_root_password }}" | ||
- | check_implicit_admin: | ||
- | - name: Sets the hashtopolis password | ||
- | mysql_user: | ||
- | name: hashtopolis | ||
- | password: "{{ hashtopolis_password }}" | ||
- | priv: " | ||
- | login_user: root | ||
- | login_password: | ||
- | state: present | ||
- | - name: Removes all anonymous user accounts | ||
- | mysql_user: | ||
- | name: '' | ||
- | host_all: true | ||
- | state: absent | ||
- | login_user: root | ||
- | login_password: | ||
- | - name: Removes the MySQL test database | ||
- | mysql_db: | ||
- | name: test | ||
- | state: absent | ||
- | login_user: root | ||
- | login_password: | ||
- | - name: Create new databases | ||
- | mysql_db: | ||
- | name: | ||
- | - hashtopolis | ||
- | state: present | ||
- | login_user: root | ||
- | login_password: | ||
- | |||
- | |||
- | # UFW Configuration | ||
- | - name: "UFW - Allow HTTP on port {{ http_port }}" | ||
- | ufw: | ||
- | rule: allow | ||
- | port: "{{ http_port }}" | ||
- | proto: tcp | ||
- | |||
- | # PHP Info Page | ||
- | - name: Sets Up PHP Info Page | ||
- | template: | ||
- | src: " | ||
- | dest: "/ | ||
- | |||
- | - name: Clone a github repository | ||
- | git: | ||
- | repo: https:// | ||
- | dest: / | ||
- | clone: true | ||
- | update: true | ||
- | - name: copy hastopolis/ | ||
- | copy: | ||
- | src: / | ||
- | dest: "/ | ||
- | remote_src: true | ||
- | owner: www-data | ||
- | group: www-data | ||
- | # - name: chown -R www-data: | ||
- | # - name: php.ini tweaking | ||
- | |||
- | handlers: | ||
- | - name: Reload Apache | ||
- | service: | ||
- | name: apache2 | ||
- | state: reloaded | ||
- | |||
- | - name: Restart Apache | ||
- | service: | ||
- | name: apache2 | ||
- | state: restarted | ||
- | </ | ||
- | - Configure the server using the Web UI | ||
- | * open web browser and point to the server' | ||
- | * complete the installation gui to configure the server | ||
- | * server hostname: localhost | ||
- | * server port: 3306 | ||
- | * mysql user: hashtopolis | ||
- | * mysql password: my_hastopolis_password | ||
- | * database name: hashtopolis | ||
- | * create a login account when prompted | ||
- | - After configuration is complete, remove the install directory. | ||
- | * <file yaml remove-hashtopolis-installer.yml> | ||
- | --- | ||
- | - hosts: server | ||
- | become: true | ||
- | vars: | ||
- | http_host: " | ||
- | tasks: | ||
- | - name: Remove install directory | ||
- | file: | ||
- | path: "/ | ||
- | state: " | ||
- | </ | ||
- | - Log in and create enough vouches for all your worker nodes | ||
- | * Click Agents > New | ||
- | * Under Vouchers, and next to the New voucher button, click Create | ||
- | * Repeat to generate vouchers for all your workers | ||
- | * Save these voucher codes to '' | ||
- | - Click Files, then the Wordlists Tab | ||
- | * Click Add File, the upload a list of passwords to use for cracking | ||
- | * Use [[https:// | ||
- | |||
- | ==== Agent Setup ==== | ||
- | - Create a text file with the list of voucher codes: ''/ | ||
- | * <file text vouchers.txt> | ||
- | A3wwdhU2 | ||
- | Yznktilt | ||
- | </ | ||
- | - Create a j2 template for the agent configuration file | ||
- | * <file json config.json.j2> | ||
- | { | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | } | ||
- | </ | ||
- | - Create unit file for the new hashtopolis-agent service | ||
- | * <file systemd hashtopolis-agent.service> | ||
- | [Unit] | ||
- | Description=Hashtopolis Agent | ||
- | After=network.target | ||
- | |||
- | [Service] | ||
- | Type=simple | ||
- | ExecStart=/ | ||
- | Restart=on-failure | ||
- | StandardOutput=syslog | ||
- | StandardError=syslog | ||
- | SyslogIdentifier=hashtopolis-client | ||
- | WorkingDirectory=/ | ||
- | |||
- | [Install] | ||
- | WantedBy=multi-user.target | ||
- | </ | ||
- | - Create playbook to install the agent | ||
- | * <file yaml hashtopolis-agent.yml> | ||
- | --- | ||
- | - hosts: server | ||
- | - hosts: agents | ||
- | become: true | ||
- | vars: | ||
- | server_ip: " | ||
- | vouchers: "{{ lookup(' | ||
- | tasks: | ||
- | - name: Install prerequisites | ||
- | apt: | ||
- | pkg: | ||
- | - zip | ||
- | - git | ||
- | - python3 | ||
- | - python3-psutil | ||
- | - python3-requests | ||
- | - pciutils | ||
- | - curl | ||
- | - name: Pull agent | ||
- | get_url: | ||
- | url: " | ||
- | dest: / | ||
- | - name: Create config file | ||
- | template: | ||
- | src: "/ | ||
- | dest: "/ | ||
- | - name: Create systemd unit file | ||
- | copy: | ||
- | src: / | ||
- | dest: / | ||
- | owner: root | ||
- | mode: 644 | ||
- | - name: Reload systemd | ||
- | command: systemctl daemon-reload | ||
- | sudo: yes | ||
- | - name: Start hashtopolis-agent service | ||
- | systemd: | ||
- | name: hashtopolis-agent | ||
- | enabled: true | ||
- | state: started | ||
- | </ | ||
- | |||
- | ==== Confirm Agents are Up and Running ==== | ||
- | - Check the services using a playbook | ||
- | * <file yaml check-agent-service.yml> | ||
- | --- | ||
- | - hosts: agents | ||
- | tasks: | ||
- | - name: Get Service Status | ||
- | ansible.builtin.systemd: | ||
- | name: " | ||
- | register: hta_service_status | ||
- | - debug: | ||
- | var: hta_service_status.status.ActiveState | ||
- | </ | ||
- | - Log in to the Hashtopolis dashboard and view the agents | ||
- | ==== Add Dictionary of Passwords to Try ==== | ||
- | - Click Files, then the Wordlists Tab | ||
- | * Click Add File, the upload a list of passwords to use for cracking | ||
- | * Use [[https:// | ||
- | |||
- | ==== Create Sample md5 Password Hashes ==== | ||
- | |||
- | md5sum | ||
- | |||
- | ==== Create a Task to Crack the Hashes ==== | ||
- | |||
- | to do | ||
- | |||
- | |||
- | I chose a hash from / |
lab/stack_of_nucs/ansible_playbook_-_fah_removal.1683137553.txt.gz · Last modified: 2023/05/03 18:12 by user