Skip to content

Instantly share code, notes, and snippets.

View master-hax's full-sized avatar
💤
sleeping

Vivek master-hax

💤
sleeping
View GitHub Profile
@vkobel
vkobel / hash_kernel_module.c
Last active March 14, 2025 03:55
Example of using the Linux Kernel Crypto API for SHA256 hashing (tested with 5.6)
#include <linux/module.h>
#include <crypto/hash.h>
struct sdesc {
struct shash_desc shash;
char ctx[];
};
static struct sdesc *init_sdesc(struct crypto_shash *alg)
{
@jerblack
jerblack / Elevate when needed in Go.md
Last active March 10, 2025 16:02
Relaunch Windows Golang program with UAC elevation when admin rights needed.

I'm buiding a command line tool in Go that has an option to install itself as a service on Windows, which it needs admin rights for. I wanted to be able to have it reliably detect if it was running as admin already and if not, relaunch itself as admin. When the user runs the tool with the specific switch to trigger this functionality (-install or -uninstall in my case) they are prompted by UAC (User Account Control) to run the program as admin, which allows the tool to relaunch itself with the necessary rights.

To detect if I was admin, I tried the method described here first:
https://coolaj86.com/articles/golang-and-windows-and-admins-oh-my/
This wasn't accurately detecting that I was elevated, and was reporting that I was not elevated even when running the tool in CMD prompt started with "Run as Administrator" so I needed a more reliable method.

I didn't want to try writing to an Admin protected area of the filesystem or registry because Windows has the ability to transparently virtualize those writes

@normoes
normoes / dns_over_tls_pubkey_value.md
Last active February 5, 2025 23:16
getting tls pubkey value for DNS over TLS certificates

Getting the tls pubkey for a DNS over TLS address

I added cloudflare-dns.com to my stubby.yml and couldn't find any information on the value of the tls_pubkey_pinset

tls_pubkey_pinset:
  - digest: "sha256"
    value: MISSING

Although I could find some examples, the value seemed to be wrong.

@hdml
hdml / custom-ssl-cert-rdp.md
Created April 19, 2017 21:24
Custom SSL Certificate for Windows RDP Service

##Custom SSL Certificate for Windows RDP Service

Requirements

  • Windows 8+ or Server 2012+
  • Certificate with private key (*.p12)
  • Intermediate CA certificate (*.cer)
  • Administrative rights to modify the certificate store
@DrDougPhD
DrDougPhD / template.py
Last active February 1, 2023 17:11
Skeleton for Python command line script, including argparse and logging
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
SYNOPSIS
python SCRIPT.py [-h,--help] [-v,--verbose]
DESCRIPTION
@PeteGoo
PeteGoo / Send-UdpDatagram.ps1
Last active November 6, 2024 15:22
Sending UDP datagrams in powershell
function Send-UdpDatagram
{
Param ([string] $EndPoint,
[int] $Port,
[string] $Message)
$IP = [System.Net.Dns]::GetHostAddresses($EndPoint)
$Address = [System.Net.IPAddress]::Parse($IP)
$EndPoints = New-Object System.Net.IPEndPoint($Address, $Port)
$Socket = New-Object System.Net.Sockets.UDPClient
@mjohnsullivan
mjohnsullivan / http_server.rs
Last active May 5, 2025 15:14
Simple HTTP server example for Rust
// Updated example from http://rosettacode.org/wiki/Hello_world/Web_server#Rust
// to work with Rust 1.0 beta
use std::net::{TcpStream, TcpListener};
use std::io::{Read, Write};
use std::thread;
fn handle_read(mut stream: &TcpStream) {
let mut buf = [0u8 ;4096];