diff --git a/README.md b/README.md index e65f90bd25a31f2639f20b011c80f24b23709c59..e654d68e4d0a56db8a304d58c5815f0533cf0b51 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,6 @@ If you plan to use this code in your work, we kindly request that you cite the f # **Introduction** -{- TODO: is this text useful ? -} - The MITIK project proposal is to carry out non-intrusive passive measurements to analyze the mobility of users through contacts while they are moving. For that, the goal is to use probe request packets from off-the-shelf mobile devices with wireless communication (specifically Wi-Fi). To ensure GPDR compliance, a data anonymization/sanitization process is carried out so that probe requests are received by the _sniffers_ [4]. The system, as a whole, is composed of an architecture that comprises three phases, as shown in Figure 1. <div style="text-align:center"> diff --git a/config/broadcast.yml b/config/broadcast.yml index 66cba350d8914cb02b6c327904ce65061acc5833..4b2fb6a2897647512c3b82912118c47b82379b65 100644 --- a/config/broadcast.yml +++ b/config/broadcast.yml @@ -6,4 +6,4 @@ tasks: - name: say things to tty1 - ansible.builtin.shell: echo {{ inventory_hostname }} {{ group_names[1] }} | sudo tee /dev/tty1 && /bin/true + ansible.builtin.shell: echo {{ inventory_hostname }} | sudo tee /dev/tty1 && /bin/true diff --git a/config/inventory b/config/inventory index 6d6c54125f530f9f32a93bb602890dce1e9bfa47..c12ab59d292bcfd698062eebe51ab8d708e8f92d 100644 --- a/config/inventory +++ b/config/inventory @@ -4,15 +4,15 @@ ss2 [ss1] -; s6-whyred ansible_host=192.168.145.56 -; s1 ansible_host=192.168.1.184 ansible_ssh_user=user -; s2 ansible_host=192.168.1.231 -; s3 ansible_host=192.168.1.239 -; s4 ansible_host=192.168.1.100 +; ss1-s6-whyred ansible_host=192.168.145.56 +; ss1-s1 ansible_host=192.168.1.184 ansible_ssh_user=user +; ss1-s2 ansible_host=192.168.1.231 +; ss1-s3 ansible_host=192.168.1.239 +; ss1-s4 ansible_host=192.168.1.100 [ss2] -s6 ansible_host=192.168.1.244 -s5 ansible_host=192.168.1.100 +ss2-s6 ansible_host=192.168.1.244 +ss2-s5 ansible_host=192.168.1.100 # rp4 ansible_host=192.168.1.248 diff --git a/config/test.yml b/config/test.yml index 4ae3a3e9543017d5710ee57f89d307ca3ec79ef1..4e87a5f41ca4b11e43bc57ae2a0178115214fec5 100644 --- a/config/test.yml +++ b/config/test.yml @@ -1,5 +1,11 @@ - hosts: all become: yes tasks: + - debug: - msg: "{{ ansible_interfaces | select('match', '^(wifi)[0-9]+')}}" \ No newline at end of file + msg: > + {% if inventory_hostname is match('^ss[0-9]-s[0-9]$') %} + "../results/{{ ansible_date_time.date }}/{{ inventory_hostname[0:3] }}/{{ inventory_hostname[4:6] }}/" + {% else %} + "../results/{{ ansible_date_time.date }}/nogroup/{{ inventory_hostname }}/" + {% endif %} \ No newline at end of file diff --git a/docs/DOCUMENTATION.md b/docs/DOCUMENTATION.md index 7c6ea20c5da67a06291d9be7a276c862167d31ae..64cc84126210439271d0ab2be13a339a1c9f7b5c 100644 --- a/docs/DOCUMENTATION.md +++ b/docs/DOCUMENTATION.md @@ -40,11 +40,12 @@ Enter the `config` folder. When running ansible from this folder, it will read c In order yo fill your inventory, you'll need to know your nodes' username and IP address. A static IP for each node is highly recommended. -In the following example, we create a group of devices `ss1` with two nodes inside. They are locally nicknamed `s1` and `s2`, and they are reachable using their respective IP addresses. Username is set to be `user` for `s1`. Inline variables set here override variables defined globally. +In the following example, we create a group of devices `ss1` with two nodes inside. They are locally nicknamed `ss1-s1` and `ss1-s2`, and they are reachable using their respective IP addresses. Inline variables set here override variables defined globally. +It is important to specify the super-sniffer inside the hostname, because else when tasks run you'll only see the number of the sniffer and not its group ```ini [ss1] -s1 ansible_host=192.168.1.184 -s2 ansible_host=192.168.1.231 +ss1-s1 ansible_host=192.168.1.184 +ss1-s2 ansible_host=192.168.1.231 ``` --- The following adds members of the `ss1` and `ss2` groups to the `sniffers` group. Upon creating new groups, you might want to add them to the `sniffers`. This will let you run commands on all of its children at once. diff --git a/docs/PLAYBOOKS.md b/docs/PLAYBOOKS.md index bbc6685b2856675bd10ac47119f2654817010f72..86e4e8776f310e3ea58321855a35c420563afaae 100644 --- a/docs/PLAYBOOKS.md +++ b/docs/PLAYBOOKS.md @@ -31,7 +31,7 @@ Multiple configuration scripts, here called microstasks, have been put into a si - `microtask_networkmanager_un_manager_setup.yml` (nodes) - set up networkmanager to ignore wifi..8 - `microtask_hostname_update.yml` (nodes) - - update device hostname to [group]-[inventory name]: ss1-s1 + - update device hostname to [inventory name]: ss1-s1 - `microtask_hosts_update.yml` (nodes) - Add addresses of all other sniffers to each sniffer's hosts file - `microtask_getty_autologin_setup.yml` (nodes) diff --git "a/playbooks/\n \"../results/2024-09-27/ss2/s6/\"\n\"\n" "b/playbooks/\n \"../results/2024-09-27/ss2/s6/\"\n\"\n" new file mode 100644 index 0000000000000000000000000000000000000000..875d6b62480fe14aa1442db71610a2be9b57d02d Binary files /dev/null and "b/playbooks/\n \"../results/2024-09-27/ss2/s6/\"\n\"\n" differ diff --git "a/playbooks/\n \"../results/2024-10-01/ss2/s5/\"\n\"\n" "b/playbooks/\n \"../results/2024-10-01/ss2/s5/\"\n\"\n" new file mode 100644 index 0000000000000000000000000000000000000000..0a7574ba7ab35d2e9b377a1576336aaeecfaa32d Binary files /dev/null and "b/playbooks/\n \"../results/2024-10-01/ss2/s5/\"\n\"\n" differ diff --git "a/playbooks/ \"../results/2024-09-27/ss2/s6/\"\n" "b/playbooks/ \"../results/2024-09-27/ss2/s6/\"\n" new file mode 100644 index 0000000000000000000000000000000000000000..875d6b62480fe14aa1442db71610a2be9b57d02d Binary files /dev/null and "b/playbooks/ \"../results/2024-09-27/ss2/s6/\"\n" differ diff --git "a/playbooks/ \"../results/2024-09-27/ss2/s6/\"\n\"\n" "b/playbooks/ \"../results/2024-09-27/ss2/s6/\"\n\"\n" new file mode 100644 index 0000000000000000000000000000000000000000..875d6b62480fe14aa1442db71610a2be9b57d02d Binary files /dev/null and "b/playbooks/ \"../results/2024-09-27/ss2/s6/\"\n\"\n" differ diff --git "a/playbooks/ \"../results/2024-10-01/ss2/s5/\"\n" "b/playbooks/ \"../results/2024-10-01/ss2/s5/\"\n" new file mode 100644 index 0000000000000000000000000000000000000000..0a7574ba7ab35d2e9b377a1576336aaeecfaa32d Binary files /dev/null and "b/playbooks/ \"../results/2024-10-01/ss2/s5/\"\n" differ diff --git "a/playbooks/ \"../results/2024-10-01/ss2/s5/\"\n\"\n" "b/playbooks/ \"../results/2024-10-01/ss2/s5/\"\n\"\n" new file mode 100644 index 0000000000000000000000000000000000000000..0a7574ba7ab35d2e9b377a1576336aaeecfaa32d Binary files /dev/null and "b/playbooks/ \"../results/2024-10-01/ss2/s5/\"\n\"\n" differ diff --git "a/playbooks/ ../results/2024-09-27/ss2/s6/\n" "b/playbooks/ ../results/2024-09-27/ss2/s6/\n" new file mode 100644 index 0000000000000000000000000000000000000000..875d6b62480fe14aa1442db71610a2be9b57d02d Binary files /dev/null and "b/playbooks/ ../results/2024-09-27/ss2/s6/\n" differ diff --git "a/playbooks/ ../results/2024-09-27/ss2/s6/\n \n" "b/playbooks/ ../results/2024-09-27/ss2/s6/\n \n" new file mode 100644 index 0000000000000000000000000000000000000000..875d6b62480fe14aa1442db71610a2be9b57d02d Binary files /dev/null and "b/playbooks/ ../results/2024-09-27/ss2/s6/\n \n" differ diff --git "a/playbooks/ ../results/2024-09-27/ss2/s6/\n | trim\n" "b/playbooks/ ../results/2024-09-27/ss2/s6/\n | trim\n" new file mode 100644 index 0000000000000000000000000000000000000000..875d6b62480fe14aa1442db71610a2be9b57d02d Binary files /dev/null and "b/playbooks/ ../results/2024-09-27/ss2/s6/\n | trim\n" differ diff --git "a/playbooks/ ../results/2024-09-27/ss2/s6/'\n" "b/playbooks/ ../results/2024-09-27/ss2/s6/'\n" new file mode 100644 index 0000000000000000000000000000000000000000..875d6b62480fe14aa1442db71610a2be9b57d02d Binary files /dev/null and "b/playbooks/ ../results/2024-09-27/ss2/s6/'\n" differ diff --git "a/playbooks/ ../results/2024-09-27/ss2/s6/\\'\n" "b/playbooks/ ../results/2024-09-27/ss2/s6/\\'\n" new file mode 100644 index 0000000000000000000000000000000000000000..875d6b62480fe14aa1442db71610a2be9b57d02d Binary files /dev/null and "b/playbooks/ ../results/2024-09-27/ss2/s6/\\'\n" differ diff --git "a/playbooks/ ../results/2024-10-01/ss2/s5/\n" "b/playbooks/ ../results/2024-10-01/ss2/s5/\n" new file mode 100644 index 0000000000000000000000000000000000000000..0a7574ba7ab35d2e9b377a1576336aaeecfaa32d Binary files /dev/null and "b/playbooks/ ../results/2024-10-01/ss2/s5/\n" differ diff --git "a/playbooks/ ../results/2024-10-01/ss2/s5/\n \n" "b/playbooks/ ../results/2024-10-01/ss2/s5/\n \n" new file mode 100644 index 0000000000000000000000000000000000000000..0a7574ba7ab35d2e9b377a1576336aaeecfaa32d Binary files /dev/null and "b/playbooks/ ../results/2024-10-01/ss2/s5/\n \n" differ diff --git "a/playbooks/ ../results/2024-10-01/ss2/s5/\n | trim\n" "b/playbooks/ ../results/2024-10-01/ss2/s5/\n | trim\n" new file mode 100644 index 0000000000000000000000000000000000000000..0a7574ba7ab35d2e9b377a1576336aaeecfaa32d Binary files /dev/null and "b/playbooks/ ../results/2024-10-01/ss2/s5/\n | trim\n" differ diff --git "a/playbooks/ ../results/2024-10-01/ss2/s5/'\n" "b/playbooks/ ../results/2024-10-01/ss2/s5/'\n" new file mode 100644 index 0000000000000000000000000000000000000000..0a7574ba7ab35d2e9b377a1576336aaeecfaa32d Binary files /dev/null and "b/playbooks/ ../results/2024-10-01/ss2/s5/'\n" differ diff --git "a/playbooks/ ../results/2024-10-01/ss2/s5/\\'\n" "b/playbooks/ ../results/2024-10-01/ss2/s5/\\'\n" new file mode 100644 index 0000000000000000000000000000000000000000..0a7574ba7ab35d2e9b377a1576336aaeecfaa32d Binary files /dev/null and "b/playbooks/ ../results/2024-10-01/ss2/s5/\\'\n" differ diff --git "a/playbooks/\"../results/2024-09-27/ss2/s6/\"\n" "b/playbooks/\"../results/2024-09-27/ss2/s6/\"\n" new file mode 100644 index 0000000000000000000000000000000000000000..875d6b62480fe14aa1442db71610a2be9b57d02d Binary files /dev/null and "b/playbooks/\"../results/2024-09-27/ss2/s6/\"\n" differ diff --git "a/playbooks/\"../results/2024-10-01/ss2/s5/\"\n" "b/playbooks/\"../results/2024-10-01/ss2/s5/\"\n" new file mode 100644 index 0000000000000000000000000000000000000000..0a7574ba7ab35d2e9b377a1576336aaeecfaa32d Binary files /dev/null and "b/playbooks/\"../results/2024-10-01/ss2/s5/\"\n" differ diff --git a/playbooks/data_transfer.yml b/playbooks/data_transfer.yml index 541a802f448376aeae4265df261a965df9a2f6f5..1bc5b4c1dcbd26dbebe74579eac2c1f2d0bcee63 100644 --- a/playbooks/data_transfer.yml +++ b/playbooks/data_transfer.yml @@ -1,4 +1,4 @@ -# This script copies resulting capture files to ../results folder +# This script copies resulting capture files to ../results/group (ss?)/sniffer (s?)/ folder - hosts: sniffers tasks: @@ -10,9 +10,24 @@ patterns: "*.pcap, *.gps" # what your target files look like register: files_to_copy + - name: get local time + shell: date +"%Y-%m-%d-%H-%M" + register: _localFname + delegate_to: localhost + run_once: true + + - name: Set destination path based on hostname pattern + set_fact: + _dest: | + {% if inventory_hostname is match('^ss[0-9]+-s[0-9]+$') %} + ../results/{{ _localFname.stdout }}/{{ inventory_hostname.split('-')[0]}}/{{ inventory_hostname.split('-')[1]}}/ + {% else %} + ../results/{{ _localFname.stdout }}/nogroup/{{ inventory_hostname}}/ + {% endif %} + - name: Copy files fetch: src: "{{ item.path }}" - dest: "../results/{{ ansible_date_time.date }}/{{ group_names[1] | default(group_names[0] | default('nogroup')) }}/{{ inventory_hostname }}/" + dest: "{{_dest | trim}}" flat: yes with_items: "{{ files_to_copy.files }}" diff --git a/playbooks/microtask_hostname_update.yml b/playbooks/microtask_hostname_update.yml index 09b8cb868d5e882bf0b7fd2a4372bb2374a089ea..9ad0af8982da8493e17ad541393d6ed23ffac5fd 100644 --- a/playbooks/microtask_hostname_update.yml +++ b/playbooks/microtask_hostname_update.yml @@ -2,5 +2,11 @@ - hosts: sniffers tasks: vars: - - name: set system hostname - shell: sudo hostnamectl set-hostname {{ group_names[1] | default(group_names[0]) }}-{{ inventory_hostname }} + - name: skip is good; check that hostnames look valid + debug: + msg: "The hostname {{ inventory_hostname }} looks invalid." + when: inventory_hostname is not match('^ss[0-9]-s[0-9]$') + + - name: set system hostname + shell: sudo hostnamectl set-hostname {{ inventory_hostname }} + diff --git a/playbooks/test_interfaces_status.yml b/playbooks/test_interfaces_status.yml index a7590bf7a1122b067a4c2028589b21d17d9ffe90..ed168a237c74c448a46e8612d138d7b63a30ca13 100644 --- a/playbooks/test_interfaces_status.yml +++ b/playbooks/test_interfaces_status.yml @@ -17,19 +17,19 @@ # removed macaddress interface_query: >- - [].[device, module] + [].[device, module, type] interfaces_formated_list: >- - {{ interfaces_list_raw | json_query(interface_query) | map('join', ': ') }} + {{ interfaces_list_raw | json_query(interface_query) | map('join', ', ') }} tasks: #Interfaces status - - debug: - msg: "{{hostvars}}" + # - debug: + # msg: "{{hostvars}}" - name: Interfaces connected debug: #var: interfaces_formated_list - msg: "{{ [ansible_hostname] + interfaces_formated_list }}" + msg: "{{ interfaces_formated_list }}" diff --git a/playbooks/test_systemctl_services.yml b/playbooks/test_systemctl_services.yml index c4fff5d254c6f8a973bef32eedde1773d98a319d..aa45828f5ca6d905c05a7f8745edc533473d4b65 100644 --- a/playbooks/test_systemctl_services.yml +++ b/playbooks/test_systemctl_services.yml @@ -39,11 +39,11 @@ - name: print current statuses debug: - msg: "{{ [ansible_hostname+':'] + service_statuses}}" + msg: "{{service_statuses}}" - name: Failure check fail: - msg: "{{ansible_hostname}} failed" + msg: "{{ansible_hostname}} failed systemctl checks" when: "not service_statuses is subset(expected_statuses)" ignore_errors: false register: _failures diff --git a/playbooks/test_time.yml b/playbooks/test_time.yml index d17788013fc0b2e9576c8520f2aa03aa647dd498..0fc11537177dea51e181889b06924525f99c9c82 100644 --- a/playbooks/test_time.yml +++ b/playbooks/test_time.yml @@ -1,5 +1,8 @@ +# gets time for all hosts. +# %T is time; same as %H:%M:%S +# %N nanoseconds - hosts: sniffers - #gather_facts: false + gather_facts: false tasks: - name: date command: date +"%T.%N" @@ -7,7 +10,7 @@ - name: Time verification debug: - msg: "{{ansible_hostname}} Time: {{ result_date.stdout }}" + msg: "Time: {{ result_date.stdout }}"