Skip to content

Instantly share code, notes, and snippets.

@up-n-atom
Last active June 20, 2024 18:31
Show Gist options
  • Select an option

  • Save up-n-atom/d41825925abf10149359443fa1cce6de to your computer and use it in GitHub Desktop.

Select an option

Save up-n-atom/d41825925abf10149359443fa1cce6de to your computer and use it in GitHub Desktop.
CircuitCam license decoder
package main
import (
"bytes"
"crypto/rsa"
"crypto/x509"
"encoding/binary"
"fmt"
"math/big"
"os"
)
var der = [...]byte{
0x30, 0x81, 0x9F, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01,
0x05, 0x00, 0x03, 0x81, 0x8D, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xA3, 0x3E, 0xE9,
0x90, 0x04, 0x5F, 0x03, 0x59, 0xFF, 0x69, 0x62, 0x1A, 0x86, 0x51, 0xF9, 0x26, 0xC7, 0x65, 0x08,
0x90, 0xFB, 0x7B, 0xE7, 0xB9, 0xFF, 0x23, 0x7C, 0xA8, 0xE8, 0x5A, 0xF6, 0x11, 0x26, 0x00, 0x23,
0xEF, 0xC7, 0x3B, 0x8E, 0x6C, 0x31, 0xA1, 0x42, 0x17, 0x9E, 0x4E, 0xC8, 0x9D, 0xC2, 0xA8, 0x35,
0x17, 0x45, 0x2F, 0x43, 0xF3, 0x3E, 0xF4, 0x98, 0xCE, 0x20, 0x11, 0x02, 0x8D, 0xCB, 0x30, 0xC9,
0x37, 0x03, 0xBD, 0x17, 0xB1, 0x4D, 0x2D, 0xB9, 0xEA, 0x4D, 0x86, 0x7B, 0xF9, 0x7C, 0x87, 0x62,
0x4E, 0x01, 0xAD, 0x81, 0xCE, 0x11, 0x44, 0xB3, 0xF3, 0xB7, 0x03, 0x02, 0x13, 0x23, 0xEF, 0x12,
0xB4, 0x0A, 0x8F, 0x72, 0xD0, 0xE7, 0x36, 0x03, 0x75, 0xCA, 0x02, 0x93, 0xCF, 0x24, 0x93, 0x2F,
0xCB, 0x29, 0xAF, 0xBC, 0x17, 0x7B, 0x6C, 0xFD, 0xD9, 0x76, 0x16, 0xB3, 0x7F, 0x02, 0x03, 0x01,
0x00, 0x01,
}
// https://stackoverflow.com/questions/44852289/decrypt-with-public-key
func RSA_public_decrypt(pubKey *rsa.PublicKey, data []byte) []byte {
c := new(big.Int)
m := new(big.Int)
m.SetBytes(data)
e := big.NewInt(int64(pubKey.E))
c.Exp(m, e, pubKey.N)
out := c.Bytes()
skip := 0
for i := 2; i < len(out); i++ {
if i+1 >= len(out) {
break
}
if out[i] == 0xff && out[i+1] == 0 {
skip = i + 2
break
}
}
return out[skip:]
}
func main() {
pub, err := x509.ParsePKIXPublicKey(der[:])
if err != nil {
panic(err)
}
dat, err := os.ReadFile("licence.lic")
if err != nil {
panic(err)
}
rdr := bytes.NewReader(dat)
for {
var slen uint16
if err := binary.Read(rdr, binary.BigEndian, &slen); err != nil {
break
}
enc := make([]byte, slen)
if len, err := rdr.Read(enc); len != int(slen) || err != nil {
break
}
dec := RSA_public_decrypt(pub.(*rsa.PublicKey), enc)
fmt.Print(string(dec))
}
}
@up-n-atom
Copy link
Author

Copy license.lic to the same directory and execute with go run licdec.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment