Skip to content

Instantly share code, notes, and snippets.

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

Tolgahan Akgun tolgahanakgun

😛
( ͡ ͡° ͜ ʖ ͡ ͡°) \╭☞
View GitHub Profile
@tolgahanakgun
tolgahanakgun / tftp.py
Created July 12, 2024 10:01
Single Python file TFTP server implementation with >32MB file support
# This code is based on https://github.com/m4tx/pyTFTP project
import os
import errno
import logging
import socket
import argparse
from pathlib import Path, PurePosixPath
from threading import Thread
from typing import List, NewType, Tuple, Union, Dict
@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 / 403.py
Last active August 5, 2024 16:02
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 / 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
@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
#!/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 \
#!/bin/bash
# download hosts file
wget -O /opt/adblock/hostfiles/someonewhocares.hosts https://someonewhocares.org/hosts/zero/hosts
wget -O /opt/adblock/hostfiles/winhelp2002.hosts http://winhelp2002.mvps.org/hosts.txt
wget -O /opt/adblock/hostfiles/tgccloud.hosts https://tgc.cloud/downloads/hosts.txt
wget -O /opt/adblock/hostfiles/stevensblack.hosts https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
wget -O /opt/adblock/hostfiles/hblock.hosts https://hblock.molinero.dev/hosts
wget -O /opt/adblock/hostfiles/spotify_x0uid_spotifyablock.hosts https://raw.githubusercontent.com/x0uid/SpotifyAdBlock/master/hosts
wget -O /opt/adblock/hostfiles/spotify_saminnet_spotify_adblock_script.hosts https://raw.githubusercontent.com/saminnet/spotify-adblock-script/master/block.txt
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