Skip to content

Instantly share code, notes, and snippets.

@latsku
latsku / powershell-tcp-server.ps1
Last active January 25, 2024 09:10
Powershell TCP server
$endpoint = New-Object System.Net.IPEndPoint ([System.Net.IPAddress]::any, 1600)
$Listener = New-Object System.Net.Sockets.TcpListener $endpoint
$Listener.Start()
$client = $Listener.AcceptTcpClient()
$stream = $client.GetStream()
$stream.Write([text.Encoding]::Ascii.GetBytes("Hello Telnet World"), 0, 18)
@latsku
latsku / Alinco_DJ-X11.txt
Last active June 10, 2017 09:06
A Serial control traffic capture from Alinco DJ-X11 wide band receiver
## A Serial control traffic capture from Alinco DJ-X11 wide band receiver.
[13/07/2016 00:09:11] Written data (COM4)
41 4c 7e 44 4a 2d 58 31 31 45 0d AL~DJ-X11E.
[13/07/2016 00:09:11] Read data (COM4)
41 4c 7e 44 4a 2d 58 31 31 45 0d 0d 0a 4f 4b 0d AL~DJ-X11E...OK.
0a .
@latsku
latsku / keygen.html
Created March 7, 2016 11:26
HTML key generator
<!DOCTYPE html>
<html>
<h1>Let's generate you a cert so you don't have to use a password!</h1>
Hit the Generate button and then install the certificate it gives you in your browser.
All modern browsers (except for Internet Explorer) should be compatible.
<form method="post">
<keygen name="pubkey" challenge="randomchars">
The username I want: <input type="text" name="username" value="Alice">
<input type="submit" name="createcert" value="Generate">
</form>
@latsku
latsku / sha2_constants.m
Created February 15, 2016 18:54
A Mathematica package to calculate SHA-2 constants
(* ::Package:: *)
(* ::Input:: *)
(* SHA-2 Constant calculator
Calculation of SHA-2 uses a group of precomputed constants as part of the hash calculation. These numbers are pregiven on the standard, but also explained to come from fractional part of a cube root of primes. This notebook calculates these constants.
Source: http://dx.doi.org/10.6028/NIST.FIPS.180-4
*)
@latsku
latsku / Makefile
Created January 20, 2016 14:55
RIOT-OS project Makefile additions for ENC28J60 ethernet adapter
# Configuration to enable ENC28J60 ethernet adapter.
USEMODULE += enc28j60
USEMODULE += gnrc_netdev2
CFLAGS += -DENC28J60_PARAM_SPI=SPI_0
CFLAGS += -DENC28J60_PARAM_CS="GPIO_PIN(PORT_B,6)"
CFLAGS += -DENC28J60_PARAM_INT="GPIO_PIN(PORT_C,7)"
CFLAGS += -DENC28J60_PARAM_RESET="GPIO_PIN(PORT_A,9)"
@latsku
latsku / Makefile
Created November 6, 2015 19:37
RIOT-OS project Makefile additions for PoEll-i Nucleo ethernet adapter
# Configuration to enable PoEll-i Nucleo ethernet adapter.
USEMODULE += encx24j600
USEMODULE += gnrc_netdev2
CFLAGS += -DENCX24J600_SPI=SPI_0
CFLAGS += -DENCX24J600_CS="GPIO_PIN(PORT_C,10)"
CFLAGS += -DENCX24J600_INT="GPIO_PIN(PORT_D,2)"
@latsku
latsku / temperature.rb
Created August 14, 2015 14:14
Get weather from Openweathermap
require "rubygems"
require "json"
require "net/http"
require "uri"
location = ARGV.join("%20")
location = "Helsinki,Finland" if location.nil? || location.empty?
uri = URI.parse("http://api.openweathermap.org/data/2.5/weather?q=" + location)
http = Net::HTTP.new(uri.host, uri.port)
@latsku
latsku / tpm2_hash.py
Created August 14, 2015 13:59
TPM2.0 hashing with just the device node
import binascii
import struct
import logging
logger = logging.getLogger()
#logger.setLevel(logging.DEBUG)
TPM2_ST_NO_SESSIONS = 0x8001
TPM2_CC_Hash = 0x0000017D
@latsku
latsku / tpm1_hash.py
Last active January 22, 2018 20:24
TPM1.2 hashing with just the device node
#!/usr/bin/env python
import binascii
import struct
import logging
logger = logging.getLogger()
#logger.setLevel(logging.DEBUG)
TPM_TAG_RQU_COMMAND = 0x00C1
@latsku
latsku / tss_hash.py
Created August 14, 2015 13:53
TSS hashing on Python
import os
from ctypes import cdll, create_string_buffer
import binascii
import logging
logger = logging.getLogger()
TSS_HASH_SHA1 = 0x00000001
def main():