Skip to content

Instantly share code, notes, and snippets.

View tolgahanakgun's full-sized avatar
😛
( ͡ ͡° ͜ ʖ ͡ ͡°) \╭☞

Tolgahan Akgun tolgahanakgun

😛
( ͡ ͡° ͜ ʖ ͡ ͡°) \╭☞
View GitHub Profile
@tolgahanakgun
tolgahanakgun / 403.py
Last active January 5, 2024 16:06
Return a nice-looking "403 Forbidden" for all HTTP requests to web scrapers
#!/usr/bin/env python3
#
# -*- coding: utf-8 -*-
import socket
from email.utils import formatdate
from ipaddress import ip_address
import argparse
import socketserver
@tolgahanakgun
tolgahanakgun / 10G_server.py
Last active December 13, 2023 13:50
Send 10GB random data via http requests to test the network throughput
#!/usr/bin/env python3
#
# -*- coding: utf-8 -*-
#
# curl -o /dev/null http://SERVER_IP:SERVER_PORT
# time printf 'GET / HTTP/1.1\n\n' | netcat SERVER_IP SERVER_PORT > /dev/null
import os
import argparse
@tolgahanakgun
tolgahanakgun / empty.py
Created November 1, 2023 08:42
Send empty reply for web scrapers
#!/usr/bin/env python3
#
# -*- coding: utf-8 -*-
#
import socket
import argparse
from ipaddress import ip_address
def run_server(ip: ip_address, port: int) -> None:
@tolgahanakgun
tolgahanakgun / gist:4a0a99979e684adcc0179329a6957caa
Created October 11, 2023 10:43
TLS 1.3 and SSH ciphersuites performance on Raspberry Pi4
tolgahan@rpi:~ $ uname -a
Linux rpi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux
tolgahan@rpi:~ $ openssl version
OpenSSL 1.1.1w 11 Sep 2023
tolgahan@rpi:~ $ openssl speed -aead -evp aes-128-gcm
tolgahan@rpi:~ $ openssl speed -aead -evp aes-256-gcm
tolgahan@rpi:~ $ openssl speed -aead -evp chacha20-poly1305
type 2 bytes 31 bytes 136 bytes 1024 bytes 8192 bytes 16384 bytes
aes-128-gcm 1679.44k 18536.78k 29135.42k 36059.82k 36956.84k 37120.68k
aes-256-gcm 1365.87k 15148.50k 22993.66k 28058.28k 28740.27k 28813.99k
#!/usr/bin/env python3
"""Extend Python's built in HTTP server to save files
curl or wget can be used to send files with options similar to the following
curl -X PUT --upload-file somefile.txt http://localhost:8000
wget -O- --method=PUT --body-file=somefile.txt http://localhost:8000/somefile.txt
__Note__: curl automatically appends the filename onto the end of the URL so
the path can be omitted.
Windows upload & download
powershell -ep bypass -c "$wc=New-Object Net.WebClient;$wc.UploadFile('http://target.com/upload.bin', 'PUT', 'c:\\upload.bin');"
#!/bin/bash
wget -O /tmp/filegator_latest.zip https://raw.githubusercontent.com/filegator/static/master/builds/filegator_latest.zip
mkdir /tmp/filegator
unzip /tmp/filegator_latest.zip -d /tmp/filegator
cd /var/www/html/filegator
sudo find . ! -name . -prune ! -path ./private \
! -path ./repository \
! -path ./configuration.php \
@tolgahanakgun
tolgahanakgun / relay_ssh_agent
Created March 28, 2023 17:24
Relay forwarded ssh-agent to docker
#!/bin/bash
set -ex
set -o pipefail
# THIS MUST BE USED WITH AN SSH-AGENT THAT SUPPORTS CONFIRMATION/NOTIFICATION UPON A SIGNATURE REQUEST.
# Mount the sock to the docker
# docker run --user $(id -u):$(id -g) --rm -it -v "$HOME/.ssh/sshsock:/sshsock" -e SSH_AUTH_SOCK=/sshsock/sock ubuntu bash
@tolgahanakgun
tolgahanakgun / DumpHex.c
Last active December 14, 2022 13:12 — forked from ccbrown/DumpHex.c
Compact C Hex Dump Function w/ASCII to buffer
#include <stdio.h>
void dump_hex(const void *data, size_t size, char *output)
{
char ascii[17];
size_t i, j;
ascii[16] = '\0';
for (i = 0; i < size; ++i)
{
Linux rock64 4.4.167-1213-rockchip-ayufan-g34ae07687fce #1 SMP Tue Jun 18 20:44:49 UTC 2019 aarch64 aarch64 aarch64 GNU/Linux
rock64@rock64:~$openssl speed -aead -evp aes-128-gcm
rock64@rock64:~$openssl speed -aead -evp aes-256-gcm
rock64@rock64:~$openssl speed -aead -evp chacha20-poly1305
type 2 bytes 31 bytes 136 bytes 1024 bytes 8192 bytes 16384 bytes
---- ------- -------- --------- ---------- ---------- -----------
aes-128-gcm 2326.81k 29137.11k 108788.53k 360005.63k 482115.58k 492399.27k
aes-256-gcm 2256.78k 28163.19k 102470.97k 320374.44k 420995.35k 423843.16k
chacha20-poly1305 807.76k 11608.37k 32482.65k 129967.34k 167075.84k 169951.23k
@tolgahanakgun
tolgahanakgun / TIPS
Last active September 2, 2020 20:40
some time saving tips
#Lists the binary files which runs with privileged rights
find / -perm -u=s -type f 2>/dev/null
# add the lines below to .bashrc file for autostarting the ssh-agent and adding all the private keys in msys2
eval `ssh-agent -s` 1>/dev/null
find ~/.ssh/ -type f -exec grep -l "PRIVATE" {} \; | xargs ssh-add >/dev/null 2>&1