46 lines
1.6 KiB
PHP
46 lines
1.6 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../vendor/autoload.php';
|
|
use Dotenv\Dotenv;
|
|
|
|
if (file_exists(__DIR__ . '/../.env')) {
|
|
$dotenv = Dotenv::createImmutable(__DIR__ . '/..');
|
|
$dotenv->load();
|
|
}
|
|
|
|
$apiUrl = $_ENV['WAZUH_API_URL'] ?? 'https://127.0.0.1:55000';
|
|
$apiUser = $_ENV['WAZUH_API_USER'] ?? 'wazuh-wui';
|
|
$apiPass = $_ENV['WAZUH_API_PASSWORD'] ?? 'wazuh-wui';
|
|
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, $apiUrl . '/security/user/authenticate');
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_USERPWD, "$apiUser:$apiPass");
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
|
$response = curl_exec($ch);
|
|
$token = json_decode($response, true)['data']['token'] ?? null;
|
|
curl_close($ch);
|
|
|
|
if (!$token) die("No token");
|
|
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, $apiUrl . '/syscollector/000/hardware');
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Authorization: Bearer $token"]);
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
|
$hwResponse = curl_exec($ch);
|
|
curl_close($ch);
|
|
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, $apiUrl . '/syscollector/000/netif');
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Authorization: Bearer $token"]);
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
|
$netResponse = curl_exec($ch);
|
|
curl_close($ch);
|
|
|
|
echo "HW: " . substr($hwResponse, 0, 500) . "\n\n";
|
|
echo "NET: " . substr($netResponse, 0, 500) . "\n";
|