Skip to content

Instantly share code, notes, and snippets.

View kryptek's full-sized avatar

Alfred Moreno kryptek

  • Amazon Web Services
  • Seattle, WA
View GitHub Profile
@kryptek
kryptek / webhook.py
Created December 10, 2023 20:53 — forked from Bilka2/webhook.py
Simple discord webhook with python
import requests #dependency
url = "<your url>" #webhook url, from here: https://i.imgur.com/f9XnAew.png
#for all params, see https://discordapp.com/developers/docs/resources/webhook#execute-webhook
data = {
"content" : "message content",
"username" : "custom username"
}
@kryptek
kryptek / traceroute.py
Created June 28, 2023 08:27 — forked from inaz2/traceroute.py
Python implementation of traceroute
# references:
# Learning by doing: Writing your own traceroute in 8 easy steps (Ksplice Blog)
# https://blogs.oracle.com/ksplice/entry/learning_by_doing_writing_your
import sys
import socket
def traceroute(dest_addr, max_hops=30, timeout=0.2):
proto_icmp = socket.getprotobyname('icmp')
proto_udp = socket.getprotobyname('udp')
@kryptek
kryptek / ethtool.py
Created November 30, 2020 22:28 — forked from yunazuno/ethtool.py
ethtool -S in Python
#!/usr/bin/env python
import socket
import fcntl
import struct
import array
SIOCETHTOOL = 0x8946
ETHTOOL_GSTRINGS = 0x0000001b
ETHTOOL_GSSET_INFO = 0x00000037
ETHTOOL_GSTATS = 0x0000001d
@kryptek
kryptek / vpn-openconnect-connect-to-cisco-anyconnect.md
Created March 12, 2020 05:04 — forked from stefancocora/vpn-openconnect-connect-to-cisco-anyconnect.md
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.

Introduction

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
kryptek / transmission_remove_finished.sh
Created March 7, 2020 04:08 — forked from pawelszydlo/transmission_remove_finished.sh
Script to clear finished torrents from transmission-daemon
#!/bin/bash
# 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
for TORRENTID in $TORRENTLIST
@kryptek
kryptek / dijkstra.py
Created February 11, 2017 21:28 — forked from kachayev/dijkstra.py
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:
g[l].append((c,r))
q, seen = [(0,f,())], set()
while q:
@kryptek
kryptek / ssh.py
Created September 25, 2018 23:20
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
kryptek / ssh.py
Created September 25, 2018 23:17 — forked from jn0/ssh.py
Custom paramiko-based python SSH client class to asynchronously run time-limited non-interactive commands and return exit status along with stdout and stderr.
#!/usr/bin/python
# -*- 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 ssh.py box user=bs command='echo aaa; echo bbb >&2; sleep 40; exit 23'" to test
@kryptek
kryptek / Chapter1
Created July 10, 2018 00:21 — forked from sh1nu11bi/Chapter1
Black Hat Python_Personal Mod Code
This code is taken fro Chapter 1-Mods included

method 1

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

alternatively

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