Exemple #1
0
def cleanup(conffile, force, distclean):
    try:
        commands = Commands(conffile, shortstart=True)

        if not force:
            print 'WARNING:'
            print 'The cleanup script will delete all folders created by MCP, including the'
            print 'src folder which may contain changes you made to the code, along with any'
            print 'saved worlds from the client or server.'
            answer = raw_input('If you really want to clean up, enter "Yes" ')
            if answer.lower() not in ['yes']:
                print 'You have not entered "Yes", aborting the clean up process'
                sys.exit(1)

        commands.checkupdates()

        try:
            commands.logger.info('> Cleaning temp')
            reallyrmtree(commands.dirtemp)

            commands.logger.info('> Cleaning src')
            reallyrmtree(commands.dirsrc)

            commands.logger.info('> Cleaning bin')
            reallyrmtree(commands.dirbin)

            commands.logger.info('> Cleaning reobf')
            reallyrmtree(commands.dirreobf)

            if distclean:
                commands.logger.info('> Cleaning lib')
                reallyrmtree(commands.dirlib)

            commands.logger.info('> Cleaning jars')
            reallyrmtree(os.path.join(commands.dirjars, 'stats'))
            reallyrmtree(os.path.join(commands.dirjars, 'texturepacks'))
            reallyrmtree(
                os.path.join(commands.dirjars, 'texturepacks-mp-cache'))
            if distclean:
                reallyrmtree(os.path.join(commands.dirjars, 'saves'))
                reallyrmtree(os.path.join(commands.dirjars, 'mcpworld'))
                reallyrmtree(os.path.join(commands.dirjars, 'versions'))
                reallyrmtree(os.path.join(commands.dirjars, 'assets'))
                reallyrmtree(os.path.join(commands.dirjars, 'libraries'))
            if os.path.exists(os.path.join(commands.dirjars, 'server.log')):
                os.remove(os.path.join(commands.dirjars, 'server.log'))
            for txt_file in glob.glob(os.path.join(commands.dirjars, '*.txt')):
                os.remove(txt_file)

            commands.logger.info('> Cleaning logs')
            logging.shutdown()
            reallyrmtree(commands.dirlogs)
        except OSError as ex:
            print >> sys.stderr, 'Cleanup FAILED'
            if hasattr(ex, 'filename'):
                print >> sys.stderr, 'Failed to remove ' + ex.filename
            sys.exit(1)
    except Exception:  # pylint: disable-msg=W0703
        logging.exception('FATAL ERROR')
        sys.exit(1)
def cleanup(conffile, force, distclean):
    try:
        commands = Commands(conffile, shortstart=True)

        if not force:
            print 'WARNING:'
            print 'The cleanup script will delete all folders created by MCP, including the'
            print 'src folder which may contain changes you made to the code, along with any'
            print 'saved worlds from the client or server.'
            answer = raw_input('If you really want to clean up, enter "Yes" ')
            if answer.lower() not in ['yes']:
                print 'You have not entered "Yes", aborting the clean up process'
                sys.exit(1)

        commands.checkupdates()

        try:
            commands.logger.info('> Cleaning temp')
            reallyrmtree(commands.dirtemp)

            commands.logger.info('> Cleaning src')
            reallyrmtree(commands.dirsrc)

            commands.logger.info('> Cleaning bin')
            reallyrmtree(commands.dirbin)

            commands.logger.info('> Cleaning reobf')
            reallyrmtree(commands.dirreobf)

            if distclean:
                commands.logger.info('> Cleaning lib')
                reallyrmtree(commands.dirlib)

            commands.logger.info('> Cleaning jars')
            reallyrmtree(os.path.join(commands.dirjars, 'stats'))
            reallyrmtree(os.path.join(commands.dirjars, 'texturepacks'))
            reallyrmtree(os.path.join(commands.dirjars, 'texturepacks-mp-cache'))            
            if distclean:
                reallyrmtree(os.path.join(commands.dirjars, 'saves'))
                reallyrmtree(os.path.join(commands.dirjars, 'mcpworld'))
                reallyrmtree(os.path.join(commands.dirjars, 'versions'))                
                reallyrmtree(os.path.join(commands.dirjars, 'assets'))                                
                reallyrmtree(os.path.join(commands.dirjars, 'libraries'))                
            if os.path.exists(os.path.join(commands.dirjars, 'server.log')):
                os.remove(os.path.join(commands.dirjars, 'server.log'))
            for txt_file in glob.glob(os.path.join(commands.dirjars, '*.txt')):
                os.remove(txt_file)

            commands.logger.info('> Cleaning logs')
            logging.shutdown()
            reallyrmtree(commands.dirlogs)
        except OSError as ex:
            print >> sys.stderr, 'Cleanup FAILED'
            if hasattr(ex, 'filename'):
                print >> sys.stderr, 'Failed to remove ' + ex.filename
            sys.exit(1)
    except Exception:  # pylint: disable-msg=W0703
        logging.exception('FATAL ERROR')
        sys.exit(1)
def cleanup(conffile=None, force=False):
    if not force:
        print "WARNING:"
        print "The cleanup script will delete all folders created by MCP, including the"
        print "src folder which may contain changes you made to the code."
        answer = raw_input('If you really want to clean up, enter "Yes" ')
        if answer.lower() not in ["yes"]:
            print 'You have not entered "Yes", aborting the clean up process'
            sys.exit(1)

    commands = Commands(conffile)
    commands.checkupdates()

    commands.logger.info("> Cleaning temp")
    try:
        reallyrmtree(commands.dirtemp)
    except OSError:
        commands.logger.error("failed cleaning temp")

    commands.logger.info("> Cleaning src")
    try:
        reallyrmtree(commands.dirsrc)
    except OSError:
        commands.logger.error("failed cleaning src")

    commands.logger.info("> Cleaning bin")
    try:
        reallyrmtree(commands.dirbin)
    except OSError:
        commands.logger.error("failed cleaning bin")

    commands.logger.info("> Cleaning reobf")
    try:
        reallyrmtree(commands.dirreobf)
    except OSError:
        commands.logger.error("failed cleaning reobf")

    commands.logger.info("> Cleaning jars")
    try:
        reallyrmtree(os.path.join(commands.dirjars, "saves"))
    except OSError:
        commands.logger.error("failed cleaning saves")
    try:
        reallyrmtree(os.path.join(commands.dirjars, "texturepacks"))
    except OSError:
        commands.logger.error("failed cleaning texturepacks")
    try:
        reallyrmtree(os.path.join(commands.dirjars, "world"))
    except OSError:
        commands.logger.error("failed cleaning world")
    if os.path.exists(os.path.join(commands.dirjars, "server.log")):
        os.remove(os.path.join(commands.dirjars, "server.log"))
    for txt_file in glob.glob(os.path.join(commands.dirjars, "*.txt")):
        os.remove(txt_file)

    commands.logger.info("> Cleaning logs")
    logging.shutdown()
    reallyrmtree(commands.dirlogs)
Exemple #4
0
def cleanup(conffile=None, force=False):
    if not force:
        print 'WARNING:'
        print 'The cleanup script will delete all folders created by MCP, including the'
        print 'src folder which may contain changes you made to the code.'
        answer = raw_input('If you really want to clean up, enter "Yes" ')
        if answer.lower() not in ['yes']:
            print 'You have not entered "Yes", aborting the clean up process'
            sys.exit(1)

    commands = Commands(conffile)
    commands.checkupdates()

    commands.logger.info('> Cleaning temp')
    try:
        reallyrmtree(commands.dirtemp)
    except OSError:
        commands.logger.error('failed cleaning temp')

    commands.logger.info('> Cleaning src')
    try:
        reallyrmtree(commands.dirsrc)
    except OSError:
        commands.logger.error('failed cleaning src')

    commands.logger.info('> Cleaning bin')
    try:
        reallyrmtree(commands.dirbin)
    except OSError:
        commands.logger.error('failed cleaning bin')

    commands.logger.info('> Cleaning reobf')
    try:
        reallyrmtree(commands.dirreobf)
    except OSError:
        commands.logger.error('failed cleaning reobf')

    commands.logger.info('> Cleaning jars')
    try:
        reallyrmtree(os.path.join(commands.dirjars, 'saves'))
    except OSError:
        commands.logger.error('failed cleaning saves')
    try:
        reallyrmtree(os.path.join(commands.dirjars, 'texturepacks'))
    except OSError:
        commands.logger.error('failed cleaning texturepacks')
    try:
        reallyrmtree(os.path.join(commands.dirjars, 'world'))
    except OSError:
        commands.logger.error('failed cleaning world')
    if os.path.exists(os.path.join(commands.dirjars, 'server.log')):
        os.remove(os.path.join(commands.dirjars, 'server.log'))
    for txt_file in glob.glob(os.path.join(commands.dirjars, '*.txt')):
        os.remove(txt_file)

    commands.logger.info('> Cleaning logs')
    logging.shutdown()
    reallyrmtree(commands.dirlogs)
Exemple #5
0
def main(conffile=None, force=False):

    if sys.version_info[0] == 3:
        print ('ERROR : Python3 is not supported yet.')
        sys.exit(1)

    if not force:
        print('WARNING:')
        print('The cleanup script will delete all folders created by MCP, including the')
        print('src folder which may contain changes you made to the code.')
        answer = raw_input('If you really want to clean up, enter "Yes" ')
        if answer.lower() not in ['yes']:
            print('You have not entered "Yes", aborting the clean up process')
            sys.exit(0)

    commands = Commands(conffile)
    commands.checkupdates()

    commands.logger.info ('> Cleaning temp')
    if not reallyrmtree(commands.dirtemp):
        commands.logger.error ('failed cleaning temp')

    commands.logger.info ('> Cleaning src')
    if not reallyrmtree(commands.dirsrc):
        commands.logger.error ('failed cleaning src')

    commands.logger.info ('> Cleaning bin')
    if not reallyrmtree(commands.dirbin):
        commands.logger.error ('failed cleaning bin')

    commands.logger.info ('> Cleaning reobf')
    if not reallyrmtree(commands.dirreobf):
        commands.logger.error ('failed cleaning reobf')

    commands.logger.info ('> Cleaning jars')
    reallyrmtree(os.path.join(commands.dirjars, 'saves'))
    reallyrmtree(os.path.join(commands.dirjars, 'texturepacks'))
    reallyrmtree(os.path.join(commands.dirjars, 'world'))
    if os.path.exists(os.path.join(commands.dirjars, 'server.log')):
        os.remove(os.path.join(commands.dirjars, 'server.log'))
    for txt_file in glob.glob(os.path.join(commands.dirjars, '*.txt')):
        os.remove(txt_file)

    commands.logger.info ('> Cleaning logs')
    logging.shutdown()
    reallyrmtree(commands.dirlogs)
def main(conffile, force=False):

    if sys.version_info[0] == 3:
        print ('ERROR : Python3 is not supported yet.')
        sys.exit(1)

    commands = Commands(conffile)
    commands.checkupdates()

    commands.logger.info ('> Cleaning temp')
    if not reallyrmtree(commands.dirtemp):
        commands.logger.error ('failed cleaning temp')
#    os.mkdir(commands.dirtemp)

    commands.logger.info ('> Cleaning src')
    if not reallyrmtree(commands.dirsrc):
        commands.logger.error ('failed cleaning src')
#    os.mkdir(commands.dirsrc)

    commands.logger.info ('> Cleaning bin')
    if not reallyrmtree(commands.dirbin):
        commands.logger.error ('failed cleaning bin')
#    os.mkdir(commands.dirbin)

    commands.logger.info ('> Cleaning reobf')
    if not reallyrmtree(commands.dirreobf):
        commands.logger.error ('failed cleaning reobf')

    commands.logger.info ('> Cleaning jars')
    reallyrmtree(os.path.join(commands.dirjars, 'saves'))
    reallyrmtree(os.path.join(commands.dirjars, 'texturepacks'))
    reallyrmtree(os.path.join(commands.dirjars, 'world'))
    if os.path.exists(os.path.join(commands.dirjars, 'server.log')):
        os.remove(os.path.join(commands.dirjars, 'server.log'))
    for txt_file in glob.glob(os.path.join(commands.dirjars, '*.txt')):
        os.remove(txt_file)

    commands.logger.info ('> Cleaning logs')
    logging.shutdown()
    reallyrmtree(commands.dirlogs)
def main(conffile, force=False):

    if sys.version_info[0] == 3:
        print ('ERROR : Python3 is not supported yet.')
        sys.exit(1)

    commands = Commands(conffile)
    commands.checkupdates()

    commands.logger.info ('> Cleaning temp')
    if not reallyrmtree(commands.dirtemp):
        commands.logger.error ('failed cleaning temp')

    commands.logger.info ('> Cleaning src')
    if not reallyrmtree(commands.dirsrc):
        commands.logger.error ('failed cleaning src')

    commands.logger.info ('> Cleaning bin')
    if not reallyrmtree(commands.dirbin):
        commands.logger.error ('failed cleaning bin')

    commands.logger.info ('> Cleaning reobf')
    if not reallyrmtree(commands.dirreobf):
        commands.logger.error ('failed cleaning reobf')

    commands.logger.info ('> Cleaning jars')
    reallyrmtree(os.path.join(commands.dirjars, 'saves'))
    reallyrmtree(os.path.join(commands.dirjars, 'texturepacks'))
    reallyrmtree(os.path.join(commands.dirjars, 'world'))
    if os.path.exists(os.path.join(commands.dirjars, 'server.log')):
        os.remove(os.path.join(commands.dirjars, 'server.log'))
    for txt_file in glob.glob(os.path.join(commands.dirjars, '*.txt')):
        os.remove(txt_file)

    commands.logger.info ('> Cleaning logs')
    logging.shutdown()
    reallyrmtree(commands.dirlogs)
def main(conffile, force=False):

    if sys.version_info[0] == 3:
        print("ERROR : Python3 is not supported yet.")
        sys.exit(1)

    commands = Commands(conffile)
    commands.checkupdates()

    commands.logger.info("> Cleaning temp")
    if not reallyrmtree(commands.dirtemp):
        commands.logger.error("failed cleaning temp")

    commands.logger.info("> Cleaning src")
    if not reallyrmtree(commands.dirsrc):
        commands.logger.error("failed cleaning src")

    commands.logger.info("> Cleaning bin")
    if not reallyrmtree(commands.dirbin):
        commands.logger.error("failed cleaning bin")

    commands.logger.info("> Cleaning reobf")
    if not reallyrmtree(commands.dirreobf):
        commands.logger.error("failed cleaning reobf")

    commands.logger.info("> Cleaning jars")
    reallyrmtree(os.path.join(commands.dirjars, "saves"))
    reallyrmtree(os.path.join(commands.dirjars, "texturepacks"))
    reallyrmtree(os.path.join(commands.dirjars, "world"))
    if os.path.exists(os.path.join(commands.dirjars, "server.log")):
        os.remove(os.path.join(commands.dirjars, "server.log"))
    for txt_file in glob.glob(os.path.join(commands.dirjars, "*.txt")):
        os.remove(txt_file)

    commands.logger.info("> Cleaning logs")
    logging.shutdown()
    reallyrmtree(commands.dirlogs)
Exemple #9
0
def decompile(conffile,
              force_jad,
              force_csv,
              no_recompile,
              no_comments,
              no_reformat,
              no_renamer,
              no_patch,
              only_patch,
              keep_lvt,
              keep_generics,
              only_client,
              only_server,
              force_rg,
              workdir,
              json,
              nocopy,
              only_joined=False):
    try:
        commands = Commands(conffile,
                            verify=True,
                            no_patch=no_patch,
                            workdir=workdir,
                            json=json)

        commands.checkupdates()

        if not commands.has_ss:
            force_rg = True

        use_ff = commands.has_ff and not force_jad
        use_srg = commands.has_srg and not force_csv

        if force_jad and not commands.has_jad:
            commands.logger.error('!! forcing jad when not available !!')
            sys.exit(1)

        if force_rg and not commands.has_rg:
            commands.logger.error(
                '!! forcing retroguard when not available !!')
            sys.exit(1)

        if force_csv and not commands.has_map_csv:
            commands.logger.error('!! forcing csvs when not available !!')
            sys.exit(1)

        # client or server
        process_client = True
        process_server = True
        if only_client and not only_server:
            process_server = False
        if only_server and not only_client:
            process_client = False
        if only_joined and not only_server and not only_client:
            process_server = False

        # always strip comments by default, turn off in update mode if required
        strip_comments = True

        # update only options
        rg_update = False
        exc_update = False

        if no_patch:
            # no_patch is basically update mode, disables everything
            # and reuses a few different options to do update stuff
            if only_patch:
                # with only_patch then we actually do the patches, but not the comment stripping, for use when updating
                # the fernflower patches
                no_patch = False
                strip_comments = False
            if no_reformat:
                # reuse -a no_reformat to switch rg to fullmap=1 startindex=RGIndex
                rg_update = True
            if no_renamer:
                # reuse -n to switch mcinjector to outputing exc file, and adding new parameters
                exc_update = True
            no_comments = True
            no_reformat = True
            no_renamer = True
            no_recompile = True
        elif only_patch:
            # if only_patch then disable everything but patching and comment stripping
            no_comments = True
            no_reformat = True
            no_renamer = True
            no_recompile = True

        # if we have generics enabled we need the lvt as well
        if keep_generics:
            keep_lvt = True

        if force_rg:
            commands.logger.info('> Creating Retroguard config files')
            commands.creatergcfg(reobf=False,
                                 keep_lvt=keep_lvt,
                                 keep_generics=keep_generics,
                                 rg_update=rg_update,
                                 joined_jar=only_joined)

        if not nocopy:
            clientCopy.copyClientAssets(commands, workdir)

        commands.setupjsr305()

        try:
            if process_client:
                cltdecomp = decompile_side(commands,
                                           CLIENT,
                                           use_ff=use_ff,
                                           use_srg=use_srg,
                                           no_comments=no_comments,
                                           no_reformat=no_reformat,
                                           no_renamer=no_renamer,
                                           no_patch=no_patch,
                                           strip_comments=strip_comments,
                                           exc_update=exc_update,
                                           keep_lvt=keep_lvt,
                                           keep_generics=keep_generics,
                                           force_rg=force_rg,
                                           rg_update=rg_update,
                                           joined=only_joined)
            else:
                cltdecomp = False
            if process_server:
                srvdecomp = decompile_side(commands,
                                           SERVER,
                                           use_ff=use_ff,
                                           use_srg=use_srg,
                                           no_comments=no_comments,
                                           no_reformat=no_reformat,
                                           no_renamer=no_renamer,
                                           no_patch=no_patch,
                                           strip_comments=strip_comments,
                                           exc_update=exc_update,
                                           keep_lvt=keep_lvt,
                                           keep_generics=keep_generics,
                                           force_rg=force_rg,
                                           rg_update=rg_update)
            else:
                srvdecomp = False
        except CalledProcessError:
            # retroguard or other called process error so bail
            commands.logger.error('Decompile failed')
            sys.exit(1)
        if not no_recompile:
            if cltdecomp:
                try:
                    updatemd5_side(commands, CLIENT)
                except CalledProcessError:
                    commands.logger.error(
                        'Initial client recompile failed, correct source then run updatemd5'
                    )
            if srvdecomp:
                try:
                    updatemd5_side(commands, SERVER)
                except CalledProcessError:
                    commands.logger.error(
                        'Initial server recompile failed, correct source then run updatemd5'
                    )
        else:
            commands.logger.info('!! recompile disabled !!')
    except Exception:  # pylint: disable-msg=W0703
        logging.exception('FATAL ERROR')
        sys.exit(1)
def main(conffile):
    commands = Commands(conffile)
    commands.checkupdates()
    #TODO: Add a check for java here.
    cltdone = False
    srvdone = False

    ffexists = os.path.exists(commands.fernflower)

    commands.logger.info('> Creating Retroguard config files')
    commands.creatergcfg()

    srcdir = os.path.join(commands.srcclient, commands.ffsource).replace(
        '/', os.sep).replace('\\', os.sep)
    if not os.path.exists(srcdir):
        commands.logger.info('== Decompiling Client ==')
        if commands.checkjars(0):
            clienttime = time.time()
            commands.logger.info('> Creating SRGS for client')
            commands.createsrgs(0)
            commands.logger.info('> Applying Retroguard to client')
            commands.applyrg(0)
            commands.logger.info('> Applying Exceptor to client')
            commands.applyexceptor(0)
            if ffexists:
                commands.logger.info('> Decompiling...')
                commands.applyff(0)
                commands.logger.info('> Unzipping the client sources')
                commands.extractsrc(0)
            commands.logger.info('> Unzipping the client jar')
            commands.extractjar(0)
            if not ffexists:
                commands.logger.info('> Applying jadretro')
                commands.applyjadretro(0)
            if not ffexists:
                commands.logger.info('> Decompiling...')
                commands.applyjad(0)
            raw_input('enter')
            commands.logger.info('> Applying patches')
            if not ffexists:
                commands.applypatches(0)
            else:
                commands.applyffpatches(0)
            commands.logger.info('> Renaming sources')
            commands.rename(0)
            commands.logger.info('> Creating reobfuscation tables')
            commands.renamereobsrg(0)
            commands.logger.info('> Done in %.2f seconds' %
                                 (time.time() - clienttime))
    else:
        commands.logger.warn(
            '!! Client already decompiled. Run cleanup before decompiling again !!'
        )
        cltdone = True

    srcdir = os.path.join(commands.srcserver, commands.ffsource).replace(
        '/', os.sep).replace('\\', os.sep)
    if not os.path.exists(srcdir):
        commands.logger.info('== Decompiling Server ==')
        if commands.checkjars(1):
            servertime = time.time()
            commands.logger.info('> Creating SRGS for server')
            commands.createsrgs(1)
            commands.logger.info('> Applying Retroguard to server')
            commands.applyrg(1)
            commands.logger.info('> Applying Exceptor to client')
            commands.applyexceptor(1)
            if ffexists:
                commands.logger.info('> Decompiling...')
                commands.applyff(1)
                commands.logger.info('> Unzipping the server sources')
                commands.extractsrc(1)
            commands.logger.info('> Unzipping the server jar')
            commands.extractjar(1)
            if not ffexists:
                commands.logger.info('> Applying jadretro')
                commands.applyjadretro(1)
            if not ffexists:
                commands.logger.info('> Decompiling...')
                commands.applyjad(1)
            commands.logger.info('> Applying patches')
            if not ffexists:
                commands.applypatches(1)
            else:
                commands.applyffpatches(1)
            commands.logger.info('> Renaming sources')
            commands.rename(1)
            commands.logger.info('> Creating reobfuscation tables')
            commands.renamereobsrg(1)
            commands.logger.info('> Done in %.2f seconds' %
                                 (time.time() - servertime))
    else:
        commands.logger.warn(
            '!! Server already decompiled. Run cleanup before decompiling again !!'
        )
        srvdone = True

    commands.logger.info('== Post decompiling operations ==')
    if not cltdone or not srvdone:
        commands.logger.info('> Recompiling')
        recompile.main(conffile)
    if not cltdone:
        commands.logger.info('> Generating the md5 (client)')
        commands.gathermd5s(0)
    if not srvdone:
        commands.logger.info('> Generating the md5 (server)')
        commands.gathermd5s(1)
Exemple #11
0
def main(conffile=None, force_jad=False):
    commands = Commands(conffile)
    commands.checkupdates()

    cltdone = False
    srvdone = False

    use_ff = os.path.exists(commands.fernflower) and not force_jad

    commands.logger.info ('> Creating Retroguard config files')
    commands.creatergcfg()

    srcdir = os.path.join(commands.srcclient, commands.ffsource).replace('/',os.sep).replace('\\',os.sep)
    if not os.path.exists(srcdir):
        commands.logger.info ('== Decompiling Client ==')
        if commands.checkjars(0):
            clienttime = time.time()
            commands.logger.info ('> Creating SRGS for client')
            commands.createsrgs(0)
            commands.logger.info ('> Applying Retroguard to client')
            commands.applyrg(0)
            commands.logger.info ('> Applying Exceptor to client')
            commands.applyexceptor(0)
            if use_ff:
                commands.logger.info ('> Decompiling...')
                commands.applyff(0)
                commands.logger.info ('> Unzipping the client sources')
                commands.extractsrc(0)
            commands.logger.info ('> Unzipping the client jar')
            commands.extractjar(0)
            if not use_ff:
                commands.logger.info ('> Applying jadretro')
                commands.applyjadretro(0)
                commands.logger.info ('> Decompiling...')
                commands.applyjad(0)
            commands.logger.info ('> Applying patches')
            if not use_ff:
                commands.applypatches(0)
            else:
                commands.applyffpatches(0)
            commands.logger.info ('> Renaming sources')
            commands.rename(0)
            commands.logger.info ('> Creating reobfuscation tables')
            commands.renamereobsrg(0)
            commands.logger.info ('> Done in %.2f seconds'%(time.time()-clienttime))
    else:
        commands.logger.warn ('!! Client already decompiled. Run cleanup before decompiling again !!')
        cltdone = True

    srcdir = os.path.join(commands.srcserver, commands.ffsource).replace('/',os.sep).replace('\\',os.sep)
    if not os.path.exists(srcdir):
        commands.logger.info ('== Decompiling Server ==')
        if commands.checkjars(1):
            servertime = time.time()
            commands.logger.info ('> Creating SRGS for server')
            commands.createsrgs(1)
            commands.logger.info ('> Applying Retroguard to server')
            commands.applyrg(1)
            commands.logger.info ('> Applying Exceptor to server')
            commands.applyexceptor(1)
            if use_ff:
                commands.logger.info ('> Decompiling...')
                commands.applyff(1)
                commands.logger.info ('> Unzipping the server sources')
                commands.extractsrc(1)
            commands.logger.info ('> Unzipping the server jar')
            commands.extractjar(1)
            if not use_ff:
                commands.logger.info ('> Applying jadretro')
                commands.applyjadretro(1)
                commands.logger.info ('> Decompiling...')
                commands.applyjad(1)
            commands.logger.info ('> Applying patches')
            if not use_ff:
                commands.applypatches(1)
            else:
                commands.applyffpatches(1)
            commands.logger.info ('> Renaming sources')
            commands.rename(1)
            commands.logger.info ('> Creating reobfuscation tables')
            commands.renamereobsrg(1)
            commands.logger.info ('> Done in %.2f seconds'%(time.time()-servertime))
    else:
        commands.logger.warn ('!! Server already decompiled. Run cleanup before decompiling again !!')
        srvdone = True

    commands.logger.info ('== Post decompiling operations ==')
    if not cltdone or not srvdone:
        commands.logger.info ('> Recompiling')
        recompile.main(conffile)
    if not cltdone:
        commands.logger.info ('> Generating the md5 (client)')
        commands.gathermd5s(0)
    if not srvdone:
        commands.logger.info ('> Generating the md5 (server)')
        commands.gathermd5s(1)
Exemple #12
0
def decompile(conffile, force_jad, force_csv, no_recompile, no_comments, no_reformat, no_renamer, no_patch, only_patch,
              keep_lvt, keep_generics, only_client, only_server):
    try:
        commands = Commands(conffile, verify=True, no_patch=no_patch)

        commands.checkupdates()

        use_ff = commands.has_ff and not force_jad
        use_srg = commands.has_srg and not force_csv

        if force_jad and not commands.has_jad:
            commands.logger.error('!! forcing jad when not available !!')
            sys.exit(1)

        if force_csv and not commands.has_map_csv:
            commands.logger.error('!! forcing csvs when not available !!')
            sys.exit(1)

        # client or server
        process_client = True
        process_server = True
        if only_client and not only_server:
            process_server = False
        if only_server and not only_client:
            process_client = False

        # always strip comments by default, turn off in update mode if required
        strip_comments = True

        # update only options
        rg_update = False
        exc_update = False

        if no_patch:
            # no_patch is basically update mode, disables everything
            # and reuses a few different options to do update stuff
            if only_patch:
                # with only_patch then we actually do the patches, but not the comment stripping, for use when updating
                # the fernflower patches
                no_patch = False
                strip_comments = False
            if no_reformat:
                # reuse -a no_reformat to switch rg to fullmap=1 startindex=RGIndex
                rg_update = True
            if no_renamer:
                # reuse -n to switch mcinjector to outputing exc file, and adding new parameters
                exc_update = True
            no_comments = True
            no_reformat = True
            no_renamer = True
            no_recompile = True
        elif only_patch:
            # if only_patch then disable everything but patching and comment stripping
            no_comments = True
            no_reformat = True
            no_renamer = True
            no_recompile = True

        # if we have generics enabled we need the lvt as well
        if keep_generics:
            keep_lvt = True

        commands.logger.info('> Creating Retroguard config files')
        commands.creatergcfg(reobf=False, keep_lvt=keep_lvt, keep_generics=keep_generics, rg_update=rg_update)

        try:
            if process_client:
                cltdecomp = decompile_side(commands, CLIENT, use_ff=use_ff, use_srg=use_srg, no_comments=no_comments,
                                           no_reformat=no_reformat, no_renamer=no_renamer, no_patch=no_patch,
                                           strip_comments=strip_comments, exc_update=exc_update)
            else:
                cltdecomp = False
            if process_server:
                srvdecomp = decompile_side(commands, SERVER, use_ff=use_ff, use_srg=use_srg, no_comments=no_comments,
                                           no_reformat=no_reformat, no_renamer=no_renamer, no_patch=no_patch,
                                           strip_comments=strip_comments, exc_update=exc_update)
            else:
                srvdecomp = False
        except CalledProcessError:
            # retroguard or other called process error so bail
            commands.logger.error('Decompile failed')
            sys.exit(1)
        if not no_recompile:
            if cltdecomp:
                try:
                    updatemd5_side(commands, CLIENT)
                except CalledProcessError:
                    commands.logger.error('Initial client recompile failed, correct source then run updatemd5')
            if srvdecomp:
                try:
                    updatemd5_side(commands, SERVER)
                except CalledProcessError:
                    commands.logger.error('Initial server recompile failed, correct source then run updatemd5')
        else:
            commands.logger.info('!! recompile disabled !!')
    except Exception:  # pylint: disable-msg=W0703
        logging.exception('FATAL ERROR')
        sys.exit(1)
def decompile(conffile=None, force_jad=False):
    commands = Commands(conffile)

    try:
        commands.checkupdates()

        cltdone = False
        srvdone = False

        use_ff = os.path.exists(commands.fernflower) and not force_jad

        commands.logger.info('> Creating Retroguard config files')
        commands.creatergcfg()

        srcdir = os.path.join(commands.srcclient, os.path.normpath(commands.ffsource))
        if not os.path.exists(srcdir):
            commands.logger.info('== Decompiling Client ==')
            if commands.checkjars(CLIENT):
                clienttime = time.time()
                commands.logger.info('> Creating SRGS for client')
                commands.createsrgs(CLIENT)
                commands.logger.info('> Applying Retroguard to client')
                commands.applyrg(CLIENT)
                commands.logger.info('> Applying Exceptor to client')
                commands.applyexceptor(CLIENT)
                if use_ff:
                    commands.logger.info('> Decompiling...')
                    commands.applyff(CLIENT)
                    commands.logger.info('> Unzipping the client sources')
                    commands.extractsrc(CLIENT)
                commands.logger.info('> Unzipping the client jar')
                commands.extractjar(CLIENT)
                if not use_ff:
                    commands.logger.info('> Applying jadretro')
                    commands.applyjadretro(CLIENT)
                    commands.logger.info('> Decompiling...')
                    commands.applyjad(CLIENT)
                    commands.logger.info('> Copying the client sources')
                    commands.copysrc(CLIENT)
                commands.logger.info('> Applying patches')
                if commands.osname == 'osx' and not use_ff:
                    commands.applypatches(CLIENT, False, True)
                commands.applypatches(CLIENT, use_ff)
                commands.logger.info('> Removing comments')
                commands.process_comments(CLIENT)
                commands.logger.info('> Renaming sources')
                commands.process_rename(CLIENT)
                commands.logger.info('> Reformating sources')
                commands.applyastyle(CLIENT)
                commands.logger.info('> Commenting OpenGL constants')
                commands.process_annotate(CLIENT)
                commands.logger.info('> Creating reobfuscation tables')
                commands.renamereobsrg(CLIENT)
                commands.logger.info('> Done in %.2f seconds' % (time.time() - clienttime))
        else:
            commands.logger.warn('!! Client already decompiled. Run cleanup before decompiling again !!')
            cltdone = True

        srcdir = os.path.join(commands.srcserver, os.path.normpath(commands.ffsource))
        if not os.path.exists(srcdir):
            commands.logger.info('== Decompiling Server ==')
            if commands.checkjars(SERVER):
                servertime = time.time()
                commands.logger.info('> Creating SRGS for server')
                commands.createsrgs(SERVER)
                commands.logger.info('> Applying Retroguard to server')
                commands.applyrg(SERVER)
                commands.logger.info('> Applying Exceptor to server')
                commands.applyexceptor(SERVER)
                if use_ff:
                    commands.logger.info('> Decompiling...')
                    commands.applyff(SERVER)
                    commands.logger.info('> Unzipping the server sources')
                    commands.extractsrc(SERVER)
                commands.logger.info('> Unzipping the server jar')
                commands.extractjar(SERVER)
                if not use_ff:
                    commands.logger.info('> Applying jadretro')
                    commands.applyjadretro(SERVER)
                    commands.logger.info('> Decompiling...')
                    commands.applyjad(SERVER)
                    commands.logger.info('> Copying the server sources')
                    commands.copysrc(SERVER)
                commands.logger.info('> Applying patches')
                if commands.osname == 'osx' and not use_ff:
                    commands.applypatches(SERVER, False, True)
                commands.applypatches(SERVER, use_ff)
                commands.logger.info('> Removing comments')
                commands.process_comments(SERVER)
                commands.logger.info('> Renaming sources')
                commands.process_rename(SERVER)
                commands.logger.info('> Reformating sources')
                commands.applyastyle(SERVER)
                commands.logger.info('> Creating reobfuscation tables')
                commands.renamereobsrg(SERVER)
                commands.logger.info('> Done in %.2f seconds' % (time.time() - servertime))
        else:
            commands.logger.warn('!! Server already decompiled. Run cleanup before decompiling again !!')
            srvdone = True

        commands.logger.info('== Post decompiling operations ==')
        if not cltdone or not srvdone:
            commands.logger.info('> Recompiling')
            recompile(conffile)
        if not cltdone:
            commands.logger.info('> Generating the md5 (client)')
            commands.gathermd5s(CLIENT)
        if not srvdone:
            commands.logger.info('> Generating the md5 (server)')
            commands.gathermd5s(SERVER)
    except Exception:  # pylint: disable-msg=W0703
        commands.logger.exception('FATAL ERROR')
        sys.exit(1)
Exemple #14
0
def decompile(conffile=None, force_jad=False):
    commands = Commands(conffile)

    try:
        commands.checkupdates()

        cltdone = False
        srvdone = False

        use_ff = os.path.exists(commands.fernflower) and not force_jad

        commands.logger.info('> Creating Retroguard config files')
        commands.creatergcfg()

        srcdir = os.path.join(commands.srcclient,
                              os.path.normpath(commands.ffsource))
        if not os.path.exists(srcdir):
            commands.logger.info('== Decompiling Client ==')
            if commands.checkjars(CLIENT):
                clienttime = time.time()
                commands.logger.info('> Creating SRGS for client')
                commands.createsrgs(CLIENT)
                commands.logger.info('> Applying Retroguard to client')
                commands.applyrg(CLIENT)
                commands.logger.info('> Applying Exceptor to client')
                commands.applyexceptor(CLIENT)
                if use_ff:
                    commands.logger.info('> Decompiling...')
                    commands.applyff(CLIENT)
                    commands.logger.info('> Unzipping the client sources')
                    commands.extractsrc(CLIENT)
                commands.logger.info('> Unzipping the client jar')
                commands.extractjar(CLIENT)
                if not use_ff:
                    commands.logger.info('> Applying jadretro')
                    commands.applyjadretro(CLIENT)
                    commands.logger.info('> Decompiling...')
                    commands.applyjad(CLIENT)
                    commands.logger.info('> Copying the client sources')
                    commands.copysrc(CLIENT)
                commands.logger.info('> Applying patches')
                if commands.osname == 'osx' and not use_ff:
                    commands.applypatches(CLIENT, False, True)
                commands.applypatches(CLIENT, use_ff)
                commands.logger.info('> Removing comments')
                commands.process_comments(CLIENT)
                commands.logger.info('> Renaming sources')
                commands.process_rename(CLIENT)
                commands.logger.info('> Reformating sources')
                commands.applyastyle(CLIENT)
                commands.logger.info('> Commenting OpenGL constants')
                commands.process_annotate(CLIENT)
                commands.logger.info('> Creating reobfuscation tables')
                commands.renamereobsrg(CLIENT)
                commands.logger.info('> Done in %.2f seconds' %
                                     (time.time() - clienttime))
        else:
            commands.logger.warn(
                '!! Client already decompiled. Run cleanup before decompiling again !!'
            )
            cltdone = True

        srcdir = os.path.join(commands.srcserver,
                              os.path.normpath(commands.ffsource))
        if not os.path.exists(srcdir):
            commands.logger.info('== Decompiling Server ==')
            if commands.checkjars(SERVER):
                servertime = time.time()
                commands.logger.info('> Creating SRGS for server')
                commands.createsrgs(SERVER)
                commands.logger.info('> Applying Retroguard to server')
                commands.applyrg(SERVER)
                commands.logger.info('> Applying Exceptor to server')
                commands.applyexceptor(SERVER)
                if use_ff:
                    commands.logger.info('> Decompiling...')
                    commands.applyff(SERVER)
                    commands.logger.info('> Unzipping the server sources')
                    commands.extractsrc(SERVER)
                commands.logger.info('> Unzipping the server jar')
                commands.extractjar(SERVER)
                if not use_ff:
                    commands.logger.info('> Applying jadretro')
                    commands.applyjadretro(SERVER)
                    commands.logger.info('> Decompiling...')
                    commands.applyjad(SERVER)
                    commands.logger.info('> Copying the server sources')
                    commands.copysrc(SERVER)
                commands.logger.info('> Applying patches')
                if commands.osname == 'osx' and not use_ff:
                    commands.applypatches(SERVER, False, True)
                commands.applypatches(SERVER, use_ff)
                commands.logger.info('> Removing comments')
                commands.process_comments(SERVER)
                commands.logger.info('> Renaming sources')
                commands.process_rename(SERVER)
                commands.logger.info('> Reformating sources')
                commands.applyastyle(SERVER)
                commands.logger.info('> Creating reobfuscation tables')
                commands.renamereobsrg(SERVER)
                commands.logger.info('> Done in %.2f seconds' %
                                     (time.time() - servertime))
        else:
            commands.logger.warn(
                '!! Server already decompiled. Run cleanup before decompiling again !!'
            )
            srvdone = True

        commands.logger.info('== Post decompiling operations ==')
        if not cltdone or not srvdone:
            commands.logger.info('> Recompiling')
            recompile(conffile)
        if not cltdone:
            commands.logger.info('> Generating the md5 (client)')
            commands.gathermd5s(CLIENT)
        if not srvdone:
            commands.logger.info('> Generating the md5 (server)')
            commands.gathermd5s(SERVER)
    except Exception:  # pylint: disable-msg=W0703
        commands.logger.exception('FATAL ERROR')
        sys.exit(1)
def main(conffile):
    commands = Commands(conffile)
    commands.checkupdates()
    #TODO: Add a check for java here.
    cltdone = False
    srvdone = False

    commands.logger.info('> Creating Retroguard config files')
    commands.creatergcfg()

    if not os.path.exists(commands.srcclient):
        commands.logger.info('== Decompiling Client ==')
        if commands.checkjars(0):
            clienttime = time.time()
            commands.logger.info('> Creating SRGS for client')
            commands.createsrgs(0)
            commands.logger.info('> Applying Retroguard to client')
            commands.applyrg(0)
            commands.logger.info('> Unzipping the client jar')
            commands.extractjar(0)
            commands.logger.info('> Applying jadretro')
            commands.applyjadretro(0)
            commands.logger.info('> Decompiling...')
            commands.applyjad(0)
            commands.logger.info('> Applying patches')
            commands.applypatches(0)
            commands.logger.info('> Renaming sources')
            commands.rename(0)
            commands.logger.info('> Creating reobfuscation tables')
            #commands.createsaffx(0)
            commands.renamereobsrg(0)
            #print ('> Cleaning temp directory')
            #commands.cleantempbin(0)
            commands.logger.info('> Done in %.2f seconds' %
                                 (time.time() - clienttime))
    else:
        commands.logger.warn(
            '!! Client already decompiled. Run cleanup before decompiling again !!'
        )
        cltdone = True

    if not os.path.exists(commands.srcserver):
        commands.logger.info('== Decompiling Server ==')
        if commands.checkjars(1):
            servertime = time.time()
            commands.logger.info('> Creating SRGS for server')
            commands.createsrgs(1)
            commands.logger.info('> Applying Retroguard to server')
            commands.applyrg(1)
            commands.logger.info('> Unzipping the server jar')
            commands.extractjar(1)
            commands.logger.info('> Applying jadretro')
            commands.applyjadretro(1)
            commands.logger.info('> Decompiling...')
            commands.applyjad(1)
            commands.logger.info('> Applying patches')
            commands.applypatches(1)
            commands.logger.info('> Renaming sources')
            commands.rename(1)
            commands.logger.info('> Creating reobfuscation tables')
            #commands.createsaffx(1)
            commands.renamereobsrg(1)
            #print ('> Cleaning temp directory')
            #commands.cleantempbin(1)
            commands.logger.info('> Done in %.2f seconds' %
                                 (time.time() - servertime))
    else:
        commands.logger.warn(
            '!! Server already decompiled. Run cleanup before decompiling again !!'
        )
        srvdone = True

    commands.logger.info('== Post decompiling operations ==')
    if not cltdone or not srvdone:
        commands.logger.info('> Recompiling')
        recompile.main(conffile)
    if not cltdone:
        commands.logger.info('> Generating the md5 (client)')
        commands.gathermd5s(0)
    if not srvdone:
        commands.logger.info('> Generating the md5 (server)')
        commands.gathermd5s(1)
def main(conffile):
    commands = Commands(conffile)
    commands.checkupdates()
    #TODO: Add a check for java here.
    cltdone = False
    srvdone = False

    commands.logger.info ('> Creating Retroguard config files')
    commands.creatergcfg()

    if not os.path.exists(commands.srcclient):
        commands.logger.info ('== Decompiling Client ==')
        if commands.checkjars(0):
            clienttime = time.time()
            commands.logger.info ('> Creating SRGS for client')
            commands.createsrgs(0)
            commands.logger.info ('> Applying Retroguard to client')
            commands.applyrg(0)
            commands.logger.info ('> Unzipping the client jar')
            commands.extractjar(0)
            commands.logger.info ('> Applying jadretro')
            commands.applyjadretro(0)
            commands.logger.info ('> Decompiling...')
            commands.applyjad(0)
            commands.logger.info ('> Applying patches')
            commands.applypatches(0)
            commands.logger.info ('> Renaming sources')
            commands.rename(0)
            commands.logger.info ('> Creating reobfuscation tables')
            #commands.createsaffx(0)
            commands.renamereobsrg(0)
            #print ('> Cleaning temp directory')
            #commands.cleantempbin(0)
            commands.logger.info ('> Done in %.2f seconds'%(time.time()-clienttime))
    else:
        commands.logger.warn ('!! Client already decompiled. Run cleanup before decompiling again !!')
        cltdone = True

    if not os.path.exists(commands.srcserver):
        commands.logger.info ('== Decompiling Server ==')
        if commands.checkjars(1):
            servertime = time.time()
            commands.logger.info ('> Creating SRGS for server')
            commands.createsrgs(1)
            commands.logger.info ('> Applying Retroguard to server')
            commands.applyrg(1)
            commands.logger.info ('> Unzipping the server jar')
            commands.extractjar(1)
            commands.logger.info ('> Applying jadretro')
            commands.applyjadretro(1)
            commands.logger.info ('> Decompiling...')
            commands.applyjad(1)
            commands.logger.info ('> Applying patches')
            commands.applypatches(1)
            commands.logger.info ('> Renaming sources')
            commands.rename(1)
            commands.logger.info ('> Creating reobfuscation tables')
            #commands.createsaffx(1)
            commands.renamereobsrg(1)
            #print ('> Cleaning temp directory')
            #commands.cleantempbin(1)
            commands.logger.info ('> Done in %.2f seconds'%(time.time()-servertime))
    else:
        commands.logger.warn ('!! Server already decompiled. Run cleanup before decompiling again !!')
        srvdone = True

    commands.logger.info ('== Post decompiling operations ==')
    if not cltdone or not srvdone:
        commands.logger.info ('> Recompiling')
        recompile.main(conffile)
    if not cltdone:
        commands.logger.info ('> Generating the md5 (client)')
        commands.gathermd5s(0)
    if not srvdone:
        commands.logger.info ('> Generating the md5 (server)')
        commands.gathermd5s(1)