wazuh / wazuh-qa

Wazuh - Quality Assurance
GNU General Public License v2.0
61 stars 30 forks source link

Test Syscollector v3.11.0 #176

Closed chemamartinez closed 4 years ago

chemamartinez commented 4 years ago

Syscollector test

Version Revision Branch
3.11.0 31100 vuln-windows

Scan

Run a complete Syscollector scan:

Test on:

Configuration

Database

sergiovp commented 4 years ago

I installed Windows agent from the vuln-windows branch, compiled the agent in Linux and generated the MSI installer in Windows from the related branch.

Check interval option Windows Server 2019

Test example 1.


Example Syscollector configuration:

<!-- System inventory -->
  <wodle name="syscollector">
    <disabled>no</disabled>
    <interval>2m</interval>
    <scan_on_start>yes</scan_on_start>
    <hardware>yes</hardware>
    <os>yes</os>
    <network>yes</network>
    <packages>yes</packages>
    <ports all="no">yes</ports>
    <processes>yes</processes>
  </wodle>

Logs:

2019/10/03 16:38:26 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/03 16:38:28 wazuh-modulesd:syscollector: INFO: Evaluation finished.
2019/10/03 16:40:26 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/03 16:40:30 wazuh-modulesd:syscollector: INFO: Evaluation finished.
2019/10/03 16:42:26 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/03 16:42:28 wazuh-modulesd:syscollector: INFO: Evaluation finished.
2019/10/03 16:44:26 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/03 16:44:27 wazuh-modulesd:syscollector: INFO: Evaluation finished.

As we can see, we get a log report every 2 minutes as I have specified on the configuration.

On /var/ossec/queue/db/Agent_ID.db we can consult datas:

root@Vela-PC:/var/ossec/queue/db# sqlite3 002.db
SQLite version 3.22.0 2018-01-22 18:45:57
Enter ".help" for usage hints.
sqlite> select * from sys_osinfo;
1499646275|2019/10/03 16:50:26|WIN-087251A1RP6|x86_64|Microsoft Windows Server 2019 Standard Evaluation|10.0.17763||10|0|17763||||6.2|1809

In this case, I consulted Agent's OS version.

2 minutes after, information has been updated:

sqlite> select * from sys_osinfo;
201478398|2019/10/03 16:52:27|WIN-087251A1RP6|x86_64|Microsoft Windows Server 2019 Standard Evaluation|10.0.17763||10|0|17763||||6.2|1809

Until two minutes pass, we won't see it updated:

590786551|2019/10/03 16:54:26|WIN-087251A1RP6|x86_64|Microsoft Windows Server 2019 Standard Evaluation|10.0.17763||10|0|17763||||6.2|1809
sqlite> select * from sys_osinfo;
590786551|2019/10/03 16:54:26|WIN-087251A1RP6|x86_64|Microsoft Windows Server 2019 Standard Evaluation|10.0.17763||10|0|17763||||6.2|1809
sqlite> select * from sys_osinfo;
590786551|2019/10/03 16:54:26|WIN-087251A1RP6|x86_64|Microsoft Windows Server 2019 Standard Evaluation|10.0.17763||10|0|17763||||6.2|1809
sqlite> select * from sys_osinfo;
742871911|2019/10/03 16:56:26|WIN-087251A1RP6|x86_64|Microsoft Windows Server 2019 Standard Evaluation|10.0.17763||10|0|17763||||6.2|1809

Test example 2.

We are going to modify syscollector configuration changing interval option by <interval>3m</interval>.

As expected, we get a log report on the agent's log every 3 minutes:

2019/10/03 17:10:35 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/03 17:10:39 wazuh-modulesd:syscollector: INFO: Evaluation finished.
2019/10/03 17:13:35 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/03 17:13:38 wazuh-modulesd:syscollector: INFO: Evaluation finished.
2019/10/03 17:16:35 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/03 17:16:37 wazuh-modulesd:syscollector: INFO: Evaluation finished.
2019/10/03 17:19:35 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/03 17:19:37 wazuh-modulesd:syscollector: INFO: Evaluation finished.

Also, we get our tables updated every 3 minutes on our manager:

sqlite> select * from sys_osinfo;
88309208|2019/10/03 17:25:35|WIN-087251A1RP6|x86_64|Microsoft Windows Server 2019 Standard Evaluation|10.0.17763||10|0|17763||||6.2|1809
sqlite> select * from sys_osinfo;
491023145|2019/10/03 17:28:36|WIN-087251A1RP6|x86_64|Microsoft Windows Server 2019 Standard Evaluation|10.0.17763||10|0|17763||||6.2|1809
sqlite> select * from sys_osinfo;
1066222077|2019/10/03 17:31:35|WIN-087251A1RP6|x86_64|Microsoft Windows Server 2019 Standard Evaluation|10.0.17763||10|0|17763||||6.2|1809

Extra test.

If we configure a minor interval than 1 minute, such as <interval>5s</interval>, we effectivelly are going to see a log report every 5 second:

2019/10/03 17:40:30 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/03 17:40:35 wazuh-modulesd:syscollector: INFO: Evaluation finished.
2019/10/03 17:40:35 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/03 17:40:37 wazuh-modulesd:syscollector: INFO: Evaluation finished.
2019/10/03 17:40:40 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/03 17:40:43 wazuh-modulesd:syscollector: INFO: Evaluation finished.
2019/10/03 17:40:45 wazuh-modulesd:syscollector: INFO: Starting evaluation.

However, we are not going to be able to see our tables updated from the manager terminal because the database hasn't got enough time to "commit" updates.

We can see it from the Wazuh-API or stopping and restarting the manager.


In shorts, it works as expected.

sergiovp commented 4 years ago

Send a Syscollector configuration by the shared conf. Windows Server 2019

To do this test, my Windows agent belongs to the default group, so I edited the /var/ossec/shared/default/agent.conf file as follows:

<agent_config>
  <wodle name="syscollector">
    <disabled>no</disabled>
    <interval>2m</interval>
    <scan_on_start>yes</scan_on_start>
    <hardware>yes</hardware>
    <os>yes</os>
    <network>yes</network>
    <packages>yes</packages>
    <ports all="no">yes</ports>
    <processes>yes</processes>
  </wodle>
</agent_config>

Actually, on the agent's ossec.conf, I have the interval option in 1 hours.

First, I checked if the file had any error:

verify-agent-conf: Verifying [/var/ossec/etc/shared/default/agent.conf]
verify-agent-conf: OK

I restarted the manager in addition to get agent.conf file available to the agents more quickly. I verified if the agent was synchronized:

root@Vela-PC:/home/vela# /var/ossec/bin/agent_groups -S -i 001
Agent '001' is synchronized.

I restarted the agent:

root@Vela-PC:/home/vela# /var/ossec/bin/agent_control -R -u 001

Wazuh agent_control: Restarting agent: 001

Syscollector new configuration supposed to be updated, let's see if it worked:

sqlite> select * from sys_osinfo; 1866113568|2019/10/04 09:07:12|WIN-087251A1RP6|x86_64|Microsoft Windows Server 2019 Standard Evaluation|10.0.17763||10|0|17763||||6.2|1809

sqlite> select * from sys_osinfo; 491103323|2019/10/04 09:09:12|WIN-087251A1RP6|x86_64|Microsoft Windows Server 2019 Standard Evaluation|10.0.17763||10|0|17763||||6.2|1809



As we can see, previously we had a diferent Syscollector configuration which has been updated remotelly with the `agent.conf`.

---
It worked as expected.

---
sergiovp commented 4 years ago

Testing diferent options. Windows Server 2019

sergiovp commented 4 years ago

Database tests. Windows Server 2019

Upgrade from a version older than v3.8.0. The databases at queue/db/ must be updated.

To do this test, I have installed Wazuh manager 3.7.

Wazuh v3.7.3 (Rev. 3728) Installation Script - http://www.wazuh.com

 You are about to start the installation process of Wazuh.
 You must have a C compiler pre-installed in your system.

  - System: Linux Vela-PC 4.15.0-64-generic (linuxmint 19.2)
  - User: root
  - Host: Vela-PC

I had to install Wazuh agent 3.7 too in Windows. image

Here, we can see the DB:

root@Vela-PC:/var/ossec/queue/db# ls -l --full-time
total 5020
-rw-r----- 1 ossec ossec 2256896 2019-10-04 11:05:59.698816866 +0200 000.db
-rw-r----- 1 ossec ossec   32768 2019-10-04 11:08:41.525487126 +0200 000.db-shm
-rw-r----- 1 ossec ossec 2517352 2019-10-04 11:08:41.349484258 +0200 000.db-wal
-rw-r----- 1 ossec ossec  147456 2019-10-04 11:13:02.621677721 +0200 001.db
-rw-r----- 1 ossec ossec   32768 2019-10-04 11:16:53.845309245 +0200 001.db-shm
-rw-r----- 1 ossec ossec  148352 2019-10-04 11:16:58.033374529 +0200 001.db-wal
srw-rw---- 1 ossec ossec       0 2019-10-04 11:06:00.770834794 +0200 wdb

Now I'm going to update the manager to the related brach and check if the DB is updated.

root@Vela-PC:/var/ossec/queue/db# ls
000.db  000.db-shm  000.db-wal  001.db  001.db-shm  001.db-wal  wdb

root@Vela-PC:/var/ossec/queue/db# sqlite3 001.db
SQLite version 3.22.0 2018-01-22 18:45:57
Enter ".help" for usage hints.
sqlite> .tables
ciscat_results        sca_policy            sys_netproto        
fim_entry             sca_scan_info         sys_osinfo          
metadata              scan_info             sys_ports           
pm_event              sys_hotfixes          sys_processes       
sca_check             sys_hwinfo            sys_programs        
sca_check_compliance  sys_netaddr           vuln_metadata       
sca_check_rules       sys_netiface

As we can see, we have the DB created and we have vuln_metadata table into our agent's DB, it means that the DB has been updated correctly.

Check that Syscollector info has been stored in the DB of the agent (queue/db/xxx.db).

In the previous tests, we have seen how it works:

root@Vela-PC:/var/ossec/queue/db# /var/ossec/bin/agent_control -l

Wazuh agent_control. List of available agents:
   ID: 000, Name: Vela-PC (server), IP: 127.0.0.1, Active/Local
   ID: 001, Name: WIN-087251A1RP6, IP: 192.168.0.150, Active

List of agentless devices:

root@Vela-PC:/var/ossec/queue/db# ls
000.db  000.db-shm  000.db-wal  001.db  001.db-shm  001.db-wal  wdb

We have our Windows agent which ID is 001 and how Syscollector info has been stored in the agent's DB. 001.db 001.db-shm 001.db-wal.

Check that a new scan deletes the previous scan from the DB. [Search by scan_id].

sqlite> select scan_id from sys_hwinfo;
1561502522
sqlite> select scan_id from sys_hwinfo;
1962231651

As we can see, a new scan deletes the previous scan.

Delete the DB of an agent (file 001.db for example) and send a new scan. Is the scan received? Is the DB restored when the manager is restarted?

root@Vela-PC:/var/ossec/queue/db# ls
000.db  000.db-shm  000.db-wal  001.db  001.db-shm  001.db-wal  wdb
root@Vela-PC:/var/ossec/queue/db# rm 001*
root@Vela-PC:/var/ossec/queue/db# ls
000.db  000.db-shm  000.db-wal  wdb
root@Vela-PC:/var/ossec/queue/db# systemctl restart wazuh-manager
root@Vela-PC:/var/ossec/queue/db# ls
000.db  000.db-shm  000.db-wal  001.db  001.db-shm  001.db-wal  wdb
root@Vela-PC:/var/ossec/queue/db# sqlite3 001.db
SQLite version 3.22.0 2018-01-22 18:45:57
Enter ".help" for usage hints.
sqlite> select * from sys_hwinfo;
769101749|2019/10/04 10:35:02|0|Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz|1|2195.0|2096692|1068284|49

As we can see, after removing agent's DB and restanting the manager, the scan is received and the DB restored.


It worked as expected.


sergiovp commented 4 years ago

I installed Windows agent from the vuln-windows branch, compiled the agent in Linux and generated the MSI installer in Windows from the related branch.

Check interval option Windows XP

Test example 1.

Example Syscollector configuration:

<!-- System inventory -->
  <wodle name="syscollector">
    <disabled>no</disabled>
    <interval>2m</interval>
    <scan_on_start>yes</scan_on_start>
    <hardware>yes</hardware>
    <os>yes</os>
    <network>yes</network>
    <packages>yes</packages>
    <ports all="no">yes</ports>
    <processes>yes</processes>
  </wodle>

Agent's logs:

2019/10/07 03:33:02 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/07 03:33:09 wazuh-modulesd:syscollector: INFO: Evaluation finished.
2019/10/07 03:35:02 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/07 03:35:06 wazuh-modulesd:syscollector: INFO: Evaluation finished.

Consult to the DB:

sqlite> select * from sys_osinfo;
5327162|2019/10/07 03:33:04|VELA-346A03F82A|i686|Microsoft Windows XP|5.1.2600||5|1|2600||||5.1
sqlite> select * from sys_osinfo;
206238926|2019/10/07 03:35:02|VELA-346A03F82A|i686|Microsoft Windows XP|5.1.2600||5|1|2600||||5.1

As we can see, we get updated DB's tables every two minutes as we have specified in the configuration.

Test example 2.

We are going to modify syscollector configuration changing interval option by 3m.

As expected, we get a log report on the agent's log every 3 minutes:

2019/10/07 03:48:36 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/07 03:48:40 wazuh-modulesd:syscollector: INFO: Evaluation finished.
2019/10/07 03:51:36 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/07 03:51:42 wazuh-modulesd:syscollector: INFO: Evaluation finished.

Also, we get our tables updated every 3 minutes on our manager:

sqlite> select * from sys_osinfo;
998799179|2019/10/07 03:48:36|VELA-346A03F82A|i686|Microsoft Windows XP|5.1.2600||5|1|2600||||5.1
sqlite> select * from sys_osinfo;
190887807|2019/10/07 03:51:36|VELA-346A03F82A|i686|Microsoft Windows XP|5.1.2600||5|1|2600||||5.1

It works as expected. Interval option works well more than the very first time.

sergiovp commented 4 years ago

Send a Syscollector configuration by the shared conf. Windows XP

Actually, on the agent's ossec.conf, this is my syscollector configuration:

<!-- System inventory -->
  <wodle name="syscollector">
    <disabled>yes</disabled>
    <interval>5m</interval>
    <scan_on_start>yes</scan_on_start>
    <hardware>yes</hardware>
    <os>yes</os>
    <network>yes</network>
    <packages>yes</packages>
    <ports all="no">yes</ports>
    <processes>yes</processes>
  </wodle>

Syscollector is disabled. Let's enable it from the manager and change the interval option from 5m to 2m.

agent.conf file configuration:

<wodle name="syscollector">
    <disabled>no</disabled>
    <interval>2m</interval>
    <scan_on_start>yes</scan_on_start>
    <hardware>yes</hardware>
    <os>yes</os>
    <network>yes</network>
    <packages>yes</packages>
    <ports all="no">yes</ports>
    <processes>yes</processes>
  </wodle>

Syscollector new configuration supposed to be updated, let's see if it worked: Agent's logs:

2019/10/07 03:57:32 wazuh-modulesd:syscollector: INFO: Module disabled. Exiting...

...

2019/10/07 04:02:52 wazuh-modulesd:syscollector: INFO: Module started.

2019/10/07 04:06:53 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/07 04:06:59 wazuh-modulesd:syscollector: INFO: Evaluation finished.
2019/10/07 04:08:53 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/07 04:08:58 wazuh-modulesd:syscollector: INFO: Evaluation finished.

Consult to the DB:

sqlite> select * from sys_osinfo;
181796598|2019/10/07 04:06:53|VELA-346A03F82A|i686|Microsoft Windows XP|5.1.2600||5|1|2600||||5.1
sqlite> select * from sys_osinfo;
122096704|2019/10/07 04:08:53|VELA-346A03F82A|i686|Microsoft Windows XP|5.1.2600||5|1|2600||||5.1

As we can see, we have enabled syscollector remotelly by the shared conf. It works as expected.

sergiovp commented 4 years ago

Testing diferent options. Windows XP

sergiovp commented 4 years ago

Database tests. Windows XP

Upgrade from a version older than v3.8.0. The databases at queue/db/ must be updated.

Check that Syscollector info has been stored in the DB of the agent (queue/db/xxx.db).

root@Vela-PC:/var/ossec/queue/db# /var/ossec/bin/manage_agents -l

Available agents: 
   ID: 003, Name: vela-346a03f82a, IP: 192.168.0.99

root@Vela-PC:/var/ossec/queue/db# ls
000.db  000.db-shm  000.db-wal  003.db  003.db-shm  003.db-wal  wdb

Syscollector info has been stored in 003.db which is the DB of our agent.

Check that a new scan deletes the previous scan from the DB. [Search by scan_id].

sqlite> select scan_id from sys_ports;
970693641
970693641
970693641
970693641
970693641
sqlite> select scan_id from sys_ports;
1606040628
1606040628
1606040628
1606040628
1606040628

A new scan deletes the previous one.

Delete the DB of an agent (file 001.db for example) and send a new scan. Is the scan received? Is the DB restored when the manager is restarted?

root@Vela-PC:/var/ossec/queue/db# ls
000.db  000.db-shm  000.db-wal  003.db  003.db-shm  003.db-wal  wdb
root@Vela-PC:/var/ossec/queue/db# rm 003.db*
root@Vela-PC:/var/ossec/queue/db# ls
000.db  000.db-shm  000.db-wal  wdb
root@Vela-PC:/var/ossec/queue/db# systemctl restart wazuh-manager
root@Vela-PC:/var/ossec/queue/db# ls
000.db  000.db-shm  000.db-wal  003.db  003.db-shm  003.db-wal  wdb
root@Vela-PC:/var/ossec/queue/db# sqlite3 003.db
SQLite version 3.22.0 2018-01-22 18:45:57
Enter ".help" for usage hints.
sqlite> select * from sys
sys_hotfixes   sys_netaddr    sys_netproto   sys_ports      sys_programs   
sys_hwinfo     sys_netiface   sys_osinfo     sys_processes  sysname        
sqlite> select * from sys_hwinfo;
481523585|2019/10/07 23:38:48|0|Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz|1|2194.0|523760|372588|28

The scan is received after deleting the agent's DB and restarting the manager.

Test worked as expected.

sergiovp commented 4 years ago

I installed Windows agent from the vuln-windows branch, compiled the agent in Linux and generated the MSI installer in Windows from the related branch.

Check interval option Windows Server 2003

Test example 1.

Example Syscollector configuration:

<wodle name="syscollector">
    <disabled>no</disabled>
    <interval>2m</interval>
    <scan_on_start>yes</scan_on_start>
    <hardware>yes</hardware>
    <os>yes</os>
    <network>yes</network>
    <packages>yes</packages>
    <ports all="no">yes</ports>
    <processes>yes</processes>
  </wodle>

Logs:

2019/10/08 10:49:43 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/08 10:49:44 wazuh-modulesd:syscollector: INFO: Evaluation finished.
2019/10/08 10:51:43 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/08 10:51:46 wazuh-modulesd:syscollector: INFO: Evaluation finished.

DB:

sqlite> select * from sys_osinfo;
1664284770|2019/10/08 10:49:43|VELA-WS2003|i686|Microsoft Windows Server 2003|5.2.3790||5|2|3790||||5.2|sp1
sqlite> select * from sys_osinfo;
216318917|2019/10/08 10:51:43|VELA-WS2003|i686|Microsoft Windows Server 2003|5.2.3790||5|2|3790||||5.2|sp1

Test example 2.

We are going to modify syscollector configuration changing interval option by 3m.

As expected, we get a log report on the agent's log every 3 minutes:

2019/10/08 11:00:06 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/08 11:00:07 wazuh-modulesd:syscollector: INFO: Evaluation finished.
2019/10/08 11:03:06 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/08 11:03:07 wazuh-modulesd:syscollector: INFO: Evaluation finished.
2019/10/08 11:06:06 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/08 11:06:07 wazuh-modulesd:syscollector: INFO: Evaluation finished.

Also, we get our tables updated every 3 minutes on our manager:

sqlite> select * from sys_osinfo;
79339549|2019/10/08 11:00:06|VELA-WS2003|i686|Microsoft Windows Server 2003|5.2.3790||5|2|3790||||5.2|sp1
sqlite> select * from sys_osinfo;
1153414919|2019/10/08 11:03:06|VELA-WS2003|i686|Microsoft Windows Server 2003|5.2.3790||5|2|3790||||5.2|sp1
sqlite> select * from sys_osinfo;
34495637|2019/10/08 11:06:06|VELA-WS2003|i686|Microsoft Windows Server 2003|5.2.3790||5|2|3790||||5.2|sp1

Interval option runs as expected more than the very first time.

sergiovp commented 4 years ago

Send a Syscollector configuration by the shared conf. Windows Server 2003

Actually, on the agent's ossec.conf, this is my syscollector configuration:

<wodle name="syscollector">
    <disabled>yes</disabled>
    <interval>3m</interval>
    <scan_on_start>yes</scan_on_start>
    <hardware>yes</hardware>
    <os>yes</os>
    <network>yes</network>
    <packages>yes</packages>
    <ports all="no">yes</ports>
    <processes>yes</processes>
  </wodle>

Syscollector is disabled. Let's enable it from the manager and change the interval option from 3m to 2m. 2019/10/08 11:10:45 wazuh-modulesd:syscollector: INFO: Module disabled. Exiting...

agent.conf file configuration:

<agent_config>

  <!-- Shared agent configuration here -->
  <wodle name="syscollector">
    <disabled>no</disabled>
    <interval>2m</interval>
    <scan_on_start>yes</scan_on_start>
    <hardware>yes</hardware>
    <os>yes</os>
    <network>yes</network>
    <packages>yes</packages>
    <ports all="no">yes</ports>
    <processes>yes</processes>
  </wodle>

</agent_config>

After restart the agent from the manager:

2019/10/08 11:13:18 wazuh-modulesd:syscollector: INFO: Module started.

2019/10/08 11:15:19 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/08 11:15:21 wazuh-modulesd:syscollector: INFO: Evaluation finished.
2019/10/08 11:17:19 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/08 11:17:20 wazuh-modulesd:syscollector: INFO: Evaluation finished.
sqlite> select * from sys_hwinfo;
572775596|2019/10/08 11:15:21|0|Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz|1|2195.0|523736|383576|26
sqlite> select * from sys_hwinfo;
712453476|2019/10/08 11:17:19|0|Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz|1|2195.0|523736|383028|26

As we can see, previously we had a diferent Syscollector configuration which has been updated remotelly with the agent.conf.

It worked as expected.

sergiovp commented 4 years ago

Testing diferent options. Windows Server 2003

sergiovp commented 4 years ago

Database tests. Windows Server 2003

Upgrade from a version older than v3.8.0. The databases at queue/db/ must be updated.

sqlite> .tables
ciscat_results  pm_event        sys_netaddr     sys_osinfo      sys_programs  
fim_entry       scan_info       sys_netiface    sys_ports     
metadata        sys_hwinfo      sys_netproto    sys_processes

In this version we don't have vuln_metadata table in our DB. Let's upgrade our manager and agent to the related branch version.

sqlite> .tables
ciscat_results        sca_policy            sys_netproto        
fim_entry             sca_scan_info         sys_osinfo          
metadata              scan_info             sys_ports           
pm_event              sys_hotfixes          sys_processes       
sca_check             sys_hwinfo            sys_programs        
sca_check_compliance  sys_netaddr           vuln_metadata       
sca_check_rules       sys_netiface

Now we have vuln_metadata table, so the DB has been updated correctly.

Check that Syscollector info has been stored in the DB of the agent (queue/db/xxx.db).

root@Vela-PC:/var/ossec/queue/db# /var/ossec/bin/agent_control -l

Wazuh agent_control. List of available agents:
   ID: 000, Name: Vela-PC (server), IP: 127.0.0.1, Active/Local
   ID: 001, Name: vela-ws2003, IP: 192.168.0.99, Active

List of agentless devices:

root@Vela-PC:/var/ossec/queue/db# ls
000.db  000.db-shm  000.db-wal  001.db  001.db-shm  001.db-wal  wdb
root@Vela-PC:/var/ossec/queue/db# sqlite3 001.db
SQLite version 3.22.0 2018-01-22 18:45:57
Enter ".help" for usage hints.
sqlite> select * from sys_hwinfo;
515554477|2019/10/08 11:31:19|0|Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz|1|2195.0|523736|381444|27

Check that a new scan deletes the previous scan from the DB. [Search by scan_id].

sqlite> select scan_id from sys_osinfo;
1331196117

sqlite> select scan_id from sys_osinfo;
159005284

Delete the DB of an agent (file 001.db for example) and send a new scan. Is the scan received? Is the DB restored when the manager is restarted?

root@Vela-PC:/var/ossec/queue/db# ls
000.db  000.db-shm  000.db-wal  001.db  001.db-shm  001.db-wal  wdb
root@Vela-PC:/var/ossec/queue/db# rm 001*
root@Vela-PC:/var/ossec/queue/db# ls
000.db  000.db-shm  000.db-wal  wdb
root@Vela-PC:/var/ossec/queue/db# systemctl restart wazuh-manager
root@Vela-PC:/var/ossec/queue/db# ls
000.db  000.db-shm  000.db-wal  001.db  001.db-shm  001.db-wal  wdb

sqlite> select * from sys_osinfo;
1331196117|2019/10/08 11:29:19|VELA-WS2003|i686|Microsoft Windows Server 2003|5.2.3790||5|2|3790||||5.2|sp1

after removing agent's DB and restanting the manager, the scan is received and the DB restored.

It worked as expected.

sergiovp commented 4 years ago

Check interval option CentOS 5

Example Syscollector configuration:

<!-- System inventory -->
  <wodle name="syscollector">
    <disabled>no</disabled>
    <interval>2m</interval>
    <scan_on_start>yes</scan_on_start>
    <hardware>yes</hardware>
    <os>yes</os>
    <network>yes</network>
    <packages>yes</packages>
    <ports all="no">yes</ports>
    <processes>yes</processes>
  </wodle>

Logs:

2019/10/09 12:10:49 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/09 12:10:53 wazuh-modulesd:syscollector: INFO: Evaluation finished.
2019/10/09 12:12:49 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/09 12:12:52 wazuh-modulesd:syscollector: INFO: Evaluation finished.
2019/10/09 12:14:49 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/09 12:14:53 wazuh-modulesd:syscollector: INFO: Evaluation finished.

Consults:

1875027997|2019/10/09 12:10:49|centos5|x86_64|CentOS Linux|5.11||5|11||centos|Linux|2.6.18-419.el5.centos.plus|#1 SMP Sat Feb 25 15:50:12 UTC 2017|
sqlite> select * from sys_osinfo;
66869581|2019/10/09 12:12:49|centos5|x86_64|CentOS Linux|5.11||5|11||centos|Linux|2.6.18-419.el5.centos.plus|#1 SMP Sat Feb 25 15:50:12 UTC 2017|
sqlite> select * from sys_osinfo;
904897234|2019/10/09 12:14:49|centos5|x86_64|CentOS Linux|5.11||5|11||centos|Linux|2.6.18-419.el5.centos.plus|#1 SMP Sat Feb 25 15:50:12 UTC 2017|

Change interval option from 2m to 3m.

Logs:

2019/10/09 12:18:02 wazuh-modulesd:syscollector: INFO: Module started.
2019/10/09 12:18:03 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/09 12:18:06 wazuh-modulesd:syscollector: INFO: Evaluation finished.
2019/10/09 12:21:03 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/09 12:21:08 wazuh-modulesd:syscollector: INFO: Evaluation finished.

Consults:

sqlite> select * from sys_osinfo;
88335618|2019/10/09 12:18:03|centos5|x86_64|CentOS Linux|5.11||5|11||centos|Linux|2.6.18-419.el5.centos.plus|#1 SMP Sat Feb 25 15:50:12 UTC 2017|
105581116|2019/10/09 12:21:04|centos5|x86_64|CentOS Linux|5.11||5|11||centos|Linux|2.6.18-419.el5.centos.plus|#1 SMP Sat Feb 25 15:50:12 UTC 2017|

It worked as expected.

sergiovp commented 4 years ago

Send a Syscollector configuration by the shared conf. CentOS 5

ossec.conf configuration:

<!-- System inventory -->
  <wodle name="syscollector">
    <disabled>yes</disabled>
    <interval>3m</interval>
    <scan_on_start>yes</scan_on_start>
    <hardware>yes</hardware>
    <os>yes</os>
    <network>yes</network>
    <packages>yes</packages>
    <ports all="no">yes</ports>
    <processes>yes</processes>
  </wodle>

As we can see, syscollector is disabled:

2019/10/09 12:24:03 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/09 12:24:07 wazuh-modulesd:syscollector: INFO: Evaluation finished.
2019/10/09 12:24:28 wazuh-modulesd:syscollector: INFO: Module finished.
2019/10/09 12:24:30 wazuh-modulesd:syscollector: INFO: Module disabled. Exiting...

agent.conf configuration:

<agent_config>
  <!-- Shared agent configuration here -->
  <wodle name="syscollector">
    <disabled>no</disabled>
    <interval>2m</interval>
    <scan_on_start>yes</scan_on_start>
    <hardware>yes</hardware>
    <os>yes</os>
    <network>yes</network>
    <packages>yes</packages>
    <ports all="no">yes</ports>
    <processes>yes</processes>
  </wodle>
</agent_config>

Logs:

2019/10/09 12:27:27 wazuh-modulesd:syscollector: INFO: Module started.
2019/10/09 12:27:28 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/09 12:27:36 wazuh-modulesd:syscollector: INFO: Evaluation finished.
2019/10/09 12:29:28 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/09 12:29:33 wazuh-modulesd:syscollector: INFO: Evaluation finished.
2019/10/09 12:31:28 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2019/10/09 12:31:32 wazuh-modulesd:syscollector: INFO: Evaluation finished.

Consults:

sqlite> select * from sys_osinfo;
1569118939|2019/10/09 12:29:28|centos5|x86_64|CentOS Linux|5.11||5|11||centos|Linux|2.6.18-419.el5.centos.plus|#1 SMP Sat Feb 25 15:50:12 UTC 2017|
158280889|2019/10/09 12:31:28|centos5|x86_64|CentOS Linux|5.11||5|11||centos|Linux|2.6.18-419.el5.centos.plus|#1 SMP Sat Feb 25 15:50:12 UTC 2017|

It worked as expected.

sergiovp commented 4 years ago

Testing diferent options. CentOS 5

It worked as expected.

sergiovp commented 4 years ago

Database tests. CentOS 5

Upgrade from a version older than v3.8.0. The databases at queue/db/ must be updated.

Wazuh v 3.7 tables:

sqlite> .tables
ciscat_results  pm_event        sys_netaddr     sys_osinfo      sys_programs  
fim_entry       scan_info       sys_netiface    sys_ports     
metadata        sys_hwinfo      sys_netproto    sys_processes 

After updating to our brach:

sqlite> .tables
ciscat_results        sca_policy            sys_netproto        
fim_entry             sca_scan_info         sys_osinfo          
metadata              scan_info             sys_ports           
pm_event              sys_hotfixes          sys_processes       
sca_check             sys_hwinfo            sys_programs        
sca_check_compliance  sys_netaddr           vuln_metadata       
sca_check_rules       sys_netiface

Check that Syscollector info has been stored in the DB of the agent (queue/db/xxx.db).

root@Vela-PC:/var/ossec/queue/db# /var/ossec/bin/agent_control -l

Wazuh agent_control. List of available agents:
   ID: 000, Name: Vela-PC (server), IP: 127.0.0.1, Active/Local
   ID: 001, Name: centos5, IP: 10.0.0.1, Active

List of agentless devices:

root@Vela-PC:/var/ossec/queue/db# sqlite3 001.db
SQLite version 3.22.0 2018-01-22 18:45:57
Enter ".help" for usage hints.
sqlite> select * from sys_osinfo;
47141211|2019/10/09 13:01:28|centos5|x86_64|CentOS Linux|5.11||5|11||centos|Linux|2.6.18-419.el5.centos.plus|#1 SMP Sat Feb 25 15:50:12 UTC 2017|

Check that a new scan deletes the previous scan from the DB. [Search by scan_id].

sqlite> select scan_id from sys_osinfo;
183729761
sqlite> select scan_id from sys_osinfo;
47141211

Delete the DB of an agent (file 001.db for example) and send a new scan. Is the scan received? Is the DB restored when the manager is restarted?

root@Vela-PC:/var/ossec/queue/db# ls
000.db      000.db-wal  001.db-shm  wdb
000.db-shm  001.db      001.db-wal
root@Vela-PC:/var/ossec/queue/db# rm 001*
root@Vela-PC:/var/ossec/queue/db# ls
000.db  000.db-shm  000.db-wal  wdb
root@Vela-PC:/var/ossec/queue/db# systemctl restart wazuh-manager
root@Vela-PC:/var/ossec/queue/db# ls
000.db      000.db-wal  001.db-shm  wdb
000.db-shm  001.db      001.db-wal
root@Vela-PC:/var/ossec/queue/db# sqlite3 001.db
SQLite version 3.22.0 2018-01-22 18:45:57
Enter ".help" for usage hints.
sqlite> select * from sys_osinfo;
183729761|2019/10/09 12:59:28|centos5|x86_64|CentOS Linux|5.11||5|11||centos|Linux|2.6.18-419.el5.centos.plus|#1 SMP Sat Feb 25 15:50:12 UTC 2017|

It worked as expected.