Skip to content

Instantly share code, notes, and snippets.

@twu
twu / NOTE.md
Last active February 13, 2022 20:44
Basic Rapid7 installer/`ir_agent` role (Initial/Working POC).

The role requires the following group_vars to be set:

# Organization ID / `--token`
rapid7organizationid: us:organization-id
rapid7configpath: "/etc/rapid7"
rapid7installerurl: "https://storage.googleapis.com/<bucket>/agent_installer_linux.sh#<generation-number>"
rapid7installerchecksum: "sha256:abcdefg"
# Will be passed to `--attributes` during install along with the `inventory_hostname` and `group_names`.
rapid7agentbaseattributes:
 - ReynholmIndustries
@twu
twu / Dockerfile
Last active February 13, 2022 20:34
Rapid7 Container Scanner with Google Cloud Build (POC)
FROM python:3.8-slim-buster
# Install known vulnerable python package to see whether it gets picked up by the scanner.
# See https://github.com/advisories/GHSA-3gh2-xw74-jmcw CVE-2020-9402
COPY requirements.txt .
RUN pip install -r requirements.txt
CMD echo "Hello Rapid7"
#!/usr/bin/env python3
# encoding: utf-8
import logging
import os
import signal
import socket
import sys
import time
from dataclasses import dataclass
from typing import Iterator, List
@twu
twu / app.py
Last active February 13, 2022 20:47
Google Tracing API - Test
import random
import time
from flask import Flask, request
from opencensus.ext.stackdriver import trace_exporter as stackdriver_exporter
import opencensus.trace.tracer
from opencensus.trace import (attributes_helper)
HTTP_METHOD = attributes_helper.COMMON_ATTRIBUTES['HTTP_METHOD']
HTTP_STATUS_CODE = attributes_helper.COMMON_ATTRIBUTES['HTTP_STATUS_CODE']
fzf-safari-browser-history()
{
local cols sep
columns=$(( COLUMNS / 3 ))
separator='{::}'
sqlite3 -separator $separator $HOME/Library/Safari/History.db \
"select distinct substr(title, 1, $columns), url from history_items
inner join history_visits on history_items.id = history_visits.history_item
order by history_visits.visit_time desc;" |
awk -F $separator '{printf "%-'$columns's \x1b[36m%s\x1b[m\n", $1, $2}' |
@twu
twu / Scratchpad
Created February 27, 2015 09:32
A more "sophisticated" approach to using the TUGBox.
#!/usr/bin/env python
import urllib2
import json
if __name__ == '__main__':
# Computer Science (557), BSc. (140), Current "Studienjahr" (1034)
# .json -> simple json
# .js -> jsonp
# webcal:// ... /exams.ical -> iCalendar
url = 'http://tugbox.herokuapp.com/tug/curriculum/557,140,1034/exams.ical'
#!/usr/bin/env python
# encoding: utf-8
import sys
import bcrypt
import argparse
from pymongo import MongoClient
def set_password_for(email, hashedPassword):
''' Sets the password hash for a given email address. '''
client = MongoClient()
@twu
twu / pysvn.rb
Last active August 29, 2015 14:05
require 'formula'
class Pysvn < Formula
homepage 'http://pysvn.tigris.org/'
url 'http://pysvn.barrys-emacs.org/source_kits/pysvn-1.7.6.tar.gz'
sha1 '720399815278a0b29a2ea87a09a0d2807d4614e4'
depends_on :python
def install
#!/usr/bin/env ruby
# encoding: utf-8
#
# File: tug-exams
# Author: Thomas Wurmitzer <t.wurmitzer+github@gmail.com>
# Last Modified: 19/08/13 15:50:57
# License: COFFEEWARE
#
# twu wrote this file. As long as you retain this notice you can do whatever
# you want with this stuff. If we meet some day, and you think this stuff is
#!/usr/bin/env ruby
# encoding: utf-8
#
# File: tug-grades
# Author: Thomas Wurmitzer <t.wurmitzer+github@gmail.com>
# Last Modified: 19/08/13 15:51:10
# License: COFFEEWARE
#
# twu wrote this file. As long as you retain this notice you can do whatever
# you want with this stuff. If we meet some day, and you think this stuff is