Skip to content

Instantly share code, notes, and snippets.

View drygdryg's full-sized avatar

Victor Golovanenko drygdryg

View GitHub Profile
@drygdryg
drygdryg / capture_pmkid.sh
Last active August 7, 2025 04:58
Simple Bash script to capture PMKID value from a WPA-protected Wi-Fi access point using only wpa_supplicant without switching to monitor mode
#!/bin/bash
set -e
help() {
cat << EOF
Usage: $0 [-r|--randomize-macaddr] <wlan interface> <AP ESSID>
Capture PMKID value from a WPA-protected Wi-Fi access point.
Options:
@drygdryg
drygdryg / bulk_oxipng.sh
Last active July 1, 2024 14:39
Find and optimize all PNG and JPG files in a directory using oxipng & jpegoptim
#!/bin/bash
directory=$1
pngfile_list=$(mktemp /tmp/oxipng_to_proceed.XXXXXX)
jpegfile_list=$(mktemp /tmp/jpegoptim_to_proceed.XXXXXX)
find "$directory" -maxdepth 1 -type f -exec file --mime-type {} + | grep 'image/png$' | cut -d ':' -f 1 > $pngfile_list
find "$directory" -maxdepth 1 -type f -exec file --mime-type {} + | grep 'image/jpeg$' | cut -d ':' -f 1 > $jpegfile_list
xargs --arg-file=$pngfile_list -d '\n' oxipng
xargs --arg-file=$jpegfile_list -d '\n' jpegoptim -m 80 -w `nproc --all`
@drygdryg
drygdryg / termux_mitmproxy_installation.md
Last active July 1, 2024 09:10
Install mitmproxy in Termux

Termux mitmrpoxy installation

Tested on Android 13 with mitmproxy 10.1.5, Python 3.11.6.

Install required system packages

pkg upgrade
pkg install python pipx rust binutils

Setup pipx:

pipx ensurepath
@drygdryg
drygdryg / emulating_usb_flash_in_linux.md
Last active March 15, 2025 07:53
How to emulate USB flash drive in Linux

Emulating mass storage USB flash devices in Linux

Create a new disk image with space pre-allocation (4000 MBytes):

fallocate -l 4000M virtual_usb.img

Create Ext4 file system:

mkfs -t ext4 virtual_usb.img
@drygdryg
drygdryg / extract_routeros_version.py
Last active November 24, 2022 18:27
A simple script for extracting RouterOS version from MikroTik Wi-Fi equipment over the air
#!/usr/bin/env python3
import subprocess
import sys
import re
import codecs
def ifaceUp(iface, down=False):
if down:
action = 'down'
@drygdryg
drygdryg / mingw.patch
Created April 9, 2021 09:39
Patch to cross-compile Masscan under MinGW
diff --git a/Makefile b/Makefile
index 8265d5e..00eebe0 100644
--- a/Makefile
+++ b/Makefile
@@ -49,8 +49,8 @@ endif
# intended environment, so it make break in the future.
ifneq (, $(findstring mingw, $(SYS)))
INCLUDES = -Ivs10/include
-LIBS = -L vs10/lib -lIPHLPAPI -lWs2_32
-FLAGS2 = -march=i686
@drygdryg
drygdryg / iwextract.py
Created March 29, 2021 14:47
Extract info about a single access point from iw scan output
#!/usr/bin/env python3
import subprocess
import sys
import re
BSS_PATTERN = re.compile(r'BSS (\S+)( )?\(on \w+\)')
if __name__ == '__main__':
if len(sys.argv) != 3:
print(f"Usage: {sys.argv[0]} <interface> <bssid>")
from macros import error, hint
from os import `/`, splitFile
import strutils
import distros
when defined(release):
switch("checks", "off")
switch("assertions", "off")
switch("debuginfo", "off")
switch("stackTrace", "off")
@drygdryg
drygdryg / test.nim
Created January 2, 2021 11:56
protobuf-nim bug
import streams
import protobuf
parseProtoFile("test.proto")
var msg = new Example
msg.field1 = @[]
let exampleNested = initExample_ExampleNested()
exampleNested.field1 = initExample_ExampleNested_ExampleNested2(field1 = "Test", field2 = @[])
let exampleNested3 = initExample_ExampleNested_ExampleNested2_ExampleNested3(field1 = "Test")
@drygdryg
drygdryg / test.nim
Created December 31, 2020 05:38
nim-protobuf-bug
import streams
import protobuf
const protoSpec = """
syntax = "proto3";
message Example2 {
string field1 = 1;
int32 field2 = 2;
}