[原创]看雪 2022·KCTF 秋季赛 > 第六题 病疫先兆 by 心学
2022-11-28 23:11:33 Author: bbs.pediy.com(查看原文) 阅读量:12 收藏

构造序列号为:XXXXXKCTFYYYYY
直接采取爆破的方式,分别获取前后的5个数字字符。
5位数值依次传给种子,逐个生成,并与内置数值比较,成功即记录并退出循环。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

seed = 0

def InitSand(sd):

    global seed

    seed = sd

def GetSand():

    global seed

    seed = seed * 0x343FD

    seed = seed & 0xFFFFFFFF

    seed = seed + 0x269EC3

    seed = seed & 0xFFFFFFFF

    returnValue = seed >> 0x10

    returnValue = returnValue & 0x7FFF

    return returnValue

preList = [0x00003BFC,0x00002173,0x000025BB,0x0000380B,0x00002C13,0x000075BE,0x00007366,0x000046A3,0x000013C1,0x0000159B,0x00005B5F,0x0000534F,0x00004E37,0x00003A04,0x00001301,0x00005D0C,0x00004155,0x000048E9,0x000061D2,0x00006158]

sufList = [0x00002BB6,0x00006B5A,0x000003D4,0x0000152B,0x00006E04,0x0000254C,0x000040AE,0x000056CA,0x000017E1,0x000055C7,0x00003641,0x00002D3C,0x00000A41,0x00004BC5,0x00006233,0x00001FE7,0x00006E05,0x00000F6E,0x00006398,0x00006AD7]

preFound = False

sufFound = False

print("寻找第一部分......")

for i in range(100000):

    InitSand(i)

    preFound = True

    for a in preList:

        if GetSand() != a:

            preFound = False

    if preFound:

        print("\t找到第一部分:{:05}".format(i))

        break

if not preFound:

    print("Failed!")

print("寻找第三部分......")

for j in range(100000):

    InitSand(j)

    sufFound = True

    for a in sufList:

        if GetSand() != a:

            sufFound = False

    if sufFound:

        print("\t找到第三部分:{:05}".format(j))

        break

if not sufFound:

    print("Failed!")

SN = "{:05}KCTF{:05}".format(i,j)

print("序列号:{}".format(SN))


文章来源: https://bbs.pediy.com/thread-275341.htm
如有侵权请联系:admin#unsafe.sh