Skip to content

Instantly share code, notes, and snippets.

View wangweij's full-sized avatar

Weijun Wang wangweij

View GitHub Profile
@wangweij
wangweij / SerialASM.java
Last active November 10, 2017 09:01
Apply ois-dump.patch to ObjectInputStream.java. If created with a PrintStream as the 2nd argument, reading will generate a dump into that PrintStream. SerialASM.java can read this dump and assemble it into a binary blob or a Java program (if -c specified).
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.io.ObjectStreamClass;
import java.io.ObjectStreamConstants;
import java.lang.reflect.Field;
// This class assembles a serialization description into a byte blob.
// "//" comment can appear anywhere (hopefully not in a string);
// A line can be "string" or 'A' (byte);
@wangweij
wangweij / make_kdcs.sh
Created September 1, 2015 07:19
A script to create multiple KDCs with trust relations
#! /bin/bash
if [ "$1" = "" ]; then
cat <<___
Usage: $(basename $0) relations+
Each relation is a string describing a trusted path. This command
creates all KDCs with the relations and basic principals
including a user and a service, and starts them up.
@wangweij
wangweij / make_kdc.sh
Created September 1, 2015 07:09
A script to create a local KDC
#! /bin/bash
if [ "$3" = "" ]; then
cat <<EOF
Usage: `basename $0` realm-name kdc-host port-number
This command will create necessary files for a new KDC instance
in the current directory. This includes a kdc.conf, a krb5.conf
and a startup script to use KDC each time. The command itself
does not make any environment changes.
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@wangweij
wangweij / stackcollapse-hprof.pl
Created December 5, 2014 03:15
A small program to translate -agentlib:hprof=cpu=times,depth=999 output to folded Flame Graphs format.
#! /usr/bin/perl
$stage = 1;
while (<STDIN>) {
if ($stage == 1) {
if (/TRACE (\d+)/) {
if ($line ne '') {
$cpu{$id} = $line;
}
@wangweij
wangweij / Listing.java
Created December 12, 2012 02:37
List various things
import java.lang.reflect.Method;
import java.nio.charset.Charset;
import java.security.Provider;
import java.security.Security;
import java.text.DateFormat;
import java.util.*;
class Listing {
public static void main(String[] args) throws Exception {