Skip to content

Instantly share code, notes, and snippets.


Alfred Moreno kryptek

  • Amazon Web Services
  • Seattle, WA
View GitHub Profile
kryptek /
Created Nov 30, 2020 — forked from yunazuno/
ethtool -S in Python
#!/usr/bin/env python
import socket
import fcntl
import struct
import array
ETHTOOL_GSTATS = 0x0000001d
kryptek / Split tunneling with openconnect - A guide on how to use openconnect to establish a vpn connection to an enterprise cisco anyconnect vpn endpoint with client side routing.


The purpose of this short howto is to show you how to:

  • use openconnect [1] to connect to an enterprise cisco anyconnect endpoint
  • whilst minimizing the amount of traffic that your route through the vpn connection

Usually VPN administrators will puth the default route to the users, so that all user traffic is routed through the vpn connection. This is to address the various security concerns around compromised user computers bridging external internet traffic into the secure VPN network.

While the VPN administrator can push routes to the clients, the client can ignore these default routes and establish client side routing so that only the required A.B.C.D/E network is routed through the VPN. All other traffic will still use the clients default route and default outbound internet connection.

kryptek /
Created Mar 7, 2020 — forked from pawelszydlo/
Script to clear finished torrents from transmission-daemon
# port, username, password
SERVER="localhost:9091 --auth user:pass"
# use transmission-remote to get torrent list from transmission-remote list
TORRENTLIST=`transmission-remote $SERVER --list | sed -e '1d' -e '$d' | awk '{print $1}' | sed -e 's/[^0-9]*//g'`
# for each torrent in the list
kryptek /
Created Sep 25, 2018
Paramiko SSH
import logging
import os
import paramiko
import subprocess
import socket
import time
logging.basicConfig(level=logging.INFO, datefmt='%F %T', format='%(asctime)s %(name)s.%(module)s %(levelname)s: %(message)s')
logger = logging.getLogger('ssh_client')
kryptek /
Created Sep 25, 2018 — forked from jn0/
Custom paramiko-based python SSH client class to asynchronously run time-limited non-interactive commands and return exit status along with stdout and stderr.
# -*- coding: UTF-8 -*-
Custom SSH client.
1. It somehow _supports_ async execution.
2. It provides exit status.
3. It jams stdin (ssh -nT).
Run like something "python box user=bs command='echo aaa; echo bbb >&2; sleep 40; exit 23'" to test
kryptek / Chapter1
Created Jul 10, 2018 — forked from sh1nu11bi/Chapter1
Black Hat Python_Personal Mod Code
View Chapter1
This code is taken fro Chapter 1-Mods included
View disable mcafee endpoint

method 1

sudo /usr/local/McAfee/AntiMalware/VSControl stopoas


sudo defaults write /Library/Preferences/com.mcafee.ssm.antimalware.plist OAS_Enable -bool False
sudo /usr/local/McAfee/AntiMalware/VSControl stop
sudo /usr/local/McAfee/AntiMalware/VSControl reload
kryptek /
Created Oct 7, 2017 — forked from shostakovich/
Chef Solo on Mac OS X - examples
mkdir ~/tmp
cd ~/tmp
# Install GCC + Git
curl > GCC-10.7-v2.pkg
sudo installer -pkg GCC-10.7-v2.pkg -target /
kryptek /
Created Aug 18, 2017 — forked from toejough/
SSH Agent Forwarding in Python: Paramiko's undocumented API


A how-to for ssh-agent forwarding via Paramiko. Specifically, I used Paramiko v1.15.2 in this example.


Paramiko's docs do not document the API required to do ssh-agent forwarding. I ended up finding out how by reading pull requests for ssh-agent forwarding features in frameworks that use Paramiko under the covers, like fabric and ansible.


Besides attempting to document this process here, I've opened a bug with Paramiko to document this API in their official docs.


kryptek /
Created Feb 11, 2017 — forked from kachayev/
Dijkstra shortest path algorithm based on python heapq heap implementation
from collections import defaultdict
from heapq import *
def dijkstra(edges, f, t):
g = defaultdict(list)
for l,r,c in edges:
q, seen = [(0,f,())], set()
while q: