Example #1
0
def GetProductVersion(product):
    company = conf.ver_company_name
    trademark = conf.ver_legal_trademarks
    copyright = conf.ver_copyright
    productname = ''
    buildlinefile = ''
    bn1 = '1'
    bn2 = '0'
    bn3 = ''
    bn4 = ''
    productversion = ''
    if product == 'bdm':
        productname = conf.ver_product_manager
        buildlinefile = conf.bdm_nsifile_buildline
    elif product == 'bdkv':
        productname = conf.ver_product_antivirus
        buildlinefile = conf.bdkv_nsifile_buildline
    ctx = comm.getMsg(buildlinefile)
    index = ctx.find('"')+1
    bn3 = ctx[index:index+1]
    if bn3 == '0' and product == 'bdm':
        bn4 = comm.getMsg(conf.customBuildIdFile)
    elif bn3 == '0' and product == 'bdkv':
        bn4 = comm.getMsg(conf.kvCustomBuildIdFile)
    elif bn3 == '1' and product == 'bdm':
        bn4 = comm.getMsg(conf.versionBuildIdFile)
    elif bn3 == '1' and product == 'bdkv':
        bn4 = comm.getMsg(conf.kvVersionBuildIdFile)
    productversion = '%s.%s.%s.%s' % (bn1,bn2,bn3,bn4)
    return (company,trademark,copyright,productname,productversion)
Example #2
0
def GetProductVersion(product):
    company = conf.ver_company_name
    trademark = conf.ver_legal_trademarks
    copyright = conf.ver_copyright
    productname = ''
    buildlinefile = ''
    bn1 = '1'
    bn2 = '0'
    bn3 = ''
    bn4 = ''
    productversion = ''
    if product == 'bdm':
        productname = conf.ver_product_manager
        buildlinefile = conf.bdm_nsifile_buildline
    elif product == 'bdkv':
        productname = conf.ver_product_antivirus
        buildlinefile = conf.bdkv_nsifile_buildline
    ctx = comm.getMsg(buildlinefile)
    index = ctx.find('"') + 1
    bn3 = ctx[index:index + 1]
    if bn3 == '0' and product == 'bdm':
        bn4 = comm.getMsg(conf.customBuildIdFile)
    elif bn3 == '0' and product == 'bdkv':
        bn4 = comm.getMsg(conf.kvCustomBuildIdFile)
    elif bn3 == '1' and product == 'bdm':
        bn4 = comm.getMsg(conf.versionBuildIdFile)
    elif bn3 == '1' and product == 'bdkv':
        bn4 = comm.getMsg(conf.kvVersionBuildIdFile)
    productversion = '%s.%s.%s.%s' % (bn1, bn2, bn3, bn4)
    return (company, trademark, copyright, productname, productversion)
Example #3
0
 def on_any_event(self, event):
     logging.info('%s, %s' % (event.event_type, event.src_path))
     if str(event.src_path).lower() == conf.watchdog_notify_ready_file:
         msg = comm.getMsg(conf.watchdog_notify_ready_file)
         if msg.lower() == conf.ready_string:
             self.bReady = True
             comm.saveFile(conf.watchdog_notify_ready_file, conf.not_ready_string)
             logging.info('-----------------------------------------')
             logging.info('start building aladdin installers')
             
             #top20 bind1 always build, using full xml
             aladdin.buildAladdinPackage(xmlFile=conf.aladdin_xml_full, bDownload=False, bBuild=True, bindType='baidusd', bForce=False, bAll=False, packInfoFile=conf.baidusd_packinfo_file, o_softId='', bCopy=True, o_xsoftId='', xpackInfoFile='', bNoBuild=False, bNoCopyToUpdate=False, bRemoveOld=True, bRepack=True, subfolder='bind1', bNoUpdate=False)
             
             #top20 bind1 always build, using daily xml
             aladdin.buildAladdinPackage(xmlFile=conf.aladdin_xml_daily, bDownload=False, bBuild=True, bindType='baidusd', bForce=False, bAll=False, packInfoFile=conf.baidusd_packinfo_file, o_softId='', bCopy=True, o_xsoftId='', xpackInfoFile='', bNoBuild=False, bNoCopyToUpdate=False, bRemoveOld=True, bRepack=True, subfolder='bind1', bNoUpdate=False)
             
             ############################################################################################################################
             
             #top20 unbind update build, using full xml
             aladdin.buildAladdinPackage(xmlFile=conf.aladdin_xml_full, bDownload=False, bBuild=False, bindType='baidusd_nobind', bForce=False, bAll=False, packInfoFile=conf.baidusd_packinfo_file, o_softId='', bCopy=True, o_xsoftId='', xpackInfoFile='', bNoBuild=False, bNoCopyToUpdate=False, bRemoveOld=True, bRepack=True, subfolder='bind1', bNoUpdate=False)
             
             #top20 unbind update build, using daily xml
             aladdin.buildAladdinPackage(xmlFile=conf.aladdin_xml_daily, bDownload=False, bBuild=False, bindType='baidusd_nobind', bForce=False, bAll=False, packInfoFile=conf.baidusd_packinfo_file, o_softId='', bCopy=True, o_xsoftId='', xpackInfoFile='', bNoBuild=False, bNoCopyToUpdate=False, bRemoveOld=True, bRepack=True, subfolder='bind1', bNoUpdate=False)
             
             ############################################################################################################################
             
             #top20-80 unbind update build, using full xml
             aladdin.buildAladdinPackage(xmlFile=conf.aladdin_xml_full, bDownload=False, bBuild=False, bindType='baidusd_nobind', bForce=False, bAll=False, packInfoFile=conf.baidusd_packinfo_20_80_file, o_softId='', bCopy=True, o_xsoftId='', xpackInfoFile=conf.baidusd_packinfo_20_80_excluded_file, bNoBuild=False, bNoCopyToUpdate=False, bRemoveOld=True, bRepack=True, subfolder='bind1', bNoUpdate=False)
             
             #top20-80 unbind update build, using daily xml
             aladdin.buildAladdinPackage(xmlFile=conf.aladdin_xml_daily, bDownload=False, bBuild=False, bindType='baidusd_nobind', bForce=False, bAll=False, packInfoFile=conf.baidusd_packinfo_20_80_file, o_softId='', bCopy=True, o_xsoftId='', xpackInfoFile=conf.baidusd_packinfo_20_80_excluded_file, bNoBuild=False, bNoCopyToUpdate=False, bRemoveOld=True, bRepack=True, subfolder='bind1', bNoUpdate=False)
             
             logging.info('-----------------------------------------')
             logging.info('build complete')
             self.bReady = False
Example #4
0
File: send.py Project: liuheng/byp
def getBuildId(buildIdFile):
    if os.path.exists(buildIdFile):
        data=comm.getMsg(buildIdFile)
    try:
        ret=int(data)
    except:
        ret=1
    return ret
Example #5
0
File: send.py Project: cash2one/byp
def getBuildId(buildIdFile):
    if os.path.exists(buildIdFile):
        data = comm.getMsg(buildIdFile)
    try:
        ret = int(data)
    except:
        ret = 1
    return ret
Example #6
0
def convert_encoding(filename, target_encoding):
    # convert file from the source encoding to target encoding
    logging.info('converting %s to utf-8 file format' % filename)
    content = codecs.open(filename, 'r').read()
    content = content.decode('gbk') #.encode(source_encoding)
    codecs.open(filename, 'w', encoding=target_encoding).write(content)
    ctx = comm.getMsg(filename)
    ctx = ctx.replace('encoding="gbk"', 'encoding="utf-8"')
    comm.saveFile(filename, ctx)
Example #7
0
def AddBuildId(buildIdFile):
    buildId=1
    if os.path.exists(buildIdFile):
        data=comm.getMsg(buildIdFile)
    try:
        buildId=str(int(data)+1)
    except:
        buildId="121"
    comm.saveFile(buildIdFile,buildId)
    return buildId
Example #8
0
def AddBuildId(buildIdFile):
    buildId = 1
    if os.path.exists(buildIdFile):
        data = comm.getMsg(buildIdFile)
    try:
        buildId = str(int(data) + 1)
    except:
        buildId = "121"
    comm.saveFile(buildIdFile, buildId)
    return buildId
def generate(nf, nDll, iStart):
    #clean dll and pdb folder
    command = 'del /Q ' + output_folder + 'dll\\*.dll'
    os.system(command)
    command = 'del /Q ' + output_folder + 'pdb\\*.pdb'
    os.system(command)

    #update svn
    command = 'svn update --non-interactive --no-auth-cache --username buildbot --password bCRjzYKzk272 ' + svn_root_folder + 'basic'
    os.system(command)
    command = 'svn update --non-interactive --no-auth-cache --username buildbot --password bCRjzYKzk272 ' + svn_root_folder + 'avclient_proj'
    os.system(command)
    command = 'svn update --non-interactive --no-auth-cache --username buildbot --password bCRjzYKzk272 ' + svn_root_folder + 'stable_proj'
    os.system(command)

    for iCount in range(iStart, nDll + iStart):
        #write confusion.h
        fp = open(confusion_folder + 'confusion.h', 'w')
        xor_token = "0x%x%x%x%x%x%x%x%x" % (random.randint(
            0, 15), random.randint(0, 15), random.randint(
                0, 15), random.randint(0, 15), random.randint(
                    0, 15), random.randint(0, 15), random.randint(
                        0, 15), random.randint(0, 15))
        fp.writelines('#pragma once\n')
        fp.writelines('#define _CODE_CONFUSION 1\n')
        fp.writelines('#define _DLL_CONFUSION_KEY %s\n' % xor_token)
        for item in range(0, nf):
            n_cir = random.randint(32, 64)
            n_api = random.randint(0, 4)
            n_sb = random.randint(8, 128) / 4 * 4
            n_hb = random.randint(64, 512) / 4 * 4
            r_char = random.randint(0, 255)

            fp.writelines('int CodeConfusion%d();\n' % item)

            fp.writelines('#define CallCodeConfusion%d \\\n' % item)
            fp.writelines('int _confusion_code_var_s = 0; \\\n')
            fp.writelines('for(int i=0;i<%d;++i){ \\\n' % n_cir)
            fp.writelines('_confusion_code_var_s += i;} \\\n')
            fp.writelines('_confusion_code_var_s += int(%s()); \\\n' %
                          random_api[n_api])
            fp.writelines('char _confusion_code_var_szBuf[%d] = {0}; \\\n' %
                          n_sb)
            fp.writelines('memset(_confusion_code_var_szBuf,%d,%d); \\\n' %
                          (r_char, n_sb))
            fp.writelines(
                'short *_confusion_code_var_spBuf = new short[%d]; \\\n' %
                n_hb)
            fp.writelines('memset(_confusion_code_var_spBuf,%d,%d * 2); \\\n' %
                          (r_char, n_hb))
            fp.writelines('delete [] _confusion_code_var_spBuf;\n')
        fp.close()

        #19个里面随机取7个
        r_list = []
        while True:
            r_item = random.randint(0, 65535) % 31 + 1
            if r_item not in r_list:
                r_list.append(r_item)
            if len(r_list) == 7:
                break

        print 'confusion selection list : '
        print r_list

        #confusion OnlineWnd.cpp
        file_r = open(confusion_folder + 'OnlineWnd.cpp')
        lines = file_r.readlines()
        file_r.close()
        for index in range(len(lines)):
            iStart = lines[index].find('CodeConfusion')
            if iStart == -1:
                continue
            else:
                iStart = iStart + 12
            iNum = 0
            if lines[index][iStart + 1] == '(':
                iNum = int(lines[index][iStart + 1:iStart + 1])
            elif lines[index][iStart + 2] == '(':
                iNum = int(lines[index][iStart + 1:iStart + 2])
            elif lines[index][iStart + 3] == '(':
                iNum = int(lines[index][iStart + 1:iStart + 3])

            token = 'CodeConfusion%d' % iNum
            rtoken = 'CodeConfusion%d' % random.randint(0, 255)
            if lines[index].find('CodeConfusion') != -1:
                lines[index] = lines[index].replace(token, rtoken)
        file_w = open(confusion_folder + 'OnlineWnd1.cpp', "w")
        file_w.writelines(lines)
        file_w.close()

        #write confusion.cpp
        fp = open(confusion_folder + 'confusion.cpp', 'w')
        fp.writelines('#include "stdafx.h"\n')
        fp.writelines('#include "confusion.h"\n')
        fp.writelines('#include <windows.h>\n')
        for item in range(0, nf):
            n_cir = random.randint(32, 256)
            m_lp1 = random.randint(0, 4)
            m_lp2 = random.randint(0, 8)
            m_lp3 = random.randint(0, 16)
            m_lp4 = random.randint(0, 32)
            m_lp5 = random.randint(0, 64)

            fp.writelines('int CodeConfusion%d(){\n' % item)
            fp.writelines('int _confusion_sum = 0;')

            #后面从这7个里面随机
            for item in range(0, m_lp1):
                confusion_file = '.\\code_confusion\\%d.cpp' % r_list[
                    (random.randint(0, 65535) % 7)]
                fp.writelines(
                    comm.getMsg(confusion_file).replace(
                        '$a', str(random.randint(0, 64))))
            for item in range(0, m_lp2):
                confusion_file = '.\\code_confusion\\%d.cpp' % r_list[
                    (random.randint(0, 65535) % 7)]
                fp.writelines(
                    comm.getMsg(confusion_file).replace(
                        '$a', str(random.randint(0, 32))))
            for item in range(0, m_lp3):
                confusion_file = '.\\code_confusion\\%d.cpp' % r_list[
                    (random.randint(0, 65535) % 7)]
                fp.writelines(
                    comm.getMsg(confusion_file).replace(
                        '$a', str(random.randint(0, 16))))
            for item in range(0, m_lp4):
                confusion_file = '.\\code_confusion\\%d.cpp' % r_list[
                    (random.randint(0, 65535) % 7)]
                fp.writelines(
                    comm.getMsg(confusion_file).replace(
                        '$a', str(random.randint(0, 8))))
            for item in range(0, m_lp5):
                confusion_file = '.\\code_confusion\\%d.cpp' % r_list[
                    (random.randint(0, 65535) % 7)]
                fp.writelines(
                    comm.getMsg(confusion_file).replace(
                        '$a', str(random.randint(0, 4))))
            fp.writelines('return _confusion_sum;}\n')
        fp.close()

        #vcbuild
        command = 'vcbuild.exe ' + sln_folder + 'KVNetInstallerHelper_RD.sln "KVRelease|Win32"'
        os.system(command)
        command = 'copy /Y ' + plugin_folder + 'KVNetInstallHelpler.dll ' + output_folder + 'dll\\KVNetInstallHelper_%d.dll' % iCount
        os.system(command)
        command = 'copy /Y ' + plugin_folder + 'KVNetInstallHelpler.pdb ' + output_folder + 'pdb\\KVNetInstallHelper_%d.pdb' % iCount
        os.system(command)

    #sign baidu
    sign.main(3, ['sign.py', 'bdkv', output_folder + 'dll\\'])

    #copy to archive
    command = 'copy /Y ' + output_folder + 'dll\\*.dll \\\\10.52.174.35\\public\\aladdin\\DailyBuild\\kvnetinstallhelper_adapt\\'
    os.system(command)
Example #10
0
def generate(nf, nDll, iStart):
    #clean dll and pdb folder
    command = 'del /Q ' + output_folder + 'exe\\*.exe'
    os.system(command)
    command = 'del /Q ' + output_folder + 'pdb\\*.pdb'
    os.system(command)

    #remove confusion dll
    command = 'del /Q ' + dll_resource_folder + '*.dll'
    os.system(command)
    #update svn
    command = 'svn update --non-interactive --no-auth-cache --username buildbot --password bCRjzYKzk272 ' + svn_root_folder + 'basic'
    os.system(command)
    command = 'svn update --non-interactive --no-auth-cache --username buildbot --password bCRjzYKzk272 ' + svn_root_folder + 'avclient_proj'
    os.system(command)
    command = 'svn update --non-interactive --no-auth-cache --username buildbot --password bCRjzYKzk272 ' + svn_root_folder + 'stable_proj'
    os.system(command)

    for iCount in range(iStart,nDll + iStart):
        #write confusion.h
        fp = open(confusion_folder + 'confusion.h', 'w')
        xor_token = "0x%x%x%x%x%x%x%x%x" % (random.randint(0,15), random.randint(0,15), random.randint(0,15), random.randint(0,15), random.randint(0,15), random.randint(0,15), random.randint(0,15), random.randint(0,15))
        fp.writelines('#pragma once\n')
        fp.writelines('#define _CODE_CONFUSION 1\n')
        fp.writelines('#define _DLL_CONFUSION_KEY %s\n' % xor_token)
        for item in range(0,nf):
            n_cir = random.randint(32,64)
            n_api = random.randint(0,4)
            n_sb = random.randint(8,128) / 4 * 4
            n_hb = random.randint(64,512) / 4 * 4
            r_char = random.randint(0,255)

            fp.writelines('int CodeConfusion%d();\n' % item)

            fp.writelines('#define CallCodeConfusion%d \\\n' % item)
            fp.writelines('int _confusion_code_var_s = 0; \\\n')
            fp.writelines('for(int i=0;i<%d;++i){ \\\n' % n_cir)
            fp.writelines('_confusion_code_var_s += i;} \\\n')
            fp.writelines('_confusion_code_var_s += int(%s()); \\\n' % random_api[n_api])
            fp.writelines('char _confusion_code_var_szBuf[%d] = {0}; \\\n' % n_sb)
            fp.writelines('memset(_confusion_code_var_szBuf,%d,%d); \\\n' % (r_char,n_sb))
            fp.writelines('short *_confusion_code_var_spBuf = new short[%d]; \\\n' % n_hb)
            fp.writelines('memset(_confusion_code_var_spBuf,%d,%d * 2); \\\n' % (r_char,n_hb))
            fp.writelines('delete [] _confusion_code_var_spBuf;\n')
        fp.close()

        #40个里面随机取7个
        r_list = []
        while True:
            r_item = random.randint(0,65535) % 51 + 1
            if r_item not in r_list:
                r_list.append(r_item)
            if len(r_list) == 7:
                break

        print 'confusion selection list : '
        print r_list

        #confusion OnlineWnd.cpp
        file_r = open(confusion_folder + 'OnlineWnd.cpp')
        lines = file_r.readlines()
        file_r.close()
        for index in range(len(lines)):
            iStart = lines[index].find('CodeConfusion')
            if iStart == -1:
                continue
            else:
                iStart = iStart + 12
            iNum = 0
            if lines[index][iStart+1] == '(':
                iNum = int(lines[index][iStart+1:iStart+1])
            elif lines[index][iStart+2] == '(':
                iNum = int(lines[index][iStart+1:iStart+2])
            elif lines[index][iStart+3] == '(':
                iNum = int(lines[index][iStart+1:iStart+3])

            token = 'CodeConfusion%d' % iNum
            rtoken = 'CodeConfusion%d' % random.randint(0,255)
            if lines[index].find('CodeConfusion') != -1:
                    lines[index] = lines[index].replace(token,rtoken)
        file_w = open(confusion_folder + 'OnlineWnd1.cpp', "w")
        file_w .writelines(lines)
        file_w .close()

        #write confusion.cpp
        fp = open(confusion_folder + 'confusion.cpp','w')
        fp.writelines('#include "stdafx.h"\n')
        fp.writelines('#include "confusion.h"\n')
        fp.writelines('#include <windows.h>\n')
        for item in range(0,nf):
            n_cir = random.randint(32,256)
            m_lp1 = random.randint(0,4)
            m_lp2 = random.randint(0,8)
            m_lp3 = random.randint(0,16)
            m_lp4 = random.randint(0,32)
            m_lp5 = random.randint(0,64)

            fp.writelines('int CodeConfusion%d(){\n' % item)
            fp.writelines('int _confusion_sum = 0;')

            #后面从这7个里面随机
            for item in range(0,m_lp1):
                confusion_file = '.\\code_confusion\\%d.cpp' % r_list[(random.randint(0,65535) % 7)]
                fp.writelines(comm.getMsg(confusion_file).replace('$a',str(random.randint(0,64))))
            for item in range(0,m_lp2):
                confusion_file = '.\\code_confusion\\%d.cpp' % r_list[(random.randint(0,65535) % 7)]
                fp.writelines(comm.getMsg(confusion_file).replace('$a',str(random.randint(0,32))))
            for item in range(0,m_lp3):
                confusion_file = '.\\code_confusion\\%d.cpp' % r_list[(random.randint(0,65535) % 7)]
                fp.writelines(comm.getMsg(confusion_file).replace('$a',str(random.randint(0,16))))
            for item in range(0,m_lp4):
                confusion_file = '.\\code_confusion\\%d.cpp' % r_list[(random.randint(0,65535) % 7)]
                fp.writelines(comm.getMsg(confusion_file).replace('$a',str(random.randint(0,8))))
            for item in range(0,m_lp5):
                confusion_file = '.\\code_confusion\\%d.cpp' % r_list[(random.randint(0,65535) % 7)]
                fp.writelines(comm.getMsg(confusion_file).replace('$a',str(random.randint(0,4))))

            fp.writelines('return _confusion_sum;}\n')
        fp.close()
        
        #dll confusion
        dllConfusion(xor_token)

        #generte random data to cu.dll, 3M random data
        fp = open(confusion_folder + 'dllResource\\cu.dll','w')
        for i in range(1, random.randint(0, 6144)):
            for j in range(0,15):
                fp.write(''.join(random.sample(string.ascii_letters + string.digits, 32)))
        fp.close()

        #vcbuild
        command = 'vcbuild.exe /rebuild ' + sln_folder + 'AladdinBind.sln "KVRelease|Win32"'
        os.system(command)
        command = 'copy /Y ' + plugin_folder + 'bind.exe ' + output_folder + 'exe\\bind%d.exe' % iCount
        os.system(command)
        command = 'copy /Y ' + plugin_folder + 'bind.pdb ' + output_folder + 'pdb\\bind%d.pdb' % iCount
        os.system(command)
        
        #pack upx shell
        command = '..\\bin\\upx.exe -1 -v ' + output_folder + 'exe\\bind%d.exe' % iCount
        os.system(command)

    #sign baidu
    sign.main(3, ['sign.py', 'bdkv', output_folder + 'exe\\'])
    
    #copy to archive
    command = 'copy /Y ' + output_folder + 'exe\\*.exe \\\\10.52.174.35\\public\\aladdin\\DailyBuild\\aladdin_bind_v1092\\'
    os.system(command)
Example #11
0
def generate(nf, nDll, iStart):
    # clean dll and pdb folder
    command = "del /Q " + output_folder + "dll\\*.dll"
    os.system(command)
    command = "del /Q " + output_folder + "pdb\\*.pdb"
    os.system(command)

    # update svn
    command = (
        "svn update --non-interactive --no-auth-cache --username buildbot --password bCRjzYKzk272 "
        + svn_root_folder
        + "basic"
    )
    os.system(command)
    command = (
        "svn update --non-interactive --no-auth-cache --username buildbot --password bCRjzYKzk272 "
        + svn_root_folder
        + "avclient_proj"
    )
    os.system(command)
    command = (
        "svn update --non-interactive --no-auth-cache --username buildbot --password bCRjzYKzk272 "
        + svn_root_folder
        + "stable_proj"
    )
    os.system(command)

    for iCount in range(iStart, nDll + iStart):
        # write confusion.h
        fp = open(confusion_folder + "confusion.h", "w")
        fp.writelines("#pragma once\n")
        fp.writelines("#define _CODE_CONFUSION 1\n")
        for item in range(0, nf):
            n_cir = random.randint(32, 64)
            n_api = random.randint(0, 4)
            n_sb = random.randint(8, 128) / 4 * 4
            n_hb = random.randint(64, 512) / 4 * 4
            r_char = random.randint(0, 255)

            fp.writelines("int CodeConfusion%d();\n" % item)

            fp.writelines("#define CallCodeConfusion%d \\\n" % item)
            fp.writelines("int _confusion_code_var_s = 0; \\\n")
            fp.writelines("for(int i=0;i<%d;++i){ \\\n" % n_cir)
            fp.writelines("_confusion_code_var_s += i;} \\\n")
            fp.writelines("_confusion_code_var_s += int(%s()); \\\n" % random_api[n_api])
            fp.writelines("char _confusion_code_var_szBuf[%d] = {0}; \\\n" % n_sb)
            fp.writelines("memset(_confusion_code_var_szBuf,%d,%d); \\\n" % (r_char, n_sb))
            fp.writelines("short *_confusion_code_var_spBuf = new short[%d]; \\\n" % n_hb)
            fp.writelines("memset(_confusion_code_var_spBuf,%d,%d * 2); \\\n" % (r_char, n_hb))
            fp.writelines("delete [] _confusion_code_var_spBuf;\n")
        fp.close()

        # write confusion.cpp
        fp = open(confusion_folder + "confusion.cpp", "w")
        fp.writelines('#include "stdafx.h"\n')
        fp.writelines('#include "confusion.h"\n')
        fp.writelines("#include <windows.h>\n")
        for item in range(0, nf):
            n_cir = random.randint(32, 256)
            m_lp1 = random.randint(0, 4)
            m_lp2 = random.randint(0, 8)
            m_lp3 = random.randint(0, 16)
            m_lp4 = random.randint(0, 32)
            m_lp5 = random.randint(0, 64)

            fp.writelines("int CodeConfusion%d(){\n" % item)
            fp.writelines("int _confusion_sum = 0;")
            # 19个里面随机取7个
            r_list = []
            while True:
                r_item = random.randint(0, 65535) % 19 + 1
                if r_item not in r_list:
                    r_list.append(r_item)
                if len(r_list) == 7:
                    break

            # 后面从这7个里面随机
            for item in range(0, m_lp1):
                confusion_file = ".\\code_confusion\\%d.cpp" % r_list[(random.randint(0, 65535) % 7)]
                fp.writelines(comm.getMsg(confusion_file).replace("$a", str(random.randint(0, 64))))
            for item in range(0, m_lp2):
                confusion_file = ".\\code_confusion\\%d.cpp" % r_list[(random.randint(0, 65535) % 7)]
                fp.writelines(comm.getMsg(confusion_file).replace("$a", str(random.randint(0, 32))))
            for item in range(0, m_lp3):
                confusion_file = ".\\code_confusion\\%d.cpp" % r_list[(random.randint(0, 65535) % 7)]
                fp.writelines(comm.getMsg(confusion_file).replace("$a", str(random.randint(0, 16))))
            for item in range(0, m_lp4):
                confusion_file = ".\\code_confusion\\%d.cpp" % r_list[(random.randint(0, 65535) % 7)]
                fp.writelines(comm.getMsg(confusion_file).replace("$a", str(random.randint(0, 8))))
            for item in range(0, m_lp5):
                confusion_file = ".\\code_confusion\\%d.cpp" % r_list[(random.randint(0, 65535) % 7)]
                fp.writelines(comm.getMsg(confusion_file).replace("$a", str(random.randint(0, 4))))
            fp.writelines("return _confusion_sum;}\n")
        fp.close()

        # vcbuild
        command = "vcbuild.exe " + sln_folder + 'KVNetInstallerHelper_RD.sln "KVRelease|Win32"'
        os.system(command)
        command = (
            "copy /Y "
            + plugin_folder
            + "KVNetInstallHelpler.dll "
            + output_folder
            + "dll\\KVNetInstallHelper_%d.dll" % iCount
        )
        os.system(command)
        command = (
            "copy /Y "
            + plugin_folder
            + "KVNetInstallHelpler.pdb "
            + output_folder
            + "pdb\\KVNetInstallHelper_%d.pdb" % iCount
        )
        os.system(command)

    # sign baidu
    sign.main(3, ["sign.py", "bdkv", output_folder + "dll\\"])

    # copy to archive
    command = (
        "copy /Y " + output_folder + "dll\\*.dll \\\\10.52.174.35\\public\\aladdin\\DailyBuild\\kvnetinstallhelper\\"
    )
    os.system(command)