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''
import socket
import struct
import json
def unpack_varint(s):
d = 0
for i in range(5):
b = ord(s.recv(1))
d |= (b & 0x7F) << 7*i
if not b & 0x80:
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)
"""
@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))
import sys
import json
import SocketServer
SocketServer.TCPServer.allow_reuse_address = True
class MCHandler(SocketServer.BaseRequestHandler):
@classmethod
def pack_varint(cls, d):
{
"redirect": null,
"suggestions": null,
"type": 0,
"has_command": false,
"children": [
{
"redirect": null,
"suggestions": null,
"has_command": true,
<?php
function ping($host, $port=25565, $timeout=30) {
//Set up our socket
$fp = fsockopen($host, $port, $errno, $errstr, $timeout);
if (!$fp) return false;
//Send 0xFE: Server list ping
fwrite($fp, "\xFE");
@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) {