hash和编码算法列表

一、hash算法对应的场景 #

  • hash均为不可逆加密,一般用于密码的校验
算法名称 位数 用途 hashcat编号 备注
NTLM v2为16位 windows密码 1000 先算hex,再使用unicode编码,再计算md4
爆破的hash类似a7fcb22a88038f35a8f39d503e7f0062
RAR5 压缩包密码 13000 爆破的hash类似$rar5$16$1e71cb65fbc2e25d134279f2cb5be013$15$f6115d7dee842c1f8901b057e2bc8952$8$1988f3ce18017cdb
RAR3-hp 压缩包密码 12500 爆破的hash类似$RAR3$*0*f3e592b768e33df0*f304b7cfd600a36ea3930f7a3c1db19b

二、编码算法对应场景 #

算法名称 位数 用途 备注
base64 数据编码传输 在线加解密https://the-x.cn/encodings/Base64.aspx
brainfuck 数据编码 在线编码解码https://www.splitbrain.org/services/ook
Ook! 数据编码 在线编码解码https://www.splitbrain.org/services/ook
与佛论禅 数据加密 在线加解密http://www.keyfc.net/bbs/tools/tudoucode.aspx

1. brainfuck #

1.1. 示例 #

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

1.2. python解密 #

  • 安装python-brainfuck
  • 解密过程
1>>> import brainfuck
2>>> text = brainfuck.to_function("""
3... +++++ +++++ [->++ +++++ +++<] >++.+ +++++ .<+++ [->-- -<]>- -.+++ +++.<
4... ++++[ ->+++ +<]>+ +++.< +++++ +[->- ----- <]>-- ----- --.<+ +++[- >----
5... <]>-- ----- .<+++ [->++ +<]>+ +++++ .<+++ +[->- ---<] >-.<+ +++++ [->++
6... ++++< ]>+++ +++.< +++++ [->-- ---<] >---- -.+++ .<+++ [->-- -<]>- ----- .<
7... """)
8>>> text()
9'flag{N7F5_AD5'

1.3. php加解密 #

https://github.com/splitbrain/ook

  • 编码
 1/**
 2 * fuck_text() generates brainfuck code from $text. The resulting code will use the current
 3 * register p for looping and the register p+1 for the resulting character. Thus, make sure
 4 * these two registers are zero (prepend "[-]>[-]<<" to clear the first two registers).
 5 *
 6 * I suggest you to use this function in conjunction with wordwrap:
 7 *
 8 * $bf = wordwrap(fuck_text("Hello World"), 75, "\n", 1));
 9 *
10 * wich will generate nice, formatted output.
11 *
12 * @param string $text
13 */
14function fuck_text($text)
15{
16    /* value of current pointer */
17    $value = 0;
18    $result = '';
19
20    for ($_t = 0; $_t < strlen($text); ++$_t) {
21
22        /* ordinal difference between current char and the one we want to have */
23        $diff = ord($text[$_t]) - $value;
24
25        /* it's easier like this than always computing this value - saves some cpu cycles*/
26        $value = ord($text[$_t]);
27
28        /* repeat current character */
29        if ($diff == 0) {
30            $result .= ">.<";
31            continue;
32        }
33
34        /* is it worth making a loop?
35           No. A bunch of + or - consume less space than the loop. */
36        if (abs($diff) < 10) {
37
38            /* output a bunch of + or - */
39            if ($diff > 0)
40                $result .= ">" . str_repeat("+", $diff);
41            else if ($diff < 0)
42                $result .= ">" . str_repeat("-", abs($diff));
43
44        } /* Yes, create a loop. This will make the resulting code more compact. */
45        else {
46
47            /*  we strictly use ints, as PHP has some bugs with floating point operations
48               (even if no division is involved) */
49            $loop = (int)sqrt(abs($diff));
50
51            /* set loop counter */
52            $result .= str_repeat("+", $loop);
53
54            /* execute loop, then add reminder */
55            if ($diff > 0) {
56                $result .= "[->" . str_repeat("+", $loop) . "<]";
57                $result .= ">" . str_repeat("+", $diff - pow($loop, 2));
58            } else if ($diff < 0) {
59                $result .= "[->" . str_repeat("-", $loop) . "<]";
60                $result .= ">" . str_repeat("-", abs($diff) - pow($loop, 2));
61            }
62
63        } /* end: if loop */
64
65        $result .= ".<";
66
67    } /* end: for */
68
69    /* cleanup */
70    return str_replace("<>", "", $result);
71}
72
73$output = fuck_text($input);
74$output = preg_replace('/(.....)/','\\1 ', $output);
75$output = wordwrap($output,75,"\n");
  • 解码
  1/**
  2 * Debug function displays valuable debug information.
  3 * Rewrite this if desired.
  4 *
  5 * @param string $s Source string
  6 * @param int $_s Source string pointer (current position)
  7 * @param array $d Data array
  8 * @param int $_d Data array pointer
  9 * @param string $i Input string
 10 * @param int $_i Input  pointer
 11 * @param string $o Output string
 12 */
 13function brainfuck_debug(&$s, &$_s, &$d, &$_d, &$i, &$_i, &$o)
 14{
 15    echo "<table>\n";
 16    echo "<tr><th>Position</th><th>Value</th><th>ASCII</th></tr>\n";
 17
 18    foreach ($d as $element => $value) {
 19        echo "<tr>\n";
 20        echo '<td style="text-align: center">' . $element . "</td>\n";
 21        echo '<td style="text-align: center">' . ord($value) . "</td>\n";
 22        echo '<td style="text-align: center">' . (ord($value) >= 32 ? htmlentities($value) : "&nbsp;") . "</td>\n";
 23        echo "</tr>\n";
 24    }
 25
 26    echo "</table>\n";
 27}
 28
 29/**
 30 * The actual interpreter
 31 *
 32 * @param string $s Source string
 33 * @param int $_s Source string pointer (current position)
 34 * @param array $d Data array
 35 * @param int $_d Data array pointer
 36 * @param string $i Input string
 37 * @param int $_i Input  pointer
 38 * @param string $o Output string
 39 */
 40function brainfuck_interpret(&$s, &$_s, &$d, &$_d, &$i, &$_i, &$o)
 41{
 42    do {
 43        switch ($s[$_s]) {
 44            /* Execute brainfuck commands. Values are not stored as numbers, but as their
 45               representing characters in the ASCII table. This is perfect, as chr(256) is
 46               automagically converted to chr(0). */
 47            case '+':
 48                $d[$_d] = chr(ord($d[$_d]) + 1);
 49                break;
 50            case '-':
 51                $d[$_d] = chr(ord($d[$_d]) - 1);
 52                break;
 53            case '>':
 54                $_d++;
 55                if (!isset($d[$_d])) $d[$_d] = chr(0);
 56                break;
 57            case '<':
 58                $_d--;
 59                break;
 60
 61            /* Output is stored in a variable. Change this to
 62                 echo $d[$_d]; flush();
 63               if you would like to have a "live" output (when running long calculations, for example.
 64               Or if you are just terribly impatient). */
 65            case '.':
 66                $o .= $d[$_d];
 67                break;
 68
 69            /* Due to PHP's non-interactive nature I have the whole input passed over in a string.
 70               I successively read characters from this string and pass it over to BF every time a
 71               ',' command is executed. */
 72            case ',':
 73                $d[$_d] = $_i == strlen($i) ? chr(0) : $i[$_i++];
 74                break;
 75
 76            /* Catch loops */
 77            case '[':
 78                /* Skip loop (also nested ones) */
 79                if ((int)ord($d[$_d]) == 0) {
 80                    $brackets = 1;
 81                    while ($brackets && $_s++ < strlen($s)) {
 82                        if ($s[$_s] == '[')
 83                            $brackets++;
 84                        else if ($s[$_s] == ']')
 85                            $brackets--;
 86                    }
 87                } /* Execute loop */
 88                else {
 89                    $pos = $_s++ - 1;
 90                    /* The closing ] returns true when the loop has to be executed again. If so, then return
 91                       to the $pos(ition) where the opening [ is. */
 92                    if (brainfuck_interpret($s, $_s, $d, $_d, $i, $_i, $o))
 93                        $_s = $pos;
 94                }
 95                break;
 96            /* Return true when loop has to be executed again. It is redundant to the [ checking, but
 97               it will save some parsing time (otherwise the interpreter would have to return to [ only
 98               to skip all characters again) */
 99            case ']':
100                return ((int)ord($d[$_d]) != 0);
101            /* Call debug function */
102            case '#':
103                brainfuck_debug($s, $_s, $d, $_d, $i, $_i, $o);
104        }
105    } while (++$_s < strlen($s));
106}
107
108/**
109 * Call this one in order to interpret brainfuck code
110 *
111 * @param string $source source data
112 * @param string $input Simulate stdin
113 * @return string the output
114 */
115function brainfuck($source, $input = '')
116{
117
118    /* Define needed variables:
119
120       $data    Brainfuck's memory
121       $source  Source data
122       $input   Simulate STDIN
123       $output  Save output in here
124
125       Each with according index variables
126    */
127
128    $data = array();
129    $data[0] = chr(0); /* It is necessary to set every element explicitly, as
130                             PHP treats arrays as hashes */
131    $data_index = 0;
132
133    $source_index = 0;
134
135    $input_index = 0;
136
137    $output = '';
138
139    /* Call the actual interpreter */
140    brainfuck_interpret(
141        $source,
142        $source_index,
143        $data,
144        $data_index,
145        $input,
146        $input_index,
147        $output
148    );
149
150    return $output;
151}

2. Ook! 格式 #

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

2.1. php编码解码 #

  • 编码
 1// 基于brain_fuck的编码转成这样
 2$output = fuck_text($input);
 3$output = strtr($output,array('>' => 'Ook. Ook? ',
 4                            '<' => 'Ook? Ook. ',
 5                            '+' => 'Ook. Ook. ',
 6                            '-' => 'Ook! Ook! ',
 7                            '.' => 'Ook! Ook. ',
 8                            ',' => 'Ook. Ook! ',
 9                            '[' => 'Ook! Ook? ',
10                            ']' => 'Ook? Ook! ',
11                            ));
  • 解码
 1$lookup = array(
 2            '.?' => '>',
 3            '?.' => '<',
 4            '..' => '+',
 5            '!!' => '-',
 6            '!.' => '.',
 7            '.!' => ',',
 8            '!?' => '[',
 9            '?!' => ']',
10            );
11
12$input = preg_replace('/[^\.?!]+/','',$input);
13$len = strlen($input);
14for($i=0;$i<$len;$i+=2){
15    $output .= $lookup[$input{$i}.$input{$i+1}];
16}
17$output = brainfuck($output);

3. 与佛论禅 #

类似下面格式

佛曰:遮等諳勝能礙皤藐哆娑梵迦侄羅哆迦梵者梵楞蘇涅侄室實真缽朋能。奢怛俱道怯都諳怖梵尼怯一罰心缽謹缽薩苦奢夢怯帝梵遠朋陀諳陀穆諳所呐知涅侄以薩怯想夷奢醯數羅怯諸