Files
asm-dashboard/app/Services/StealerParser.php

48 lines
1.1 KiB
PHP

<?php
namespace App\Services;
class StealerParser
{
/**
* @param string $content
*/
public function __construct(
private readonly string $content = ''
){
}
/**
* @return array
*/
public function parse(): array{
$lines = explode("\n", $this->content);
$credentials = [];
$current = [];
foreach ($lines as $line) {
if (str_starts_with($line, 'URL:')) {
if (!empty($current)) {
$credentials[] = $current;
}
$current = ['url' => trim(substr($line, 4))];
} elseif (str_starts_with($line, 'Username:')) {
$current['username'] = trim(substr($line, 9));
} elseif (str_starts_with($line, 'Password:')) {
$current['password'] = trim(substr($line, 9));
} elseif (str_starts_with($line, 'Application:')) {
$current['application'] = trim(substr($line, 12));
}
}
if (!empty($current)) {
$credentials[] = $current;
}
return $credentials;
}
}