Unicode string "obfuscation"

Share your advanced PureBasic knowledge/code with the community.
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

Unicode string "obfuscation"

Post by Lunasole »

Hi. Here is some small and funny experimental stuff based on Unicode character 823/0x337 I recently encountered :mrgreen:
Doesn't look too much usable, rather just another playfUllnes (like bypassing word-filters on internet services, lol).

Code: Select all

EnableExplicit


Define *A.Unicode = @"Write something funny"
Define OutStr$

Repeat
	Select *A\u
		Case '0' To '9', 'a' To 'z', 'A' To 'Z':
			OutStr$ + Chr(823) + Chr(*A\u)
		Case 0:
			Break
		Default
			OutStr$ + Chr(*A\u)
	EndSelect
	*A+SizeOf(Unicode)
ForEver

Debug OutStr$
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
devox
User
User
Posts: 32
Joined: Thu Apr 01, 2021 7:25 pm

Re: Unicode string "obfuscation"

Post by devox »

Nice thanks for sharing. I'll have to try it in video games when naming a character and the word filter won't let me.
User avatar
NicTheQuick
Addict
Addict
Posts: 1224
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Unicode string "obfuscation"

Post by NicTheQuick »

I don't get it. It's just a forward slash before every letter.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
User avatar
Keya
Addict
Addict
Posts: 1891
Joined: Thu Jun 04, 2015 7:10 am

Re: Unicode string "obfuscation"

Post by Keya »

NicTheQuick wrote:I don't get it. It's just a forward slash before every letter.

It changes the string from typical ascii chars (eg. "W" is 0x57 in ascii, or 0x5700 in unicode) to a character set higher up in the Unicode table that still looks the same (eg. "W" is 0x37035700)

Code: Select all

Before:
004330B0  57 00 72 00 69 00 74 00 65 00 20 00 73 00 6F 00  W.r.i.t.e. .s.o.
004330C0  6D 00 65 00 74 00 68 00 69 00 6E 00 67 00 20 00  m.e.t.h.i.n.g. .

After:
00395EE8  37 03 57 00 37 03 72 00 37 03 69 00 37 03 74 00  7.W.7.r.7.i.7.t.
00395EF8  37 03 65 00 20 00 37 03 73 00 37 03 6F 00 37 03  7.e. .7.s.7.o.7.
So if some code is specifically just looking for 0x57 or 0x5700 it might miss 0x37035700 and allow it through
User avatar
NicTheQuick
Addict
Addict
Posts: 1224
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Unicode string "obfuscation"

Post by NicTheQuick »

No. It looks like this afterwards:

Code: Select all

̷W̷r̷i̷t̷e ̷s̷o̷m̷e̷t̷h̷i̷n̷g ̷f̷u̷n̷n̷y
In my debug window it even looks more like this:

Code: Select all

/W/r/i/t/e /s/o/m/e/t/h/i/n/g /f/u/n/n/y
I think a better way would be to use the full width letter category:

Code: Select all

EnableExplicit

Define *a.Character = @"Write something funny 0123"
Define out.s

While *a\c
   Select *a\c
      Case '0' To '9', 'a' To 'z', 'A' To 'Z':
         out + Chr($FF00 + *a\c - 32)
      Default
         out + Chr(*a\c)
   EndSelect
   *a + SizeOf(Character)
Wend

Debug out
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
BarryG
Addict
Addict
Posts: 3293
Joined: Thu Apr 18, 2019 8:17 am

Re: Unicode string "obfuscation"

Post by BarryG »

I get the same output as NicTheQuick, with the slashes. Nothing interesting to see here.
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

Re: Unicode string "obfuscation"

Post by Lunasole »

devox wrote:Nice thanks for sharing. I'll have to try it in video games when naming a character and the word filter won't let me.
Don't know about games (maybe some of them allow), but at least for Youtube and some other sites it works this way :mrgreen:
Of course there are lot others ways to modify a string to fool different word-filters and neural networks, I just liked this one as it doesn't distorts original characters too much.
Would be nice anyway to collect many others examples. I have some nice and table-based things from my very old code, but was too lazy to search and recover it all.

NicTheQuick wrote: I think a better way would be to use the full width letter category:

"̷W̷r̷i̷t̷e ̷s̷o̷m̷e̷t̷h̷i̷n̷g ̷f̷u̷n̷n̷y"
vs
"Write something funny 0123"

That might be a good way too.
But your variant doesn't work correctly in slightly different cases, btw

Code: Select all

Define *A.Unicode = @"кириллический пример"
..
Case 'а' To 'я', '0' To '9', 'a' To 'z', 'A' To 'Z':

... but at least result becomes some more funny when combining 2 variants together :mrgreen: (yes I'm probably too happy now, lol)
> "̷ss̷oo̷mm̷ee̷tt̷hh̷ii̷nn̷gg ̷ff̷uu̷nn̷nn̷yy"
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
User avatar
NicTheQuick
Addict
Addict
Posts: 1224
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Unicode string "obfuscation"

Post by NicTheQuick »

It seems that there are quite big differences on Linux and Windows and fonts in general. Here it was I see.
My post on Linux and Windows:
Linux:
Image
Windows:
Image

And this is how it looks like in my Debugger Window:
Image
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: Unicode string "obfuscation"

Post by Saki »

For plain text, you can do this with a deterministic random generator, but then nobody reads it.
It is also OK to use an AES based one.
地球上の平和
User avatar
NicTheQuick
Addict
Addict
Posts: 1224
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Unicode string "obfuscation"

Post by NicTheQuick »

Saki wrote:For plain text, you can do this with a deterministic random generator, but then nobody reads it.
It is also OK to use an AES based one.
What are you talking about? :lol:
We are not talking about encryption but obfuscation.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: Unicode string "obfuscation"

Post by Saki »

This is not encryption, after all.
It only prevents the text from being readable.
An obfuscator that is no good is no obfuscator.
If the thing has the security of an encryption,
it should not be a disadvantage. :o
Putting a character in between is nonsense.
It also bloats the text, which is not what you want at all.

If I have some time, I can make one, if I feel like it.
地球上の平和
User avatar
NicTheQuick
Addict
Addict
Posts: 1224
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Unicode string "obfuscation"

Post by NicTheQuick »

What? :lol:
If you encrypt something, nobody can read it afterwards.

Did you even read the whole thread?
Lunasole wrote:(like bypassing word-filters on internet services, lol)
The text has to be readable by a human person but should pass some simple word filters. That's all.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: Unicode string "obfuscation"

Post by Saki »

Ah, OK, I had only read Obfuscator
地球上の平和
User avatar
Tenaja
Addict
Addict
Posts: 1948
Joined: Tue Nov 09, 2010 10:15 pm

Re: Unicode string "obfuscation"

Post by Tenaja »

Saki wrote: If I have some time, I can make one, if I feel like it.
There should be at least a few on this forum, if you search--both encryption and obfuscators.
viewtopic.php?f=7&t=14590&p=84717&hilit ... ate#p84717

viewtopic.php?f=12&t=62732&p=468613&hil ... on#p468613

There are probably more, and certainly some with different forms of the word encryption.

And there is nothing wrong with encrypting the words for use as data, just decrypt it when you need it.
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: Unicode string "obfuscation"

Post by Saki »

Hi, yes thank you.
You can do very nice and interesting things here
地球上の平和
Post Reply