Skip to content

Instantly share code, notes, and snippets.

View boxofrad's full-sized avatar

Dan Upton boxofrad

View GitHub Profile
require 'hexdump'
BUFFER_SIZE = 1024
loop do
data = socket.recv(BUFFER_SIZE)
Hexdump.dump(data)
end
# Receive every packet
ETH_P_ALL = 0x0300
# Size in bytes of a C `sockaddr_ll` structure on a 64-bit system
#
# struct sockaddr_ll {
# unsigned short sll_family; /* Always AF_PACKET */
# unsigned short sll_protocol; /* Physical-layer protocol */
# int sll_ifindex; /* Interface number */
# unsigned short sll_hatype; /* ARP hardware type */
require 'socket'
# Size in bytes of a C `ifreq` structure on a 64-bit system
# http://man7.org/linux/man-pages/man7/netdevice.7.html
#
# struct ifreq {
# char ifr_name[IFNAMSIZ]; /* Interface name */
# union {
# struct sockaddr ifr_addr;
# struct sockaddr ifr_dstaddr;
socket = Socket.new(:INET, :DGRAM)
require 'socket'
BUFFER_SIZE = 1024
socket = UDPSocket.new
socket.bind('192.168.33.10', 4321)
loop do
message, sender = socket.recvfrom(BUFFER_SIZE)
package main
import (
"fmt"
"time"
)
type Video struct {
Name string
}
class Calc
NUMBERS = %w[one two three four five six seven eight nine ten]
def initialize(number = 0, meth = nil)
@number = number
@meth = meth
end
NUMBERS.each_with_index do |number, index|
define_method(number) do
@boxofrad
boxofrad / gist:8492161
Created January 18, 2014 15:46
Install curl and wget on pfSense
setenv PACKAGESITE ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-8-stable/Latest/
/usr/sbin/pkg_add -r curl
/usr/sbin/pkg_add -r wget
@boxofrad
boxofrad / nth.rb
Last active December 31, 2015 08:29
require 'io/console'
Signal.trap(:SIGINT) { exit }
puts "CTRL-C to quit...\n"
print 'Password: '
password = STDIN.noecho(&:gets)
puts
@boxofrad
boxofrad / captiveportal-register.php
Created November 1, 2013 12:29
pfSense 2.0 captive portal self registration
<?php
require_once("functions.inc");
require_once("config.lib.inc");
require_once("auth.inc");
if ($_POST) {
$a_user = &$config['system']['user'];
unset($input_errors);
$pconfig = $_POST;