Skip to content

Instantly share code, notes, and snippets.

View mykola2312's full-sized avatar

mykola2312 mykola2312

  • Saint-Brune 1147
  • 23:03 (UTC +03:00)
View GitHub Profile
@mykola2312
mykola2312 / nokia-router-cfg-tool.py
Created January 1, 2025 00:35 — forked from rajkosto/nokia-router-cfg-tool.py
Nokia/Alcatel-Lucent router backup configuration tool
#!/usr/bin/env python3
#
# Nokia/Alcatel-Lucent router backup configuration tool
# G2425 support added by rajkosto on 20/11/2022
# XS-2426G-B support added by rajkosto on 28/02/2023
#
# Features:
# - Unpack/repack .cfg files generated from the backup and restore functionnality
@mykola2312
mykola2312 / dnsmasq.conf
Created November 29, 2024 22:42
Linux NAT networking for QEMU VMs
interface=vnet0
listen-address=10.1.0.1,127.0.0.1
dhcp-range=10.1.0.2,10.1.0.254,12h
dhcp-host=52:54:00:12:34:56,win7,10.1.0.2
dhcp-option=option:dns-server,8.8.8.8
@mykola2312
mykola2312 / snat_dnat_advantech.md
Created November 29, 2024 21:41 — forked from tomasinouk/snat_dnat_advantech.md
examples of SNAT, DNAT with iptables for Advantech, Conel routers, with comments (probably will work on other routers where iptables can be manipulated, care needs to be taken on applying these commands after reboot).

Some examples of SNAT, DNAT with iptables with comments

mainly used in start-up script

How to test 'safely'

When we play with iptables aka firewall we might end up in situation, where we execute rule, which has unforseen impact - lock yourself out. Recovering from this situation is necessity.

How to:

  • Enable reboot via SMS.
  • Test all commands in shell first before putting them into Start-up script. This way the command will be wiped out, when unit is rebooted.

masquarade all outgoing packets to be WLAN0 IP

@mykola2312
mykola2312 / win7-rdp.sh
Created November 24, 2024 06:32
QEMU config for Windows 7
#!/bin/sh
xfreerdp /d:win7-vm /v:192.168.69.1 /p:password /sec:rdp /w:1920 /h:1000
@mykola2312
mykola2312 / mptv2.sh
Created November 21, 2024 21:45
MPTV2 - script to keep MPV running
#!/usr/bin/env bash
# AUTHOR: mykola2312
# LICENSE: BSD-2Clause
# REQUIREMENTS: multimedia/mpv textproc/jq net/socat
# mpv: https://www.freshports.org/multimedia/mpv/
# jq: https://www.freshports.org/textproc/jq/
# socat: https://www.freshports.org/net/socat/
MPV="$(which mpv)"
@mykola2312
mykola2312 / rip.sh
Created August 18, 2024 02:48
bash script for CD/DVD music ripping
#!/usr/bin/env bash
# first, we need to determine type of disk
# this can be achieved by trying first mount_cd9660 and checking error
# if it returns "Device not configured" - we need to wait,
# otherwise its not CD9660 fs and we can move to next
#
# try mounting UDF, if it returns "Invalid argument" - it's not an UDF
#
# the last remaining disc type is CD audio disc, that we must
@mykola2312
mykola2312 / nm-fix-dns.sh
Created June 9, 2024 07:56
Make NetworkManager use proper DNS
#!/bin/sh
dns="1.1.1.1 8.8.8.8 8.8.4.4"
active_network=$(nmcli con show --active | awk 'NR==2 {print $2}')
nmcli connection modify uuid $active_network ipv4.ignore-auto-dns yes
nmcli connection modify uuid $active_network ipv4.dns "$dns"
echo "DNS fixed for ${active_network}"
@mykola2312
mykola2312 / mpv-socket-client.c
Created April 25, 2024 23:17
mpv ipc socket client
#include <sys/un.h>
#include <sys/unistd.h>
#include <sys/socket.h>
#include <stdio.h>
int main() {
int sockfd = socket(PF_UNIX, SOCK_STREAM, 0);
struct sockaddr_un addr = {0};
if (sockfd < 0) {
@mykola2312
mykola2312 / strhex.c
Last active March 31, 2022 14:59
text hex to binary data
int htoi(char h)
{
return h < 0x3A ? h - 0x30 : h - 0x57;
}
void strhex(const char* str, uint8_t* out)
{
for (unsigned i = 0; i < strlen(str) >> 1; i++)
out[i] = htoi(str[i<<1]) << 4 | htoi(str[i<<1|1]);
}
#include "chook.h"
CHook::CHook(DWORD Func,SIZE_T Size)
{
pFunc = Func;
DetourSize = Size;
OrigBytes = (PBYTE)malloc(Size);
}