Skip to content

Commit

Permalink
Add some limited homoglyph support.
Browse files Browse the repository at this point in the history
  • Loading branch information
Maikuolan committed Aug 22, 2022
1 parent 106a91d commit 4dafc2e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ __*Why "v3.0.0" instead of "v1.0.0?"*__ Prior to phpMussel v3, the "phpMussel Co
### v3.1.3

[2022.08.18; Maikuolan]: Added L10N for Persian/Farsi, Hebrew, Malay, and Ukrainian.

[2022.08.23; Maikuolan]: Added some limited homoglyph support for some CLI commands.
15 changes: 8 additions & 7 deletions src/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* License: GNU/GPLv2
* @see LICENSE.txt
*
* This file: CLI handler (last modified: 2022.03.24).
* This file: CLI handler (last modified: 2022.08.23).
*/

namespace phpMussel\CLI;
Expand Down Expand Up @@ -104,10 +104,11 @@ public function __construct(\phpMussel\Core\Loader &$Loader, \phpMussel\Core\Sca
}

/** Fetch the command. */
$Command = strtolower($this->Loader->substrBeforeFirst($Clean, ' ') ?: $Clean);
$CommandNatural = $this->Loader->substrBeforeFirst($Clean, ' ') ?: $Clean;
$Command = strtolower($CommandNatural);

/** Exit CLI-mode. */
if ($Command === 'quit' || $Command === 'q' || $Command === 'exit') {
if (preg_match('~^(?:(?:[Qq]|ԛ)(?:[Uu][Ii][Tt])?|[Ee][Xx][Ii][Tt])$~', $CommandNatural)) {
break;
}

Expand Down Expand Up @@ -183,7 +184,7 @@ public function __construct(\phpMussel\Core\Loader &$Loader, \phpMussel\Core\Sca
}

/** Generate a CoEx signature using a string. */
elseif ($Command === 'coex') {
elseif (preg_match('~^(?:(?:[Cc]|ϲ|с)(?:[Oo]|ο|о)(?:[Ee]|е)(?:[Xx]|х))$~', $CommandNatural)) {
$TargetData = substr($Clean, strlen($Command) + 1);
echo sprintf(
"\n\$sha256:%s;\$StringLength:%d;%s\n",
Expand All @@ -194,7 +195,7 @@ public function __construct(\phpMussel\Core\Loader &$Loader, \phpMussel\Core\Sca
}

/** Convert a binary string to a hexadecimal. */
elseif ($Command === 'hex_encode' || $Command === 'x') {
elseif (preg_match('~^(?:[Hh][Ee][Xx]_[Ee][Nn][Cc][Oo][Dd][Ee]|[Xx]|х)$~', $CommandNatural)) {
$TargetData = substr($Clean, strlen($Command) + 1);
echo "\n" . bin2hex($TargetData) . "\n";
}
Expand All @@ -218,14 +219,14 @@ public function __construct(\phpMussel\Core\Loader &$Loader, \phpMussel\Core\Sca
}

/** Scan a file or directory. */
elseif ($Command === 'scan' || $Command === 's') {
elseif (preg_match('~^(?:[Ss][Cc][Aa][Nn]|[Ss]|ѕ)$~', $CommandNatural)) {
$TargetData = substr($Clean, strlen($Command) + 1);
echo "\n";
echo $this->Scanner->scan($TargetData) . "\n";
}

/** Print the command list. */
elseif ($Command === 'c') {
elseif (preg_match('~^(?:[Cc]|ϲ|с)$~', $CommandNatural)) {
echo "\n" . $this->Loader->L10N->getString('cli_commands');
}

Expand Down

0 comments on commit 4dafc2e

Please sign in to comment.