Skip to content

Instantly share code, notes, and snippets.

# code mostly from by https://nathancahill.com/duo-cli
import plistlib
# enable backup in Duo app w/ encryption, set ascii password and enter here.
# if you do not want to write the password to disk, instead of saving this
# file, start iPython, copy the code, and type %paste into the prompt
password = b'xxx'
# off an encrypted backup of your phone, get the app's
#!/usr/bin/env python
import base64, hashlib, hmac, json, sys, getpass
from Crypto.Cipher import AES
from Crypto.Hash import RIPEMD, SHA256
base58_chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
def prompt(p):
return getpass.getpass(p + ": ")
import re
class ReDict(dict):
def __setitem__(self, key, value):
dict.__setitem__(self, re.compile(key), value)
def __getitem__(self, key):
return [v for k,v in self.items() if k.match(key)]
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello, World!'
@anfedorov
anfedorov / poolqueue.py
Last active November 3, 2019 14:16
Use multiprocessing's primitives to process events while also extending the Queue
from time import sleep
from multiprocessing import Queue, JoinableQueue, Process
class PoolQueue(object):
def __init__(self, n):
self.num_procs = n
self.procs = []
self.payloads = JoinableQueue()
self.results = Queue()
# $OpenBSD: sshd_config,v 1.101 2017/03/14 07:19:07 djm Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
@anfedorov
anfedorov / crypto1.py
Created September 20, 2013 06:43
Exercise from Coursera's Crypto I
def hex2bitlist(s):
return [int(s[:2], 16)] + hex2bitlist(s[2:]) if s else []
cs = map(
hex2bitlist,
[
'315c4eeaa8b5f8aaf9174145bf43e1784b8fa00dc71d885a804e5ee9fa40b16349c146fb778cdf2d3aff021dfff5b403b510d0d0455468aeb98622b137dae857553ccd8883a7bc37520e06e515d22c954eba5025b8cc57ee59418ce7dc6bc41556bdb36bbca3e8774301fbcaa3b83b220809560987815f65286764703de0f3d524400a19b159610b11ef3e',
'234c02ecbbfbafa3ed18510abd11fa724fcda2018a1a8342cf064bbde548b12b07df44ba7191d9606ef4081ffde5ad46a5069d9f7f543bedb9c861bf29c7e205132eda9382b0bc2c5c4b45f919cf3a9f1cb74151f6d551f4480c82b2cb24cc5b028aa76eb7b4ab24171ab3cdadb8356f',
'32510ba9a7b2bba9b8005d43a304b5714cc0bb0c8a34884dd91304b8ad40b62b07df44ba6e9d8a2368e51d04e0e7b207b70b9b8261112bacb6c866a232dfe257527dc29398f5f3251a0d47e503c66e935de81230b59b7afb5f41afa8d661cb',
'32510ba9aab2a8a4fd06414fb517b5605cc0aa0dc91a8908c2064ba8ad5ea06a029056f47a8ad3306ef5021eafe1ac01a81197847a5c68a1b78769a37bc8f4575432c198ccb4ef63590256e305cd3a9544ee4160ead45aef520489e7da7d83540
@anfedorov
anfedorov / diff_dict_recur.py
Created August 15, 2013 23:43
recursively diff two dicts
def diff_dicts_recur(dict1, dict2, prefix=tuple()):
"""Takes the diff of two dicts, recursively."""
for k, v in dict1.iteritems():
if k not in dict2:
# only in dict1
yield ('-', prefix + (k,), v)
else:
w = dict2[k]
if w != v: # in both, but different values
if isinstance(w, dict) and isinstance(v, dict):
<!DOCTYPE html>
<html>
<head>
<meta name="referrer" content="never">
</head>
<body>
<script language="JavaScript">
<!--
Traceback (most recent call last):
File "/usr/local/bin/remote_api_shell.py", line 173, in <module>
run_file(__file__, globals())
File "/usr/local/bin/remote_api_shell.py", line 169, in run_file
execfile(script_path, globals_)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/remote_api_shell.py", line 169, in <module>
main(sys.argv)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/remote_api_shell.py", line 165, in main
appengine_rpc.HttpRpcServer)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/remote_api_shell.py", line 81, in remote_api_shell