#203459 - 2011-11-06 05:35 PM
Kixgolf - Whitespace Obfuscation - Private Round
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4549
Loc: USA
|
============= The Challenge - Whitespace Obfuscation =============
Introduced at DEFCON 16 in 2008 by Kolisar, whitespace obfuscation (WO) was used with javascript to hide code in html. Whitespace characters are ascii characters, that when printed or displayed, appear as blanks. Although there are others, the most common whitespace characters are spaces " ", and a tabs " ".
The process of WO is to use whitespace characters to encode binary ascii values. When encoding, the first step is to convert a standard line of text to its binary equivalent, and then substitute the binary 1s and 0s, with tabs and spaces. The end result is what appears to be nothing but blank space.
Binary ascii characters are represented as 0s and 1s and are 8 digits long. The following chart defines those values.
Num Chr Binary Num Chr Binary Num Chr Binary
----------------------------------------------------------------------------
9 Tab 00001001
32 00100000 64 @ 01000000 96 ` 01100000
33 ! 00100001 65 A 01000001 97 a 01100001
34 " 00100010 66 B 01000010 98 b 01100010
35 # 00100011 67 C 01000011 99 c 01100011
36 $ 00100100 68 D 01000100 100 d 01100100
37 % 00100101 69 E 01000101 101 e 01100101
38 & 00100110 70 F 01000110 102 f 01100110
39 ' 00100111 71 G 01000111 103 g 01100111
40 ( 00101000 72 H 01001000 104 h 01101000
41 ) 00101001 73 I 01001001 105 i 01101001
42 * 00101010 74 J 01001010 106 j 01101010
43 + 00101011 75 K 01001011 107 k 01101011
44 , 00101100 76 L 01001100 108 l 01101100
45 - 00101101 77 M 01001101 109 m 01101101
46 . 00101110 78 N 01001110 110 n 01101110
47 / 00101111 79 O 01001111 111 o 01101111
48 0 00110000 80 P 01010000 112 p 01110000
49 1 00110001 81 Q 01010001 113 q 01110001
50 2 00110010 82 R 01010010 114 r 01110010
51 3 00110011 83 S 01010011 115 s 01110011
52 4 00110100 84 T 01010100 116 t 01110100
53 5 00110101 85 U 01010101 117 u 01110101
54 6 00110110 86 V 01010110 118 v 01110110
55 7 00110111 87 W 01010111 119 w 01110111
56 8 00111000 88 X 01011000 120 x 01111000
57 9 00111001 89 Y 01011001 121 y 01111001
58 : 00111010 90 Z 01011010 122 z 01111010
59 ; 00111011 91 [ 01011011 123 { 01111011
60 < 00111100 92 \ 01011100 124 | 01111100
61 = 00111101 93 ] 01011101 125 } 01111101
62 > 00111110 94 ^ 01011110 126 ~ 01111110
63 ? 00111111 95 _ 01011111
Using "Hello World" as an example, first convert the string of ascii characters to binary
Hello World=0100100001100101011011000110110001101111001000000101011101101111011100100110110001100100
or broken down by letter: H=01001000 e=01100101 l=01101100 l=01101100 o=01101111 space=00100000 W=01010111 o=01101111 r=01110010 l=01101100 d=01100100 Then substituting a space with the 0s, and a tab with the 1s, results in what appears to be a blank data on the right side of the equals sign below. However, there is data there and it represents Hello World in WO form.
Hello World=
Encoding and Decoding will require a KEY. During *ENCODING* the KEY defines what value is substitued for the 0's and 1's and is provided as the second parameter (optional). If the KEY is a space, then 0s are substituted with spaces and 1's are substituted with tabs. If the KEY is a tab, then 0's are substituted with tabs and 1's are substituted with spaces.
During *DECODING*, the KEY is found as the last character of the WO string. Again it will define what values are substituted for spaces and tabs. If the KEY is a space, then spaces are substituted with 0's and tabs are substituted with 1's. If the KEY is a tab, then tabs are substituted with 0's and spaces are substituted with 1's.
*-->A download is available at http://www.kixtart.org/forums/ubbthreads.php?ubb=download&Number=250
============= Specification =============
Using WO encode a clear text string or decode the WO string to a clear text string.
When encoding clear text to WO text: - Convert each character to it's binary equivalant - Using the KEY, substitute each 0 and 1 with it's defined replacement of either a space or tab - Append the KEY to the end of the WO string
When decoding WO text to clear text: - Determine the KEY from the last character of the WO string - Using the KEY, substitute each space and tab with its defined replacement of either a 0 or 1 - Convert the Binary numbers to the character equivalant
============= Inputs and Outputs =============
The input consists of either a clear text string or a WO encoded string.
When encoding there will also be a second parameter called the KEY. The KEY value will either be a space or tab. The KEY defines what to substitue the 0 value with. The 1 value will be substituted with the other of the two characters (either space or tab). For example, if $key=" " (space), 0's are substituted with spaces, and 1's are substituted with tabs. And if $key=" " (tab), 0's are substituted with tabs, and 1's are substituted with spaces.
================================================================= Notes ================================================================ - The scoring engine has added code to help diagnose which cases are failing. To see test case results:
kix32 kixgolf_wo $verbose=1 ;shows failing results
kix32 kixgolf_wo $verbose=2 ;shows all results
- The scoring engine expects your (primary) function to be named a().
======= Scoring =======
The solution must pass all tests in order for it's KiXgolf Score to be considered.
When posting KiXtart Golf Scores, please include the KIXGOLF_*.TXT file that is created in the script directory. It contains some basic information about the computer that the script is run on and the resulting scores.
============ Test program ============
Test cases are provided to help screen entries and to provide the Golf Score. Any script that passes the test cases can be submitted. If you are surprised that your solution passed the test cases, please submit it anyway! That will help me identify bugs in the test program.
================================================================ KiXtart GOLF - How To Play ================================================================
Most importantly, anybody can play, no age restrictions, no penalties, no handicap!
The object in "real" golf is to hit the ball in the hole in the fewest strokes. The object in KiXtart Golf is to get from input (tee) to target (hole) in the fewest keystrokes.
Example: How many positive elements are in array $a?
Array $a could be of structure $a=[1, 2 ,-3, 4, -5, -7, 8, 9]
One approach:
for $b=0 to ubound($a)
if $a[$b]>0
$c=$c+1
endif
next
for a score of 45.
Another solution is:
DO
$b=$b+1
if $a[$b]>0
$c=$c+1
endif
UNTIL $b>(UBOUND($a)+1)
for a score of 53.
Better approach: Code sample 1
================================================================ KiXtart GOLF - The Rules ================================================================
1) The goal of KiXtart Golf is to score the lowest strokes. 2) Strokes are all characters in a piece of code except whitespace characters, unless the whitespace character is necessary for the line of code to work. Therefore, carriage returns and line feeds do not count or spaces in between the '=' sign when assigning variables, e.g. '$a = $b' scores 5. 3) Code can be constructed any way you like, as long as it does not generate syntax or other errors when running the script in KiXtart. 4) The final solution MUST pass all test scripts that are part of the KiXtart golf challenge. 7) During the private coding phase, no code is allowed to be posted. Violations result in disqualification of said player. 8) During the public coding phase, code should be posted, reused, and borrowed from other players. 9) The test script contains the official KiXgolf scoring engine 10) Only the person posting a particular score will be recognized for the score, unless the KiXtart Golf Challenge organizer or another delegate posts code on behalf of a player 11) KiXtart Golf (a.k.a KiXgolf) codes must be written inside the KiXgolf UDF collection tags, ';!' and ';!;!' 12) Parameter names of the UDF's can be changed and additional optional parameters can be added. 13) Additional helper UDFs and code can be written as long as they reside inside the ';!' and ';!;!' tags. 14) The use of '$' as a variable is allowed. 15) The UDF layout is up to coder. 16) The UDF is expected to finish in a reasonable time, that is, on modern computers inside 1 hour timeframe. 17) You can submit scores as often as you want. 18) If you reach leading score, you are obligated to post your score immediately so others can try to compete with you. 19) The UDF may only use the KiXtart/KiXforms commands/functions/macros, no other code fragments are allowed. 20) Calls to COM components that are part of a standard default Windows installation are allowed. 21) The use of the KiXforms DLL is also permitted as the KiXforms DLL can now be considered an integral part of KiXtart scripting. 22) Calls to other executables, as long as they are part of a standard default Windows installation are allowed. 23) The UDF should be self-contained (except for any I/O mentioned in the challenge). In particular, you may not do things like fetching extra data from a remote site or file. 24) You may assume ASCII as character set. 25) You may use block comments as the KiXgolf Scoring Engine now supports block comments. 26) You are allowed to only use publicly available versions of KiXtart and KiXforms, private builds or alpha builds are NOT allowed. 27) Your submitted score must include the result print of the KiXgolf test-engine. 28) The SETOPTION() parameters in the KiXgolf script may not be modified and will govern the script behavior. SETOPTION() parameters may change depending on the particular needs of the KiXgolf challenge. 29) Tokenizing the UDF, script, or portions thereof is not allowed. 30) If something is not explicitly denied by the rules, it's allowed. 31) If Confusion arises, arranger of the KiXgolf round has the final say. 32) Additional test cases can be added at any time during the KiXgolf round. The code is expected to pass based on the rules. The test cases may not include tests for all rules and exceptions. Test cases that are added during the public round will not alter the results of the private round.
================================================================ KiXtart GOLF - The Duration of the Competition ================================================================
1) Private coding phase: 2011-11-06 to 2011-11-13 (Official Count down clock will determine end time)
2) Public coding phase: 2011-11-13 to 2011-11-20
3) Final results: 2011-11-21
*--> You will need the complete package from http://www.kixtart.org/forums/ubbthreads.php?ubb=download&Number=250.
Attachments
kixgolf_wo.zip (544 downloads) Description:
|
Top
|
|
|
|
#203462 - 2011-11-06 06:44 PM
Re: Kixgolf - Whitespace Obfuscation - Private Round
[Re: Allen]
|
Jochen
KiX Supporter
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 429 anonymous users online.
|
|
|