From ada14cf443e74504cffebdb7f37567dd35fc38e4 Mon Sep 17 00:00:00 2001
From: autodistries <automatedactions@protonmail.com>
Date: Mon, 16 Sep 2024 16:33:42 +0200
Subject: [PATCH] check CHANGELOG.md

---
 CHANGELOG.md                                  | 54 +++++++++++
 ansible/tasks/playbook_data_transfer.yml      | 23 -----
 ansible/tasks/playbook_hostname.yml           |  4 -
 ansible/tasks/playbook_hosts.yml              | 18 ----
 config/ansible.cfg                            |  6 +-
 config/{hosts => inventory}                   | 20 +++--
 config/test.yml                               | 18 ++--
 files/99-unmanaged-devices.conf               |  3 +
 files/setInterfacesToMonitorMode.sh           | 34 +++++++
 {ansible/tasks => playbooks}/README.md        |  2 +-
 playbooks/data_transfer.yml                   | 18 ++++
 playbooks/device_setup.yml                    | 90 +++++++++++++++++++
 playbooks/hostname_update.yml                 |  5 ++
 playbooks/hosts_update.yml                    | 23 +++++
 playbooks/playbook_GPIO_status                | 25 ++++++
 .../playbook_GPS_sync.yml                     |  0
 .../playbook_NIC_config.yml                   |  3 +-
 .../playbook_SSH_keygen.yml.unt               |  2 +
 playbooks/playbook_interfaces_status          | 32 +++++++
 playbooks/playbook_service_status             | 33 +++++++
 playbooks/playbook_test                       |  4 +
 playbooks/playbook_time                       | 16 ++++
 playbooks/ssh_setup.yml                       | 56 ++++++++++++
 .../start_sens_sniffer.yml                    | 31 ++++---
 playbooks/stop_sens_sniffer.yml               | 19 ++++
 ...st_azeyuityriuyteuirytuierytuerytuiry.pcap |  0
 ...st_azeyuityriuyteuirytuierytuerytuiry.pcap |  0
 27 files changed, 463 insertions(+), 76 deletions(-)
 create mode 100644 CHANGELOG.md
 delete mode 100644 ansible/tasks/playbook_data_transfer.yml
 delete mode 100644 ansible/tasks/playbook_hostname.yml
 delete mode 100644 ansible/tasks/playbook_hosts.yml
 rename config/{hosts => inventory} (61%)
 create mode 100644 files/99-unmanaged-devices.conf
 create mode 100755 files/setInterfacesToMonitorMode.sh
 rename {ansible/tasks => playbooks}/README.md (95%)
 create mode 100644 playbooks/data_transfer.yml
 create mode 100644 playbooks/device_setup.yml
 create mode 100644 playbooks/hostname_update.yml
 create mode 100644 playbooks/hosts_update.yml
 create mode 100644 playbooks/playbook_GPIO_status
 rename ansible/tasks/playbook_GPS_sync.yml.unt => playbooks/playbook_GPS_sync.yml (100%)
 rename {ansible/tasks => playbooks}/playbook_NIC_config.yml (72%)
 rename {ansible/tasks => playbooks}/playbook_SSH_keygen.yml.unt (86%)
 create mode 100644 playbooks/playbook_interfaces_status
 create mode 100644 playbooks/playbook_service_status
 create mode 100644 playbooks/playbook_test
 create mode 100644 playbooks/playbook_time
 create mode 100644 playbooks/ssh_setup.yml
 rename ansible/tasks/playbook_scapy-sniffer_GPS.yml => playbooks/start_sens_sniffer.yml (72%)
 create mode 100644 playbooks/stop_sens_sniffer.yml
 delete mode 100644 results/2024-09-11/ss1/s3/capture-test_azeyuityriuyteuirytuierytuerytuiry.pcap
 delete mode 100644 results/ss1_2024-09-11/capture-test_azeyuityriuyteuirytuierytuerytuiry.pcap

diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..803d478
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,54 @@
+# Additions
+
+
+
+
+
+
+
+
+# Modifications
+
+## First master-nodes connection: SSH setup
+In order to ease configuring ssh keys and passwordless authentication, the playbook **ssh_setup.yml** (previously **playbook_SSH_keygen.yml**) has been re-written.
+- Asks for password and username
+- Installs sshpass and keychain (master)
+- Creates a ssh key (master)
+- Copy public ssh key to authorized_hosts (nodes)
+- Using .bashrc, autoload the ssh key (master)
+
+
+## Nodes configuration
+- install git, bc, + other optional packages (nodes)
+- Switch off predictable netfowk interface naming (nodes)
+- set up udev rules for forced interface naming (nodes)
+- clone, build and install custom rtl8188 module (nodes)
+- set up networkmanager to ignore wlan5..7
+- copy script to setup interfaces monitor mode
+- create crontab to run that cript when rebooted
+
+
+## Data transfer (fetch results)
+
+- Renamed playbook_data_transfer to data_transfer
+- Move results to ../results/DATE/GROUP NAME, like SS1/INVENTORY NAME, like S1/filename"
+
+## Update hosts
+- Renamed from playbook_hosts to hosts_update
+- Fix it
+- Added super-sniffer inside hosts
+ex: `192.168.1.244 ss2-s6`
+
+
+## Hostame setup
+- renamed from playbook_hostname to hostname_update
+- added group (super-sniffer) to hostname: `ss2-s6`
+
+
+## Experiment start
+- renamed from playbook_scapy-sniffer_GPS.yml to start_sens_sniffer.yml
+- Added and removed parameters to make it usable with mitik-sens
+
+## Experiment interrupt
+- Removes related crontabs
+- Stops current sniffer.py processes
diff --git a/ansible/tasks/playbook_data_transfer.yml b/ansible/tasks/playbook_data_transfer.yml
deleted file mode 100644
index 02f4c1f..0000000
--- a/ansible/tasks/playbook_data_transfer.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-- hosts: sniffers
-
-
-  vars:
-    remote_src_file: "/home/tribe/mitik-sens-mod/capture-*.pcap"
-    dest_file: "../results/"
-    cap_file: capture-* 
-
-  tasks:
-
-    - name: find files to copy
-      find: 
-        paths: "/home/tribe/mitik-sens-mod/"
-        recurse: no 
-        patterns: "capture-*.pcap"
-      register: files_to_copy
-
-    - name: Copy files
-      fetch: 
-        src: "{{ item.path }}"
-        dest: "../results/{{ ansible_date_time.date }}/{{ group_names[1] }}/{{ inventory_hostname }}/"
-        flat: yes
-      with_items: "{{ files_to_copy.files }}"
diff --git a/ansible/tasks/playbook_hostname.yml b/ansible/tasks/playbook_hostname.yml
deleted file mode 100644
index db7bd4b..0000000
--- a/ansible/tasks/playbook_hostname.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-- hosts: all
-  tasks:
-   - name: set system hostname
-     command: sudo hostnamectl set-hostname {{ group_names[1] | default(group_names[0]) }}-{{ inventory_hostname }}
diff --git a/ansible/tasks/playbook_hosts.yml b/ansible/tasks/playbook_hosts.yml
deleted file mode 100644
index 8eacb9e..0000000
--- a/ansible/tasks/playbook_hosts.yml
+++ /dev/null
@@ -1,18 +0,0 @@
-  - name: host file update - Local DNS setup across all the servers
-    hosts: sniffers
-    gather_facts: yes
-    tasks:
-
-    - name: Update the /etc/hosts file with node name
-      tags: etchostsupdate
-      become: yes
-      become_user: root
-      lineinfile:
-        dest: "/etc/hosts"
-        regexp: ".*\t{{ hostvars[item]['ansible_hostname']}}\t{{ hostvars[item]['ansible_hostname']}}"
-        line: "{{ hostvars[item]['ansible_default_ipv4']['address'] }}\t{{ hostvars[item]['ansible_hostname']}}\t{{ hostvars[item]['ansible_hostname']}}"
-        state: present
-      register: etchostsupdate
-      when: 
-        ansible_hostname !=  "item" or ansible_hostname == "item"
-      with_items: "{{groups['sniffers']}}"
diff --git a/config/ansible.cfg b/config/ansible.cfg
index 56faddd..0b36347 100644
--- a/config/ansible.cfg
+++ b/config/ansible.cfg
@@ -91,7 +91,7 @@
 ;debug=False
 
 # (string) This indicates the command to use to spawn a shell under, which is required for Ansible's execution needs on a target. Users may need to change this in rare instances when shell usage is constrained, but in most cases, it may be left as is.
-executable=/bin/bash
+;executable=/bin/bash
 
 # (string) This option allows you to globally configure a custom path for 'local_facts' for the implied :ref:`ansible_collections.ansible.builtin.setup_module` task when using fact gathering.
 # If not set, it will fall back to the default from the ``ansible.builtin.setup`` module: ``/etc/ansible/facts.d``.
@@ -134,7 +134,7 @@ executable=/bin/bash
 ;hash_behaviour=replace
 
 # (pathlist) Comma-separated list of Ansible inventory sources
-inventory=./hosts
+inventory=./inventory
 
 # (pathspec) Colon-separated paths in which Ansible will search for HttpApi Plugins.
 ;httpapi_plugins=/home/guigui/.ansible/plugins/httpapi:/usr/share/ansible/plugins/httpapi
@@ -326,7 +326,7 @@ inventory=./hosts
 ;inject_facts_as_vars=True
 
 # (string) Path to the Python interpreter to be used for module execution on remote targets, or an automatic discovery mode. Supported discovery modes are ``auto`` (the default), ``auto_silent``, ``auto_legacy``, and ``auto_legacy_silent``. All discovery modes employ a lookup table to use the included system Python (on distributions known to include one), falling back to a fixed ordered list of well-known Python interpreter locations if a platform-specific default is not available. The fallback behavior will issue a warning that the interpreter should be set explicitly (since interpreters installed later may change which one is used). This warning behavior can be disabled by setting ``auto_silent`` or ``auto_legacy_silent``. The value of ``auto_legacy`` provides all the same behavior, but for backward-compatibility with older Ansible releases that always defaulted to ``/usr/bin/python``, will use that interpreter if present.
-interpreter_python=/usr/bin/python3.11
+;interpreter_python=/usr/bin/python3.11
 
 # (boolean) If 'false', invalid attributes for a task will result in warnings instead of errors.
 ;invalid_task_attribute_failed=True
diff --git a/config/hosts b/config/inventory
similarity index 61%
rename from config/hosts
rename to config/inventory
index 9594eae..088e997 100644
--- a/config/hosts
+++ b/config/inventory
@@ -1,20 +1,26 @@
+[sniffers:children]
+ss1
+ss2
+
+
 [ss1]
-s1 ansible_host=192.168.1.184
+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.248
 
 [ss2]
-s4 ansible_host=192.168.1.248
 s5 ansible_host=192.168.1.246
-s6 ansible_host=192.168.1.244
 
 [test]
-rp4  ansible_host=192.168.1.248
+s6 ansible_host=192.168.1.244
+
+# rp4  ansible_host=192.168.1.248
+
 
-[sniffers:children]
-ss1
-ss2
 
 [all:vars]
 ansible_connection=ssh
 ansible_ssh_user=tribe
+ansible_python_interpreter=/usr/bin/python3
+ansible_executable=/bin/bash
diff --git a/config/test.yml b/config/test.yml
index 0e5dda1..c83b7e5 100644
--- a/config/test.yml
+++ b/config/test.yml
@@ -1,7 +1,13 @@
-- hosts: ss2
+- hosts:  s6
   tasks:
-   - name: set system hostname
-     command: echo {{ group_names[1] | default(group_names[0]) }}-{{ inventory_hostname }}
-     register: outt
-   - debug:
-       msg: "{{outt.stdout}}"
+
+
+    - name: Clone sens repository
+      ansible.builtin.git:
+        repo: https://mitik-sens-mod:glpat-F9S1EPn2KKts_a8syNWu@gitlab.inria.fr/gfarhiri/mitik-sens-mod
+        dest: ~/mitik-sens-mod
+        update: true
+      register: outr
+
+    - debug:
+       msg: "{{outr}}"
diff --git a/files/99-unmanaged-devices.conf b/files/99-unmanaged-devices.conf
new file mode 100644
index 0000000..ea974bf
--- /dev/null
+++ b/files/99-unmanaged-devices.conf
@@ -0,0 +1,3 @@
+[keyfile]
+unmanaged-devices=interface-name:wlan5;interface-name:wlan6;interface-name:wlan7;interface-name:wlan8
+
diff --git a/files/setInterfacesToMonitorMode.sh b/files/setInterfacesToMonitorMode.sh
new file mode 100755
index 0000000..14fa6d5
--- /dev/null
+++ b/files/setInterfacesToMonitorMode.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+# Check if interfaces exist before attempting to configure them
+if [ -n "$(ip link show wlan5 2>/dev/null)" ]; then
+  sudo ifconfig wlan5 up
+  sudo ifconfig wlan5 down
+  sudo iwconfig wlan5 mode monitor
+  sudo ifconfig wlan5 up
+  echo "Set wlan5 to monitor mode"
+fi
+
+if [ -n "$(ip link show wlan6 2>/dev/null)" ]; then
+  sudo ifconfig wlan6 up
+  sudo ifconfig wlan6 down
+  sudo iwconfig wlan6 mode monitor
+  sudo ifconfig wlan6 up
+  echo "Set wlan6 to monitor mode"
+fi
+
+if [ -n "$(ip link show wlan7 2>/dev/null)" ]; then
+  sudo ifconfig wlan7 up
+  sudo ifconfig wlan7 down
+  sudo iwconfig wlan7 mode monitor
+  sudo ifconfig wlan7 up
+  echo "Set wlan7 to monitor mode"
+fi
+
+if [ -n "$(ip link show wlan8 2>/dev/null)" ]; then
+  sudo ifconfig wlan8 up
+  sudo ifconfig wlan8 down
+  sudo iwconfig wlan8 mode monitor
+  sudo ifconfig wlan8 up
+  echo "Set wlan8 to monitor mode"
+fi
diff --git a/ansible/tasks/README.md b/playbooks/README.md
similarity index 95%
rename from ansible/tasks/README.md
rename to playbooks/README.md
index d38102a..0093f19 100644
--- a/ansible/tasks/README.md
+++ b/playbooks/README.md
@@ -28,7 +28,7 @@ A modified version of Raspian has been provided by [1], as part of the experimen
 
 ## **Sniffer manager**
 
-A sniffer manager is defined in a Mitik laptop (Macbook Pro). All the instructions executed in the sniffers are defined in the sniffer manager. To establish communication with the sniffers, an inventory with specific parameters is defined.Each sniffer is assigned a static IP. Besides that, sniffers are organized in groups (super-sniffers). _inventory_ shows the definition for each sniffer. Four groups (super-sniffers) are defined (ss1 to ss4), and each one contains five sniffers (sniffer#-ss#). 
+A sniffer manager is defined in a Mitik laptop (Macbook Pro). All the instructions executed in the sniffers are defined in the sniffer manager. To establish communication with the sniffers, an inventory with specific parameters is defined. Each sniffer is assigned a static IP. Besides that, sniffers are organized in groups (super-sniffers). _inventory_ shows the definition for each sniffer. Four groups (super-sniffers) are defined (ss1 to ss4), and each one contains five sniffers (sniffer#-ss#).
 
 In addition to the inventory, the sniffer manager sends all the instructions and configurations contained in the playbooks to be executed in each sniffer. 
 
diff --git a/playbooks/data_transfer.yml b/playbooks/data_transfer.yml
new file mode 100644
index 0000000..97db4b0
--- /dev/null
+++ b/playbooks/data_transfer.yml
@@ -0,0 +1,18 @@
+# This script copies resulting capture files to ../results folder
+- hosts: sniffers
+
+  tasks:
+
+    - name: find files to copy
+      find: 
+        paths: "~/termporary-transfer-sniffer/hopping-time-tests/" # top folder to search from/in
+        recurse: yes # yes|no recursive file search ?
+        patterns: "*.pcap" # what your target files look like
+      register: files_to_copy
+
+    - name: Copy files
+      fetch: 
+        src: "{{ item.path }}"
+        dest: "../results/{{ ansible_date_time.date }}/{{ group_names[1] | default(group_names[0] | default('nogroup')) }}/{{ inventory_hostname }}/"
+        flat: yes
+      with_items: "{{ files_to_copy.files }}"
diff --git a/playbooks/device_setup.yml b/playbooks/device_setup.yml
new file mode 100644
index 0000000..eaf17ce
--- /dev/null
+++ b/playbooks/device_setup.yml
@@ -0,0 +1,90 @@
+# Device configuration. Can be ran multiple times on one device
+
+
+- name: Set up the sniffers
+  hosts: s6
+  become: yes
+  become_user: root
+  tasks:
+    - name: Install packages
+      tags: sniffer-setup  config nodes
+      apt:
+        pkg:
+          # required
+          - git # to clone rtl8188 repo
+          - bc # required to compile the rtl8188 driver
+
+          # optional
+          # - lshw # list hardware and drivers
+          # - tcpdump # capture and view packets from command-line
+          # - python3-scapy # capture packets using python
+
+    - name: Switch off predictable naming mechanism mechanism
+      tags: nodes device-setup
+      command: sudo ls -nfs /dev/null /etc/systemd/network/99-default.link
+
+    - name: Copy UDEV rules to set interface names based on physical USB positions
+      tags: device-setup nodes
+      copy:
+            src: "../files/72-wlan-geo-dependent.rules"
+            dest: /etc/udev/rules.d/72-wlan-geo-dependent.rules
+
+    - name: Build and install rtl8188eus module
+      tags: device-setup  config nodes
+      shell: |
+        ls ./rtl8188eus 2>/dev/null || git clone https://github.com/aircrack-ng/rtl8188eus/ # only pull if it doesn't already exists
+        cd rtl8188eus
+        make && sudo make install
+        echo 'blacklist rtl8xxxu' | sudo tee -a '/etc/modprobe.d/realtek.conf'  #this is the default driver that we don't want it to use
+        sudo rmmod rtl8xxxu
+        sudo modprobe 8188eu
+
+    - name: Setup NetworkManager to ignore wlan5..8
+      tags: device-setup network nodes
+      copy:
+        src: "../files/99-unmanaged-devices.conf"
+        dest: /etc/NetworkManager/conf.d/99-unmanaged-devices.conf
+
+
+    - name: Copy setInterfacesToMonitorMode.sh to ~/setInterfacesToMonitorMode.sh
+      tags: device-setup nodes
+      copy:
+        src: "../files/setInterfacesToMonitorMode.sh"
+        dest: "~/setInterfacesToMonitorMode.sh"
+        mode: '0770'
+
+    - name: Crontab - set interfaces to monitor mode on reboot
+      ansible.builtin.cron:
+        name: "setInterfacesToMonitorMode.sh"
+        special_time: reboot
+        job: "~/setInterfacesToMonitorMode.sh"
+
+    - name: Clone and/or sens repository
+      ansible.builtin.git:
+        repo: https://mitik-sens-mod:glpat-F9S1EPn2KKts_a8syNWu@gitlab.inria.fr/gfarhiri/mitik-sens-mod
+        dest: ~/mitik-sens-mod
+        update: true
+
+
+- import_playbook: hostname_update.yml
+- import_playbook: hosts_update.yml
+
+
+- name: idk,reboot
+  hosts: s6
+  become: yes
+  become_user: root
+  vars_prompt:
+    - name: user_reboot
+      prompt: If this is your first configuration ever, it is advised to reboot. Reboot ? (y/n)
+      default: "n"
+      private: no
+
+
+  tasks:
+  - name: Perform reboot
+    ansible.builtin.reboot:
+        post_reboot_delay: 30
+    when: user_reboot == 'y'
+
+
diff --git a/playbooks/hostname_update.yml b/playbooks/hostname_update.yml
new file mode 100644
index 0000000..6e27b39
--- /dev/null
+++ b/playbooks/hostname_update.yml
@@ -0,0 +1,5 @@
+# This playbook sets the hostname of targets to group-device name (ss1-s1)
+- hosts: s6
+  tasks:
+   - name: set system hostname
+     shell: sudo hostnamectl set-hostname {{ group_names[1] | default(group_names[0]) }}-{{ inventory_hostname }}
diff --git a/playbooks/hosts_update.yml b/playbooks/hosts_update.yml
new file mode 100644
index 0000000..6825e47
--- /dev/null
+++ b/playbooks/hosts_update.yml
@@ -0,0 +1,23 @@
+# This update the hosts file of all nodes with local addresses of all nodes
+# 192.168.1.184 ss2-s1
+# 192.168.1.231 ss2-s2
+# 192.168.1.239 ss2-s3
+# 192.168.1.248 ss2-s4
+# 192.168.1.246 ss2-s5
+# 192.168.1.244 ss2-s6
+# It works when this line does not exist before; it also updates existing lines if necessary
+- name: host file update - Local DNS setup across all the nodes
+  hosts: sniffers
+  gather_facts: yes
+  become: yes
+  become_user: root
+  tasks:
+
+    - name: Add IP address of all hosts to all hosts
+      lineinfile:
+            dest: "/etc/hosts"
+            regexp: '.*{{ item }}$'
+            line: "{{ hostvars[item].ansible_host }} {{ group_names[1] | default(group_names[0] | default('nogroup')) }}-{{item}}"
+            state: present
+      when: hostvars[item].ansible_host is defined
+      with_items: "{{ groups.sniffers }}"
diff --git a/playbooks/playbook_GPIO_status b/playbooks/playbook_GPIO_status
new file mode 100644
index 0000000..4333eb4
--- /dev/null
+++ b/playbooks/playbook_GPIO_status
@@ -0,0 +1,25 @@
+- hosts: sniffers
+  gather_facts: false
+  user: gta
+  become: yes
+  become_user: root
+
+  tasks:
+
+#GPIO status
+    - name: GPIO status test
+      shell: raspi-gpio get 18 |  awk -F" |  |=" '{print $4}'
+      register: result
+
+    - name: GPS module enabled
+      debug:
+        msg: "GPS module is enabled"
+      when: result.stdout == '0'
+
+    - name: GPS module disabled
+      debug:
+        msg: "GPS module is disabled"
+      when: result.stdout != '0'
+    
+
+    
diff --git a/ansible/tasks/playbook_GPS_sync.yml.unt b/playbooks/playbook_GPS_sync.yml
similarity index 100%
rename from ansible/tasks/playbook_GPS_sync.yml.unt
rename to playbooks/playbook_GPS_sync.yml
diff --git a/ansible/tasks/playbook_NIC_config.yml b/playbooks/playbook_NIC_config.yml
similarity index 72%
rename from ansible/tasks/playbook_NIC_config.yml
rename to playbooks/playbook_NIC_config.yml
index e3a316a..c73fb9b 100644
--- a/ansible/tasks/playbook_NIC_config.yml
+++ b/playbooks/playbook_NIC_config.yml
@@ -1,3 +1,4 @@
+# Copies network interfaces naming scheme (based on physical usb location)
 - hosts: sniffers
   become: yes
   become_user: root
@@ -8,5 +9,5 @@
 
    - name: Copy new rules to identify interfaces based on USB positions
      copy:
-      src: "{{ playbook_dir }}/../../files/72-wlan-geo-dependent.rules"
+      src: "../files/72-wlan-geo-dependent.rules"
       dest: /etc/udev/rules.d/72-wlan-geo-dependent.rules
diff --git a/ansible/tasks/playbook_SSH_keygen.yml.unt b/playbooks/playbook_SSH_keygen.yml.unt
similarity index 86%
rename from ansible/tasks/playbook_SSH_keygen.yml.unt
rename to playbooks/playbook_SSH_keygen.yml.unt
index c369424..cd32451 100644
--- a/ansible/tasks/playbook_SSH_keygen.yml.unt
+++ b/playbooks/playbook_SSH_keygen.yml.unt
@@ -1,3 +1,5 @@
+# Why do we need to get public key of remote nodes ?
+# (and why not give all nodes OUR (master) public key instead ?)
 - name: Exchange Keys between servers
   hosts: sniffers
   tasks:
diff --git a/playbooks/playbook_interfaces_status b/playbooks/playbook_interfaces_status
new file mode 100644
index 0000000..6664c6a
--- /dev/null
+++ b/playbooks/playbook_interfaces_status
@@ -0,0 +1,32 @@
+- hosts: all
+  gather_facts: true
+  become: yes
+  become_user: root
+
+  vars:
+    active_interfaces: "{{ ansible_interfaces | reject('==', 'lo') | reject('==', 'eth0') }}"
+
+    interfaces_list_raw: >-
+      {{
+        hostvars[inventory_hostname]
+        | dict2items
+        | selectattr('value.device', 'defined')
+        | selectattr('value.device', 'in', active_interfaces)
+        | map(attribute='value')
+      }}
+
+    interface_query: >-
+      [].[device, macaddress]
+
+    interfaces_formated_list: >-
+      {{ interfaces_list_raw | json_query(interface_query) | map('join', ': ') }}
+
+  tasks:
+#Interfaces status
+    - name: Interfaces connected
+      debug:
+        #var: interfaces_formated_list
+        msg: "Interfaces: {{ interfaces_formated_list }}"
+    
+
+    
diff --git a/playbooks/playbook_service_status b/playbooks/playbook_service_status
new file mode 100644
index 0000000..6fa3e75
--- /dev/null
+++ b/playbooks/playbook_service_status
@@ -0,0 +1,33 @@
+- hosts: sniffers
+  gather_facts: false
+  user: gta
+  become: yes
+  become_user: root
+
+  tasks:
+
+#Services status
+    - name: Check time sync service status
+      systemd:
+        name: "chronyd.service"
+      register: chrony_service
+
+    - name: Check gpsd_scoket status
+      systemd:
+        name: "gpsd.socket"
+      register: gpsd_socket
+
+    - name: Check gpsd_sservice status
+      systemd:
+        name: "gpsd.service"
+      register: gpsd_service
+
+    - name: Check networking status
+      systemd:
+        name: "networking.service"
+      register: networking_service
+
+    - name: Service status
+      debug:
+        #var: gpsd_socket.status.ActiveState
+        msg: "chrony: {{ chrony_service.status.ActiveState }}, gpsd socket: {{ gpsd_socket.status.ActiveState }}, gpsd service: {{ gpsd_service.status.ActiveState }}, networking: {{ networking_service.status.ActiveState }}"
diff --git a/playbooks/playbook_test b/playbooks/playbook_test
new file mode 100644
index 0000000..937ae50
--- /dev/null
+++ b/playbooks/playbook_test
@@ -0,0 +1,4 @@
+- import_playbook: playbook_interfaces_status
+- import_playbook: playbook_GPIO_status
+- import_playbook: playbook_service_status
+- import_playbook: playbook_time
\ No newline at end of file
diff --git a/playbooks/playbook_time b/playbooks/playbook_time
new file mode 100644
index 0000000..4560766
--- /dev/null
+++ b/playbooks/playbook_time
@@ -0,0 +1,16 @@
+- hosts: sniffers
+  #gather_facts: false
+  user: gta
+  become: yes
+  become_user: root
+  tasks:
+    - name: date
+      command: date
+      register: result_date
+
+    - name: Time verification
+      debug:
+        msg: "Date and time: {{ result_date.stdout }}"
+    
+
+    
diff --git a/playbooks/ssh_setup.yml b/playbooks/ssh_setup.yml
new file mode 100644
index 0000000..b1d7350
--- /dev/null
+++ b/playbooks/ssh_setup.yml
@@ -0,0 +1,56 @@
+# This script generates a private key, then pushes it to all nodes
+- name: Set up login-less controls (run once !)
+  hosts: s6
+  vars_prompt:
+  vars:
+    ansible_host_key_checking: False
+
+    - name: _username
+      prompt: Enter the nodes' username
+      private: no
+
+
+  tasks:
+    - name: Install sshpass and keychain to master device
+      tags: ssh-setup ssh-keygen config keychain sshpass master
+      apt:
+        pkg:
+          - sshpass # for the first login into nodes, using password auth
+          - keychain # to load the private key when opening a terminal
+      delegate_to: 127.0.0.1
+      run_once: True
+      when: false
+
+
+    - name: SSH KeyGen command on master device
+      tags: ssh-setup ssh-keygen config master
+      shell:
+        cmd: ssh-keygen -q -b 2048 -t rsa -N "" -C "master sniffer ssh access" -f ~/.ssh/id_sniffer
+        creates: "~/.ssh/id_sniffer"
+      delegate_to: 127.0.0.1
+      run_once: True
+      register: ssh_keygen_result
+
+
+    - name: Copy the master's public key and add to nodes' authorized_keys
+      tags: ssh-setup config ssh-copy nodes
+      authorized_key:
+        user: "{{_username}}"
+        key: "{{ lookup('file','~/.ssh/id_sniffer.pub')}}"
+
+    - name: keygen failure status check
+      tags: ssh-setup config keychain master
+      debug:
+        msg: "~/.ssh/id_sniffer already existed before, so your bashrc might already have been written to before. If you're unsure about this, check that the end of your ~/.bashrc contains `keychain --eval --quiet id_sniffer`. \nNext task will be skipped."
+      delegate_to: 127.0.0.1
+      run_once: True
+      when: ssh_keygen_result.stdout.find('skipped') == 0 | default(false)
+
+    - name: Set up keychain inside .bashrc
+      tags: ssh-setup config keychain master
+      shell:
+        cmd: echo "eval \$(keychain --eval --quiet id_sniffer)" >> ~/.bashrc; eval \$(keychain --eval --quiet id_sniffer)
+      delegate_to: 127.0.0.1
+      run_once: True
+      when: ssh_keygen_result.stdout.find('skipped') == -1 | default(true)
+
diff --git a/ansible/tasks/playbook_scapy-sniffer_GPS.yml b/playbooks/start_sens_sniffer.yml
similarity index 72%
rename from ansible/tasks/playbook_scapy-sniffer_GPS.yml
rename to playbooks/start_sens_sniffer.yml
index 970435b..0c10545 100644
--- a/ansible/tasks/playbook_scapy-sniffer_GPS.yml
+++ b/playbooks/start_sens_sniffer.yml
@@ -1,11 +1,12 @@
-- hosts: sniffers
+# Start the sniffer. SUpports multiple sniffers and starting channels
+- hosts: s5
   #become: yes
   #become_user: root
 
   vars_prompt:
 
     - name: _workdir
-      prompt: Enter the folder name to save traces in the sniffer
+      prompt: Enter the folder where the script is and results will be
       default: "/home/tribe/mitik-sens-mod/"
       private: no
     # This will always be the mitik-sens-mod folder
@@ -17,14 +18,17 @@
 
     - name: _hour
       prompt: Enter an hour to start the experiment
+      default: "{{ lookup('pipe', 'date -d \"+15 minutes\" +%H') }}"
       private: no
 
     - name: _minute
       prompt: Enter minutes to start the experiment
+      default: "{{ lookup('pipe', 'date -d \"+15 minutes\" +%M') }}"
       private: no
 
     - name: _timeout
       prompt: Please specify the runtime duration in sec
+      default: 3600
       private: no
 
     - name: _interfaces_csv
@@ -42,9 +46,15 @@
       default: 1
       private: no
 
+    - name: _channel_hopping
+      prompt: Interval of channel hopping in seconds. Enter for 0 (no hopping) (by default)
+      default: 0
+      private: no
+
+
     - name: _hash_function
       prompt: Please specify the hash function (None, MD5, SHA256). For default just press enter
-      default: 'MD5'
+      default: 'SHA256'
       private: no
 
     - name: _hash_pattern
@@ -67,18 +77,13 @@
       run_once: True
 
 
-    # - name: Create Folder
-    #   file:
-    #     path: "{{ _workdir }}"
-    #     owner: tribe
-    #     group: tribe
-    #     #mode: 0755
-    #     state: directory
 
-    - name: start scapy-sniffer
+    - name: start sens-sniffer
       cron:
-        name: "ansible_scapy-sniffer {{ _hour }} {{ _minute }} {{ item }}"
+        name: "ansible_sens_sniffer {{ _hour }} {{ _minute }} {{ item }}"
         minute: "{{ _minute }}"
         hour: "{{ _hour }}"
-        job: "cd {{_workdir}}; sudo python ./sniffer.py -s {{_timeout}} -i {{item}} -c {{}} -sf {{_filter}} -p {{_hash_pattern}} -e {{_hash_function}}"
+        job: "cd {{_workdir}}; sudo python ./sniffer.py -s {{_timeout}} -i {{item}} -c {{_channels[my_idx]}} -j {{_channel_hopping}} -sf {{_filter}} -p {{_hash_pattern}} -e {{_hash_function}}"
       loop: "{{_interfaces}}"
+      loop_control:
+        index_var: my_idx
diff --git a/playbooks/stop_sens_sniffer.yml b/playbooks/stop_sens_sniffer.yml
new file mode 100644
index 0000000..d47978d
--- /dev/null
+++ b/playbooks/stop_sens_sniffer.yml
@@ -0,0 +1,19 @@
+- name: Stop and abort future sniffing activity
+  hosts: sniffers
+  tasks:
+    - name: List active snifing crontabs
+      tags: device-setup  config nodes
+      shell: "crontab -l | grep ansible_sens_sniffer | sed 's/#Ansible: //g'"
+      register: crontabs
+
+
+    - name: Disable all crontabs
+      cron:
+        name: "{{item}}"
+        state: absent
+      with_items: "{{crontabs.stdout_lines}}"
+
+
+    - name: Interrupt currently running sniffers
+      shell: pgrep -f "sniffer.py" | xargs kill
+      failed_when: false
diff --git a/results/2024-09-11/ss1/s3/capture-test_azeyuityriuyteuirytuierytuerytuiry.pcap b/results/2024-09-11/ss1/s3/capture-test_azeyuityriuyteuirytuierytuerytuiry.pcap
deleted file mode 100644
index e69de29..0000000
diff --git a/results/ss1_2024-09-11/capture-test_azeyuityriuyteuirytuierytuerytuiry.pcap b/results/ss1_2024-09-11/capture-test_azeyuityriuyteuirytuierytuerytuiry.pcap
deleted file mode 100644
index e69de29..0000000
-- 
GitLab