Brainfuck与Ook!编程语言解析与解密

MarkdownPad Document

Brainfuck与Ook!编程语言解析与解密

CTF的Crypto中经常会遇到这样的加密

++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.

有经验的赛棍一眼就可以看出这是Brainfuck加密,brainfuck又被称为brainf**k或者BF
brainfuck语言用> < + - . , [ ]八种符号来替换C语言的各种语法和命令,具体规则如下:


The Brainfuck programming language consists of eight commands, each of which is represented as a single character.

> Increment the pointer.
< Decrement the pointer.
+ Increment the byte at the pointer.
- Decrement the byte at the pointer.
. Output the byte at the pointer.
, Input a byte and store it in the byte at the pointer.
[ Jump forward past the matching ] if the byte at the pointer is zero.
] Jump backward to the matching [ unless the byte at the pointer is zero.

The semantics of the Brainfuck commands can also be succinctly expressed in terms of C, as follows (assuming that p has been previously defined as a char*):

> becomes ++p;
< becomes --p;
+ becomes ++*p;
- becomes --*p;
. becomes putchar(*p);
, becomes *p = getchar();
[ becomes while (*p) {
] becomes }

brainfuck的更多资料

而另一种类似的Ook!编程语言也偶尔遇到,如下:

Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook.
Ook! Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook?
Ook! Ook! Ook? Ook! Ook? Ook. Ook. Ook. Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook. Ook! Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook! Ook. Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook.
Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook.
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook.
Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook.
Ook! Ook. Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook.
Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook!
Ook! Ook. Ook. Ook? Ook. Ook? Ook. Ook. Ook! Ook.

Ook!语言与brainfuck类似,也是用了替换,具体规则如下:


Syntax Elements

Ook! has only three distinct syntax elements:
Ook.
Ook?
Ook!
These are combined into groups of two, and the various pair combinations specify commands. Programs must thus contain an even number of "Ook"s. Line breaks are ignored.

Commands

Ook. Ook?
Move the Memory Pointer to the next array cell.
Ook? Ook.
Move the Memory Pointer to the previous array cell.
Ook. Ook.
Increment the array cell pointed at by the Memory Pointer.
Ook! Ook!
Decrement the array cell pointed at by the Memory Pointer.
Ook. Ook!
Read a character from STDIN and put its ASCII value into the cell pointed at by the Memory Pointer.
Ook! Ook.
Print the character with ASCII value equal to the value in the cell pointed at by the Memory Pointer.
Ook! Ook?
Move to the command following the matching Ook? Ook! if the value in the cell pointed at by the Memory Pointer is zero. Note that Ook! Ook? and Ook? Ook! commands nest like pairs of parentheses, and matching pairs are defined in the same way as for parentheses.
Ook? Ook!
Move to the command following the matching Ook! Ook? if the value in the cell pointed at by the Memory Pointer is non-zero.

Ook!语言的更多资料

当然对于我们而言,我们没有必要弄清楚Ook!brainfuck的语法,因为网上已经有了很多现成的解密脚本和在线网站,这里提供一个在线的Ook!和brainfuck的在线加密解密网址:
https://www.splitbrain.org/services/ook
2017-2-7 11:21;03

 

 

 

posted @ 2017-02-07 11:24  M4x  阅读(18956)  评论(0编辑  收藏  举报