It looks like you're new here. If you want to get involved, click one of these buttons!
#!/usr/bin/python
import sys
def usage() :
print 'Usage : %s [file] [key]' % sys.argv[0]
exit()
def main(fn, key) :
try :
Input = file(fn, 'r').read()
except :
usage()
enc = ''
res = ''
c = 0
if Input.find('<?php') != -1 :
Input = Input.replace('<?php', '')
elif Input.find('<?') != -1 :
Input = Input.replace('<?', '')
elif Input.find('?>') != -1 :
Input = Input.replace('?>', '')
for i in Input :
enc += chr(ord(i) ^ ord(key[c]))
if c == len(key)-1 :
c = 0
continue
c += 1
for ii in enc :
res += r'\x' + ii.encode('hex')
x = fn[:-fn.find('.')-2]
y = x + 'xored.'
z = y + fn[fn.find('.')+1:]
Output = file(z, 'w')
Output.write('<?php\n')
Output.write('$code = \"' + res + '\";\n')
Output.write('$key = \"' + key + '\";\n')
Output.write('''$mcode = \"\";
$c2 = 0;
for ($c=0; $c<=strlen($code)-1; $c++)
{
$mcode .= chr(ord($code[$c]) ^ ord($key[$c2]));
if ($c2 == strlen($key)-1)
{
$c2 = 0;
continue;
}
$c2++;
}
eval($mcode);
?>''')
Output.close()
if len(sys.argv) == 3 :
main(sys.argv[1], sys.argv[2])
print 'Done!'
else :
usage()