Skip to content

Instantly share code, notes, and snippets.

@ansh

ansh/decode.py Secret

Created November 15, 2020 02:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ansh/feb7147c9935b0986fa1e2e3111c53a8 to your computer and use it in GitHub Desktop.
Save ansh/feb7147c9935b0986fa1e2e3111c53a8 to your computer and use it in GitHub Desktop.
import sys
import psycopg2
import yaml
import zlib
import base64
import ctypes
import gzip
import json
from struct import *
def connect():
print('Connecting to the PostgreSQL database...')
conn = psycopg2.connect(
host="localhost",
database="postgres",
user="postgres",
password="6174",
port="5432")
return conn
def add_origin(file):
cur = connect().cursor()
print("executing db stuff")
cur.execute("SELECT content FROM question WHERE id=1")
compressed_content = bytes(cur.fetchone()[0])
print(compressed_content)
print(compressed_content.decode())
if __name__ == '__main__':
file_name = sys.argv[1]
print(file_name)
with open(f"./{file_name}") as file:
file_obj = yaml.load(file, Loader=yaml.FullLoader)
print(file_obj)
add_origin(file_obj)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment