ffftp.ini パスワードデコーダ
諸事情で書いたので. 入力は標準入力、出力は標準出力.
#!/usr/bin/env python # -*- coding: utf-8 -*- from sys import stdin, stdout def decode(s): result = '' t = [ord(c) for c in s] + [0] i = 0 while i < len(s): rnd = (t[i] >> 4) & 0x3 ch = (t[i] & 0xf) | ((t[i + 1] & 0xf) << 4) ch <<= 8 if (t[i] & 0x1) != 0: i += 1 i += 2 ch >>= rnd ch = (ch & 0xff) | ((ch >> 8) & 0xff) result += chr(ch) return result def main(): for s in stdin: s = s.rstrip('\r\n') if s.startswith('HostAdrs'): stdout.write('\n[%s]\n' % (s.split('=')[1],)) elif s.startswith('UserName'): stdout.write('ID: %s\n' % (s.split('=')[1],)) elif s.startswith('Password'): stdout.write('PW: %s\n' % (decode(s.split('=')[1].replace('\\\\', '\\')),)) if __name__ == "__main__": main()