This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
decode_cesu8(B) -> | |
decode_cesu8(B, []). | |
% https://en.wikipedia.org/wiki/UTF-16 | |
% | |
decode_surrogate_pairs([], Acc) -> | |
Acc; | |
decode_surrogate_pairs([Low, High | Rest], Acc) when High >= 16#D800, High =< 16#DBFF, Low >= 16#DC00, Low =< 16#DFFF -> | |
decode_surrogate_pairs(Rest, [16#10000 + (((High - 16#D800) bsl 10) bor (Low - 16#DC00)) | Acc]); | |
decode_surrogate_pairs([Other | Rest], Acc) -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(decode_erlang_external_term_format). | |
-export([binary_to_term/1]). | |
binary_to_term(<<131, 80, _UncompressedSize:32, CompressedData/binary>>) -> | |
Data = zlib:uncompress(CompressedData), | |
decode(Data); | |
binary_to_term(<<131, Data/binary>>) -> | |
decode(Data). | |
decode(<<82, _AtomCacheReferenceIndex, _Rest/binary>>) -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-spec zlib_safe_uncompress(binary(), non_neg_integer()) -> binary() | no_return(). | |
zlib_safe_uncompress(CompressedData, UncompressedSize) -> | |
Z = zlib:open(), | |
zlib:inflateInit(Z), | |
zlib:setBufSize(Z, UncompressedSize), | |
case zlib:inflateChunk(Z, CompressedData) of | |
{more, _Chunk} -> | |
error({badarg, uncompressed_size_mismatch}); | |
Data -> | |
zlib:inflateEnd(Z), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(create_zlib_bomb). | |
-export([do_it/1]). | |
-define(CHUNK_SZ, (128 * (1 bsl 10))). | |
do_it(Size) -> | |
Z = zlib:open(), | |
zlib:deflateInit(Z, 9, deflated, 15, 9, default), | |
Data = deflate_zeroes(Z, Size), | |
zlib:deflateEnd(Z), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import select | |
import socket | |
import sys | |
tcp_ip = '0.0.0.0' | |
tcp_port1 = int(sys.argv[1]) | |
tcp_port2 = int(sys.argv[2]) | |
s1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s1.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import select | |
import socket | |
import sys | |
tcp_ipA = sys.argv[1] | |
tcp_portA = int(sys.argv[2]) | |
tcp_ipB = sys.argv[3] | |
tcp_portB = int(sys.argv[4]) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import json | |
import multiprocessing | |
import sys | |
import unicodedata | |
from collections import namedtuple | |
def run(): | |
print('Preparing work', file=sys.stderr) | |
groups = generate_groups() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(fatbin). | |
-export([generate/1]). | |
generate(Size) -> | |
generate(Size, 1024). | |
generate(Size, BlockSize) -> | |
NumOfBlocks = | |
case Size rem BlockSize of |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Originally from: http://erlang.org/pipermail/erlang-questions/2017-August/093170.html | |
For a safe and fast Erlang SSL server, there's a few | |
configuration values you might want by default: | |
[{ciphers, CipherList}, % see below | |
{honor_cipher_order, true}, % pick the server-defined order of ciphers | |
{secure_renegotiate, true}, % prevent renegotiation hijacks | |
{client_renegotiation, false}, % prevent clients DoSing w/ renegs | |
{versions, ['tlsv1.2', 'tlsv1.1']}, % add tlsv1 if you must |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo apt-get install git python-pip make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev curl | |
sudo pip install virtualenvwrapper | |
git clone https://github.com/yyuu/pyenv.git ~/.pyenv | |
git clone https://github.com/yyuu/pyenv-virtualenvwrapper.git ~/.pyenv/plugins/pyenv-virtualenvwrapper | |
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc | |
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc |
OlderNewer