Skip to content

Instantly share code, notes, and snippets.

@kazkansouh
kazkansouh / blender_extrude.py
Created May 28, 2018 08:30
Python function for Blender to automate the process of repeated extruding, rotation and scaling of a given face.
def extrude(step = 5, start = 0, end = 360, minimum_width = 0.5, hstep = 1, rotation = 2) :
"""Extrude, rotate and scale at same time. Before calling, select the
face that this should be applied in the 3d view.
"""
K = (sin(radians(start)) + 1 + minimum_width)
for x in range(start + step, end, step) :
bpy.ops.mesh.extrude_region_move(TRANSFORM_OT_translate={"value":(0,0,hstep)})
bpy.ops.transform.rotate(value=radians(rotation), axis=(0, 0, 1))
L = (sin(radians(x)) + 1 + minimum_width)
@kazkansouh
kazkansouh / svgtopngs.sh
Created July 27, 2018 23:16
Generate a range of PNG images of varying sizes from an SVG image
#! /bin/bash
WIDTHS="32 64 128 256 512 1024"
if test -z "$#" -o "$#" -ne 1 -o ! -f "$1" ; then
1>&2 echo "Usage: " `basename $0` " <SVGFILE>"
exit 1
fi
@kazkansouh
kazkansouh / cookie.py
Created September 28, 2018 14:30
Calculate password from cookie for Cisco router
@kazkansouh
kazkansouh / Dockerfile
Last active October 5, 2018 15:24
GNS3 ipterm image with support for dhclient instead of udhcpc
FROM gns3/ipterm:latest
RUN DEBIAN_FRONTEND=noninteractive && \
apt-get -q update && \
apt-get -qq -y install isc-dhcp-client && \
rm -rf /var/lib/apt/lists/*
# Need to make dhclient available during init script execution
# RUN mkdir -p /tmp/gns3/bin && ln -s /sbin/dhclient /tmp/gns3/bin/dhclient
# ^^ does not work as directory /tmp/gns/bin should not exist.
@kazkansouh
kazkansouh / aiohttp-issue.py
Last active November 27, 2018 15:38
Investigate an issue with aiohttp when using StreamReader as the body of a post resulting in poor performance.
#! /usr/bin/python3
#
# Demonstrates an issue identified on aiohttp version 3.2.1, 3.3.0,
# where the upload between frontend and backend stalls (or goes very
# slowly by only sending chunks of 128 bytes due to tcp window being
# full). This only happens when both the sender and receiver are in
# the same event loop and lots of small chunks are sent triggering the
# performance hit. To mitigate this performance hit, the size of the
# chunks should be maximised. The issue is exasperated in versions of
# aiohttp <= 3.3.0 as the default iterator used tries to read the
@kazkansouh
kazkansouh / url_decode.c
Created February 23, 2019 08:56
URL decode in C with only stdlib as dependency, written for use on an embedded device.
#include <stdio.h>
#include <stdlib.h>
void urldecode(char* pch_url) {
int i = 0;
char* ptr = pch_url;
while (*ptr != '\0') {
if (*ptr != '%') {
pch_url[i++] = *(ptr++);
@kazkansouh
kazkansouh / prime-test.c
Created December 13, 2019 17:57
Command line app to call openssl primality check
/* Copyright (C) 2019 Karim Kanso. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@kazkansouh
kazkansouh / crc32-extender.c
Created April 29, 2020 14:07
Simple algorithm to modify a payload in such a way to have a specific CRC32 value
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
const uint32_t ui_crc32_table[] =
{
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
@kazkansouh
kazkansouh / searchsploit-filt.sh
Created August 28, 2020 10:29
Wrapper script for searchsploit that uses jq to sort the results by date.
#! /bin/bash
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@kazkansouh
kazkansouh / rshell-build.sh
Last active December 26, 2020 08:59
Bash script for building a windows reverse shell.
#!/bin/bash
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the