Skip to content

Instantly share code, notes, and snippets.

@kjiwa
kjiwa / search.py
Last active May 21, 2019 21:04
A parser for simple boolean search expressions. Demo: https://repl.it/repls/AcceptableTornMath.
"""A parser for boolean search expressions.
This parser understands three types of tokens:
1. AND <expression> <expression>
2. OR <expression> <expression>
3. <string>
All strings must be encapsulated in double quotes. The parser converts the
search expression into a set of lists containing all possible combinations of
@kjiwa
kjiwa / apache-james-exploit.py
Last active December 8, 2022 08:50
An exploit for Apache James 2.3.2 that executes remote commands. https://crimsonglow.ca/~kjiwa/2016/06/exploiting-apache-james-2.3.2.html
"""An exploit for Apache James 2.3.2 that executes remote commands.
This script creates a new user and enqueues a payload to be executed the next
time a user logs in to the machine. The vulnerability is documented in
CVE-2015-7611.
For more details, see http://www.securityfocus.com/bid/76933 and
https://www.exploit-db.com/exploits/35513/.
"""
/**
* An Arduino program that listens for messages on an RF radio and prints them
* on the serial console.
*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
/**
/**
* An Arduino program that reads a value from a temperature sensor, transmits it
* over an RF radio, and then enters a low-power sleep until repeating the
* process.
*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <LowPower.h>
@kjiwa
kjiwa / OptifyApiLeadPageviews.java
Created June 27, 2012 20:02
Show pageviews for all Optify leads in the last 24 hours
GetVisitorsParameters params = new GetVisitorsParameters(siteToken);
int offset = 0;
while (true) {
Visitor[] visitors = service.getVisitors(params);
if (visitors.length == 0)
break;
for (Visitor visitor : visitors) {
if (!visitor.isLead())
@kjiwa
kjiwa / OptifyApiGetSites.java
Created June 27, 2012 20:00
Get a list of your sites in Optify
Site[] sites = service.getSites();
for (Site site : sites) {
System.out.println("Name: " + site.getName() + "\nToken: " + site.getSiteToken() + "\nURL: " + site.getUrl());
}
@kjiwa
kjiwa / OptifyApiInit.java
Created June 27, 2012 19:56
Initializing the Optify API client for Java
OptifyService service = new OptifyServiceImpl(accessToken);