Skip to content

Instantly share code, notes, and snippets.

View BastienClement's full-sized avatar

Bastien Clément BastienClement

View GitHub Profile
@BastienClement
BastienClement / detect.sh
Last active April 2, 2024 12:21
Check for CVE-2024-3094 vulnerability
#!/bin/bash
# https://www.openwall.com/lists/oss-security/2024/03/29/4
set -eu
# find path to liblzma used by sshd
path="$(ldd $(which sshd) | grep liblzma | grep -o '/[^ ]*')"
# does it even exist?
if [ "$path" == "" ]
@BastienClement
BastienClement / gist:b34f14dd93381498a7a1
Created June 17, 2014 17:20
The CASC (Content Addressable Storage Container) Filesystem
---------------------------------------------------------------------
| The CASC (Content Addressable Storage Container) Filesystem |
| Warlords of Draenor Alpha, Build 6.0.1.18125 |
| Written April 14th, 2014 by Caali |
| Version 1.2 |
---------------------------------------------------------------------
Distribution and reproduction of this specification are allowed without
limitation, as long as it is not altered. Quotation in other works is
freely allowed, as long as the source and author of the quote are stated.
<?php
// ...
function window(array $array, int $width): array {
$results = [];
$count = count($array);
if ($count < $width) {
throw new InvalidArgumentException('Not enough items in array');
@BastienClement
BastienClement / parse_lua.php
Created May 8, 2012 11:09
PHP WoW-config Lua parser
<?php
class LuaParseError extends Exception {}
class LuaParser {
private $source;
private $source_len;
private $offset = 0;
private $line = 1;
@BastienClement
BastienClement / commit-msg.php
Created September 18, 2018 06:35
Git ticket ref hook
#!/usr/bin/env php
<?php
$REF_PATTERN = "[A-Z]{3,}-\\d+";
$branch = exec("git rev-parse --abbrev-ref HEAD");
if (preg_match("/(bug|feature)\\/($REF_PATTERN)/", $branch, $matches)) {
$msg = file_get_contents($argv[1]);
$ticket = $matches[2];
@BastienClement
BastienClement / BlizzAuth.cs
Created January 22, 2016 15:43
Blizzard Authenticator number generation
/// <summary>
/// 10^0..10^8 (NumDigits used in the HOTP)
/// </summary>
private static readonly int[] DigitsPower = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000};
private static int DynamicTruncate(byte[] hash)
{
int offset = hash[hash.Length - 1] & 15;
return ((hash[offset] & 127) << 24) + ((hash[offset + 1] & 255) << 16) + ((hash[offset + 2] & 255) << 8) +
/**
* Bastien Clément
*/
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
class Mapper {
/**
* TE3
* Bastien Clément
* 26.04.2016
*/
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
@BastienClement
BastienClement / Blash.lua
Created April 1, 2016 13:55
Archimonde Chaos
function(e, time, event, _, source, sourceName, _, _, dest, destName, _, _, spell, spellName)
if spell == 185014 and source and dest then
local Hud = FS.Hud
local key = source .. "_chaos_target"
if event == "SPELL_AURA_APPLIED" then
Hud:RemovePoint(key)
local source_pt = Hud:GetPoint(source)
if not source_pt then return end
@BastienClement
BastienClement / blocklist.js
Created June 9, 2014 18:02
Blocklist experiments
var ip = require('ip');
console.time("load");
var list = require("./bt_level1.js").map(function(block) {
try {
block.start = ip.toLong(block.start);
block.end = ip.toLong(block.end);
} catch(e) {
console.log(e, block);
process.exit(0);