WinDbg,449388字节
as, }@$t1
as. }0;?@$t0
asThink n10;ed8<<22;r$t0=dwo(8<<22);r$t1=0;.do{
aSa " "
asQ .printf";r$t1=1;.do{r$t1=@$t1-1;r$t0=@$t0
as/c add Q +"
aSby " "
as/c divide Q /"
asfrom 0;r$t0=-@$t0+
as/c multiply Q *"
aSnumber " "
aSof " "
asrepeat +1
as/c subtract Q -"
.for(r$t9=1;by(@$t0);r$t0=@$t0+1){j44!=by(@$t0) .printf"%c",by(@$t0);.if116!=by(@$t0-1){.printf" , "}};.printf"\b ."
通过定义重复代码的别名来生成-61字节
受LambdaBeta使用的启发#define
。这种方法会稍微修改WordMath语法(,
并且.
必须像其他单词一样用空格分隔,并且,
不遵循repeat
),并创建别名,使修改后的WordMath语法是有效的WinDbg代码。最后一行通过将输入转换为修改后的语法来执行问题并进行翻译。
通过在存储器地址处设置字符串并将伪寄存器$t0
设置为该地址来进行输入。注意:这将覆盖int
at 0x2000000
,因此,如果您在此处开始字符串,它将被部分覆盖。$t0
也将被覆盖。
因为它创建别名,所以取决于此代码是在设置字符串之前还是之后运行的,因此输出代码将有所不同(是否为别名)。不幸的是,我没有找到一种方法来在没有用空格分隔的情况下使别名正确扩展(这意味着WordMath脚本不能不先转换就直接执行)。
怎么运行的:
* $t1 is used for repeating and $t0 is used to read the input and hold the accumulator
* Alias , to }@$t1 -- closing do-while loop and allowing repeat
as , }@$t1
* Alias . to }0;?@$t0 -- close do-while loop and evaluate $t0 (accumulator)
as . }0;?@$t0
* Alias Think to (note this is one line)
as Think n10; * Set base 10
ed 8<<22; * Read ints to address 0x2000000. Enter nothing to exit input mode
r$t0 = dwo(8<<22); * Set $t0 = first int
r$t1=0;.do{ * Open do-while
* Alias a to nothing
aS a " "
* Alias add to (note one line):
as add ; * Close previous statement
r$t1=1;.do{r$t1=@$t1-1; * Open do-while (once) loop
r$t0=@$t0+ * Add number to $t0
* Alias by to nothing
aS by " "
* Alias divide to (note one line):
as divide ; * Close previous statement
r$t1=1;.do{r$t1=@$t1-1; * Open do-while (once) loop
r$t0=@$t0/ * Divide next number from $t0
* Alias from to (note one line):
as from 0; * Preceding subtract statement subtracts 0
r$t0=-@$t0+ * Subtract $t0 from next number
* Alias multiply to (note one line):
as multiply ; * Close previous statement
r$t1=1;.do{r$t1=@$t1-1; * Open do-while (once) loop
r$t0=@$t0* * Multiply next number with $t0
* Alias number to nothing
aS number " "
* Alias of to nothing
aS of " "
* Alias repeat to +1 making do-while (once) loops into do-while (once)+1
as repeat +1
* Alias subtract to (note one line):
as subtract ; * Close previous statement
r$t1=1;.do{r$t1=@$t1-1; * Open do-while (once) loop
r$t0=@$t0- * Subtract next number from $t0
.for (r$t9=1; by(@$t0); r$t0=@$t0+1) * Enumerate the string
{
j 44!=by(@$t0) * If not comma
.printf "%c",by(@$t0); * Print the char
* implicit else
.if 116!=by(@$t0-1) * Else if the previous char is not t
{
.printf " , " * Print the comma with spaces around it
}
};
.printf "\b ." * Replacing ending "." with " ."
输出示例,在运行此代码一次之前输入字符串(结果程序类似于WordMath):
0:000> r$t0=8<<22
0:000> eza8<<22"Think of a number, add 5, add 10, multiply by 2, subtract 15, repeat, divide by 2."
0:000> as, }@$t1
0:000> as. }0;?@$t0
0:000> asThink n10;ed8<<22;r$t0=dwo(8<<22);r$t1=0;.do{
0:000> aSa " "
0:000> asadd ;r$t1=1;.do{r$t1=@$t1-1;r$t0=@$t0+
0:000> aSby " "
0:000> asdivide ;r$t1=1;.do{r$t1=@$t1-1;r$t0=@$t0/
0:000> asfrom 0;r$t0=-@$t0+
0:000> asmultiply ;r$t1=1;.do{r$t1=@$t1-1;r$t0=@$t0*
0:000> aSnumber " "
0:000> aSof " "
0:000> asrepeat +1
0:000> assubtract ;r$t1=1;.do{r$t1=@$t1-1;r$t0=@$t0-
0:000> .for(r$t9=1;by(@$t0);r$t0=@$t0+1){j44!=by(@$t0) .printf"%c",by(@$t0);.if116!=by(@$t0-1){.printf" , "}};.printf"\b ."
Think of a number , add 5 , add 10 , multiply by 2 , subtract 15 , repeat divide by 2 }0;?@$t0
0:000> Think of a number , add 5 , add 10 , multiply by 2 , subtract 15 , repeat divide by 2 }0;?@$t0
base is 10
02000000 6e696854 18
18
02000004 666f206b
Evaluate expression: 18 = 00000012
示例输出,在此代码运行一次之后输入字符串(输入字符串时别名会扩展,因此生成的程序不太漂亮):
0:000> r$t0=8<<22
0:000> eza8<<22"Think of a number, add 5, add 10, multiply by 2, subtract 15, repeat, divide by 2."
0:000> as, }@$t1
0:000> as. }0;?@$t0
0:000> asThink n10;ed8<<22;r$t0=dwo(8<<22);r$t1=0;.do{
0:000> aSa " "
0:000> asadd ;r$t1=1;.do{r$t1=@$t1-1;r$t0=@$t0+
0:000> aSby " "
0:000> asdivide ;r$t1=1;.do{r$t1=@$t1-1;r$t0=@$t0/
0:000> asfrom 0;r$t0=-@$t0+
0:000> asmultiply ;r$t1=1;.do{r$t1=@$t1-1;r$t0=@$t0*
0:000> aSnumber " "
0:000> aSof " "
0:000> asrepeat +1
0:000> assubtract ;r$t1=1;.do{r$t1=@$t1-1;r$t0=@$t0-
0:000> .for(r$t9=1;by(@$t0);r$t0=@$t0+1){j44!=by(@$t0) .printf"%c",by(@$t0);.if116!=by(@$t0-1){.printf" , "}};.printf"\b ."
n10;ed8<<22;r$t0=dwo(8<<22);r$t1=0;.do{ number , ;r$t1=1;.do{r$t1=@$t1-1;r$t0=@$t0+ 5 , ;r$t1=1;.do{r$t1=@$t1-1;r$t0=@$t0+ 10 , ;r$t1=1;.do{r$t1=@$t1-1;r$t0=@$t0* 2 , ;r$t1=1;.do{r$t1=@$t1-1;r$t0=@$t0- 15 , repeat ;r$t1=1;.do{r$t1=@$t1-1;r$t0=@$t0/ 2 }0;?@$t0
0:000> n10;ed8<<22;r$t0=dwo(8<<22);r$t1=0;.do{ number , ;r$t1=1;.do{r$t1=@$t1-1;r$t0=@$t0+ 5 , ;r$t1=1;.do{r$t1=@$t1-1;r$t0=@$t0+ 10 , ;r$t1=1;.do{r$t1=@$t1-1;r$t0=@$t0* 2 , ;r$t1=1;.do{r$t1=@$t1-1;r$t0=@$t0- 15 , repeat ;r$t1=1;.do{r$t1=@$t1-1;r$t0=@$t0/ 2 }0;?@$t0
base is 10
02000000 3b30316e 26
26
02000004 3c386465
Evaluate expression: 26 = 0000001a
仅使用稍微修改的WordMath语法,即可获得更多示例输出:
0:000> Think of a number , add 1 , repeat repeat repeat divide by 3 .
base is 10
02000000 0000001a 3
3
02000004 3c386465
Evaluate expression: 2 = 00000002
0:000> Think of a number , divide by 5 , subtract from 9 .
base is 10
02000000 00000003 29
29
02000004 3c386465
Evaluate expression: 4 = 00000004