Skip to content

Instantly share code, notes, and snippets.

@bulk88
Created March 10, 2025 03:58
Show Gist options
  • Save bulk88/4e0f4c201b6611cd0efd1ec8e326c500 to your computer and use it in GitHub Desktop.
Save bulk88/4e0f4c201b6611cd0efd1ec8e326c500 to your computer and use it in GitHub Desktop.
toxic UTF8
use Win32::API;
use Devel::Peek 'Dump';
$f = Win32::API::More->new('kernel32', 'MultiByteToWideChar', 'NNPiPi', 'i');
$a = "\xFE\xFB\xB1\x00";
$u = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
$r = $f->Call(65001, 0, $a, 3, $u, 5);
Dump($r);
Dump($a);
Dump($u);
C:\sources>perl mb.pl
SV = IV(0x2199370) at 0x2199380
REFCNT = 1
FLAGS = (IOK,pIOK)
IV = 3
SV = PV(0x55d1f0) at 0x2193188
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x221eb30 "\xFE\xFB\xB1\x00"\0
CUR = 4
LEN = 24
SV = PV(0x55d220) at 0x218e0e8
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x133a70 "\xFD\xFF\xFD\xFF\xFD\xFF\x00\x00\x00\x00"\0
CUR = 10
LEN = 32
C:\sources>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment