title: How to implement a Bit-Flipping attack on AES-CBC?
body: <p>Performing a task with <a href="https://root-me.org" rel="nofollow noreferrer">root-me.org</a>, as I understand from the attack statement, it is necessary to perform a byte shift to receive <strong>is_member</strong> = true After reading some instructions, I supplement the message with a block and accordingly do <strong>xor</strong> with the previous one, but when I pass the token, the next decryption output</p>
  
  <pre><code>b'[id=546815648;name=iziziz;is_member=false;mail=blablacar;pad=00]r\xe5\xf2\x1dM\xa5\xcae\xff\x16\xa2\xc6\xbe\xd8~I'
  </code></pre>
  
  <p>Tell me what I could miss, my code:</p>
  
  <pre><code>var TOKEN = 
  "IRZjBh6GxjeYI7YZvxwfBHmxjY+Wd7bPr7s73wWwLHKaR+N8fPDIjT8/AlUIDSzniMgqCV9bJArQbec64kPYXQ=="
  
  // [id=546815648;name=iziziz;is_member=false;mail=blablacar;pad=00]
  func main() {
      //block 16
      tokenHex, err := base64.StdEncoding.DecodeString(TOKEN) // lenght 64
      if err != nil {
          log.Fatal(err)
      }
      block := 16
      for i := 0; i &lt; len(tokenHex); i += block {
          fmt.Println(tokenHex[i : i+block])
      }
  
      tmp := make([]byte, block)
      for i := 0; i &lt; block; i++ {
          tmp[i] = byte('a')
      }
      tokenHex = append(tokenHex,tmp...)
      expected := []byte(`;is_member=true]`)
      //last block
      current := []byte{136 ,200 ,42 ,9 ,95 ,91, 36, 10 ,208 ,109, 231, 58, 226, 67 ,216, 93}
      for i := 0; i &lt; 16; i++ {
          xor := expected[i] ^ current[i]
          tokenHex[64+i] ^= xor
      }
      fmt.Println(base64.StdEncoding.EncodeToString(tokenHex))
  }
  </code></pre>