diff --git a/app/Services/StealerParser.php b/app/Services/StealerParser.php index 6e4e67f..0476cb8 100644 --- a/app/Services/StealerParser.php +++ b/app/Services/StealerParser.php @@ -18,27 +18,17 @@ class StealerParser */ public function parse(): array{ - $lines = explode("\n", $this->content); + $items = 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; + foreach ($items as $item) { + preg_match_all('/URL:\s(.*)\nUsername:\s(.*)\nPassword:\s(.*)\nApplication:\s(.*)\n/m',$item,$matches); + $credentials[] = [ + 'url' => trim($matches[1][0] ?? ''), + 'username' => trim($matches[2][0] ?? ''), + 'password' => trim($matches[3][0] ?? ''), + 'application' => trim($matches[4][0] ?? '') + ]; } return $credentials;