2022 年网刃杯 ez_algorithm

99 篇文章 34 订阅

2022 年网刃杯 ez_algorithm

下载附件:
在这里插入图片描述
.
.
照例扔入 exeinfope 中查看信息,64 位无壳:
在这里插入图片描述
.
.
照例运行一下,查看主要回显信息:
在这里插入图片描述
.
.
照例扔入 IDA64 中查看伪代码,有 main 函数看 main 函数:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
.
.
进入到 encryption2 和 嵌在里面的 encryption3 分析可知它们两个是加密解密同一函数的:
在这里插入图片描述
在这里插入图片描述
.
.
然后,嗯~代码比较长,我曾一度想在脑子中梳理逆向逻辑,结果梳乱了,所以还是写在纸上了,写完之后再写脚本思路就很清晰:
我想以后遇到题目也可以这样先在纸上梳理逻辑,毕竟逆向分析过程是很长的,也不缺我书写逻辑这点时间,还是对我自己来说求稳比较好。
在这里插入图片描述
在这里插入图片描述

secret = list("BRUF{E6oU9Ci#J9+6nWAhwMR9n:}")
xiaoxie = list("ckagevdxizblqnwtmsrpufyhoj")
daxie = list("TMQZWKGOIAGLBYHPCRJSUXEVND")
xiabiao = 0 #输入下标
xiaobiao2=0 #映射下标
yushu=0 #逻辑相关的余数
def encryption3(s):     #从最内层的 if 开始逆向
  if ord(s)==71 or ord(s)==103: #如果是大G或小g的话就变成大T或小t 
    s=chr(ord(s)+13)
  elif ord(s)==84 or ord(s)==116: #如果是大T或小t的话就变成大G或小g
    s=chr(ord(s)-13)
  elif ord(s)>47 and ord(s)<=57:  #如果是数字的话就0-9和9-0一一对应,调转
    s=chr(105-ord(s))
  elif (ord(s)>77 and ord(s)<=83)  or (ord(s)>109 and ord(s)<=115):  #如果字母是大写的 N~S或小写的 n~s 就变成H~M或h~m
    s=chr(ord(s)-6)
  elif (ord(s)>71 and ord(s)<=77) or (ord(s)>103 and ord(s)<=109):  #如果字母是大写的 H~M或小写的 h~m 就变成N~S或n~s
    s=chr(ord(s)+6)
  elif (ord(s) >84 and ord(s)<=90) or (ord(s)>116 and ord(s)<=122): #如果字母是大写的 U~Z或小写的 u~z 就变成A~F或a~f
    s=chr(ord(s)-20)
  elif (ord(s) >64 and ord(s)<=70) or (ord(s)>96 and ord(s)<=102): #如果字母是大写的 A~F或小写的 a~f 就变成U~Z或u~z
    s=chr(ord(s)+20)
  else:
    pass
  return s

def encryption2(s):
  if ord(s) >= 64 and ord(s)  <=  90:  #是大写字母的话
    s=encryption3(chr(ord(s)+32))
  elif ord(s) >=96 and ord(s) <=122: #是小写字母的话
    s=encryption3(chr(ord(s)-32))
  elif ord(s) >47 and ord(s) <=57:  #是数字的话
    s=encryption3(s) 
  else:   #是特殊字符的话
    pass
  return s

if __name__ == '__main__':     #主函数运行
  flag=""
  for s in secret:
    yushu=xiabiao%4
    xiabiao+=1
    if ord(s) >64 and ord(s)  <=  90:  #是大写字母的话
      s=encryption2(s)
      xiaobiao2=xiaoxie.index(s)
      if yushu==1:
        flag+=chr(xiaobiao2+97)
      elif yushu==2:
        flag+=chr((xiaobiao2^2)+97)
      elif yushu==3:
        flag+=chr(xiaobiao2-3+97)
      else:
        flag+=chr(xiaobiao2+97)
      continue
    elif ord(s) >96 and ord(s) <=122: #是小写字母的话
      s=encryption2(s)
      xiaobiao2=daxie.index(s)
      if yushu==1:
        flag+=chr(xiaobiao2-1+65)
      elif yushu==2:
        flag+="!" #没法逆向
      elif yushu==3:
        flag+=chr((xiaobiao2^3)+65)
      else:
        flag+=chr(xiaobiao2+65)
      continue
    elif ord(s) >47 and ord(s) <=57:  #是数字的话
      s=encryption2(s)
      flag+=s 
      continue
    elif ord(s)==38 or ord(s)==43 or ord(s)==42 or ord(s)==92 or ord(s)==63 or ord(s)==36 or ord(s)==35:
      flag+="_"
      continue
    else:   #是特殊字符的话
      flag+=s
      continue
  print(flag)

在这里插入图片描述
.
.
自己菜,所以要多学习~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

沐一 · 林

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值