Ejemplo n.º 1
0
def dumpAllData(connection, passphrase):
  for key in getKeys(connection):
    key_id = key["id"]
    secret_key = crypto.extractSecretKey(key, passphrase)
    if not secret_key:
      print "key %s could not be decrypted" % key_id
      continue

    print "---"
    print "name: %s" % crypto.decryptSecret(key["name"], secret_key)
    print "description: %s" % crypto.decryptSecret(key["description"], secret_key)
    print "---"
    for secret in getSecrets(connection, key_id):
      secret_id = secret["id"]
      name = crypto.decryptSecret(secret["name"], secret_key)
      description = crypto.decryptSecret(secret["description"], secret_key)
      print "  name: \"%s\"\n  description: \"%s\"" % (name, description)

      for property in connection.get("/api/keys/%s/secrets/%s/properties" % (key_id, secret_id)):
        name = crypto.decryptSecret(property["name"], secret_key)
        value = crypto.decryptSecret(property["value"], secret_key)
        print "    name: \"%s\"\n    value: \"%s\"" % (name, value)
Ejemplo n.º 2
0

#cookie = GetNewCookie("*****@*****.**", "")
#print "name: " + cookie.name
#print "value: " + cookie.value
#sys.exit(0)

connection = AuthenticatedConnection()
passphrase = getpass.getpass()
dumpAllData(connection, passphrase)

if False:
  new_key = createNewKey(connection, "the quick brown fox jumps over the lazy dog", "The Name", "The Description")
  #prettyprint(new_key)

  secret_key = crypto.extractSecretKey(new_key, "the quick brown fox jumps over the lazy dog")

  secrets = set()
  for i in range(10):
    if not secrets or random.randint(0, len(secrets)) == 0:
      new_secret = createNewSecret(connection, new_key["id"], secret_key, "Secret From Iteration %d" % i, "%d %d" % (i, i*i))
      secrets.add(new_secret["id"])
    else:
      id = random.choice(list(secrets))
      createNewSecretProperty(connection, new_key["id"], id, secret_key, "Property From Iteration %d" % i, "%d %d %d" % (i, i*i, i*i*i))

  dumpAllData(connection, "the quick brown fox jumps over the lazy dog")

  #deleteKey(connection, new_key["id"])
  print "deleted"