I don't understand why running the tcpdump program doesn't work but with other commands and programs it does, for example: Ping, openSSL, ...
When I run it for example with Ping and OpenSSL, data appears in the console, but tcpdump does nothing, it just ends and that's it.
Somebody could help me? Thanks.
const {spawn} = require('child_process');
spawn('tcpdump', ['-D']).stdout.on('data', (data) => console.log(data.toString()))
//spawn('ping', ['127.0.0.1']).stdout.on('data', (data) => console.log(data.toString()))
//spawn('openssl', ['req', '-x509', '-newkey','rsa:4096','-keyout', 'key.pem', '-out', 'cert.pem', '-days', '365']).stdout.on('data', (data) => console.log(data.toString()))
In the end the problem was due to permissions, but in my case it worked using the super user (root), tcpdump finally worked with some commands with root privileges, but not all of them could be used such as capturing traffic.
Keep in mind that you have the necessary permissions to be able to use the applications.