Ejemplo n.º 1
0
    def __init__(self, executable):
        """ init function

        Args:
            executable: target executable file path
        """
        self.logger = LogUtil.get_logger()
        self.executable = executable
        self.elf = getELF(executable)
        self.arch = get_arch(self.elf)

        self.functions = {}
        self.addr2func = {}
        self.get_func()

        self.signs = {}
        self.explored_addr = []

        self.matched = {}

        self.sign_cache_file = "/tmp/" + md5(executable) + "_sign.cache"
        if os.path.exists(self.sign_cache_file):
            with open(self.sign_cache_file) as f:
                data = f.read()
                try:
                    self.signs = json.loads(data)
                except Exception as e:
                    self.logger.error(str(e))
Ejemplo n.º 2
0
 def __init__(self):
     self.logger = LogUtil.get_logger(self.__class__.__name__, "_logs")
     self.xml_parser = XMLParser(encoding="utf-8",
                                 huge_tree=True,
                                 ns_clean=True)
Ejemplo n.º 3
0
import json
import unittest
import time
import os

from config import BASE_DIR, BASE_HOST
from page.index_page import IndexProxy
from page.login_page import LoginProxy
from utils import DriverUtil, LogUtil, case_driver_quit, jietu
from parameterized import parameterized

logger = LogUtil.get_logger()


# 读取json 构造参数化数据
def get_data():
    # 1.创建参数化数据的结果列表
    result = []
    # 2.读取json 构造参数化数据
    # 通过项目绝对路径+数据位置
    with open(BASE_DIR + "/data/test_login.json", "r", encoding="utf-8") as f:
        python_data = json.load(f)
        for i in python_data:
            username = i["username"]
            password = i["password"]
            code = i["code"]
            yuqi = i["yuqi"]
            result.append((username, password, code, yuqi))
    # 3.返回参数化数据的结果列表
    logger.info("参数化数据:{}".format(result))
    return result
Ejemplo n.º 4
0
from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset
from torch.utils.data.distributed import DistributedSampler
from tqdm import tqdm, trange

from pytorch_pretrained_bert.file_utils import PYTORCH_PRETRAINED_BERT_CACHE
from pytorch_pretrained_bert.modeling import BertForSequenceClassification, BertConfig, WEIGHTS_NAME, CONFIG_NAME, BertPreTrainedModel
from pytorch_pretrained_bert.tokenization import BertTokenizer
from pytorch_pretrained_bert.optimization import BertAdam, warmup_linear

from bert_utils import BertForMultiLabelSequenceClassification
from utils import DataHandler, EvaluationUtil, LogUtil

# Taken and adapted from
# https://github.com/huggingface/pytorch-pretrained-BERT/blob/master/examples/run_classifier.py

logger = LogUtil.get_logger("bert_multilabel", "_logs")
#


def accuracy_thresh(y_pred: Tensor,
                    y_true: Tensor,
                    thresh: float = 0.5,
                    sigmoid: bool = True):
    "Compute accuracy when `y_pred` and `y_true` are the same size."
    if sigmoid: y_pred = y_pred.sigmoid()
    #     return ((y_pred>thresh)==y_true.byte()).float().mean().item()
    return np.mean(((y_pred > thresh) == y_true.byte()).float().cpu().numpy(),
                   axis=1).sum()


class InputInstance(object):