Skip to content

Instantly share code, notes, and snippets.

View stolen's full-sized avatar

Danil Zagoskin stolen

  • Erlyvideo
  • Moscow, Russia
View GitHub Profile
#!/usr/bin/env escript
%% -*- mode: erlang -*-
%% vim: sw=2 ts=2
% This escript sends garbage SSLv3 record between client_hello and any other record
% to specified server causing acceptor to crash with function_clause
%
% Usage example: ./badhandshake.escript localhost 9998
-module(badhandshake).
-include_lib("ssl/src/ssl_handshake.hrl").
@stolen
stolen / badhello.escript
Created April 15, 2014 21:56
escript demonstrating bad negotiation in OTP SSL server
#!/usr/bin/env escript
% This escript sends malformed SSLv3 client_hello to specified server
% and prints negotiated version and cipher suite
%
% Usage example: ./badhello.escript localhost 9998
-module(badhello).
-include_lib("ssl/src/ssl_handshake.hrl").
client_hello() ->
@stolen
stolen / no_deep_case.erl
Last active February 21, 2018 16:38
Erlang refactoring proposal
-module(no_deep_case).
-export([deep/1, no_deep/1]).
deep(X) ->
case x:do_something(X) of
{ok, Result1} ->
case x:do_something_else(X, Result1) of
{ok, Result2} ->
case x:final_action(Result2) of
@stolen
stolen / bubble.erl
Last active December 14, 2015 03:28
Recursive bubble sort in Erlang (just for fun)
-module(bubble).
-export([sort/1, sort/2]).
sort(List) ->
sort(fun erlang:'=<'/2, List, []).
sort(Compare, List) ->
sort(Compare, List, []).
@stolen
stolen / gs_up.erl
Created September 27, 2012 09:33
gen_server with self-upgrading state prototype
-module(gs_up).
-export([init/1, handle_call/3, terminate/2]).
-record(state, {
own_fields,
field1,
field2,
field3
}).
@stolen
stolen / leb128.erl
Created July 20, 2012 22:07
LEB128 erlang implementation
-module(leb128).
-export([encode/2, decode/2]).
encode(Value, signed) ->
encode_ranged(Value, 0, 16#40);
encode(Value, unsigned) when Value >= 0 ->
encode_ranged(Value, 0, 16#80).
@stolen
stolen / .gitignore
Created March 21, 2012 13:30
Erlang parse_transform tutorial files
*.beam
@stolen
stolen / .gitignore
Created February 13, 2012 16:10
Erlang module alias generator
ebin/*.beam