Skip to content

Instantly share code, notes, and snippets.

@tothi
tothi / antirootbypass.js
Created August 12, 2021 01:24
Frida antiroot check bypass for hu.khb (using com.vasco.digipass)
// Frida dumb antiroot check bypass on LineageOS for the
// com.vasco.digipass root checker in hu.khb banking app
//
// run with: frida -U -f hu.khb -l antirootbypass.js --no-pause
// root file existence check
Interceptor.attach(Module.findExportByName(null, 'access'), {
onEnter: function (args) {
this._pathname = args[0].readCString();
this._mode = args[1];
@tothi
tothi / compress-pdf-with-gs.md
Created January 24, 2021 23:32 — forked from vibegui/compress-pdf-with-gs.md
Compress PDF files with ghostscript

This can reduce files to ~15% of their size (2.3M to 345K, in one case) with no obvious degradation of quality.

ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

Other options for PDFSETTINGS:

  • /screen selects low-resolution output similar to the Acrobat Distiller "Screen Optimized" setting.
  • /ebook selects medium-resolution output similar to the Acrobat Distiller "eBook" setting.
  • /printer selects output similar to the Acrobat Distiller "Print Optimized" setting.
  • /prepress selects output similar to Acrobat Distiller "Prepress Optimized" setting.
@tothi
tothi / filmhiradokonline-dl.py
Created November 2, 2020 12:35
download video files from filmhiradokline.hu
#!/usr/bin/env python3
#
# download video from https://filmhiradokonline.hu
#
import argparse
import requests
import urllib.request
import sys
from tqdm import tqdm
#!/usr/bin/env python3
import socket
import struct
import re
import argparse
from termcolor import colored
# used for telnet switching
defaultcreds = 'admin:ipcam'
# action_0 (move files in case of '0' key is pressed):
find ~/images/ -type f -newermt "2019-12-07" ! -newermt "2019-12-15" | sort | feh -f - -F -A "mv %F ~/images_selected/%N"
@tothi
tothi / undrop_innodb.sh
Last active November 12, 2022 18:00
recover innodb from corrupted tablespace
### DANGEROUS OPERATIONS: do not run automatically
### (notes)
# https://web.archive.org/web/20170105064212/https://twindb.com/recover-corrupt-mysql-database/
DB=dbname; TBL=tablename
# from prod mysql instance
mysqlfrm --user=root --server=root:xxx@localhost --port=3307 /var/lib/mysql/${DB}/${TBL}.frm | sed -e 's/^CREATE TABLE `[^`]*`\./CREATE TABLE /g' -e '1d' -e '$a;' | grep -v '^#' > schemas/${DB}_${TBL}_author.sql
@tothi
tothi / frida-bypass-jb-check.js
Created September 15, 2019 09:06
simple jailbreak check bypass (frida hook for a custom app)
// simple jailbreak check bypass (frida hook for a custom app)
//
// launch app with frida hook:
// frida -U -l frida-bypass-jb-check.js -f ... --no-pause
var fileExistsAtPath = ObjC.classes.NSFileManager["- fileExistsAtPath:"];
var hideFile = 0;
var jailbreakFiles = ["/Applications/Cydia.app",
"/bin/bash",
@tothi
tothi / pdf2a4
Created August 4, 2019 11:35
convert pdf to a4 (fit-to-page) using imagemagick
# comment out <policy domain="delegate" rights="none" pattern="gs"/> from /etc/ImageMagick-7/policy.xml
convert -density 150 -define pdf:fit-page=A4 $src.pdf $dst.pdf
# adobe reader error -> use chrome to open & print (on win)
@tothi
tothi / imagemagick.txt
Last active November 11, 2019 21:43
imagemagick magic
# batch convert jpg photos to a4 pdf keeping exif orientation
convert *jpg -compress jpeg -auto-orient -quality 75 -resize 1240x1754 -extent 1240x1754 -gravity center -units PixelsPerInch -density 150x150 out.pdf
# add auto-rotate to A4 portrait (e.g. for printing):
convert *jpg -compress jpeg -rotate "-90>" -quality 75 -resize 1240x1754 -extent 1240x1754 -gravity center -units PixelsPerInch -density 150x150 out.pdf
@tothi
tothi / tunnel_vm_socks.txt
Last active October 14, 2024 15:43
tunnel virtualbox through socks (using poor man's vpn = ssh socks tunnel)
# ssh socks server on :5000 (tunnels traffic to tunnel-endpoint-server)
ssh -D5000 -NT -v user@tunnel-endpoint-server
# redsocks: https://github.com/darkk/redsocks
# 1.) as a socks client, listen on :4999 and connect to :5000
# 2.) run a dummy udp dns server on :5300 (to force vm to fallback to tcp which is working through ssh socks)
cat > redsocks.conf <<EOF
base { log_info=on; redirector=iptables; }
redsocks { local_ip=127.0.0.1; local_port=4999; ip=127.0.0.1; port=5000; type=socks4; }
dnstc { local_ip=127.0.0.1; local_port=5300; }