Skip to content

Instantly share code, notes, and snippets.

@karnauskas
karnauskas / dhcp_server.py
Created June 22, 2023 05:00 — forked from yosshy/dhcp_server.py
DHCP Server with Python Scapy
from scapy.all import DHCP_am
from scapy.base_classes import Net
dhcp_server = DHCP_am(iface='eth1', domain='example.com',
pool=Net('192.168.10.0/24'),
network='192.168.10.0/24',
gw='192.168.10.254',
renewal_time=600, lease_time=3600)
dhcp_server()
@karnauskas
karnauskas / init.c
Created March 20, 2023 10:40 — forked from rofl0r/init.c
minimal init daemon by rich felker, author of musl libc
#define _XOPEN_SOURCE 700
#include <signal.h>
#include <unistd.h>
int main()
{
sigset_t set;
int status;
if (getpid() != 1) return 1;
@karnauskas
karnauskas / cleanup_swap.md
Created March 16, 2023 14:57 — forked from anildigital/cleanup_swap.md
Cleanup swap space on macOS

To see current swap usage

sysctl -a | grep swap

Use only when when your system is in a very bad shape

$ sudo pkill -HUP -u _windowserver 
@karnauskas
karnauskas / now_tv_hg_612_openwrt.md
Created February 27, 2023 03:08 — forked from gzzsound/now_tv_hg_612_openwrt.md
NOW TV configuration for Openreach HG612 + OpenWRT router

I am hoping to save a few hours for people like me who have a modem + router setup and switched to NOW TV ISP.

Extract Client ID and Vendor Class ID from DHCP handshake

  • Connect to the NOW TV router and select "WANOE only" from advanced > router mode
  • With a computer connected to LAN 2, using Wireshark, collect DHCP Client ID and Vendor Class ID (options 60 and 61) (1)
  • Convert those two values to hexadecimal

Configuration for HG 612

@karnauskas
karnauskas / deskew.py
Created December 13, 2021 22:32 — forked from russss/deskew.py
Automatic scanned image rotation/deskew with OpenCV
import cv2
import numpy as np
def deskew(im, max_skew=10):
height, width = im.shape
# Create a grayscale image and denoise it
im_gs = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
im_gs = cv2.fastNlMeansDenoising(im_gs, h=3)
/*****************************************
* Read QSee/Zmodo cameras *
* Forward stream to FIFO pipe *
* Author: Daniel Osborne *
* Based on IP Cam Viewer by Robert Chou *
* License: Public Domain *
*****************************************/
/* Version history
* 0.41 - 2013-05-03
@karnauskas
karnauskas / 00README.md
Created November 27, 2021 16:36 — forked from smarek/00README.md
E3372s-153 from Stick mode to HiLink mode automatic installer

E3372s from STICK to HiLink mode installer

You need

  • curl, usb-modeswitch, grep, awk, sudo (not necessary, last step can fail safely)
  • balong_flash in $PATH ( https://github.com/forth32/balongflash.git )
  • atinout in $PATH ( https://github.com/beralt/atinout.git will work fine )
  • 2 files we flash (core sw update version 22.x, WebUI installer), we use these (you can probably use different balong-compatible):
    • core sw: "E3372sUpdate_22.298.03.02.965.BIN" / "E3372sUpdate_22.298.03.02.965.exe"
    • webui: "Update_WEBUI_17.100.06.00.03_Hilink_V7R2_9x25_CPIO.exe"
@karnauskas
karnauskas / androidManifestDecompress.py
Created November 24, 2021 01:14 — forked from i64/androidManifestDecompress.py
decompress androidmanifest file in python
class AndroidXMLDecompress():
endDocTag = 0x00100101
startTag = 0x00100102
endTag = 0x00100103
def decompressXML(self, xml: bytearray) -> str:
finalXml = str()
numbStrings = self.LEW(xml, 4*4)
@karnauskas
karnauskas / PKPass.md
Created November 16, 2021 21:32 — forked from rlanyi/PKPass.md
How to create Apple PKPass .p12 certificate using Linux

How to create Apple PKPass .p12 certificate using Linux

You don't need a Mac to do this :-)

For generating PKPass files, you'll need 4 things after this tutorial:

  • Certificate Identifier (pass.com.example.www)
  • Team Identified (Organizational Unit (OU) in the cert generated by Apple)
  • The .p12 file
  • The password for the .p12 file
@karnauskas
karnauskas / sms-mailer.py
Created October 10, 2021 12:30 — forked from joneskoo/sms-mailer.py
Send unread SMS messages (from adb shell) to email
#!/usr/bin/env python3
# Joonas Kuorilehto 2013
# This script is Public Domain.
import csv
import subprocess
import pipes
from datetime import datetime
import smtplib