示例#1
0
文件: cdb.py 项目: stillson/cdb
def dec_ext(f, indt=0, showasm=0, showast=0, deob=0):
    rv = []

    with CaptureStdout(rv):
        uncompyle('2.7', f, sys.stdout, showasm=showasm, showast=showast, deob=deob)
    rv = [indent(indt) + j for j in rv]
    return "\n".join(rv)
示例#2
0
def decompile(co):
    version = magics.versions["\x03\xf3\r\n"]
    s = StringIO.StringIO()
    try:
        uncompyle(version, co, s, showasm=0, showast=0)
        ret = s.getvalue()
    except Exception, e:
        return str(e)
示例#3
0
def decompile(co):
	version = magics.versions["\x03\xf3\r\n"]
	s = StringIO.StringIO()
	try:
		uncompyle(version, co, s, showasm=0, showast=0)
		ret = s.getvalue()
	except Exception, e:
		return str(e)
示例#4
0
文件: evedec.py 项目: strich/evedec
def process_func(code_q, result_q, store_path, lock):
    okay_files = failed_files = 0
    try:
        import sys, os, marshal, errno, Queue
        import uncompyle2
        while 1:
            filename, marshalled_code = code_q.get(True,
                                                   5)  #give up after 5 sec
            if filename == None:  #None is our end marker
                break
            try:
                code = marshal.loads(marshalled_code[8:])

                #prepend our store_path
                filename = os.path.join(store_path, filename)
                filename = os.path.abspath(filename)
                try:
                    os.makedirs(os.path.dirname(filename))
                except OSError as e:
                    #the dir may already exist, in which case ignore error
                    if e.errno != errno.EEXIST:
                        raise
                try:
                    os.remove(filename + '_failed')
                    os.remove(filename + 'c')
                except OSError as e:
                    if e.errno != errno.ENOENT:
                        raise
                with open(filename, 'w') as out_file:
                    uncompyle2.uncompyle('2.7', code, out_file)
            except KeyboardInterrupt:
                raise
            except:
                with lock:
                    print '### Can\'t decompile %s' % filename
                    sys.stdout.flush()
                os.rename(filename, filename + '_failed')
                with open(filename + 'c', 'wb') as codefile:
                    codefile.write(marshalled_code)
                failed_files += 1
            else:
                with lock:
                    print '+++ Okay decompiling %s' % filename
                    sys.stdout.flush()
                okay_files += 1

    except Queue.Empty:  #timeout reached
        pass
    finally:
        result_q.put((okay_files, failed_files))
示例#5
0
文件: evedec.py 项目: bbday/evedec
def process_func(code_q, result_q, store_path, lock):
    okay_files = failed_files = 0
    try:
        import sys, os, marshal, errno, Queue
        import uncompyle2
        while 1:
            filename, marshalled_code = code_q.get(True, 5) #give up after 5 sec
            if filename == None: #None is our end marker
                break
            try:
                code = marshal.loads(marshalled_code)
                
                #prepend our store_path
                filename = os.path.join(store_path, filename)
                filename = os.path.abspath(filename)
                try:
                    os.makedirs(os.path.dirname(filename))
                except OSError as e:
                    #the dir may already exist, in which case ignore error
                    if e.errno != errno.EEXIST:
                        raise
                try:
                    os.remove(filename+'_failed')
                except OSError as e:
                    if e.errno != errno.ENOENT:
                        raise
                with open(filename, 'w') as out_file:
                    uncompyle2.uncompyle('2.7', code, out_file)
            except KeyboardInterrupt:
                raise
            except:
                with lock:
                    print '### Can\'t decompile %s' % filename
                    sys.stdout.flush()
                os.rename(filename, filename+'_failed')
                failed_files += 1
            else:
                with lock:
                    print '+++ Okay decompiling %s' % filename
                    sys.stdout.flush()
                okay_files += 1
                
    except Queue.Empty: #timeout reached
        pass
    finally:
        result_q.put((okay_files, failed_files))
示例#6
0
def decompile(code, version="2.7"):

    import meta
    from uncompyle2 import uncompyle

    try:
        source = StringIO.StringIO()
        uncompyle(version, code, source)
        source = source.getvalue()
    except:
        try:
            code_obj = meta.decompile(code)
            source = meta.dump_python_source(code_obj)
        except:
            return None

    return source.lstrip(' \n')
def decompile(code, version="2.7"):

    import meta
    from uncompyle2 import uncompyle

    try:
        source = StringIO.StringIO()
        uncompyle(version, code, source)
        source = source.getvalue()
    except:
        try:
            code_obj = meta.decompile(code)
            source = meta.dump_python_source(code_obj)
        except:
            return None

    return source.lstrip(' \n')
示例#8
0
def uncompyle_file(filename,
                   outstream=None,
                   showasm=0,
                   showast=0,
                   ignore_the_first_8_bytes=False,
                   is_zlib_decompress=False):
    '''
    ref: uncompyle2.uncompyle_file

    decompile Python byte-code file (.pyc)
    '''
    version, co = _load_module(filename,
                               ignore_the_first_8_bytes=True,
                               is_zlib_decompress=is_zlib_decompress)
    if type(co) == list:
        for con in co:
            uncompyle(version, con, outstream, showasm, showast)
    else:
        uncompyle(version, co, outstream, showasm, showast)
    co = None
示例#9
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

'''
import marshal, zlib, base64

exec(marshal.loads(zlib.decompress(base64.b64decode('eJyNVktv00AQXm/eL0igiaFA01IO4cIVCUGFBBJwqRAckLhEIQmtRfPwI0QIeio/hRO/hJ/CiStH2M/prj07diGRP43Hs9+MZ2fWMxbnP6mux+oK9xVMHPFViLdCTB0xkeKDFEFfTIU4E8KZq8dCvB4UlN3hGEsdddXU9QTLv1eFiGKGM4cKUgsFCNLFH7dFrS9poayFYmIZm1b0gyqxMOwJaU3r6xs9sW1ooakXuRv+un7Q0sIlLVzOCZq/XtsK2oTSYaZlStogXi1HV0iazoN2CV2HZeXqRQ54TlJRb7FUlKyUatISsdzo+P7UU1Gb1POdMruckepGwk9tIXQTftz2yBaT5JQovWvpSa6poJPuqgao+b9l5Aj/R+mLQIP4f6Q8Vb3g/5TB/TJxWGdZr9EQrmn99fwKtTvAZGU7wzS7GNpZpDm2JgCrr8wrmPoo54UqGampFIeS9ojXjc4E2yI06bq/4DRoUAc0nVnng4k6p7Ks0+j/S8z9V+NZ5dhmrJUM/y7JTJeRtnJ2TSYJvsFq3CQt/vnfqmQXt5KlpuRcIvDAmhnn2E0t9BJ3SvB/SfLWhuOWNiNVZ+h28g4wlwUp00w95si43rZ3r6+fUIEdgOZbQAsyFRRvBR6dla8KCzRdslar7WS+a5HFb39peIAmG7uZTHVm17Czxju4m6bayz8e7J40DzqM0jr0bmv9PmPvk6y5z57HU8wdTDHeiUJvBMAM4+0CpoAZ4BPgJeAYEAHmgAUgAHiAj4AVAGORtwd4AVgC3gEmgBBwCPgMWANOAQ8AbwBHgHuAp4D3gLuARwoGmNUizF/j4yDC5BWM1kNvvlxFA8xikRrBxHIUhutFMBlgQoshhPphGAXe/OggKqqb2cibxwuEXjUcQjccxi5eFRL1fDSbKrUhy2CMb2aLyepkegDWsBwPlrVC0/kLHmeCBQ=='))))
'''
import uncompyle2, marshal, zlib, base64

co = marshal.loads(zlib.decompress(base64.b64decode('eJyNVktv00AQXm/eL0igiaFA01IO4cIVCUGFBBJwqRAckLhEIQmtRfPwI0QIeio/hRO/hJ/CiStH2M/prj07diGRP43Hs9+MZ2fWMxbnP6mux+oK9xVMHPFViLdCTB0xkeKDFEFfTIU4E8KZq8dCvB4UlN3hGEsdddXU9QTLv1eFiGKGM4cKUgsFCNLFH7dFrS9poayFYmIZm1b0gyqxMOwJaU3r6xs9sW1ooakXuRv+un7Q0sIlLVzOCZq/XtsK2oTSYaZlStogXi1HV0iazoN2CV2HZeXqRQ54TlJRb7FUlKyUatISsdzo+P7UU1Gb1POdMruckepGwk9tIXQTftz2yBaT5JQovWvpSa6poJPuqgao+b9l5Aj/R+mLQIP4f6Q8Vb3g/5TB/TJxWGdZr9EQrmn99fwKtTvAZGU7wzS7GNpZpDm2JgCrr8wrmPoo54UqGampFIeS9ojXjc4E2yI06bq/4DRoUAc0nVnng4k6p7Ks0+j/S8z9V+NZ5dhmrJUM/y7JTJeRtnJ2TSYJvsFq3CQt/vnfqmQXt5KlpuRcIvDAmhnn2E0t9BJ3SvB/SfLWhuOWNiNVZ+h28g4wlwUp00w95si43rZ3r6+fUIEdgOZbQAsyFRRvBR6dla8KCzRdslar7WS+a5HFb39peIAmG7uZTHVm17Czxju4m6bayz8e7J40DzqM0jr0bmv9PmPvk6y5z57HU8wdTDHeiUJvBMAM4+0CpoAZ4BPgJeAYEAHmgAUgAHiAj4AVAGORtwd4AVgC3gEmgBBwCPgMWANOAQ8AbwBHgHuAp4D3gLuARwoGmNUizF/j4yDC5BWM1kNvvlxFA8xikRrBxHIUhutFMBlgQoshhPphGAXe/OggKqqb2cibxwuEXjUcQjccxi5eFRL1fDSbKrUhy2CMb2aLyepkegDWsBwPlrVC0/kLHmeCBQ==')))

strr = zlib.decompress(base64.b64decode('eJyNVktv00AQXm/eL0igiaFA01IO4cIVCUGFBBJwqRAckLhEIQmtRfPwI0QIeio/hRO/hJ/CiStH2M/prj07diGRP43Hs9+MZ2fWMxbnP6mux+oK9xVMHPFViLdCTB0xkeKDFEFfTIU4E8KZq8dCvB4UlN3hGEsdddXU9QTLv1eFiGKGM4cKUgsFCNLFH7dFrS9poayFYmIZm1b0gyqxMOwJaU3r6xs9sW1ooakXuRv+un7Q0sIlLVzOCZq/XtsK2oTSYaZlStogXi1HV0iazoN2CV2HZeXqRQ54TlJRb7FUlKyUatISsdzo+P7UU1Gb1POdMruckepGwk9tIXQTftz2yBaT5JQovWvpSa6poJPuqgao+b9l5Aj/R+mLQIP4f6Q8Vb3g/5TB/TJxWGdZr9EQrmn99fwKtTvAZGU7wzS7GNpZpDm2JgCrr8wrmPoo54UqGampFIeS9ojXjc4E2yI06bq/4DRoUAc0nVnng4k6p7Ks0+j/S8z9V+NZ5dhmrJUM/y7JTJeRtnJ2TSYJvsFq3CQt/vnfqmQXt5KlpuRcIvDAmhnn2E0t9BJ3SvB/SfLWhuOWNiNVZ+h28g4wlwUp00w95si43rZ3r6+fUIEdgOZbQAsyFRRvBR6dla8KCzRdslar7WS+a5HFb39peIAmG7uZTHVm17Czxju4m6bayz8e7J40DzqM0jr0bmv9PmPvk6y5z57HU8wdTDHeiUJvBMAM4+0CpoAZ4BPgJeAYEAHmgAUgAHiAj4AVAGORtwd4AVgC3gEmgBBwCPgMWANOAQ8AbwBHgHuAp4D3gLuARwoGmNUizF/j4yDC5BWM1kNvvlxFA8xikRrBxHIUhutFMBlgQoshhPphGAXe/OggKqqb2cibxwuEXjUcQjccxi5eFRL1fDSbKrUhy2CMb2aLyepkegDWsBwPlrVC0/kLHmeCBQ=='))
f = open('d:/hitcon_rev50.py', 'wb');
uncompyle2.uncompyle('2.7',co,f);
示例#10
0
import uncompyle2
import marshal

file = open("D:/rcode/func.marshal","rb")
outputfile = open("D:/rcode/func.py","wb")
func = marshal.load(file)

uncompyle2.uncompyle("2.7",func,out=outputfile)

file.close()
outputfile.close()
示例#11
0
import uncompyle2
import marshal

file = open("D:/rcode/func.marshal", "rb")
outputfile = open("D:/rcode/func.py", "wb")
func = marshal.load(file)

uncompyle2.uncompyle("2.7", func, out=outputfile)

file.close()
outputfile.close()
示例#12
0
#!/usr/bin/env python
#coding=utf-8
#flag.py

import marshal, zlib, base64

bs = marshal.loads(
    zlib.decompress(
        base64.b64decode(
            'eJxtVP9r21YQvyd/ieWm66Cd03QM1B8C3pggUuzYCSWstHSFQijyoJBhhGq9OXJl2ZFeqAMOK6Q/94f9Ofvn1s+d7Lgtk/3O997du/vc584a0eqpYP2GVfwDEeOrKCU6g2LRRyiK4oooFsVVUSqkqxTX6J1F+SfSNYrrdKPorC76luhbpOEGCZNFZw2KG3Rmk26QtuXi3xTb7ND6/aVu0g2RuvhEcZNut5lAGbTvAFbyH57TkYLKy8J6xpDvQxiiiaIlcdqJxVcHbXY6bXNlZgviPCrO0+StqfKd88gzNh/qRZyMdWHE29TZZvIkG7eZFRGGRcBmsXJaUoKCQ9fWKHwSqNeKFnsM5PnwJ7q2aKk4AFhcWtQCh+ChB5+Lu/RmyYUxmtOEYxas7i/2iuR7Ti14OEOSmU0RADd4+dQzbM1FJhukAUeQ+kZROuLyioagrau76kc1slY1NNaY/y3LAxDQBrAICJisV2hMdF2lxQcyFuMoqcX3+TCl6xotqzSpkqmxYVmjXVjAXiwBsEfBrd1VvTvLCj2EXRnhoryAKdpxcIgJcowUB68yAx/tlCAuPHqDuZo0CN3CUGHwkPhGMA7aXMfphjbmQLhLhJcHa0a+mpgB191c1U1lnHJQbgkHx+WGxeJbejnpkzSavo2jkxZ7i725npGAaTc8FXmUjbUETHUmkxXN5zqL5WiWxwE7Bc11yyYzNJpN02jerq+DzNNodfxOX8kE4FcmYKscDdYD1oPGGucXYNmgs1F+NTf3GOt3Mg7b+NTVruqoQyX1hOEUacKw+AGbP38ZOq9THRXaSbL5pXGQ8bho/Z/lrzQaHxdoCrlev+t6nZ7re57r+57rHXag93Deh37k+vuw9zorO/Qj/B50cAf2oyOsvut3D+ADWxdxfN/1Drqu39mHzvcRswv/Hvz7sHeg9w8Qzy99DzuFwxhPhs6zWTbOI3OZRiaZZcVj5wVwOklx7OwVxR47PR46r/SVM8ulBJic9zku/eqY/MqJxiDj+Gd55wS3f35pbLCzHoEwzKKpDkN5i+TR+1AYCWTo5IV0Z0P9H3phDDd6lMzPdS5bbo9eJGbTsW9nbDqLL1N9Iq+rRxDbll2x67a9Lf27hw5uK1s1rZr6DOPF+FI='
        )))
# exec(marshal.loads(bs))
# http://www.cnblogs.com/rainduck/p/3524557.html
# https://github.com/wibiti/uncompyle2
import uncompyle2
with open('f.py', 'w') as f:
    uncompyle2.uncompyle('2.7', bs, f)