Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Top Posters

Who's Online (0)

Powered by Vanilla. Made with Bootstrap.
xor encoder v1.0
  • s1n4
    Posts: 88
    Hi everyone,

    I wrote a simple xor encoder in python.

    #!/usr/bin/python

    #A simple xor encoder
    #Xor the input file with 0-255
    #Written by s1n4


    import sys

    def usage() :
    print 'Usage: %s [Key] [File]' % sys.argv[0]
    print '[Key] 0x00-0xff same as 0-255'
    exit()


    def xor(key, fn) :
    try :
    Input = open(fn, 'rb').read()

    except IOError :
    usage()

    res = ''

    for i in Input :
    try :
    res += chr(ord(i) ^ eval(key))

    except :
    usage()


    try :
    Output = open(fn, 'wb')
    Output.write(res)

    finally :
    Output.close()
    print fn, 'xor', key


    def main() :
    if len(sys.argv) == 3 :
    xor(sys.argv[1], sys.argv[2])

    else :
    usage()

    main()


    For example :
    xor.py 0x4a test.txt


    For access to the original file you must xor again with latest key.
  • Xin
    Posts: 3,251
    Nice , you should make the key bigger though as that can be bruted in a matter of seconds/minutes.
    Xin