[关闭]
@Scarlet 2020-04-22T15:56:44.000000Z 字数 961 阅读 1271

Simple Number Theory

  1. from nonebot import on_command, CommandSession
  2. import gmpy2
  3. import random
  4. from CTF.flag import FLAG
  5. from CTF.flow import FLOW,GROUPLIST
  6. def main(x,args):
  7. a,m,c=args
  8. return a*x%m==c
  9. @on_command('SimpleNT', only_to_me=False)
  10. async def SimpleNT(session: CommandSession):
  11. state=session.get("AC")
  12. if state==1:
  13. await session.send("Accepted")
  14. await session.send(FLOW("SimpleNT"))
  15. else:
  16. await session.send("Wrong Answer")
  17. @SimpleNT.args_parser
  18. async def _(session: CommandSession):
  19. if session.ctx.get('group_id') not in GROUPLIST:
  20. return
  21. txt = session.current_arg
  22. if session.is_first_run:
  23. m=int(gmpy2.next_prime(random.randint(2**60, 2**62)))
  24. a=random.randint(2**60, 2**62)
  25. c=random.randint(2**60, 2**62)
  26. session.state['args'] = (a,m,c)
  27. session.state['flag'] = FLAG()
  28. session.state['AC'] = 0
  29. session.pause(f'm={m},a={a},c={c}')
  30. if txt == session.state['flag']:
  31. session.state['AC']=1
  32. return
  33. if txt=="HELP":
  34. session.pause('https://zybuluo.com/Scarlet/note/1696013')
  35. if main(int(txt),session.state['args']):
  36. session.pause
  37. else:
  38. return None
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注