Skip to content

Instantly share code, notes, and snippets.

@zer0tonin zer0tonin/main.go
Created Jun 22, 2019

Embed
What would you like to do?
AES-CBC exploit
package main
import (
"encoding/hex"
"fmt"
"os"
"github.com/gdamore/encoding"
)
func main() {
if os.Args[1] == "get-diff" {
xor(toASCII(os.Args[2]), toASCII(os.Args[3]))
} else if os.Args[1] == "apply-diff" {
iv, _ := hex.DecodeString(os.Args[2])
diff, _ := hex.DecodeString(os.Args[3])
xor(iv, diff)
}
}
func toASCII(plaintext string) []byte {
encoder := encoding.ASCII.NewEncoder()
result, _ := encoder.Bytes([]byte(plaintext))
return result
}
func xor(plaintext, malicious []byte) {
output := make([]byte, len(plaintext))
for i := 0; i < len(plaintext); i++ {
output[i] = plaintext[i] ^ malicious[i]
}
fmt.Printf("%x\n", output)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.