Skip to content

Instantly share code, notes, and snippets.

View kristovatlas's full-sized avatar

Kristov Atlas kristovatlas

View GitHub Profile
@kristovatlas
kristovatlas / evidence.py
Created October 23, 2020 20:10
evidence.py
"""
https://twitter.com/elliot_olds/status/1319364546880942080
To keep calculations simple, let's fix population size to 100
"""
POPULATION = 100
FRED_PROB_FIRST = 1/(0.6 * POPULATION)
NOT_FRED_PROB_FIRST = 1-FRED_PROB_FIRST
def prob_no_blood_type(population, num_crime_scene):
@kristovatlas
kristovatlas / emailer.py
Created September 16, 2020 17:08
Send GMail
#python3
# Usage: emailer.send(recipient_email, mail_subject, message)
#https://stackabuse.com/how-to-send-emails-with-gmail-using-python/
import smtplib
gmail_user = 'username@gmail.com'
gmail_password = 'password_goes_here'
sent_from = gmail_user
def send(recipients, subject, body):
NUM_FIB_NUMS = 100
F1 = 0
F2 = 1
POS = 2
print "0,0"
print "1,1"
for count in range(1, NUM_FIB_NUMS + 1):
@kristovatlas
kristovatlas / README.md
Created April 16, 2018 01:22
How to verify Trezor Bridge on MacOS (and maybe other operating systems)

Background reading

Verification Steps

  1. Visit https://wallet.trezor.io/data/bridge/latest/index.html. For MacOS, you download a .pkg file.
  2. From https://wallet.trezor.io/data/bridge/latest/index.html also download the PGP signature file.
  3. The Satoshi Labs CTO signs the Bridge releases. Download his PGP key from his Keybase signature: https://keybase.io/stick This means at least that someone created an account with his identity and bothered to link a specific PGP key. If you retain this key over time, you can be sure that it wasn't recently swapped out. You can find same PGP under his identity in various places on the web: https://duckduckgo.com/?q=Pavol+Rusn%C3%A1k+pgp+key&ia=web
@kristovatlas
kristovatlas / randsim.py
Last active December 27, 2017 22:40
simulating the broadcasting of Bitcoin transactions and first-hop reception by sybil attacker
import itertools
from random import randint
#p = 0.95
OTHER_NODES = 10000
MY_NODES = 4410
MY_CONNECTIONS = 8 * MY_NODES #my nodes are malicious and make 8 connections per peer
ALL_NODES = OTHER_NODES + MY_CONNECTIONS
NUM_BROADCASTED = 2
"""Find first block has a TXO created and spent in the same block
Using a remote API because this should be a fast search early in the blockchain
"""
import json
from time import sleep
import requests
BLOCK_HEIGHT_URL = "https://blockchain.info/block-height/{height}?format=json"
TX_INDEX_URL = "https://blockchain.info/tx-index/{tx_index}/{txo_n}?format=json"
@kristovatlas
kristovatlas / demo.py
Created June 7, 2017 19:23
Demo requests using Tor and changing circuits
"""Prints external IP address and a few bytes from example.com repeatedly."""
import time
from torrequests import Tor # pip install torrequests
from stem import Signal # pip install stem
from stem.control import Controller # pip install stem
SLEEP_SEC_BT_REQS = 10
def _new_nym():
@kristovatlas
kristovatlas / drozer_setup.sh
Last active February 16, 2020 11:58
Instructions for setting up drozer in MacOS 10.11 "El Capitan"
#Based on https://blog.ropnop.com/installing-drozer-on-os-x-el-capitan/
#Install recent python 2 and viritualenvwrapper
brew install python
brew upgrade python
pip install virtualenvwrapper
#At this point if you try to run mkvirtualenv, you'll get an error message. To resolve, follow the instructions indicated in /usr/local/bin/virtualenvwrapper.sh. In my current copy, they are:
# 1. Create a directory to hold the virtual environments.
# (mkdir $HOME/.virtualenvs).
@kristovatlas
kristovatlas / cssbanner-beautified2.js
Last active March 9, 2018 21:49
cleaned up version of cssbanner.js
//beautified at http://jsbeautifier.org/ with default options
//and then manually modified
/*jslint bitwise: true */
self.onmessage = function (msg) {
var thecode = msg.data;
/**
* Ostensibly unused function
<!-- brute forces answer to http://alf.nu/ReturnTrue 'transitive' challenge -->
<html>
<head>
<script type="text/javascript">
vals = [NaN, 0, 1, true, false, null, [0], undefined, new Boolean, "", "1", "0", Number(0), Number(1)];
function sleep (time) {
return new Promise((resolve) => setTimeout(resolve, time));
}