Skip to content

Instantly share code, notes, and snippets.

View jgru's full-sized avatar

Jan jgru

View GitHub Profile
#!/usr/bin/python3
import sys
import re
import argparse
from http import HTTPStatus
req_pattern = r'\"(GET|POST|PUT|DELETE)\s(.*)\"\s(\d{3})'
ts_pattern = r'\[(.*)\s[-+]\d{4}\]'
@jgru
jgru / cli_template.py
Last active June 5, 2021 14:24
A minimal template for building a CLI, which reads from a positional file-parameter, if such an argument is existent and from stdin otherwise.
#!/usr/bin/python3
import argparse
import sys
"""
This is a minimal template for building a CLI, which reads from a positional file-parameter, if such a argument is
existent and from stdin otherwise.
Usage:
<#
.SYNOPSIS
This script creates a .xml-file containing the installed choco packages
with their corresponding version numers
.DESCRIPTION
This script creates a .xml-file containing the installed choco packages,
which can be used to automate the install of these packages in the exact same
version on a different system. (Right now you can get this only by using the
choco GUI-tool)
@jgru
jgru / repnocc.py
Created April 12, 2021 08:13
A tool for manipulation of text files. It replaces the last n occurences of a given character in each line and prints the result on stdout
#!/bin/python3
import sys
import argparse
def repl_stream(inp, n, inchar, outchar):
"""
Replaces n last inchars in io wrapper with outchars
and prints to stdout.
<#
.SYNOPSIS
This script converts multimedia files in a nested directory structure with the help of ffmpeg
.DESCRIPTION
This script converts multimedia files in a nested directory structure with the help of ffmpeg. Note that, ffmpeg has to be inserted in your $PATH.
.PARAMETER InParentDir
Path to the folder containing all files
.PARAMETER OutParentDir
Path to the folder, where the converted files should be stored.
.PARAMETER Suffix
@jgru
jgru / mousejiggler.ino
Last active May 23, 2021 13:26
Mouse jiggler code for a Digispark USB board development board. Tested on an ATtiny85, upload it by using Arduino IDE
// Inspired by: https://blog.jeronimus.net/2019/08/attiny85-mouse.html
#include <DigiMouse.h>
void setup() {
DigiMouse.begin(); //start or reenumerate USB
}
// Moves mouse pointer left and right by 2 px and blinks the LED
@jgru
jgru / mouselogger.c
Last active May 23, 2021 13:52
A simple program to continuously retrieve mouse coordinates with the help of Win32-API and send those via TCP to a specified host.
#include <windows.h>
#include <winuser.h>
#include <stdio.h>
#include <stdlib.h>
#include <winsock2.h>
/*
* This program records the current cursor position in a given interval and sends
* the retrieved coordinates in a TCP stream to the specified host and port.
* The program utilizes the Win32-API to collect query the cursor position.
@jgru
jgru / dump_pmem.sh
Last active August 3, 2022 12:45
Script to dump the process memory of a given process on a Linux system to a file
#!/bin/sh
#
# Version dump_proc_mem 0.0.1
# Author Jan Gru
# Copyright Copyright (c) Jan Gru
# License GNU General Public License
# Checks, if root permissions
if [ $(id -u) -ne 0 ]
then echo "Error: needing root permissions!" >&2
@jgru
jgru / respawn_wnd.c
Last active July 15, 2021 15:12
A helper program based on Win32-API, which respawns a window on each click to test the automatic injection of mouse clicks in a sandbox guest
/*
* The purpose of this Win32 API-program is to test the reconstruction
* of a GUI via virtual machine introspection and to test the
* injection of mouse clicks.
*
* To do this, the program creates a randomly sized window and displays
* it at a random screen location. If the button containing one of the
* specified button labels is clicked, it will immediately respawn
* another randomized instance. This goes onward forever until the
* "Quit"-button is clicked.
@jgru
jgru / BlackMatterApiHashing.java
Last active January 11, 2022 15:55
BlackMatterApiHashing
//@author jgru (building up on a script of larsborn)
//@category _NEW_
//@keybinding
//@menupath
//@toolbar
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;