如何“解码”字体文件的eexec?

时间:2013-03-23 06:30:37

标签: fonts adobe postscript glyph

我有一个.pfa font file,我想阅读用于渲染字体的“算法”。但是,大多数信息都隐藏在行中的二进制文件中:

currentfile eexec
743F8413F3636CA85A9FFEFB50B4BB27302A5F6C876586CCC1670A7EF5521E6ADE15AAB4
DD2DDDB83735311FC63DB80D2C96AECFA05BB67F865EA35934B4B79A203A8DD489B09C79
FF6EB9DBCFD889C3E73F8C94BC342AF671D6F688870A62EE1A0DF216E150FFEC64A8C2B7
509AD05C011599C1AD84E6C4B668E07EA219BD72663D8AF4CA8EC8E23AA90DE90BE940C6
6DB849CEDB3B64961365A7CCE47F4FC9E30FDEE4B14B90C2E0D8C344EBC974EABF417B3D
28251A78ACEE2BFC4212B1E3E9C7EBC3262821EE98E538713C64DF0BC13C19337B1307DB
D795D285F959C924FC14AEF7E9D406406CDEE1A35377887A16B13DD51717A86284369FA7
6ABB6A4488B9174A561DA854C33821F3172E4CF956EC9B65F829D69E02BC0EE23044DB1D
9A4D45A14A3998115BEE5DDC582F158DB2E..................

我们如何“解码”这些信息?

4 个答案:

答案 0 :(得分:8)

除非你真的想编写自己的eexec解密,然后你自己的字符串解密,否则我建议你只使用t1disasm。如果你在Linux发行版上运行,你可以找到一个包含t1utils的软件包,或者你可以在很多地方获取源代码(谷歌是你的朋友),这里是一个:

http://freepcb.googlecode.com/svn/clibpdf/trunk/util/t1utils-1.9/t1disasm.c

如果你在Windows上,你可以在这里查看t1utils包fopr WIndows:

http://gnuwin32.sourceforge.net/packages/t1utils.htm

答案 1 :(得分:3)

我在解密eexec加密时发现this document 非常有用中使用此处提到的代码的一个简单示例。

#Getting the eexec binary, make sure you exclude the ascii part in the end, after the binary portion 
text = open('fontfile.pfa').read()
raw_hex = text.split('eexec')[1]
decarr = list()
count = 0
hex_code = str()

#Converting pairs of the hexadecimal digits to decimal, e.g. ff -> 255, and storing it in an array decarr
for i in range(len(raw_hex)):
    if raw_hex[i] == '\n':
        decarr.append(raw_hex[i])
        continue
    else:
        hex_code = hex_code + raw_hex[i]
        count += 1
        if count == 2:
            decarr.append(int(hex_code, 16))
            count = 0
            hex_code = str()

一旦我们得到一对十六进制数字的十进制等值数组,我们就会执行Adobe Type 1 Font Format Specification第7章中提到的解密。常量如说明书中所述。

c1 = 52845
c2 =  22719
R = 55665
p = list()
for i in range(0,len(decarr)):
    if decarr[i] is not '\n':
        p.append(decarr[i]^(R >> 8))
        R = ((decarr[i] + R)*c1 + c2) & ((1 << 16) - 1)
    else:
        p.append(decarr[i])
decrypted = list()
for i in range(len(p)):
    if p[i] is not '\n':
        decrypted.append(chr(p[i]))
    else:
        decrypted.append(p[i])

希望它有所帮助!

答案 2 :(得分:0)

我认为KenS的答案更好,但是,作为一个好奇心,这里是一个emacs函数,它执行eexec解密一个旁路输入(即没有十六进制输入的解密和没有字符串解密)。该算法来自亨利答案中的文件。

(defun eexec-decrypt ()
  "decrypt eexec binary block (see Type1 font);
   NB: no charstring decryption"
  (interactive)
  (search-forward "currentfile eexec")(forward-char 1)
  (with-output-to-temp-buffer (concat (buffer-name) "-eexec-decripted")
    (setq r 55665)
    (setq c1 52845)
    (setq c2 22719)
    (setq here (point))
    (setq count 4)
    (while (< here (point-max)) ; I'm not really sure where to stop...
      (setq cipher (get-byte here))
      (setq plain (logxor cipher (lsh r -8)))
      (cond ((> count 0) ; skip first 4 bytes
         (setq count (- count 1)))
        (t (princ (byte-to-string plain))))

      (setq r (mod (+ c2 (* c1 (+ cipher r))) 65536))
      (setq here (+ 1 here)))))

答案 3 :(得分:0)

真正整洁的是,任何一位七年级学生都可以看懂eexec文件!

只需插入一个随机字符并查看堆栈和错误报告即可。每隔几十个字符重复一次。

就像语音响应保险箱一样,“尝试单击三下”。