Skip to content

Instantly share code, notes, and snippets.

View gist:a65ece60c1b54003e9b2a7d5520ce091
==== Server ===
In [1]: from opcua import ua, server
...:
...: s = server.server.Server()
...: s.load_certificate("/etc/pki/tls/certs/mycert.pem")
...: s.load_private_key("/etc/pki/tls/certs/mykeykey.der")
...:
...: # allow Basic256Sha256_SignAndEncrypt
...: # s.get_endpoint() would return only that security policy
@ZuZuD
ZuZuD / testing
Created Jan 22, 2020
Testing opcua Client.Signature
View testing
==== Server ====
In [1]: from opcua import ua, server
...:
...: s = server.server.Server()
...: s.load_certificate("/etc/pki/tls/certs/mycert.pem")
...: s.load_private_key("/etc/pki/tls/certs/mykey.key.der")
...:
...: # allow Basic256Sha256_SignAndEncrypt
...: # s.get_endpoint() would return only that security policy
@ZuZuD
ZuZuD / exhaust_ephemeral_ports.py
Last active Apr 27, 2022
Simulate an ephemeral port exhaustion on a Linux client.
View exhaust_ephemeral_ports.py
import socket
import time
import argparse
import subprocess
import shlex
"""
Usage: python3 exhaust_ephemeral_ports.py <dst> <dport> <optional:loop>
Example: python3 exhaust_ephemeral_ports.py 172.31.23.144 80
Help: exhaust_ephemeral_ports.py --help
@ZuZuD
ZuZuD / tracer-for-ssm.service
Created Jul 4, 2019
systemd_unit to strace amazon-ssm-agent.service
View tracer-for-ssm.service
[Unit]
Description=stracer for SSM
After=amazon-ssm-agent.service
PartOf=amazon-ssm-agent.service
[Service]
ExecStart=/usr/bin/bash -l -c '/bin/strace -p $(pidof amazon-ssm-agent) > /var/log/strace_ssm_agent.log 2>&1'
[Install]
WantedBy=multi-user.target
@ZuZuD
ZuZuD / tcp_syn_ack.py
Last active Jul 28, 2018
TCP states break down with Scappy
View tcp_syn_ack.py
from scapy.all import *
import time
import random
def sendit(src=None, dst=None, dport=None):
"""
See the different status of a TCP connection
Was initially written to identify a docker-proxy bug: https://github.com/moby/moby/issues/27539
I suggest to keep a netstat running from the server side: $ watch -0.1 'netstat -laptn|grep 80'
View gist:aa94ed6ed831b69d85c8e08cec05316b
alias pprint="python -c \"import pprint, sys, json; pprint.pprint(json.loads(''.join([x.strip() for x in sys.stdin.readlines()]))) \""
View alias_kodi.sh
kodi_ip=192.168.0.100
function cpkodi {
scp $@ root@$kodi_ip:/storage/tvshows
}
function lskodi {
ssh root@$kodi_ip ls -ltrh /storage/tvshows
}
function rmkodi {
ssh root@$kodi_ip "cd /storage/tvshows && rm $@"
@ZuZuD
ZuZuD / gist:68725dd8e2227be0d35e0e3b69798d3a
Last active Mar 27, 2018
ElasticCache auto discovery PHP 7.0 - POC non-consistency getAllKeys() method
View gist:68725dd8e2227be0d35e0e3b69798d3a
<?php
function printkv($store) {
if (is_array($store)) {
foreach($store as $item) {
echo "Key: ".$item['key']." Value: ".$item['value']."\n";
}
}
}
@ZuZuD
ZuZuD / gist:c281df71a79a4a14137c187715988b3d
Created Mar 27, 2018
ElasticCache memcached (memcached.so) PHP5 auto-discovery getAllKeys() workaround
View gist:c281df71a79a4a14137c187715988b3d
# workaround for bug on getallKeys() on version superior to 1.4.22
# https://bugs.launchpad.net/libmemcached/+bug/1534062
<?php
function listKeys($srv,$max)
{
foreach($srv as $node) {
echo "Host: ".$node['host']." Port: ".$node['port']."\n";
$mem = new Memcached();
$mem->addServer($node['host'], $node['port']);
@ZuZuD
ZuZuD / gist:66decbe330ec560ac8e57e87150891b8
Created Jan 17, 2018
Parse /boot/grub/grub.cfg to help set GRUB_DEFAULT opts in /etc/default/grub
View gist:66decbe330ec560ac8e57e87150891b8
#!/bin/bash
export GRUB_CONFIG=`sudo find /boot -name "grub.cfg"`
awk 'BEGIN {submenu=0;menu=0};$1 ~ /submenu/ {submenu+=1;menu=0;sub(/\$.*$/,"");print submenu" " $0};/menuentry / && /Linux/ {gsub(/menuentry/,"");gsub(/--class.*$/,"");gsub(/\047/,"");print " "submenu">"menu " " $0;menu+=1}' $GRUB_CONFIG
# 1 submenu 'Advanced options for Ubuntu 3.19'
# 1>0 Ubuntu, with Linux 3.19.0-75-generic
# 1>1 Ubuntu, with Linux 3.19.0-75-generic (recovery mode)
# 1>2 Ubuntu, with Linux 3.13.0-139-generic
# 1>3 Ubuntu, with Linux 3.13.0-139-generic (recovery mode)
# 2 submenu 'Advanced options for Ubuntu 4.2'