Skip to content

Instantly share code, notes, and snippets.

View drygdryg's full-sized avatar

Victor Golovanenko drygdryg

View GitHub Profile
@drygdryg
drygdryg / termux_mitmproxy_installation.md
Last active January 24, 2024 06:38
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 December 17, 2023 20:57
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 / wps_checksum.py
Created July 1, 2020 06:59
Validating and calculating WPS PIN checksum
# -*- coding: utf-8 -*-
def checksum(pin):
'''
Standard WPS checksum algorithm.
@pin — A 7 digit pin to calculate the checksum for.
Returns the checksum value.
'''
accum = 0
while pin:
accum += (3 * (pin % 10))
@drygdryg
drygdryg / iw_wpa_supplicant_static.txt
Last active February 4, 2023 03:44
Сборка статично скомпонованных беспроводных утилит для Linux ARM (Android): iw и wpa_supplicant
Сборка статичного iw в Alpine:
# Установка базового инструментария для сборки
apk add build-base
mkdir iw_static
cd iw_static/
wget https://github.com/thom311/libnl/releases/download/libnl3_5_0/libnl-3.5.0.tar.gz
mkdir prefix
tar xvf libnl-3.5.0.tar.gz
cd libnl-3.5.0/
@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 / PMKIDgen.py
Last active May 31, 2022 07:21
Fake WPA PMKID generator
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from hashlib import pbkdf2_hmac, sha1
import hmac
import subprocess
essid = input('ESSID: ')
passphrase = input('Passphrase: ')
bssid = input('BSSID: ').lower().replace(':', '').replace('-', '').replace('.', '')
sta_mac = input('Client MAC: ').lower().replace(':', '').replace('-', '').replace('.', '')
@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>")
@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
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")