Beispiel #1
0
def loadPoc(pocFile):
    if pocFile.endswith(".pyc"):
        conf.isPycFile = True

    if conf.isPocString:
        poc = conf.pocFile
        if not conf.pocname:
            if conf.pocFile:
                conf.pocname = os.path.split(conf.pocFile)[1]
            else:
                errMsg = "Use pocString must provide pocname"
                logger.log(CUSTOM_LOGGING.ERROR, errMsg)
        pocname = conf.pocname
    else:
        pocname = os.path.split(pocFile)[1]
        poc = readFile(pocFile)

    if not conf.isPycFile:
        if not re.search(POC_REGISTER_REGEX, poc):
            warnMsg = "poc: %s register is missing" % pocname
            logger.log(CUSTOM_LOGGING.WARNING, warnMsg)
            className = getPocClassName(poc)
            poc += POC_REGISTER_STRING.format(className)

        retVal = multipleReplace(poc, POC_IMPORTDICT)
    else:
        retVal = poc
    return {pocname: retVal}
Beispiel #2
0
def loadPoc(pocFile):
    if pocFile.endswith(".pyc"):
        conf.isPycFile = True

    if conf.isPocString:
        poc = conf.pocFile
        if not conf.pocname:
            if conf.pocFile:
                conf.pocname = os.path.split(conf.pocFile)[1]
            else:
                errMsg = "Use pocString must provide pocname"
                logger.log(CUSTOM_LOGGING.ERROR, errMsg)
        pocname = conf.pocname
    else:
        pocname = os.path.split(pocFile)[1]
        poc = readFile(pocFile)

    if not conf.isPycFile:
        if not re.search(POC_REGISTER_REGEX, poc):
            warnMsg = "poc: %s register is missing" % pocname
            logger.log(CUSTOM_LOGGING.WARNING, warnMsg)
            className = getPocClassName(poc)
            poc += POC_REGISTER_STRING.format(className)

        retVal = multipleReplace(poc, POC_IMPORTDICT)
    else:
        retVal = poc
    return {pocname: retVal}
Beispiel #3
0
 def registerPoc(self):
     pocString = multipleReplace(self.pocString, POC_IMPORTDICT)
     _, self.moduleName = filepathParser(self.pocName)
     try:
         importer = StringImporter(self.moduleName, pocString)
         importer.load_module(self.moduleName)
     except ImportError, ex:
         logger.log(CUSTOM_LOGGING.ERROR, ex)
Beispiel #4
0
def setTemporaryPoc(pocFile):
    pocFilename = "_" + os.path.split(pocFile)[1]
    if not os.path.isdir(paths.POCSUITE_TMP_PATH):
        os.makedirs(paths.POCSUITE_TMP_PATH)
    pocname = os.path.join(paths.POCSUITE_TMP_PATH, pocFilename)
    poc = readFile(pocFile)
    retVal = multipleReplace(poc, POC_IMPORTDICT)
    # TODO 直接写入tmp文件夹 没有考虑是否存在文件 或者使用后删除文件
    writeFile(pocname, retVal)
    return pocname
Beispiel #5
0
def setTemporaryPoc(pocFile):
    pocFilename = os.path.split(pocFile)[1]
    if not pocFilename.startswith("_"):
        pocFilename = "_" + pocFilename
    pocname = os.path.join(paths.POCSUITE_TMP_PATH, pocFilename)
    poc = readFile(pocFile)
    retVal = multipleReplace(poc, POC_IMPORTDICT)
    # TODO 直接写入tmp文件夹 没有考虑是否存在文件 或者使用后删除文件
    writeFile(pocname, retVal)
    return pocname