ZXX Font & OCR – some thoughts

It is in all media that Edward Snowden has revealed the surveillance activities of the NSA. This act of spionage can be criticised as an break-in into the privacy of every person’s life.

Therefore Sang Mun has released a Font called ZXX which makes it more difficult for automated optical character recognition (OCR) programs to detect letters. Here a german article from the austrian online newspaper derstandard.at

I have looked on this font with great interrest and think that this could be a great way to avoid automated spionage from others.

When you watch the ZXX Type Secimen Video you will be surprised by how easy you can confuse OCR programs. The most interessting thing for me were the XED and the noise font. It just adds either a thin cross (X) or optimised “random” pixels to the letters where humans are still able to read the text pretty fast. This is not the case for the Camo Font. More to that later.

So thinking of this, why is a human being able to read the Xed and noised text, while computers can’t? The answer was simple for me. (this might not be scientifically proven). The human eye takes a look at a picture and tries to recognise something. If not it focuses or “zooms in and out” to remember the patterns we have all learned in early school years. Moreover we do not only have one point of view, we have two of them. There are two eyes with maybe two different focuspoints which makes us able to see letters behind all that camouflaging stuff. A very easy trick to solve CAPTCHAs and to read the ZXX font is to unfocus the stuff you want to read. It looks blurry. There was a program which I had in mind which can do this for me.

Simple as that I tried it – with success. Have a look at your own.

I took a sample picture from ZXX and cut off the stuff on the side (for better reading)

ZXX sample

 I uploaded this onlineocr.net

This is the result:

ABCDEFGHIJKLMNOPUPST
UVWXYZabcdefghijklmn
opqrstuvwxyz00123450
789%!?@#/&*().,:$£
+x÷±-=-_"°154afyX%%[]
ABCDEFGHIJKLMNOPUPST
UVWXYZabcdefghijklmn
opqrstuvwxyz00123450
789%!?@#/&*().,:$
+x÷±-=-_"1@4afyflfl?[]
IMBODffiGliffiktMNOPRPSt
UVWOWEabedgeflijklms
owettAvw*gzelS/2@xtga
U;flZYXWVUTSPUPONML
KJIHGEEDCBAzyxwvutsr
ciponmIkjihgfedcbagg8
765432101 ?ABCDEFGHI3,
KEMNOPR•STUVWXYZabcd
afghilkImnopqrstwvwx
wii01.2345878gRIA22DE 
NW N■v1.• • • 
• • wawl0K461ISdielP•E*
4.*AP101010104.: 
twintootra21224Rea,a

As you can see only some of the characters are found be the program.

If I blur the image all the confusing stuff (for the OCR Software) is removed or partly removed, so that the matches are higher than before. See for yourself.

Blurred image:

zxx-blurred

 

and this is the result.

ABCDEFGHIJKLIANOPOPST
UVWXYZabcdefqhijklmn
opqrstuvwxyz00123450
789%!?@0/&*(),,:WO
+x+t-m-_".0:42fOgq]
ABCDEFGHIJKLMNOPOPST
UVWXYZabcdefqh1jklmn
opqrstuvwxyz00123450
789%"?"/"().,:$EV
+x-ft-m-_".11:saiyfint[]
IMOCIVIIIJK5M4GPOOSI
UVIORYilabcdsfeit311Imm
opqrstswesszt62234Vd
Re914ZYKWVUTSPOPONML
KJIHGFEDCBAzyxwvutsr
qponmlkjihgfedcba998
70543210!?ABCDEFGHIJ
KLMNOPOPSTUVWXYZebcd
•ighijklionopqrstuvws
yz00123450789? IABCDE
FGHIJKLMNOPOPSTUVWXY
Zabcdefighijklmnopqrs
tuvwxyz0012345078931

I think this is a remarkable difference to the original image.

I also have some words to the two other fonts.

The False font can be easily trained as I have been trained by the video. One needs to search for a big letter, but does not take its information. Instead you search for another letter within the smallest rectangle you can fit around the big letter you just found. (to explain it technically 😉 )

The Camo font is a real hard one. If you simply read the Camo alphabet it is easy to see the letters, because you expect the very next letter. And with this image in mind you procet the vectors over the image you see where it is easy to recognise. Some sort of this is also used in examples of optical illusion. What I have in mind is the Kanizsa triangle.

Kanizsa_triangle.svg

Image from the Wikimedia Commons

You as human see a white triangle where really is none. You just have some points or “suggestions” of vectors and your brain finishes them to form this triangle.

 

Windows Command Line – Password function

Here is a little password function if you need it. Be aware that it is very slow, don’t type too fast. 😉 It’s more a concept than a tool you can work with.

Just Enter your password and hit ALT+222 (on your numblock) to terminate.

@echo off
setLocal EnableDelayedExpansion

set allchar=Þ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
set pw=

echo Please enter password SLOWLY and terminate with ALT+222
:pwloop
choice /C %allchar% /CS >nul
set cint=%errorlevel%
set /a cint-=1
set pw=%pw%!allchar:~%cint%,1!
if %cint% neq 0 goto pwloop

set pw=%pw:~0,-1%
echo %pw%
set pw=
pause>nul

Here a picture for proof of concept

Commandline-password

Windows Command Line – Service Menu

If you have a collection of CMD Tools you fast loose the overview of what you have. For this I have developed a little menu where you can choose from your programs by name.

Here is the Main Menu

menu-and-logo-ready-to-use

 

You can create your own logo with the following steps.

copy-ascii-logo

 

  • Search and replace all occurences of | with ^| (Mostly found with CTRL+H)

replace-special-characters

 

  • Add echos and some extras

main-menu-with-extras

  •  Copy it into your menu

The good thing about this menu is, that you don’t have to search in a big script for stuff. You just alter this file here

rem Variables
@echo off

call :Var "%source%Add printer.vbs"				"Add a Printer"
call :Var "%source%all-printers-settings.cmd"	"Apply BW Print to all Printers"
call :Var "%source%printercolor.cmd"	"Apply Color Print to one Printer"
call :Var "%source%AddWSUSURLs.cmd"				"Add WSUS to Registry"
call :Var "%source%Softphone.cmd"				"Set Softphone DW"
call :Var "%source%userinfo.cmd"				"User Information + Services"
call :Var "%source%connectionstab.cmd"			"IE Connections Tab - Internet Explorer Verbindungen Reiter"
call :Var "%source%dfue.cmd"						"Create DFUE"
call :Var "%source%austria.hol"					"Outlook Holidays 2013-2015"
call :Var "%source%office-languagepacks.cmd"		"Office Language Packs"
call :var "%source%Abfragegenerator2007.cmd"			"Query Builder - Abfragegenerator Office 2007"
call :var "%source%Terminal-Autologin.cmd"			"Terminal Autologin"
call :Var "%source%VM2-ODBC.cmd"			"Versandmodule 2 - ODBC Settings"
call :var "%source%Lawi-setup.cmd"			"Lawi Setup"
call :Var "%source%lawi-etikett.cmd"			"Lawi Etikett"
call :var "%source%emppack.cmd"			"Install Empirum Package"
call :var "%source%EmpirumAgent.cmd"			"Install Empirum Agent"

goto :end

rem Variables
:Var
set /a id+=1
set /a nextpage=%id%%9
if [%nextpage%] EQU [0] set /a menumaxsiteindex+=1
rem set %id%.name=%1&& shift
set %id%.path=%1&& shift
set %id%.description=%1
goto:EOF

:end

And here is the menu where you put your logo

@echo off
cls
setLocal EnableDelayedExpansion

set version=0.6
set menusiteindex=0
set menumaxsiteindex=0
set id=0
set uid=0

rem Choose Source
call :ChooseSource
rem User Variables
if exist "%source%uservar.cmd" (call "%source%uservar.cmd") else (call "%source%..uservar.cmd")
rem Program Variables
if exist "%source%progvar.cmd" (call "%source%progvar.cmd") else (call "%source%..progvar.cmd")

set /a menumaxsiteindex=%id%/9+1
rem Variables

:ServiceLoop
call :MenuMapping
call :WriteScreen !%menu_1%.description! !%menu_2%.description! !%menu_3%.description! !%menu_4%.description! !%menu_5%.description! !%menu_6%.description! !%menu_7%.description! !%menu_8%.description! !%menu_9%.description!
goto:ServiceLoop

rem ***************************************************************************
rem * Functions
rem ***************************************************************************

:WriteScreen
cls
call :Logo
call :Menu %*
call :MenuChoice
goto:EOF

:MenuMapping
set prefix=%1
for /L %%a in (1,1,9) do (
	set menuindex=%%a
	set /a menu_%prefix%!menuindex!=!menuindex!+!menusiteindex!*9"
)
goto:EOF

:Logo
rem http://patorjk.com/software/taag/#p=display&f=Doom&t=www.sysstem.at
echo *******************************************************************************
echo *******************************************************************************
echo                                                 _                        _   
echo                                                ^| ^|                      ^| ^|  
echo __      ____      ____      _____ _   _ ___ ___^| ^|_ ___ _ __ ___    __ _^| ^|_ 
echo   / / /  / / /  / / / __^| ^| ^| / __/ __^| __/ _  '_ ` _   / _` ^| __^|
echo   V  V /   V  V /   V  V /__  ^|_^| __ __  ^|^|  __/ ^| ^| ^| ^| ^|^| (_^| ^| ^|_ 
echo   _/_/    _/_/    _/_(_)___/__, ^|___/___/_____^|_^| ^|_^| ^|_(_)__,_^|__^|
echo                                    __/ ^|                                     
echo                                  ^|___/                                    
echo ***************************************************Phone: 0043123456       ****
echo ***************************************************Email: admin@sysstem.at ****
echo.
goto:EOF

:Menu
set menucount=0
set choicestr=

rem http://www.robvanderwoude.com/parameters.php
:Loop
if [%1]==[] GOTO MenuFooter
	rem counter
	set /a menucount+=1
	rem save parameters in variables
	set _%menucount%=%1
	rem dequote variables
	call :DeQuote _%menucount%
	rem [Number] variable value
	echo [%menucount%] !_%menucount%!
	rem add Menunumber to string
	set choicestr=%choicestr%%menucount%
	rem get next parameter
	shift
goto Loop
:MenuFooter
echo.
echo [N]ext [P]revious [F]irst [L]ast [G]oto Page [A]dmin [E]xit
set choicestr=%choicestr%NPFLGAE
goto:EOF

:MenuChoice

choice /c %choicestr%
set /a menuchoice=%errorlevel%
set /a length=%menuchoice%-1
set programid=!menu_%menuchoice%!

if !menuchoice! LEQ !menucount! (
	start !%programid%.description! !%programid%.path!
) else (
	call :MenuSelection !choicestr:~%length%,1!
)
goto:EOF

:MenuSelection
set selection=%1
if /I [%selection%] equ [N] call :NextPage
if /I [%selection%] equ [P] call :PreviousPage
if /I [%selection%] equ [F] call :FirstPage
if /I [%selection%] equ [L] call :LastPage
if /I [%selection%] equ [G] call :GotoPage
if /I [%selection%] equ [A] call :Admin
if /I [%selection%] equ [E] call :Exit
goto:EOF

:NextPage
set /a maxpage=%menumaxsiteindex%-1
if [%menusiteindex%] LSS [%maxpage%] (
	set /a menusiteindex+=1
) else echo This is already the last page &pause>nul
goto:EOF

:PreviousPage
if [%menusiteindex%] GTR [0] (
	set /a menusiteindex-=1
) else echo This is already the first page &pause>nul
goto:EOF

:FirstPage
set /a menusiteindex=0
goto:EOF

:LastPage
set /a menusiteindex=%menumaxsiteindex%-1
goto:EOF

:GotoPage
set /p gotopage="Please enter pagenumber: "
set /a gotopage-=1
if %gotopage% GEQ 0 (
	if %gotopage% LSS %menumaxsiteindex% (
		set /a menusiteindex=%gotopage%
	) else echo No valid page number&pause>nul
) else echo No valid page number&pause>nul
goto:EOF

:Admin
2>nul 1>nul start "%source%runasadmin.exe" "%~dpf0"&&exit||(echo.&echo Could not get Admin rights.&pause>nul)
goto:EOF

:Exit
exit
goto:EOF

rem ******************************************
rem * Removes Quotes
rem * http://ss64.com/nt/syntax-dequote.html
rem ******************************************

:DeQuote
SET _DeQuoteVar=%1
CALL SET _DeQuoteString=%%!_DeQuoteVar!%%
IF [!_DeQuoteString:~0^,1!]==[^"] (
IF [!_DeQuoteString:~-1!]==[^"] (SET _DeQuoteString=!_DeQuoteString:~1,-1!
) ELSE (GOTO :EOF)
) ELSE (GOTO :EOF)
SET !_DeQuoteVar!=!_DeQuoteString!
SET _DeQuoteVar=
SET _DeQuoteString=
GOTO :EOF

:ChooseSource
set workingdir=%~dp0
set workingdir=%workingdir:~0,-1%
if exist "%workingdir%CMDTools" (set source=%workingdir%CMDTools
) else (
	set source=\backupserverCMDTools
)
GOTO:EOF

 

This currently only runs on Windows 7 (have not tested Windows 8, but should work too) because Windows XP does not bring choice.exe

And before I forget: you have to provide all the tools for yourselfs. But let me know if you are interessted in one of these mentioned here.