Skip to content

Instantly share code, notes, and snippets.

View ktosiu's full-sized avatar

Marcin Boćkowski ktosiu

View GitHub Profile
@ktosiu
ktosiu / dahua_rpc.py
Created July 31, 2022 00:01 — forked from gxfxyz/dahua_rpc.py
Basic Dahua RPC wrapper
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Basic Dahua RPC wrapper.
Example:
from dahua_rpc import DahuaRpc
dahua = DahuaRpc(host="192.168.1.10", username="admin", password="password")
@ktosiu
ktosiu / ffmpeg_stream.md
Created August 25, 2020 09:11 — forked from docPhil99/ffmpeg_stream.md
Streaming FFmpeg and Python

This is running on Linux Mint

  1. Install ffmpeg
sudo apt-get install ffmpeg
  1. A simple test: open two terminals, in first run ffplay udp://127.0.0.1:23000 and in the second ffmpeg -i sample.mp4 -vcodec mpeg4 -f mpegts udp://127.0.0.1:23000 . This should play the video sample.mp4 although the quality is rather blocky.
@ktosiu
ktosiu / honey.py
Created September 1, 2019 16:15 — forked from dustyfresh/honey.py
quick and simple honeypot in python3 using scapy, and raw sockets file logging
#!/usr/bin/env python3
import argparse
import threading
from threading import Thread
from scapy.all import *
import logging
import socket
import chardet
def listen():
@ktosiu
ktosiu / gist:cf72bf63ad34f2557c4aa020d9084803
Created April 15, 2019 15:26 — forked from kewogc/gist:1d679c6c83977d69106f
HOW TO INSTALL KANNEL ON UBUNTU
~# uname -a
~# lsb_release -a
~# locale-gen en_US
~# locale-gen en_US.UTF-8
~# apt-get -y --force-yes remove ntpdate
~# apt-get -y --force-yes install ntp
~# /etc/init.d/ntp restart
~# dpkg-reconfigure tzdata
@ktosiu
ktosiu / README.md
Created January 22, 2019 13:17 — forked from gleicon/README.md
Using Graphite/Grafana to gather Locust.io test data

Using Locust.io with Grafana

On your locust master server:

  • Install and configure Graphite. Follow a good tutorial
  • Install and configure Grafana: tutorial

Use logra.py on your locust test file. See locustfile.py.

@ktosiu
ktosiu / gDNS.py
Created January 22, 2019 13:16 — forked from gleicon/gDNS.py
gevent/dnslib/redis based DNS server
# dns server using dnslib and gevent
# based on https://bitbucket.org/paulc/dnslib/src/80d85555aae4/src/server/gevent_server.py
# set the key as
# set IP:name ip_addr
# set TXT:name txtfield
# fallback on gevent's dns resolver
# gleicon 2011
import gevent
#!/usr/bin/env python
from __future__ import unicode_literals
import pymongo
import threading
DB_NAME = 'events'
COLLECTION_NAME = 'events'
class Subscriber(threading.Thread):
@ktosiu
ktosiu / README.md
Created April 19, 2017 18:24 — forked from jsheedy/README.md
asyncio + uvloop echo server benchmark

asyncio + uvloop echo server benchmark

This is an attempt at a bare minimum client/server benchmark of asyncio with optional use of uvloop. On my 2015 macbook pro, I get almost 2.5X improvement using uvloop in the server.

The client runs PARALLEL tasks at once. Running only a single task results in about 1/8 the throughput of 100 simultaneous tasks.

# with uvloop
$ python client.py
satisfied 100000 requests in 1.41021 seconds (70911.42 reqs/s)
@ktosiu
ktosiu / simple_socket_example.c
Created February 27, 2017 09:09 — forked from browny/simple_socket_example.c
simple socket example in C
/* --- Usage --- */
g++ server.c -o server
g++ client.c -o client
./server
./client 127.0.0.1
/* --- server.c --- */
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@ktosiu
ktosiu / locust_basic_auth_test.py
Created February 9, 2017 10:46 — forked from hartfordfive/locust_basic_auth_test.py
Sample LocustIO testing script with basic auth
'''
Simple LocustIO testing script with basic auth
'''
import random, gzip, StringIO, threading, urllib2, re, getpass
from locust import HttpLocust, TaskSet, task, web
from random import randint
from urlparse import urlparse
#resource.setrlimit(resource.RLIMIT_NOFILE, (999999, 999999))
USER_AGENTS = [