Skip to content

Instantly share code, notes, and snippets.

wget http://dl-cdn.alpinelinux.org/alpine/v3.7/releases/armhf/alpine-uboot-3.7.0-armhf.tar.gz
wget http://dl-cdn.alpinelinux.org/alpine/v3.7/releases/armhf/alpine-minirootfs-3.7.0-armhf.tar.gz
qemu-img create -f raw sd.img 512M
sudo losetup /dev/loop0 sd.img
sudo kpartx -av /dev/loop0
lsblk
sudo mkfs.ext4 /dev/mapper/loop0p1
mount -t ext4 /dev/mapper/loop0p1 /mnt
@tuxmartin
tuxmartin / udp_ipv6_client.py
Last active May 25, 2024 10:12
Python UDP IPv6 client & server
import socket
UDP_IP = "::1" # localhost
UDP_PORT = 5005
MESSAGE = "Hello, World!"
print "UDP target IP:", UDP_IP
print "UDP target port:", UDP_PORT
print "message:", MESSAGE
@tuxmartin
tuxmartin / app.yml
Last active October 1, 2022 15:03
IoT: ESPHome current transformer
esphome:
name: test
platform: ESP32
board: esp32doit-devkit-v1
wifi:
ssid: "My_WiFi_AP"
password: "secretPassword123"
ap:
ssid: "Test Fallback Hotspot"
@tuxmartin
tuxmartin / iptables_limit.md
Last active August 31, 2022 06:47
IPTABLES - limit connections & security

syn-flood protection

Limit the number of incoming TCP connections.

iptables -N syn_flood
iptables -A INPUT -p tcp --syn -j syn_flood
iptables -A syn_flood -m limit --limit 1/s --limit-burst 3 -j RETURN
iptables -A syn_flood -j DROP

--limit 1/s: Maximum average matching rate in seconds

@tuxmartin
tuxmartin / v4l.sh
Last active April 26, 2022 14:31
Create fake /dev/videoX device from video file
# mozna neni potreba: sudo apt-get install linux-generic
sudo apt-get install v4l2loopback-dkms
sudo modprobe v4l2loopback
modprobe v4l2loopback
ffmpeg -i /home/martin/Downloads/video.mp4 -f v4l2 -vcodec rawvideo /dev/video0
ffmpeg -i rtsp://10.104.103.138/user=admin_password=tlJwpbo6_channel=1_stream=0.sdp -f v4l2 -pix_fmt yuv420p -vcodec rawvideo /dev/video0
wget http://dl-cdn.alpinelinux.org/alpine/v3.7/releases/armhf/alpine-uboot-3.7.0-armhf.tar.gz
tar xzvf alpine-uboot-3.7.0-armhf.tar.gz
mkdir fat
qemu-system-arm -M virt -m 64 -drive file=fat:fat/ -kernel boot/vmlinuz-hardened -initrd boot/initramfs-hardened -append modules=loop,squashfs,sd-mod,usb-storage
@tuxmartin
tuxmartin / README.md
Last active January 5, 2022 20:34
Minimal Poco websocket C++ client

Stazeni a kompilace POCO

wget http://pocoproject.org/releases/poco-1.7.3/poco-1.7.3.tar.gz
tar xzf poco-1.7.3.tar.gz
cd poco-1.7.3
./configure --minimal --static --no-samples --no-tests
time make -j4 -s
cd lib/Linux/x86_64/
for f in *.a; do "strip $f"; done
@tuxmartin
tuxmartin / navod.sh
Last active November 24, 2021 07:19
Ubuntu 16.04 Xenial v QEMU-ARM (armhf)
# Download a rootfs img and a kernel:
sudo apt-get install qemu-user-static qemu-system-arm
wget http://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-armhf-disk1.img
wget http://launchpadlibrarian.net/353613547/linux-image-4.4.0-111-generic-lpae_4.4.0-111.134_armhf.deb
# (https://launchpad.net/ubuntu/xenial/armhf/linux-image-4.4.0-111-generic-lpae/4.4.0-111.134)
dpkg -X linux-image-4.4.0-111-generic-lpae_4.4.0-111.134_armhf.deb .
mkdir -p tmp
qemu-img convert xenial-server-cloudimg-armhf-disk1.img xenial-server-cloudimg-armhf.img
sudo kpartx -av xenial-server-cloudimg-armhf.img
sudo mount /dev/mapper/loop0p1 tmp
@tuxmartin
tuxmartin / compile.sh
Last active October 7, 2021 21:14
Inno Setup on Linux (Docker)
docker run --rm -i -v "$PWD:/work" \
-e OVPN_VER="2.5.3" \
-e OVPN_BIN32="OpenVPN-2.5.3-I601-x86.msi" \
-e OVPN_BIN64="OpenVPN-2.5.3-I601-amd64.msi" \
-e OVPN_CONF="user.ovpn" \
-e OVPN_SITE="vpn.example.net" \
-e OUT_NAME="vpn_rdp_setup" \
-e PASSWORD="asdf" \
amake/innosetup:64bit openvpn_rdp_docker.iss
@tuxmartin
tuxmartin / poco_uri_parser.cpp
Created December 16, 2015 14:01
C++ POCO URI parser
// g++ -o poco_uri_parser poco_uri_parser.cpp -L/usr/local/lib -lPocoNet -lPocoFoundation
// http://pocoproject.org/slides/160-URIandUUID.pdf
#include "Poco/URI.h"
#include <iostream>
using namespace std;
int main(int argc, char** argv)
{