bits ctf

baby rev

image

  • check the type of file image
  • try to use ghidra and see the main function
  • main function led to my funciton
  • image
  • we see the chars and see we got the flag

    solve.py

    a = """(((param_1[4] == 'C') && (param_1[0xd] == 'm')) && (param_1[0x13] == 'r')) &&
       (((param_1[3] == 'S' && (param_1[10] == 'l')) &&
       ((param_1[2] == 'T' && ((param_1[0xe] == 'e' && (param_1[0x11] == '0')))))))) &&
       ((param_1[0x16] == '}' &&
       (((param_1[7] == '{' && (param_1[5] == 'T')) && (param_1[0xf] == '_')))))) &&
       (((param_1[1] == 'I' && (param_1[0x15] == 'v')) &&
       (((param_1[8] == 'w' && ((param_1[0xb] == 'c' && (param_1[6] == 'F')))) &&
       (param_1[0x14] == '3')))))) &&
       ((((param_1[9] == '3' && (param_1[0xc] == '0')) && (param_1[0x10] == 't')) &&
       (param_1[0x12] == '_')))
    """
    a = a.replace("(", "")
    a = a.replace(")", "")
    a = a.split("&&")
    ans = [0 for i in range(23)]
    indices = []
    for i in a:
      i = i.strip()
      s = i.find("[")
      e = i.find("]")
      index = i[s+1:e]
      if index.startswith("0x"):
          index = int(index, 16)
      index = int(index)
      indices.append(index)
      f = i.find("'")
      l = len(i)-1
      string = i[f+1:l]
      ans[index] = string
      print(index, string)
    print(ans)
    ans = "".join(str(e) for e in ans)
    print(ans)
    
  • which gives the flag
  • image

image