#!/bin/bash
$'\141'
string1="$'\\"
number=141
string2="'"
result="${string1}${number}${string2}"
$result
运行此脚本会给出以下响应:
./temp.sh: line 2: a: command not found
./temp.sh: line 8: $'\141': command not found
为什么这两者不等价?第二次尝试时需要更改哪些内容才能获得正确的 ASCII 转换?
显然第二次尝试没有按预期转换为“a”。为什么是这样?我想也许是因为我通过做
\\
逃避了反斜杠的特殊含义。但如果是这样的话,是否意味着无法对构造的字符串进行 ASCII 转换?
有关更多信息,这是针对 CTF 的,我必须在不使用任何字母的情况下运行
cat ../../flag
或等效命令。所以我尝试使用 ASCII 转换。
生成
ascii
字母需要什么:
$ for i in {141..143}; do printf '%b\n' '\'$i; done
a
b
c