Skip to content

Instantly share code, notes, and snippets.

from os import urandom
from socket import create_connection
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives.serialization import load_der_public_key
def read(sock, length):
result = b''
{
"redirect": null,
"suggestions": null,
"type": 0,
"has_command": false,
"children": [
{
"redirect": null,
"suggestions": null,
"has_command": true,
import sys, marshal, functools, subprocess
child_script = """
import marshal, sys, types;
fn, args, kwargs = marshal.load(sys.stdin)
marshal.dump(
types.FunctionType(fn, globals())(*args, **kwargs),
sys.stdout)
"""
import sys
import json
import SocketServer
SocketServer.TCPServer.allow_reuse_address = True
class MCHandler(SocketServer.BaseRequestHandler):
@classmethod
def pack_varint(cls, d):
@barneygale
barneygale / check_mode.py
Last active November 28, 2022 18:02
Check if a minecraft server is in offline or online mode
import json
import socket
### Helper functions
# Read n bytes from the socket
def read(sock, n):
o = ""
while len(o) < n:
o += sock.recv(n-len(o))
from __future__ import division, print_function, unicode_literals
import types
import dis
import os
import struct
import sys
def _unpack(s):
@barneygale
barneygale / throttlepatch.py
Created March 6, 2013 02:34
This script will patch a minecraft_server.jar to have a connection-throttle of zero. This is useful to folks running behind proxies. It requires python 2.7 and the java runtime environment (specifically the `jar` binary)
from os import chdir, path
from tempfile import mkdtemp
from shutil import rmtree
from struct import pack
from subprocess import check_output
def jar_contents(j_path):
return check_output(['jar', 'tf', j_path]).split("\n")
def jar_extract(j_path):
#!/usr/bin/python
import struct
from twisted.internet import protocol, reactor
PR_VERSION = "51"
MC_VERSION = "1.4.7"
class DowntimeProtocol(protocol.Protocol):
def __init__(self, message):
import java.io.*;
import javax.crypto.*;
import java.util.*;
import javax.crypto.spec.*;
import java.net.*;
public class decrypt {
static String DESpassword = "passwordfile";
static byte[] salt = { 12, -99, 74, -28, 30, -125, 21, -4 };
public static void main(String[] args) {
#Shortcut to /mod-broadcast
*:/mb $ = >>>
_assertperm('mod', 0)
assign(@mods, _get_mods())
foreach(@mods, @mod,
tmsg(@mod, concat('[', color(red), 'Mod - ', player(), color(white), '] ', color(green), $))
)
<<<