Skip to content

Instantly share code, notes, and snippets.

View Kungergely's full-sized avatar

Gergely Kún Kungergely

  • Bratislava, Slovakia
View GitHub Profile
@Kungergely
Kungergely / gist:94b9e972f6023f483d51a7d6ce2e24b3
Last active November 15, 2022 15:25
RADRRTM format description
The file is read in Fortran as "unstructured" binary. The data is encoded in little endian format, while the size is encoded in big endian format.
# The first four bytes denote a block length (0x00009600 = 38400, 0x00037000 = 225280, 0x00002080 = 8320, 0x00019A00 = 104960, 0x00012480 = 74880 )
# The rest of the block consists of 64-bit floats
# Each block is succeeded by the size value (the same as in the beginning) again and this is the offset the block length at the beginning points to
# The individual blocks (complete with the block length prepended and appended to it) are concatenated together into a single file
# This is consistent with the FORTRAN "unformatted" file saving convention described e.g. in https://www.mathworks.com/matlabcentral/answers/97118-how-do-i-read-a-fortran-unformatted-binary-data-file-into-matlab#answer_106468
@Kungergely
Kungergely / ff_history_backup.py
Last active January 10, 2022 11:36
A Py3 script for backing up the places.sqlite file (Firefox history) which's known to become corrupt and lose contents during crashes. It should work on both Windows and Linux with backing up the file from the first FF profile folder found. It requires a working Py3 installation and on Windows it should be scheduled using pythonw.exe to avoid CL…
import gzip, os, platform, shutil, sqlite3
from datetime import datetime
# The paths are somewhat different on Linux and Windows
if platform.system()=="Windows":
destdir="D:\\FF backups"
srcdir=os.environ["APPDATA"]+"\\Mozilla\\Firefox\\Profiles"
elif platform.system()=="Linux":
destdir="/media/backup"
srcdir=os.environ["HOME"]+"/.mozilla/firefox"
@Kungergely
Kungergely / binwalk_on_win10.txt
Last active July 4, 2024 13:00
How to make binwalk work on Windows 10
The following steps are meant either to complement the wonderful book titled "The IoT Hacker’s Handbook A Practical Guide to Hacking the Internet of Things" by Aditya Gupta or to act as a generic aid in firmware exploiting and pentesting for Win10 users.
1. Clone akx's branch of binwalk:
git clone -b packaging-fixes https://github.com/akx/binwalk.git
2. Change to this newly-created directory and install the module:
cd C:\Path\to\binwalk
pip3 install .
3. Download squashfs for Windows:
@Kungergely
Kungergely / hdf5version.py
Last active August 9, 2020 15:19
Detecting the version of the HDF5 library
import ctypes
lib=ctypes.windll.LoadLibrary("C:\\Path\\to\\hdf5.dll")
#lib=ctypes.cdll.LoadLibrary("/usr/lib/libhdf5.so")
length = 1
majnum = ctypes.cast(ctypes.create_string_buffer(length), ctypes.POINTER(ctypes.c_uint))
minnum = ctypes.cast(ctypes.create_string_buffer(length), ctypes.POINTER(ctypes.c_uint))
relnum = ctypes.cast(ctypes.create_string_buffer(length), ctypes.POINTER(ctypes.c_uint))
lib.H5get_libversion.argtypes = [ ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint)]
lib.H5get_libversion(majnum, minnum, relnum)
@Kungergely
Kungergely / bindfs-build-rpm.sh
Created January 3, 2020 17:02
Bash script for building bindfs for CentOS 8 from the Fedora 31 src.rpm package using Docker
#!/bin/bash
wget http://download-ib01.fedoraproject.org/pub/fedora/linux/releases/31/Everything/source/tree/Packages/b/bindfs-1.14.1-2.fc31.src.rpm
cat > Dockerfile <<"EOF"
FROM centos:8
RUN mkdir -p /root/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} && mkdir -p /bindfs
RUN dnf -y --nogpgcheck install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm wget zip unzip bzip2 gcc gcc-c++ rpm-build make ruby valgrind fuse-devel
@Kungergely
Kungergely / eccodes-static-rpm.sh
Last active January 2, 2020 13:53
Bash script for creating a static subpackage of eccodes 2.15.0 and subsequent build of the RPM package for CentOS 8
#!/bin/bash
mkdir docker-eccodes; cd docker-eccodes
wget https://dl.fedoraproject.org/pub/epel/8/Everything/SRPMS/Packages/e/eccodes-2.14.1-1.el8.src.rpm
wget https://confluence.ecmwf.int/download/attachments/45757960/eccodes-2.15.0-Source.tar.gz
rpm2cpio ./eccodes-*.src.rpm | cpio -dium
@Kungergely
Kungergely / curl-static-rpm.sh
Last active January 2, 2020 13:56
Bash script for creating a static subpackage of (lib)curl 7.61.1 and subsequent rebuild of the RPM package for CentOS 8
eccodes#!/bin/bash
mkdir docker-curl; cd docker-curl
wget http://vault.centos.org/8.0.1905/BaseOS/Source/SPackages/curl-7.61.1-8.el8.src.rpm
rpm2cpio ./curl-*.src.rpm | cpio -dium
cat > curl-spec.patch <<"EOF"
--- curl.spec.orig 2019-05-16 08:57:52.000000000 +0200
@Kungergely
Kungergely / Dockerfile
Created December 31, 2019 14:07
Dockerfile for rebuilding openssl-1.1.1 on CentOS 8 to obtain the static subpackage of the build as well
FROM centos:8
RUN mkdir -p /root/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
RUN dnf -y --nogpgcheck install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm wget zip unzip bzip2 gcc gcc-c++ rpm-build make krb5-devel perl-interpreter zlib-devel lksctp-tools-devel perl-podlators perl-Test-Harness perl-Math-BigInt perl-Module-Load-Conditional perl-File-Temp perl-Time-HiRes perl-CPAN perl-Test-Simple
# The src.rpm can be obtained e.g. from http://vault.centos.org/8.0.1905/BaseOS/Source/SPackages/openssl-1.1.1-8.el8.src.rpm
COPY openssl-1.1.1-8.el8.src.rpm /root/rpmbuild/
RUN cd /root/rpmbuild/ && \
@Kungergely
Kungergely / jasper-static-rpm.sh
Last active January 2, 2020 13:55
Bash script for creating a static subpackage of jasper 2.0.14 and subsequent rebuild of the RPM package for CentOS 8
#!/bin/bash
mkdir docker-jasper; cd docker-jasper
wget https://downloads.redhat.com/redhat/rhel/rhel-8-beta/appstream/source/Packages/jasper-2.0.14-4.el8.src.rpm
rpm2cpio ./jasper-*.src.rpm | cpio -dium
cat > jasper-spec.patch <<"EOF"
--- jasper.spec.orig 2018-08-12 14:44:42.000000000 +0200
@Kungergely
Kungergely / libjpeg-turbo-static-rpm.sh
Last active January 2, 2020 13:54
Bash script for re-enabling the static subpackage of libjpeg-turbo 1.5.3 and subsequent rebuild of the RPM package for CentOS 8
#!/bin/bash
mkdir docker-libjpeg-turbo && cd docker-libjpeg-turbo
wget http://vault.centos.org/8.0.1905/AppStream/Source/SPackages/libjpeg-turbo-1.5.3-7.el8.src.rpm
rpm2cpio ./libjpeg-turbo-*.src.rpm | cpio -dium
cat > libjpeg-turbo-spec.patch <<"EOF"
--- libjpeg-turbo.spec.orig 2019-05-14 03:36:19.000000000 +0200