Skip to content

Instantly share code, notes, and snippets.

View cr0hn's full-sized avatar

cr0hn cr0hn

View GitHub Profile
@cr0hn
cr0hn / generate-rst.py
Last active May 24, 2018 19:18
Generate python documentation project, using sphinx, dynamically. The snippet must be pasted in the top of config.py file, the sphinx configuration file.
__author__ = 'cr0hn - cr0hn<-at->cr0hn.com (@ggdaniel)'
import os
# --------------------------------------------------------------------------
# Config
# --------------------------------------------------------------------------
# Do not process this files/dirs
EXCLUDE_FILES_OR_DIRS = ["bin"]
@cr0hn
cr0hn / sphinx-conf.py
Created August 1, 2014 07:24
Locate automatically all .py files in your project to add to sphinx engine to generate documentation.
# Source code base directory
PROJECT_DIR = os.path.abspath(os.path.join(os.path.join(os.getcwd()), "../../."))
# Insert Base project dir
sys.path.insert(0, os.path.abspath(os.path.join(PROJECT_DIR, "../.")))
# Run!
for root, dirs, files in os.walk(PROJECT_DIR):
# Looking for .py files and packages
if any(x.endswith(".py") for x in files) and any("__init__.py" in x for x in files):
@cr0hn
cr0hn / agents.md
Last active October 28, 2020 03:17 — forked from Paratron/agents.md

#Social Network Crawler User Agents Users can post URLs on a lot of different platforms nowadays. Most of those platforms will send a request to that URL to generate some preview data from it.

These are a couple of user agents I quickly tested out.

##Facebook

facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)
@cr0hn
cr0hn / http-websocket-test.nse
Last active February 3, 2023 18:01 — forked from d33tah/http-websocket-test.nse
nmap script do detect WebSocket listen services, and fingerprint it
local shortport = require "shortport"
local stdnse = require "stdnse"
description = [[
Detects whether the given server is running a WebSocket service on its root
directory.
]]
---
-- @usage
@cr0hn
cr0hn / pkg_to_json.py
Last active September 21, 2023 17:43
Transform a Scapy packet to JSON data
# -*- coding: utf-8 -*-
"""
This file contains the function to convert a Scapy packet to JSON representation
"""
from __future__ import print_function
import json
from collections import defaultdict
@cr0hn
cr0hn / process_threads_tasks_asyncio.py
Last active April 25, 2016 17:13
PoC that mixes Python 3 Process -> threads -> asyncio Tasks.
# -*- coding: utf-8 -*-
#
# Author: Daniel Garcia (cr0hn) - @ggdaniel
# Github: https://github.com/cr0hn
#
import asyncio
from multiprocessing import Process
@cr0hn
cr0hn / get_hardware_id.py
Created May 4, 2016 14:01
Get unique hardware ID (and always the same) based on CPU-info
#
# Author: Daniel Garcia (cr0hn) - @ggdaniel
# License: BSD
#
# Dependencies: py-cpuinfo (pip install py-cpuinfo)
#
def get_hardware_id():
"""
Get an unique hardware ID, based on CPU info. All the times called, the value will be the same.
@cr0hn
cr0hn / pub_sub.py
Created June 21, 2016 14:05
Simple producer / consumer using native asyncio Python >= 3.3 module, using non-blocking Queues and non-blocking system commands calls
# -*- coding: utf-8 -*-
import asyncio
@asyncio.coroutine
def cmd_runner(cmd):
# cmd = "ls"
print(cmd)
@cr0hn
cr0hn / install_docker_ubuntu.sh
Created July 20, 2016 14:00
Bash for install Docker in Ubuntu 16
sudo apt-get update && apt-get -y install linux-image-extra-$(uname -r)
sudo apt-get -y install apt-transport-https ca-certificates
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo deb https://apt.dockerproject.org/repo ubuntu-xenial main > /etc/apt/sources.list.d/docker.list
sudo apt-get update -y
sudo apt-get purge -y lxc-docker
sudo apt-get install -y docker-engine docker-compose
sudo service docker start
init 6
@cr0hn
cr0hn / PyInstaller_vs_Nuitka_for_kapow.rst
Created August 5, 2019 13:58
PyInstaller vs Nuitka for Kapow!

Compilations was made in a Docker Ubuntu x64 image. There the results:

Nuikta

Command v1

python3 -m nuitka --follow-imports -j 4 --plugin-enable=multiprocessing kapow.py