Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@duketwo
duketwo / gist:8f96f860d36803ec6d66d6531c74c92b
Created March 14, 2024 08:06
C# Enumerate TCP connections
using System;
using System.Collections.Generic;
using System.Net;
using System.Runtime.InteropServices;
namespace YourNamespace
{
public class TcpConnectionInfo
{
public IPAddress LocalIPAddress { get; }
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@duketwo
duketwo / mac-vendor.txt
Created April 2, 2023 02:39 — forked from aallan/mac-vendor.txt
List of MAC addresses with vendors identities
000000 Officially Xerox
000001 SuperLAN-2U
000002 BBN (was internal usage only, no longer used)
000003 XEROX CORPORATION
000004 XEROX CORPORATION
000005 XEROX CORPORATION
000006 XEROX CORPORATION
000007 XEROX CORPORATION
000008 XEROX CORPORATION
000009 powerpipes?
@duketwo
duketwo / gist:df82510046ded027ff1686f23edead2b
Created January 5, 2023 06:53
HDD Serial DeviceIoControl
#include <windows.h>
#include <memory>
#include <string>
//returns the serial number of the first physical drive in a std::string or an empty std::string in case of failure
//based on http://codexpert.ro/blog/2013/10/26/get-physical-drive-serial-number-part-1/
std::string getFirstHddSerialNumber() {
//get a handle to the first physical drive
HANDLE h = CreateFileW(L"\\\\.\\PhysicalDrive0", 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if (h == INVALID_HANDLE_VALUE) return {};
#include <windows.h>
#include <stdio.h>
int main()
{
// The drive letter of the hard drive you want to get the serial number for
wchar_t drive[] = L"C:\\";
// Buffer to receive the volume serial number
DWORD serial_number;
#include <iostream>
#include <Windows.h>
#include <winternl.h>
#define OUT
// define MessageBoxA prototype
using PrototypeMessageBox = int (WINAPI*)(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType);
// remember memory address of the original MessageBoxA routine
PrototypeMessageBox originalMsgBox = MessageBoxA;
@duketwo
duketwo / gist:f445de3a7d23b93e06efdbde3b91f437
Created November 21, 2022 08:49
OpenWRT 4G LTE WAN connection failover handling python Wireguard VPN
import ifaddr
import ipaddress
import logging
import threading
import time
import platform
import subprocess
# 1x Wireguard service running on 100.100.100.100
# One DSL-Line and one LTE/4G-Line and want automatically swap between both while keeping current connections ACTIVE
# run with "python2 piwik.py http://1.2.3.4/"
import base64
import requests
import sys
class php_ize:
def translate(self, variable):
msg = ""
if type(variable).__name__ == 'int':
find / -type f -a \( -perm -u+s -o -perm -g+s \) -exec ls -l {} \; 2> /dev/null
ls -alh /etc/cron.*
sudo -l
ps -aux
netstat -tulpn
ss -ls
find / -type f -writable 2>&1 | grep -v 'Permission denied'
dpkg -l | grep X
python3 -m http.server
find / -user root -perm -4000 -exec ls -ldb {}
@duketwo
duketwo / gist:e3ef1518b1a6f84c525ee126029543c9
Created March 27, 2021 18:41
Ip route secondary gateway rule
echo 200 fritz >> /etc/iproute2/rt_tables
ip route add default via 192.168.10.1 table fritz
ip rule add from 192.168.10.133 table fritz
ip rule add from 192.168.1.210 table fritz