Skip to content

Instantly share code, notes, and snippets.

@foospidy
foospidy / example_redis_api_request.php
Created May 2, 2018 10:14
Example function for incrementing a counter based on the key of $id in Redis.
<?php
function api_request($id='nobody') {
$redis = new Redis();
if($redis->connect($GLOBALS['REDIS_HOST'], $GLOBALS['REDIS_PORT'])) {
if($redis->auth($GLOBALS['REDIS_PASSWORD'])) {
$redis->incr($id);
} else {
error_log('Error authenticating to redis!');
}
@foospidy
foospidy / sigsci_site_availability.py
Last active February 25, 2019 13:37
Script to generate aggregate availability based on data from Signal Sciences.
#!/usr/bin/env python
"""
Script to generate aggregate availability based on data from Signal Sciences.
https://landing.google.com/sre/book/chapters/embracing-risk.html#risk-management_measuring-service-risk_aggregate-availability-equation
Usage:
./sigsci_site_availability.py -1d
Examples specifying different time periods:
./sigsci_site_availability.py -3d
#!/usr/bin/env python
"""
# HoneyDB helper script:
# honeydb-search-payloads.py
# For a given array of strings, this script will search payloads for a match.
# https://riskdiscovery.com/honeydb/threats#sensor_data_filtered
# Edit the SEARCH_STRINGS variable to specify what you want to search for.
# DATE is a required field for the API, and the default is today's date.
# Edit the DATE variable to search on a specific date.
# Requires:
@foospidy
foospidy / sigsci-copy-users.sh
Last active February 25, 2019 13:37
Copy all users from a site to other sites.
#!/usr/bin/env bash
###################
# Signal Sciences helper script:
# sigsci-copy-users.sh
# For a given site, copy all users to specified sites.
# Requires:
# - pysigsci (https://pypi.org/project/pysigsci/)
# - jq (https://stedolan.github.io/jq/)
# short name of site that has users you want to copy
@foospidy
foospidy / sigsci-copy-request-rule.sh
Last active February 25, 2019 13:37
Copy a rule to all sites in Signal Sciences
#!/usr/bin/env bash
###################
# Signal Sciences helper script:
# sigsci-copy-request-rule.sh
# For a given site and rule id, the script will the rule to all sites.
# Requires:
# - pysigsci (https://pypi.org/project/pysigsci/)
# - jq (https://stedolan.github.io/jq/)
if [ -z $1 ];
@foospidy
foospidy / sigsci-copy-custom-signal.sh
Last active February 25, 2019 13:37
Copy a signal to all sites in Signal Sciences
#!/usr/bin/env bash
###################
# Signal Sciences helper script:
# sigsci-copy-custom-siganl.sh
# For a given site and tagName, the script will copy that signal to all sites.
# Requires:
# - pysigsci (https://pypi.org/project/pysigsci/)
# - jq (https://stedolan.github.io/jq/)
if [ -z $1 ];
@foospidy
foospidy / sigsci-expire-all-events.sh
Last active February 25, 2019 13:37
Expire all flagged IP events in Signal Sciences.
#!/usr/bin/env bash
###################
# Signal Sciences helper script:
# sigsci-expire-all-events.sh
# For a given site, the script will expire all flagged ip events.
# Requires:
# - pysigsci (https://pypi.org/project/pysigsci/)
# - jq (https://stedolan.github.io/jq/)
if [ -z $1 ];
@foospidy
foospidy / example_redis_reset_request_count.php
Last active February 25, 2019 13:37
Example script to reset the value to 0 for all keys in Redis.
<?php
if($redis->connect($GLOBALS['REDIS_HOST'], $GLOBALS['REDIS_PORT'])) {
if($redis->auth($GLOBALS['REDIS_PASSWORD'])) {
$keys = $redis->keys('*');
foreach($keys as $key) {
$redis->set($key, 0);
}
} else {
error_log('Error authenticating to redis!');
@foospidy
foospidy / example_redis_api_limit_exceeded.php
Created May 2, 2018 10:18
Example function for checking the count value based on the key of $id in Redis against the value of $limit.
<?php
function api_limit_exceeded($id='nobody', $limit=1500) {
$redis = new Redis();
$usage = 0;
if($redis->connect($GLOBALS['REDIS_HOST'], $GLOBALS['REDIS_PORT'])) {
if($redis->auth($GLOBALS['REDIS_PASSWORD'])) {
$usage = $redis->get($id);
} else {
error_log('Error authenticating to redis!');
@foospidy
foospidy / honeydb-agent-install.sh
Last active February 25, 2019 13:37
honeydb-agent install script.
#!/usr/bin/env bash
#
# Installs/upgrades the latest version of honeydb-agent.
# An existing configuration will be backed up, and applied
# to the new install/upgrade.
#
# sudo ./honeydb-agent-install.sh
#
ARCHITECTURE=`uname -m`