当前位置: 首页>>代码示例>>Python>>正文


Python nfp_log.log函数代码示例

本文整理汇总了Python中nfp_log.log函数的典型用法代码示例。如果您正苦于以下问题:Python log函数的具体用法?Python log怎么用?Python log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: reload_statistics

 def reload_statistics(self):
   if self.state_file is not None:
     with open(self.state_file, "rb") as f:
       self.stats = json.loads(f.read())
   line = "Reloaded statistics: Min %d, Max %d, Avg %f"
   line = line % (self.stats["min"], self.stats["max"], self.stats["avg"])
   log(line)
开发者ID:distribute,项目名称:nightmare,代码行数:7,代码来源:bcf.py

示例2: debug_server

  def debug_server(self, shared_queue):
    self.read_configuration()

    uid = int(self.server_uid)
    if os.getuid() != uid:
      os.setresuid(uid, uid, uid)

    gid = int(self.server_gid)
    if os.getgid() != gid:
      os.setresgid(gid, gid, gid)

    for key in self.env:
      debug("Setting environment variable %s=%s" % (key, self.env[key]))
      os.putenv(key, self.env[key])

    if self.pre_command is not None:
      os.system(self.pre_command)

    crash = None
    for i in range(0,3):
      try:
        crash = self.launch_debugger(self.timeout, self.command, "")
        break
      except:
        log("Exception: %s" % sys.exc_info()[1])
        continue

    if self.post_command is not None:
      os.system(self.post_command)

    if crash is not None:
      self.crash_info = crash
      shared_queue.put(crash)
      return True
    return False
开发者ID:ArashAll,项目名称:nightmare,代码行数:35,代码来源:generic_client_server.py

示例3: __init__

  def __init__(self, tube_prefix):
    if tube_prefix.endswith("-samples"):
      log("Notice: Removing '-samples' suffix from the queue name")
      tube_prefix = tube_prefix.replace("-samples", "")

    self.tube_prefix = tube_prefix
    self.q = get_queue(watch=False, name="%s-samples" % tube_prefix)
开发者ID:joxeankoret,项目名称:nightmare,代码行数:7,代码来源:queue_tool.py

示例4: run

  def run(self, timeout=60):
    def target():
      debug('Thread started')
      self.process = subprocess.Popen("exec %s" % self.cmd, shell=True)
      self.process.communicate()
      debug('Thread finished')

    thread = threading.Thread(target=target)
    thread.start()

    thread.join(timeout)
    if thread.is_alive():
      log('Terminating process after timeout (%d)' % timeout)
      try:
        self.process.terminate()
        self.process.terminate()
        self.process.kill()
        self.process.wait()
      except:
        log("Error killing process: %s" % str(sys.exc_info()[1]))

      thread.join()
    self.process.wait()
    ret = self.process.returncode

    # A negative return code means a signal was received and the return
    # code is -1 * SIGNAL. Return the expected Unix return code.
    if ret is not None and ret < 0:
      ret = abs(ret) + 128
    return ret
开发者ID:labba,项目名称:nightmare,代码行数:30,代码来源:nfp_process.py

示例5: resolve_windbg_path

 def resolve_windbg_path(self):
   try:
     reg = ConnectRegistry(None,HKEY_LOCAL_MACHINE)
     key = OpenKey(reg, r"SOFTWARE\Microsoft\Microsoft SDKs\Windows")
     if key:
       for i in range(QueryInfoKey(key)[0]):
         value = EnumKey(key, i)
         if value:
           full_key = r"SOFTWARE\Microsoft\Microsoft SDKs\Windows\\" + value
           key2 = OpenKey(reg, full_key)
           if key2:
             name = QueryValueEx(key2, "ProductName")
             name = name[0]
             if name and name.startswith("Microsoft Windows SDK for Windows"):
               vals = QueryValueEx(key2, "InstallationFolder")
               val = vals[0]
               if val is not None:
                 log("Found installation path at %s" % val)
                 self.windbg_path = val
                 break
             CloseKey(key2)
     CloseKey(key)
   except WindowsError:
     print "Cannot resolve Windows SDKs path:", sys.exc_info()[1]
     print "Did you install Windows SDKs for Windows?"
   except:
     print "Cannot resolve Windows SDKs path:", sys.exc_info()[1]
开发者ID:alvarofe,项目名称:nightmare,代码行数:27,代码来源:pykd_iface.py

示例6: check_cpu

  def check_cpu(self):
    while True:
      try:
        if self.pid is None:
          time.sleep(0.2)
          continue

        proc = psutil.Process(self.pid)
        if proc is None:
          break

        cpu = 0
        l = []
        for x in xrange(20):
          tmp = int(proc.cpu_percent(interval=0.1))
          cpu += tmp
          l.append(tmp)

        if cpu is not None and (cpu <= 100 or l.count(0) > 10):
          log("CPU at 0%, killing")
          self.do_stop = True
          pykd.breakin()
          break
        else:
          time.sleep(0.5)
      except psutil.NoSuchProcess:
        self.do_stop = True
        break
开发者ID:joxeankoret,项目名称:nightmare,代码行数:28,代码来源:pykd_iface.py

示例7: do_fuzz

def do_fuzz(cfg, section):
  try:
    fuzzer = CGenericFuzzer(cfg, section)
    fuzzer.fuzz()
  except KeyboardInterrupt:
    log("Aborted")
  except:
    log("Error: %s" % str(sys.exc_info()[1]))
开发者ID:labba,项目名称:nightmare,代码行数:8,代码来源:generic_fuzzer.py

示例8: timeout_func

 def timeout_func(self):
   log("Timeout (%d seconds), killing the target..." % self.timeout)
   self.do_stop = True
   try:
     pykd.breakin()
   except:
     # A race condition might happen in the timeout function and in 
     # such cases we must ignore the error.
     pass
开发者ID:ArashAll,项目名称:nightmare,代码行数:9,代码来源:pykd_iface.py

示例9: launch_debugger

 def launch_debugger(self, timeout, command, filename):
   self.iface.timeout = int(timeout)
   
   if command.find("@@") > -1:
     cmd = [command.replace("@@", filename), ]
   else:
     cmd = [command, filename]
   
   log("Launching debugger with command %s" % " ".join(cmd))
   crash = self.iface.main(cmd)
   return crash
开发者ID:labba,项目名称:nightmare,代码行数:11,代码来源:generic_fuzzer.py

示例10: get_html_buffer

  def get_html_buffer(self, lines, skip_tags):
    log("Rewriting HTML...")
    rewriter = CHTMLRewriter()
    ret = rewriter.rewrite("\n".join(lines), skip_tags)
    if not ret:
      return None, None

    lines = ret
    log("Total line(s) %d" % len(lines))

    return "".join(lines), lines
开发者ID:joxeankoret,项目名称:nightmare,代码行数:11,代码来源:minimize_html.py

示例11: run

  def run(self, timeout=60, get_output=False):
    def target():
      debug('Thread started')
      if os.name == "nt":
        line = self.cmd
        shell = False
      else: # Unix based
        line = "exec %s" % self.cmd
        shell = True
      
      if get_output:
        self.process = subprocess.Popen(line, stdout=subprocess.PIPE,\
                                      stderr=subprocess.PIPE, shell=shell)
        self.pid = self.process.pid
        out, err = self.process.communicate()
        self.stdout = out[:8192]
        self.stderr = err[:8192]
      else:
        self.process = subprocess.Popen(line, shell=shell)
        self.pid = self.process.pid
        self.process.communicate()

      debug('Thread finished')

    thread = threading.Thread(target=target)
    thread.start()

    if str(timeout).lower() == "auto":
      self.thread = threading.Thread(target=self.check_cpu)
      self.thread.start()
      thread.join(self.default_timeout)
    else:
      thread.join(timeout)

    if thread.is_alive():
      log('Terminating process after timeout (%s)' % str(timeout))
      try:
        self.do_kill()
      except:
        log("Error killing process: %s" % str(sys.exc_info()[1]))

      thread.join()

    self.process.wait()
    ret = self.process.returncode

    # A negative return code means a signal was received and the return
    # code is -1 * SIGNAL. Return the expected Unix return code.
    if ret is not None and ret < 0:
      if os.name == "nt":
        ret = ret & 0xFFFFFFFF
      else:
        ret = abs(ret) + 128
    return ret
开发者ID:ArashAll,项目名称:nightmare,代码行数:54,代码来源:nfp_process.py

示例12: recalculate_statistics

  def recalculate_statistics(self, old_stats, bbs):
    self.stats["max"] = bbs
    self.stats["min"] = old_stats["max"]
    self.stats["avg"] = (self.stats["max"] + self.stats["min"]) / 2.
    #self.stats = self.mgr.dict(self.stats)
    line = "New statistics: Min %d, Max %d, Avg %f"
    line = line % (self.stats["min"], self.stats["max"], self.stats["avg"])
    log(line)

    if self.state_file is not None:
      with open(self.state_file, "wb") as f:
        f.write(json.dumps(dict(self.stats)))
开发者ID:distribute,项目名称:nightmare,代码行数:12,代码来源:bcf.py

示例13: minimize

  def minimize(self, template, outdir):
    self.read_template(template)

    log("Performing line-level test case minimization")
    start_at = os.getenv("NIGHTMARE_ITERATION")
    if start_at is not None:
      start_at = int(start_at)
      log("Starting from iteration %d\n" % start_at)
    else:
      start_at = 0

    self.do_try(outdir, start_at)
开发者ID:alvarofe,项目名称:nightmare,代码行数:12,代码来源:generic_minimizer.py

示例14: apply_bytes

  def apply_bytes(self, offset, size, buf):
    debug("Acquiring lock...")
    self.lock.acquire()
    try:
      debug("Saving old generation (%s)" % sha1(self.template).hexdigest())
      if len(self.generations) >= self.max_generations:
        del self.generations[0]
      self.generations.append([bytearray(self.template), dict(self.stats), self.generation_value])
      
      if self.save_generations:
        file_hash = sha1(buf).hexdigest()
        ext = os.path.splitext(self.input_file)[1]
        filename = "generation_%s%s" % (file_hash, ext)
        filename = os.path.join(self.output, filename)
        log("Writing discovered generation file %s (%s)" % (file_hash, filename))

        with open(filename, "wb") as f:
          f.write(buf)

      if not self.radamsa:
        debug("Applying patch at offset %d of size %d" % (offset, size))
      else:
        debug("Replacing old buffer")

      self.template = buf
      """
      if self.skip_bytes > 0:
        header = self.template[0:self.skip_bytes]

      if len(buf) > len(self.template):
        self.template = bytearray(buf)
      else:
        for i in range(size):
          self.template[offset+i] = buf[i]

      if self.skip_bytes > 0:
        self.template[0:self.skip_bytes] = header
      """

      if self.current_state is not None:
        ext = os.path.splitext(self.input_file)[1]
        filename = "%s%s" % (self.current_state, ext)
        filename = os.path.join(self.output, filename)
        file_hash = sha1(self.template).hexdigest()

        debug("Creating or updating current state file %s (%s)" % (filename, file_hash))
        with open(filename, "wb") as f:
          f.write(self.template)

    finally:
      debug("Releasing lock...")
      self.lock.release()
开发者ID:distribute,项目名称:nightmare,代码行数:52,代码来源:bcf.py

示例15: disasm_around

  def disasm_around(self):
    try:
      lines = pykd.dbgCommand("u %s-c L12" % self.pc_register)
      for line in lines.split("\n"):
        tmp = re.findall("([a-f0-9]{1,}) ([a-f0-9]{2,}) (.*)", line)
        if len(tmp) > 0:
          line = tmp[0]

          addr = line[0]
          dis = line[2]
          self.crash_data.add_data("disassembly", int(addr, 16), dis)
    except:
      log("Error in disasm_around: %s" % str(sys.exc_info()[1]))
开发者ID:joxeankoret,项目名称:nightmare,代码行数:13,代码来源:pykd_iface.py


注:本文中的nfp_log.log函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。