Skip to content

Instantly share code, notes, and snippets.

View darktohka's full-sized avatar

Derzsi Dániel darktohka

View GitHub Profile
@darktohka
darktohka / rewrite_python_version.py
Created July 31, 2021 14:40
Rewrite all .pyc files to use an older bytecode version (as long as the script is not using newer opcodes)
import os, struct
# Last known working Python 3.8 version
# Python 3.9a0 3420 (add LOAD_ASSERTION_ERROR #34880)
# Python 3.9a0 3421 (simplified bytecode for with blocks #32949)
# Python 3.9a0 3422 (remove BEGIN_FINALLY, END_FINALLY, CALL_FINALLY, POP_FINALLY bytecodes #33387)
# Python 3.9a2 3423 (add IS_OP, CONTAINS_OP and JUMP_IF_NOT_EXC_MATCH bytecodes #39156)
# Python 3.9a2 3424 (simplify bytecodes for *value unpacking)
# Python 3.9a2 3425 (simplify bytecodes for **value unpacking)
PYTHON38_VERSION = 3413
@darktohka
darktohka / detect.py
Created July 31, 2021 13:40
Detect Python version from pyc
from datetime import datetime
import struct
filename = 'ScavengerHuntBase.cpython-37.pyc'
PYTHON_MAGIC = {
# Python 1
20121: (1, 5),
50428: (1, 6),
@darktohka
darktohka / decrypt.py
Created June 28, 2021 09:27
Decrypt s3bubble's static key video encryption
# Decrypt s3bubble's static key video encryption
# darktohka 2021
# python -m pip install pycryptodome
# hlsdl.exe: https://rwijnsma.home.xs4all.nl/files/hlsdl/hlsdl-0.27-e9420c4-win32-static-xpmod-sse.7z
from Crypto.Protocol.KDF import PBKDF2
from Crypto.Hash import SHA512
from Crypto.Cipher import AES
from Crypto.Util.Padding import unpad
@darktohka
darktohka / multifile.py
Last active February 26, 2021 01:42
Panda3D Multifiles implemented in Python
from panda3d.core import IDecryptStream, StringStream
from panda3d.core import Datagram, DatagramIterator
SF_compressed = 0x0008
SF_encrypted = 0x0010
SF_signature = 0x0020
class Subfile(object):
def __init__(self, mf):
from panda3d.core import get_model_path, Filename, LoaderOptions, PNMImage, TexturePool, Texture, VirtualFileSystem
import os
class ContentPackFilter(object):
# The alpha map keeps track of whether our PNG files have an alpha channel or not.
alpha_map = {}
@staticmethod
def load_img(vfs, model_path, path):
"""
@darktohka
darktohka / convert_pandora_png.py
Created June 11, 2020 12:50
Converts PANDORA/Spotify image resources to PNG recursively.
from panda3d.core import PNMImage, Filename
from PIL import Image
from functools import reduce
import operator
import shutil, math, os
# PLEASE RUN WITH PYTHON 3
# Made by Disyer 2020/06/11 for PANDORA
# Version 1.1: duplicates now saved
cd src/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /star/opt/qBittorrent/src/src.pro -qtconf /usr/lib/arm-linux-gnueabihf/qt5/qt.conf -early QMAKE_CC=arm-linux-gnueabihf-gcc QMAKE_CXX=arm-linux-gnueabihf-g++ QMAKE_LINK=arm-linux-gnueabihf-g++ QMAKE_QMAKE=/usr/bin/arm-linux-gnueabihf-qmake PKG_CONFIG=arm-linux-gnueabihf-pkg-config -before QMAKE_LRELEASE= ) && make -f Makefile install
make[1]: Entering directory '/star/opt/qBittorrent/src'
linking qbittorrent-nox
/usr/bin/ld: application.o: in function `Application::exec(QStringList const&)':
/star/opt/qBittorrent/src/app/application.cpp:563: undefined reference to `WebUI::fatalError()'
/usr/bin/ld: /star/opt/qBittorrent/src/app/application.cpp:563: undefined reference to `WebUI::staticMetaObject'
/usr/bin/ld: logger.o: in function `Logger::freeInstance()':
/star/opt/qBittorrent/src/base/logger.cpp:69: undefined reference to `vtable for Logger'
/usr/bin/ld: logger.o: in function `Logger::Logger()':
/star/opt/qBittorrent/src/base/logger.cpp:51:
@darktohka
darktohka / keybase.md
Created September 15, 2019 07:21
keybase.md

Keybase proof

I hereby claim:

  • I am darktohka on github.
  • I am derzsidaniel (https://keybase.io/derzsidaniel) on keybase.
  • I have a public key ASASAynx4v4ww-r-Lcb6wmTY9nHrt0xixxN2qFALMoBrLgo

To claim this, I am signing this object: