示例#1
0
def encryption_oracle(s,key="",prefix=""):
  import c10
  import base64
  from Crypto.Cipher import AES

  secret = "Um9sbGluJyBpbiBteSA1LjAKV2l0aCBteSByYWctdG9wIGRvd24gc28gbXkg\n\
aGFpciBjYW4gYmxvdwpUaGUgZ2lybGllcyBvbiBzdGFuZGJ5IHdhdmluZyBq\n\
dXN0IHRvIHNheSBoaQpEaWQgeW91IHN0b3A/IE5vLCBJIGp1c3QgZHJvdmUg\n\
YnkK"
  s = prefix + s + base64.b64decode(secret)

  return AES.new(key,AES.MODE_ECB).encrypt(c10.pkcs7pad(s))
示例#2
0
def encryption_oracle(s):
    import c10
    import random
    from Crypto.Cipher import AES

    key = open("/dev/urandom").read(16)

    prefix = open("/dev/urandom").read(random.randint(5, 10))
    suffix = open("/dev/urandom").read(random.randint(5, 10))

    s = str(prefix) + str(s) + str(suffix)
    if random.randint(0, 1) == 1:
        return c10.cbcencrypt(s, open("/dev/urandom").read(16), key)
    else:
        return AES.new(key, AES.MODE_ECB).encrypt(c10.pkcs7pad(s))
示例#3
0
def encrypt(s,key):
  import c10
  from Crypto.Cipher import AES

  return AES.new(key,AES.MODE_ECB).encrypt(c10.pkcs7pad(s))