Skip to content

Instantly share code, notes, and snippets.

@grawity
grawity / RunConsole.cs
Created Mar 15, 2011
Run a process on the console session
View RunConsole.cs
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
class RunConsole {
[DllImport("kernel32.dll")]
static extern uint WTSGetActiveConsoleSessionId();
[DllImport("wtsapi32.dll", SetLastError=true)]
static extern bool WTSQueryUserToken(UInt32 sessionId, out IntPtr Token);
@grawity
grawity / .gitignore
Created Mar 31, 2011
Terminal Services session event monitor for http://superuser.com/q/264935
View .gitignore
__pycache__
events.py
@grawity
grawity / README.md
Created Jun 2, 2011
ADVENT magic mode script for TOPS-10-In-a-Box
View README.md

This script was written for the TOPS-10-In-a-Box project. It calculates the passwords for Magic Mode in ADVENT, and is based on the one available at Zonadepruebas website.

Description copied from Zonadepruebas:

Don Woods, who deviced this authentication scheme 29 years ago, has given his kind permission to disclose it publically

'Advent' is reputedly the first text adventure game. It was originally created by William Crowthers, and later expanded by Don Woods. It was programmed in Fortran, on a DEC PDP-10 computer, and Woods' version dates from 1977. This first version has a maintenance feature called "Magic Mode". It was intended for administrators only, and involves a bizarre authentication process. After entering "MAGIC MODE" as first command in the game, the program will ask:

  1. "ARE YOU A WIZARD?", (replay "YES")
  2. "PROVE IT! SAY MAGIC WORD", (default is "DWARF")
@grawity
grawity / Makefile
Created Jan 11, 2012
NTFS volume creation timestamp
View Makefile
CC = i486-mingw32-gcc
LDFLAGS = -lntoskrnl -lntdll
volumeinfo.exe: volumeinfo.c
$(CC) -o $@ $< $(LDFLAGS)
View WinlogonUnlocker.cpp
#include "stdafx.h"
#define WM_LOGONNOTIFY 0x004c
#define LN_UNLOCK_WORKSTATION 0x0006
void showError()
{
LPTSTR pBuf;
DWORD nBytes = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL, GetLastError(), LANG_USER_DEFAULT, (LPWSTR)&pBuf, 4096, NULL);
View _Example polkit rules_.md

These are only examples, for a few very common actions. You are expected to write your own rules for the rest. The syntax is regular JavaScript, but see the polkit(8) manpage for the object structure and available API. These examples are for polkit versions 106 and later, with the JS interpreter. They won't work with Debian's polkit v105.

  • If you don't know the action name, run pkaction:

    pkaction | grep cups
    
  • The possible results are YES, AUTH_SELF(_KEEP), AUTH_ADMIN(_KEEP), NO. Returning a result is final. Returning null will continue checking other rules.

  • Put your rules in /etc/polkit-1/rules.d/*.rules. (You can check everything in one giant addRule, or you can have a separate file and separate addRule for each program; it doesn't matter.)

@grawity
grawity / GitHub protocol comparison.md
Last active Sep 13, 2021
A comparison of protocols offered by GitHub (for #git on Freenode).
View GitHub protocol comparison.md

Primary differences between SSH and HTTPS. This post is specifically about accessing Git repositories on GitHub.

Protocols to choose from when cloning:

plain Git, aka git://github.com/

  • Does not add security beyond what Git itself provides. The server is not verified.

    If you clone a repository over git://, you should check if the latest commit's hash is correct.

@grawity
grawity / README.md
Last active Jan 8, 2019
Eggdrop scripts
View README.md
@grawity
grawity / journal-follow.php
Last active Oct 29, 2018
PHP class that wraps `journalctl --follow`; for joltmode in #systemd and http://stackoverflow.com/q/18711610
View journal-follow.php
<?php
/* © 2013 Mantas Mikulėnas <grawity@gmail.com>
* Released under the MIT Expat License <https://opensource.org/licenses/MIT>
*/
/* Iterator extends Traversable {
void rewind()
boolean valid()
void next()
mixed current()
@grawity
grawity / SASL.md
Last active Jul 9, 2021
SASL authentication from the perspective of IRC server-to-server protocols
View SASL.md

SASL authentication in IRC

© 2014 Mantas Mikulėnas <grawity@gmail.com>

This documentation is released under Creative Commons 3.0 Attribution license.


This is a description of server-server protocol, intended for ircd and services developers. For the client-server protocol descriptions, intended for client & bot developers, see the IRCv3 [sasl-3.1][] and [sasl-3.2][] specifications.