#!/usr/bin/env python2

"""cracf2john.py processes CRACF.TXT files (generated by CRACF program)
into a format suitable for use with JtR."""

import sys


def process_file(filename):
    with open(filename, "r") as f:
        for line in f.readlines():
            data = line.split()
            sys.stdout.write("%s:$racf$*%s*%s*%s\n" % \
                     (data[0], data[0], data[-1], data[-2]))

if __name__ == "__main__":
    if len(sys.argv) < 2:
        sys.stderr.write("Usage: %s <CRACF.TXT>\n" % sys.argv[0])
        sys.exit(-1)

    for i in range(1, len(sys.argv)):
        process_file(sys.argv[i])
