Skip to content

Instantly share code, notes, and snippets.

View lighterowl's full-sized avatar

Daniel Kamil Kozar lighterowl

  • Poland
View GitHub Profile
@lighterowl
lighterowl / mitmproxy-unsafe-legacy-renegotiation.md
Last active May 30, 2022 18:52
mitmproxy error : "unsafe legacy renegotiation disabled"

Are you getting a unsafe legacy renegotiation disabled OpenSSL error from your mitmproxy while trying to snoop traffic between you and a weird server? Well, you've come to the right place.

Create this file :

ssl_conf = ssl_sect
  
[ssl_sect]
system_default = system_default_sect
@lighterowl
lighterowl / qt563-linux.diff
Created November 1, 2021 00:06
Small code changes needed to compile Qt 5.6.3 on current-ish Linux and newer GCCs
diff -pur qt-everywhere-opensource-src-5.6.3/qtbase/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp qt-everywhere-opensource-src-5.6.3_built/qtbase/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
--- qt-everywhere-opensource-src-5.6.3/qtbase/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp 2017-09-06 14:13:54.000000000 +0200
+++ qt-everywhere-opensource-src-5.6.3_built/qtbase/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp 2021-10-31 19:15:07.120340205 +0100
@@ -698,14 +698,6 @@ void QXcbConnection::xi2ProcessTouch(voi
" Minimum libXi version required is 1.7.4."
" Expect issues with touch behavior.");
}
-#elif LIBXI_MAJOR == 1 && (LIBXI_MINOR < 7 || (LIBXI_MINOR == 7 && LIBXI_PATCH < 4))
- static bool allowTouchWarningShown = false;
- if (!allowTouchWarningShown) {
@lighterowl
lighterowl / converttogif.sh
Created June 16, 2020 20:48
Handy script for converting stuff to GIFs
#!/usr/bin/env bash
set -e
delpalette() {
rm -f "$palette"
}
usage() {
echo >&2 "Usage : $0 [-f fps] [-x xres] <input> <output>"
exit 1
@lighterowl
lighterowl / gist:856f9a6e0777c9a65db0dae5f3d7fa5f
Created January 28, 2020 19:58
Migrating an existing Ubuntu installation from MBR to UEFI+LVM-with-LUKS
# install these before the migration in the source system
apt install cryptsetup-initramfs lvm2
# assumed partition layout : sda1 - efi, sda2 - boot, sda3 - lvm
mkfs.vfat -F 32 /dev/sda1
mkfs.ext4 /dev/sda2
cryptsetup luksFormat /dev/sda3
cryptsetup open /dev/sda3 sda3_crypt
pvcreate /dev/mapper/sda3_crypt
vgcreate xubuntu /dev/mapper/sda3_crypt
@lighterowl
lighterowl / nxp_crc.c
Created February 19, 2019 21:55
PoC code comparing bitwise and bytewise NXP CRC implementations
#include <stdint.h>
#include <stdio.h>
#define CRC_PRESET 0xc7
void nxp_crc(uint8_t *crc, const uint8_t value) {
/* x^8 + x^4 + x^3 + x^2 + 1 => 0x11d */
const uint8_t poly = 0x1d;
*crc ^= value;
@lighterowl
lighterowl / crc_benchmark.cpp
Last active February 18, 2019 17:45
A benchmark comparing bytewise and bitwise CRC implementations
#include <benchmark/benchmark.h>
#include <cstdint>
#include <array>
#include <random>
#include <algorithm>
static std::array<std::uint8_t, (1 << 16)> data;
static unsigned int CRC16_bitwise(const uint8_t *buf, int len)
{
struct FooInterface; // full definition irrelevant here
struct FooFactoryInterface {
virtual FooInterface* create(int p1, float p2) = 0;
};
class Foo : public FooInterface {
public:
Foo(FooFactoryInterface& f):f_(f) {}
bool init(int p1, float p2) {
foo_.reset(f_.create(p1, p2));
// https://stackoverflow.com/questions/32172144
#include <array>
template<typename T, size_t N, typename UnaryFunction = std::less<T>>
void sortNet10(std::array<T, N> &data, UnaryFunction&& f = UnaryFunction()) {
static_assert(N == 10, "this function can only work for 10-element arrays");
if (f(data[0], data[5])) std::swap(data[0], data[5]);
if (f(data[1], data[6])) std::swap(data[1], data[6]);
if (f(data[2], data[7])) std::swap(data[2], data[7]);
@lighterowl
lighterowl / qbytearraylist-serialization.cpp
Created May 8, 2017 23:22
Serializing and deserializing a QByteArrayList to/from a QDataStream
#include <QByteArray>
#include <QByteArrayList>
#include <QDataStream>
#include <QDebug>
#include <QFile>
#include <cstring>
int main(int argc, char *argv[]) {
if (argc != 2) {
return 1;
@lighterowl
lighterowl / sqlite-vtab-isnull.c
Created February 2, 2017 17:44
A demonstration of differences between = NULL and IS NULL queries in SQLite virtual tables
/*
** 2009 November 10
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**