Skip to content

Instantly share code, notes, and snippets.

@subzer0iq
subzer0iq / asyncio_socket_server.py
Created January 25, 2025 15:26 — forked from johnliu55tw/asyncio_socket_server.py
Python asyncio socket server template
import asyncio
import logging
# XXX: REMOVE THIS LINE IN PRODUCTION!
logging.basicConfig(format='%(asctime)s %(lineno)d %(levelname)s:%(message)s', level=logging.DEBUG)
logger = logging.getLogger(__name__)
# Connected client records
clients = dict()
@subzer0iq
subzer0iq / client.py
Created January 24, 2025 20:52 — forked from zapstar/client.py
Python Asyncio SSL client and server examples
#!/usr/bin/env python3
import asyncio
import ssl
@asyncio.coroutine
async def echo_client(data, loop):
ssl_ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
ssl_ctx.options |= ssl.OP_NO_TLSv1
@subzer0iq
subzer0iq / AdbCommands
Created November 14, 2024 15:36 — forked from Pulimet/AdbCommands
Adb useful commands list
Hi All!
I've recently launched a tool that wraps many of the commands here with a user interface. This desktop application is currently available for macOS. There's a roadmap outlining planned features for the near future.
Feel free to request any features you'd like to see, and I'll prioritize them accordingly.
One of the most important aspects of this application is that every command executed behind the scenes is displayed in a special log section. This allows you to see exactly what’s happening and learn from it.
Here's the link to the repository: https://github.com/Pulimet/ADBugger
App Description:
ADBugger is a desktop tool designed for debugging and QA of Android devices and emulators. It simplifies testing, debugging, and performance analysis by offering device management, automated testing, log analysis, and remote control capabilities. This ensures smooth app performance across various setups.
@subzer0iq
subzer0iq / nginx-tuning.md
Created June 13, 2024 14:05 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@subzer0iq
subzer0iq / tmux-cheatsheet.markdown
Created May 21, 2024 14:45 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@subzer0iq
subzer0iq / bond1.netdev
Created May 20, 2024 17:37 — forked from kbeckmann/bond1.netdev
LACP port trunking with systemd-networkd
[NetDev]
Name=bond1
Kind=bond
[Bond]
Mode=802.3ad
MIIMonitorSec=1s
LACPTransmitRate=fast
UpDelaySec=2s
DownDelaySec=8s
@subzer0iq
subzer0iq / iptables.sh
Created May 17, 2024 13:55 — forked from einyx/iptables.sh
Anti DDos kernel settings
### 1: Drop invalid packets ###
/sbin/iptables -t mangle -A PREROUTING -m conntrack --ctstate INVALID -j DROP
### 2: Drop TCP packets that are new and are not SYN ###
/sbin/iptables -t mangle -A PREROUTING -p tcp ! --syn -m conntrack --ctstate NEW -j DROP
### 3: Drop SYN packets with suspicious MSS value ###
/sbin/iptables -t mangle -A PREROUTING -p tcp -m conntrack --ctstate NEW -m tcpmss ! --mss 536:65535 -j DROP
### 4: Block packets with bogus TCP flags ###
@subzer0iq
subzer0iq / get_default_gw.py
Last active March 28, 2024 10:35
Python: List all default gateways on host
#!/usr/bin/env python3
"""
Determine IPv4/IPv6 default gateway(s) on a Linux machine via the socket interface.
"""
import socket
import struct
### Base netlink constants. See include/uapi/linux/netlink.h
@subzer0iq
subzer0iq / netlink_ifnew.py
Created March 21, 2024 14:43 — forked from Lukasa/netlink_ifnew.py
Monitor for new links using Python and Netlink
@subzer0iq
subzer0iq / enumerate_interfaces.py
Created March 15, 2024 15:32 — forked from pklaus/enumerate_interfaces.py
Python: List all Network Interfaces On Computer
"""
Determine IPv4 addresses on a Linux machine via the socket interface.
Thanks @bubthegreat the changes to make it Py2/3 compatible and the helpful
code comments: https://gist.github.com/pklaus/289646#gistcomment-2396272
This version has all comments removed for brevity.
"""
import socket
import array
import struct