mutator_hodor.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:Hodor 作者: nccgroup 项目源码 文件源码
def bflipper(tokens):
  mutated_tokens = []
  procnum = int(multiprocessing.current_process().name)
  threadnum = int(threading.current_thread().name)
  mystart = procnum*max((config_hodor.iterations/config_hodor.procs), 8)
  # Figure out how to spread threads in a sensible manner
  for item in tokens:
    buf = bytearray(item) if isinstance(item, str) else item
    if len(buf) == 0:
      mutated_tokens.append(buf) # Nothing to do
      continue
    # This is supposed to deal with iterations > buflen in a sane way
    # Should just loop through and flip more bits at once
    myflip = config_hodor.mutator["bflipper"]["flipmode"] + (mystart+threadnum)/(len(buf)*8) 
    flipme = (threadnum/8)+(mystart/8)
    if flipme >= len(buf):
      flipme = flipme % len(buf)
    for j in range(myflip):
      buf[flipme] ^= (1 << ((threadnum+j)%8)) # Minor bug here, will do one extra xor on myflip>1
    mutated_tokens.append(buf)
  return mutated_tokens

# Quid pro quo, swap out old tokens for user specified tokens
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号