schade, dass DU es nicht verstanden hast, was im kern genau gemeint ist""" °!*Also ich werde wie ich schon gesagt habe, mir definitiv keine Mehrarbeit machen, weil Person A es so will, Person B es so will, Person C es so will. Wer etwas sich selbst sortieren/filtern will, kann das tun, ich werde bei meinem Format bleiben. Wie undankbar will man denn hier noch sein, dass man jetzt sogar auch noch ein bestimmtes Format verlangt, anstatt sich zu bedanken und sich zu freuen.
Mit dem heutigen Tag, werde ich auf unbestimmte Zeit nun auch das Posten von Listen einstellen, wird mir zu undankbar langsam.
Was hab ich dir damals gesagt?Mit dem heutigen Tag, werde ich auf unbestimmte Zeit nun auch das Posten von Listen einstellen, wird mir zu undankbar langsam.
Hier:
(ungetestetet und auf die Schnelle)
(aus Portals "geklaut"
Da ist es dann nur mit Copy&Paste zu erledigen. Ohne Terminal)
Usage: php conv.php <scanfile.txt> <output_base>
Example: php conv.php ./scan/scan_123.txt ./scan/done/example
PHP:<?php declare(strict_types=1); ini_set('memory_limit', '350M'); if ($argc < 3) { fwrite(STDERR, "Usage: php conv.php <scanfile.txt> <output_base>\n"); fwrite(STDERR, "Example: php conv.php ./scan/scan_123.txt ./scan/done/example\n"); exit(1); } $inputFile = $argv[1]; $outputBase = $argv[2]; if (!file_exists($inputFile)) { fwrite(STDERR, "File not found: $inputFile\n"); exit(1); } $outputDir = dirname($outputBase); if (!is_dir($outputDir)) { mkdir($outputDir, 0755, true); } function loadExistingFileData(string $filePath): array { $existingUrls = []; $existingMacs = []; $existingUserPass = []; if (file_exists($filePath)) { $fileContent = file_get_contents($filePath); preg_match_all('/http:\/\/([a-zA-Z0-9.-]+)(:\d+)?/', $fileContent, $existingUrls); $existingUrls = isset($existingUrls[0]) ? array_unique($existingUrls[0]) : []; preg_match_all('/[0-9A-Fa-f]{2}(:[0-9A-Fa-f]{2}){5}/', $fileContent, $existingMacs); $existingMacs = isset($existingMacs[0]) ? array_unique($existingMacs[0]) : []; preg_match_all('/get\.php\?username=([a-zA-Z0-9._]+)&password=([a-zA-Z0-9._]+)/', $fileContent, $existingUserPass); $existingUserPass = (isset($existingUserPass[1], $existingUserPass[2])) ? array_map(fn($u, $p) => "$u/$p", $existingUserPass[1], $existingUserPass[2]) : []; } return [ 'urls' => $existingUrls, 'macs' => $existingMacs, 'userpass' => $existingUserPass, ]; } $inputData = file_get_contents($inputFile); preg_match_all('/http:\/\/([a-zA-Z0-9.-]+)(:\d+)?/', $inputData, $urls); preg_match_all('/[0-9A-Fa-f]{2}(:[0-9A-Fa-f]{2}){5}/', $inputData, $macs); preg_match_all('/get\.php\?username=([a-zA-Z0-9._]+)&password=([a-zA-Z0-9._]+)/', $inputData, $userPass); $outputMacFile = $outputBase . '_mac.txt'; $outputUpFile = $outputBase . '_up.txt'; if (!empty($urls[0])) { $portalUrl = $urls[0][0]; $existingData = loadExistingFileData($outputMacFile); $existingUrls = $existingData['urls']; $existingMacs = $existingData['macs']; $existingUserPass = loadExistingFileData($outputUpFile)['userpass']; $newMacs = array_unique(array_diff($macs[0], $existingMacs)); $newUserPassCombos = array_map(fn($u, $p) => "$u/$p", $userPass[1], $userPass[2]); $newUserPassCombos = array_unique(array_diff($newUserPassCombos, $existingUserPass)); if (!file_exists($outputMacFile) || strpos(file_get_contents($outputMacFile), $portalUrl) === false) { file_put_contents($outputMacFile, $portalUrl . PHP_EOL, FILE_APPEND); } if (!empty($newMacs)) { $macFileHandle = fopen($outputMacFile, 'a'); foreach ($newMacs as $mac) { fwrite($macFileHandle, "$mac\n"); } fclose($macFileHandle); chmod($outputMacFile, 0755); echo "MACs saved to $outputMacFile\n"; } if (!file_exists($outputUpFile) || strpos(file_get_contents($outputUpFile), $portalUrl) === false) { file_put_contents($outputUpFile, $portalUrl . PHP_EOL, FILE_APPEND); } if (!empty($newUserPassCombos)) { $upFileHandle = fopen($outputUpFile, 'a'); foreach ($newUserPassCombos as $combo) { fwrite($upFileHandle, "$combo\n"); } fclose($upFileHandle); chmod($outputUpFile, 0755); echo "User/Pass combos saved to $outputUpFile\n"; } if (empty($newMacs) && empty($newUserPassCombos)) { echo "Nothing new to add. Files are already up-to-date.\n"; } } else { echo "No valid portal URLs found in scan file.\n"; }
Ergibt dann:
fancy txt Mac Liste rein --> txt mit Portalname und alle Macs darunter.
So auch für User/path
<?php
declare(strict_types=1);
ini_set('memory_limit', '350M');
if ($argc < 3) {
fwrite(STDERR, "Usage: php process_scans_cli.php <scanfile.txt> <output_dir>\n");
exit(1);
}
$inputFile = $argv[1];
$outputDir = rtrim($argv[2], '/');
if (!file_exists($inputFile)) {
fwrite(STDERR, "File not found: $inputFile\n");
exit(1);
}
if (!is_dir($outputDir)) {
mkdir($outputDir, 0755, true);
}
function loadExistingFileData(string $filePath): array {
$existingUrls = [];
$existingMacs = [];
$existingUserPass = [];
if (file_exists($filePath)) {
$fileContent = file_get_contents($filePath);
preg_match_all('/http:\/\/([a-zA-Z0-9.-]+)(:\d+)?/', $fileContent, $existingUrls);
$existingUrls = $existingUrls[0] ?? [];
preg_match_all('/[0-9A-Fa-f]{2}(:[0-9A-Fa-f]{2}){5}/', $fileContent, $existingMacs);
$existingMacs = $existingMacs[0] ?? [];
preg_match_all('/([a-zA-Z0-9._-]+)\/([a-zA-Z0-9._-]+)/', $fileContent, $existingUserPass);
$existingUserPass = (isset($existingUserPass[1], $existingUserPass[2]))
? array_map(fn($u, $p) => "$u/$p", $existingUserPass[1], $existingUserPass[2])
: [];
}
return [
'urls' => array_unique($existingUrls),
'macs' => array_unique($existingMacs),
'userpass' => array_unique($existingUserPass),
];
}
$lines = file($inputFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$currentPortal = null;
$portalBlocks = [];
foreach ($lines as $line) {
$line = trim($line);
if ($line === '') continue;
if (preg_match('/^http:\/\/[a-zA-Z0-9.-]+(:\d+)?\/?$/', $line)) {
$currentPortal = $line;
if (!isset($portalBlocks[$currentPortal])) {
$portalBlocks[$currentPortal] = ['macs' => [], 'userpass' => []];
}
} elseif ($currentPortal !== null) {
if (preg_match('/^[0-9A-Fa-f]{2}(:[0-9A-Fa-f]{2}){5}$/', $line)) {
$portalBlocks[$currentPortal]['macs'][] = strtoupper($line);
} elseif (preg_match('/get\.php\?username=([a-zA-Z0-9._-]+)&password=([a-zA-Z0-9._-]+)/', $line, $m)) {
$portalBlocks[$currentPortal]['userpass'][] = $m[1] . '/' . $m[2];
}
}
}
foreach ($portalBlocks as $portalUrl => $data) {
$host = parse_url($portalUrl, PHP_URL_HOST);
$port = parse_url($portalUrl, PHP_URL_PORT);
if (!$host) continue;
$baseName = preg_replace('/[^a-zA-Z0-9]+/', '_', $host);
if ($port !== null && $port != 80) {
$baseName .= '_' . $port;
}
$macFile = $outputDir . '/' . $baseName . '_mac.txt';
$upFile = $outputDir . '/' . $baseName . '_up.txt';
$existing = loadExistingFileData($macFile);
if (!in_array($portalUrl, $existing['urls'])) {
file_put_contents($macFile, $portalUrl . PHP_EOL, FILE_APPEND);
}
$newMacs = array_diff($data['macs'], $existing['macs']);
if (!empty($newMacs)) {
file_put_contents($macFile, implode(PHP_EOL, $newMacs) . PHP_EOL, FILE_APPEND);
chmod($macFile, 0755);
echo "MACs saved to $macFile\n";
}
$existing = loadExistingFileData($upFile);
if (!in_array($portalUrl, $existing['urls'])) {
file_put_contents($upFile, $portalUrl . PHP_EOL, FILE_APPEND);
}
$newUserPass = array_diff($data['userpass'], $existing['userpass']);
if (!empty($newUserPass)) {
file_put_contents($upFile, implode(PHP_EOL, $newUserPass) . PHP_EOL, FILE_APPEND);
chmod($upFile, 0755);
echo "User/Pass combos saved to $upFile\n";
}
}
if (empty($portalBlocks)) {
echo "No valid portal URLs found in $inputFile\n";
} else {
echo "Processing complete.\n";
}
?>
Wir verwenden Cookies und ähnliche Technologien für folgende Zwecke:
Akzeptieren Sie Cookies und diese Technologien?
Wir verwenden Cookies und ähnliche Technologien für folgende Zwecke:
Akzeptieren Sie Cookies und diese Technologien?