Skip to content

Instantly share code, notes, and snippets.

View jfinstrom's full-sized avatar
💭
making stuff

James Finstrom jfinstrom

💭
making stuff
View GitHub Profile
#!/bin/bash
# THIS SCRIPT SETS UP SOME BASIC IP TABLES RULES FOR YOUR SYSTEM.
# YOU SHOULD BUY A BOOK AND GOOGLE TO UNDERSTAND WHAT IS GOING ON HERE.
# YOUR SYSTEM'S SECURITY SHOULD NOT BE LEFT UP TO A SCRIPT APPLICATION
# OR ME. IT IS YOUR RESPONSIBILITY TO ENSURE YOUR OWN SECURITY.
# THIS IS PRESENTED WITHOUT ANY WARRANTY. ANY USE OF THIS IS AT YOUR OWN RISK
#
# Written by James Finstrom (james.finstrom@schmoozecom.com)
#
#!/usr/bin/env python
# Copyright (c) 2014 James Finstrom.
# Copyright (c) 2014 Schmoozecom Inc
# All rights reserved.
#
# Redistribution and use in source and binary forms are permitted
# provided that the above copyright notice and this paragraph are
# duplicated in all such forms and that any documentation,
# advertising materials, and other materials related to such
# distribution and use acknowledge that the software was developed by Schmoozecom.
<?php
class US_Federal_Holidays
{
private $year, $list;
const ONE_DAY = 86400; // Number of seconds in one day
function __construct($year = null, $timezone = 'America/Chicago')
{
try
{
@jfinstrom
jfinstrom / config_gen.py
Created June 19, 2014 01:46
Config generator for dahdi in python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# rhino_genconf
VERSION = "svn"
# Copyright 2012 James Finstrom <jfinstrom@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
@jfinstrom
jfinstrom / asteriskPB2Json.py
Created July 10, 2014 20:09
Dump Asterisk Phonebook to json as an interchange format
#!/usr/bin/env python
import subprocess
import json
callerid = {}
speeddial = {}
p = subprocess.Popen(["asterisk", "-rx", "database show"], stdout=subprocess.PIPE)
out = p.communicate()
out = out[0].splitlines()
for line in out:
if line.startswith('/cidname'):
@jfinstrom
jfinstrom / hotel.py
Created July 25, 2014 15:49
For later reference.... This is my keep alive script to prevent the hotel wifi from dropping me in to a captive portal
#!/usr/bin/env python
import requests
data=[('res','login'),('value','1012'),('gw_addr','10.10.12.1'),('gw_port','2060'),('password','newspaper'),('submit', 'True')]
r = requests.post('http://192.168.182.1:2060/index.php?res=login&amp;gw_id=1012&amp;gw_address=10.10.12.1&amp;gw_port=2060&amp;gw_mac=00%3A15%3A6D%3AC9%3A46%3AA7&amp;username=&amp;password=&amp;mac=54%3A35%3A30%3A8c%3Ab2%3A83&amp;url=http%253A%252F%252Fallviewnetworksdb.com%252Flocalproject%252FpageV2%252F%253Fid%253D2056"', data=data)
@jfinstrom
jfinstrom / hash.py
Created September 29, 2014 18:44
Passing thought on hash reversal of simple hashes.
#!/usr/bin/env python
import hashlib
import sys
m = hashlib.md5()
for x in range(1000,9999):
ext = str(x)
m.update(ext+":asterisk:"+ext)
if m.hexdigest() == sys.argv[1]:
print ext
print m.hexdigest()
@jfinstrom
jfinstrom / backup_hook.py
Created October 6, 2014 22:01
FreePBX backup hook script...
#!/usr/bin/env python
#
# Usage: backup_hook.py <id>
#
import requests
import sys
import base64
import tempfile
hookurl = ''
TMPDIR = tempfile.gettempdir()
@jfinstrom
jfinstrom / parsemodxml.py
Created September 25, 2015 21:47
Parsing module xml in python
#!/usr/bin/env python
import sys
import xml.etree.ElementTree as ET
tree = ET.parse(sys.argv[1])
root = tree.getroot()
version = root.find('version').text
description = root.find('description').text
@jfinstrom
jfinstrom / cdrcsv.php
Last active October 7, 2015 13:55
Last 30 days of CDR as CSV with FreePBX bootstrap
#!/usr/bin/env php
<?php
if (!@include_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) {
include_once('/etc/asterisk/freepbx.conf');
}
$outfile = '/tmp/report.csv';
$dbh = \FreePBX::Database();
$sql = "SELECT * FROM asteriskcdrdb.cdr WHERE date(calldate) >= date(now()-interval 30 day);";
$stmt = $dbh->prepare($sql);
$stmt->execute();