Skip to content

Instantly share code, notes, and snippets.

View corny's full-sized avatar

Julian Kornberger corny

View GitHub Profile
@corny
corny / kti-arp.py
Created November 17, 2016 10:11
KTI switch ARP table
#!/usr/bin/env python3
# Script to read the ARP table from a KTI switch using SSH without password
import pexpect
import sys
from collections import defaultdict
res = defaultdict(list)
prompt = '\S+:/>'
@corny
corny / kti-mac-table.py
Last active July 14, 2021 15:58
Python script to read the MAC table from KTI switches via SSH
#!/usr/bin/env python3
import pexpect
import sys
prompt = '\S+:/>'
s = pexpect.spawn("sshpass", ["-p",'', "ssh", "-l", "admin", "-oStrictHostKeyChecking=no", "-oKexAlgorithms=+diffie-hellman-group1-sha1", sys.argv[1]])
s.expect(prompt)
s.send("mac dump\r\n")
@corny
corny / accumulator.go
Created October 3, 2016 11:28
Customized Telegraf
package main
import (
"fmt"
"log"
"math"
"sync/atomic"
"time"
"github.com/influxdata/telegraf"
@corny
corny / fix_unix_socket.yml
Created September 24, 2016 00:11
Ansible task to fix `Plugin 'unix_socket' is not loaded` on MariaDB
---
- name: Enable plugin unix_socket
command: mysql --defaults-file=/etc/mysql/debian.cnf -e "INSTALL PLUGIN unix_socket SONAME 'auth_socket'"
register: mysql_result
changed_when: mysql_result.rc == 0
failed_when: mysql_result.rc != 0 and 'already installed' not in mysql_result.stderr
@corny
corny / journal.go
Last active June 15, 2023 20:37
SQLite journal in Go (golang)
/*
Stores entries in a local SQLite database
until they have been processed by a submit function.
*/
package journal
import (
"database/sql"
_ "github.com/mattn/go-sqlite3"
"sync"
@corny
corny / erx-boot.log
Created August 4, 2016 11:17
ER-X booting from stock firmware
===================================================================
MT7621 stage1 code 10:33:11 (ASIC)
CPU=50000000 HZ BUS=16666666 HZ
==================================================================
Change MPLL source from XTAL to CR...
do MEMPLL setting..
MEMPLL Config : 0x11100000
3PLL mode + External loopback
=== XTAL-40Mhz === DDR-1200Mhz ===
PLL4 FB_DL: 0xc, 1/0 = 747/277 31000000
@corny
corny / flash.sh
Last active July 12, 2016 08:22
Breminale flasher
#!/bin/bash -e
remote=$1
options="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=15 -o ServerAliveInterval=10"
filename=gluon-ffhb-2016.1.5+breminale1-tp-link-tl-wdr3600-v1-sysupgrade.bin
scp $options /tmp/$filename "root@[$remote]:/tmp/"
ssh $options "root@$remote" "sysupgrade -n /tmp/$filename"
@corny
corny / lua-udp.lua
Created July 4, 2016 16:08
Lua UDP example
#!/usr/bin/env lua5.2
--
-- apt install lua5.2 lua-socket
--
local socket = require("socket")
local udp = assert(socket.udp())
local data
udp:settimeout(1)
@corny
corny / ipv6-scan.py
Last active July 4, 2016 15:06
IPv6-scan
#!/usr/bin/python3
import re
import os
import sys
if len(sys.argv) != 2:
sys.stderr.write('device angeben!\n')
sys.exit(1)
@corny
corny / ssh-multi.sh
Last active October 24, 2019 22:25 — forked from dmytro/ssh-multi.sh
Start multiple synchronized SSH connections with Tmux
#!/bin/bash
# ssh-multi.sh - a script to ssh multiple servers over multiple tmux panes
# usage: type tmux then from inside tmux type ssh-multi.sh HOST1 HOST2 ... HOSTN
# Muayyad Alsadi, D.Kovalov
# https://gist.github.com/muayyad-alsadi/bd25845776bb6b4185ba/
# https://gist.github.com/dmytro/3984680
# Based on http://linuxpixies.blogspot.jp/2011/06/tmux-copy-mode-and-how-to-control.html
# Tested with Ubuntu 16.04 and tmux 2.1
function error() {