Skip to content

Instantly share code, notes, and snippets.

@msantos
msantos / unix_dgram1.erl
Created December 25, 2010 12:16
Erlang Unix datagram socket
-module(unix_dgram1).
-export([client/1, server/0]).
-define(PF_LOCAL, 1).
-define(SOCK_DGRAM, 2).
-define(UNIX_PATH_MAX, 108).
-define(PATH, <<"/tmp/unix_dgram.sock">>).
server() ->
@msantos
msantos / unix_dgram.erl
Created December 25, 2010 12:14
Erlang Unix datagram socket
-module(unix_dgram).
-export([client/1, server/0]).
-define(PF_LOCAL, 1).
-define(SOCK_DGRAM, 2).
-define(UNIX_PATH_MAX, 108).
-define(PATH, <<"/tmp/unix_dgram.sock">>).
server() ->
@msantos
msantos / ptun.erl
Created December 4, 2010 01:41
ICMP Ping tunnel
-module(ptun).
-include("epcap_net.hrl").
-export([client/2, server/2]).
-define(TIMEOUT, 5000).
-define(PORT, 8787).
-record(state, {
addr,
@msantos
msantos / wsd.erl
Created November 15, 2010 01:53
Erlang API for websequencediagrams.com
-module(wsd).
-export([start/0, render/0, render/1]).
-export([body/1, request/1, fetch/1]).
-define(STYLE, "napkin").
-define(MESSAGE, "Alice->Bob: Authentication Request\n"
"note right of Bob: Bob thinks about it\n"
"Bob->Alice: Authentication Response\n").
@msantos
msantos / carp.erl
Created October 25, 2010 18:57
ARP poisoning
-module(carp).
-export([send/1, send/3]).
-define(ETHER_BROADCAST, <<16#FF, 16#FF, 16#FF, 16#FF, 16#FF, 16#FF>>).
-define(ETH_P_ARP, 16#0806).
-define(ETH_P_IP, 16#0800).
-define(ARPOP_REPLY, 2).
-define(ARPOP_REQUEST, 1).
@msantos
msantos / dumpetag.erl
Created August 31, 2010 21:45
dumpetag: parse payloads using epcap
-module(dumpetag).
-include("epcap_net.hrl").
-export([start/0, start/1]).
-export([filename/1]).
-record(state, {
c % monitored connections
}).
-module(pdump).
-include("epcap_net.hrl").
-export([start/0, start/1]).
-export([filename/1]).
-record(state, {
s, % PF_PACKET socket
c % monitored connections
%% Copyright (c) 2010, Michael Santos <[email protected]>
%% All rights reserved.
%%
%% Redistribution and use in source and binary forms, with or without
%% modification, are permitted provided that the following conditions
%% are met:
%%
%% Redistributions of source code must retain the above copyright
%% notice, this list of conditions and the following disclaimer.
%%
%% Copyright (c) 2010, Michael Santos <[email protected]>
%% All rights reserved.
%%
%% Redistribution and use in source and binary forms, with or without
%% modification, are permitted provided that the following conditions
%% are met:
%%
%% Redistributions of source code must retain the above copyright
%% notice, this list of conditions and the following disclaimer.
%%
%% Copyright (c) 2010, Michael Santos <[email protected]>
%% All rights reserved.
%%
%% Redistribution and use in source and binary forms, with or without
%% modification, are permitted provided that the following conditions
%% are met:
%%
%% Redistributions of source code must retain the above copyright
%% notice, this list of conditions and the following disclaimer.
%%