http заголовки — PHP-скрипт, который определяет, требуется ли авторизация в Apache Splunk или нет

В настоящее время я пытаюсь сделать PHP-скрипт, который автоматически определяет, требуется ли аутентификация Apache Splunk или нет, но мне трудно, так как HTTP-код 303 всегда возвращается, даже если требуется аутентификация или нет.

Вот сценарий bash до сих пор;

<?php
/**
* Apache Splunk script to verify if auth is required or not
* Version : 1.0
*/
ini_set('memory_limit', '800M'); // Set ram limit
require('zebracurl.php');

if($argc === 3){
$file = $argv[1];
if(is_readable($file)){
$handle = fopen($file, 'r');
if ($handle){
$i = 0;
$curl = new Zebra_cURL();
$line_id = 0;
$total_lines = count_lines(__DIR__.DIRECTORY_SEPARATOR.$file);
$url_to_check = array();
$curl->threads = 100;
$curl->option(array(CURLOPT_TIMEOUT => 20));
echo 'Welcome in Apache Splunk detector'.PHP_EOL;
echo '[!] Total lines to parse in '.$file.': '.$total_lines.PHP_EOL;
echo '--------------------------------------------------------------------------------'.PHP_EOL;
while (($uri = fgets($handle)) !== false){
if (!empty($uri) ){
$url_to_check[] = trim($uri).':'.$argv[2].'/splunk/en-US/manager/search/apps/local';
if ($i === 99 || $line_id + 1 === $total_lines){
$curl->get($url_to_check, function($request){
if ($request->response[1] == CURLE_OK && $request->info['http_code'] === 200){
for ($_i = 0; $_i < count($request->headers['responses']); $_i++){
$header_array = array_change_key_case($request->headers['responses'][$_i], CASE_LOWER);
if (isset($header_array['Server'])){
file_put_contents('results.txt', $request->info['original_url'].PHP_EOL,FILE_APPEND | LOCK_EX);
echo '[+] '.$request->info['original_url'].PHP_EOL;
}
}
}
});
$i = 0;
$url_to_check = array();
}
}
$i++;
$line_id++;
}
} else {
echo setColor('An error was occurred on file opening '.$config['input_file'], $with_color ? 'danger' : '').PHP_EOL;
fclose($handle);
unset($curl);
die();
}
fclose($handle);
unset($curl);
}
}else { echo '[!] Usage: php splunk-detector.php LAN-IPs.txt 8000'; }

function count_lines($file){
$total_lines = 0;
if (file_exists($file)){
$handle = fopen($file, "r");
while (!feof($handle)){ if (fgets($handle) !== false) $total_lines += 1; }
fclose($handle);
} return $total_lines;
}

Я открыт для любых решений / предложений, пока я могу достичь своей цели.

Спасибо

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector