Skip to content

Instantly share code, notes, and snippets.

View fishi0x01's full-sized avatar
💾
0x01

Karl Fischer fishi0x01

💾
0x01
View GitHub Profile
/*
* A simple client that opens a socket.
*/
#include <stdio.h>
#include <sys/socket.h>
int main(int argc, char *argv[])
{
int sockfd;
@fishi0x01
fishi0x01 / ConnectWMINamespace.java
Last active March 21, 2020 15:22
Basic j-interop DCOM bridge setup snippets. Code for blog post https://fishi.devtail.io/weblog/2015/01/21/pure-java-dcom-bridge-j-interop/
/**
* Code snippet that tries to create a connection with the given wmiLocator object to the given namespace.
* @return An IJIDispatch object that can be used for WQL queries to the given namesapce of the target machine.
* @Exception In case the ConnectServer method could not be properly executed.
*/
public IJIDispatch createNamespaceServer(IJIDispatch wmiLocator, String nameSpace, String ipAddress) throws Exception
{
// create an instance of the WbemScripting.SWbemLocator object to talk to WMI on the target machine.
// namespace could be for instance "root\\cimv2"
JIVariant results[] =
@fishi0x01
fishi0x01 / bw_msrmnt.c
Last active November 17, 2023 07:44
Measuring Bandwidth and Round-Trip Time of a TCP Connection inside the Application Layer. Code for blog post https://fishi.devtail.io/weblog/2015/04/12/measuring-bandwidth-and-round-trip-time-tcp-connection-inside-application-layer/
/* Code snippet for measuring bandwidth with harmonic mean */
#define SKIPS 10 // initial measurement skips - skip the first slow-start values
// bandwidth metrics
double bandwidth = -1; // in MB/s
float total_bytes = 0;
int n = 0; // number of measure values
int skips = SKIPS;
@fishi0x01
fishi0x01 / power_set.py
Last active March 21, 2020 15:19
Bitwise Techniques for Subset Iterations in Python. Code for blog post https://fishi.devtail.io/weblog/2015/05/18/common-bitwise-techniques-subset-iterations/
#!/usr/bin/env python3
"""
Iterate over each subset of any size (Power set)
"""
def power_set(A):
subsets = []
N = len(A)
# iterate over each subset
#!/usr/bin/env python3
"""
A simple python(3) bf interpreter.
First argument is .bf file with code to execute.
Optionally a file with input arguments can be specified as second argument.
"""
import sys
import re