Skip to content

Instantly share code, notes, and snippets.

View M0nteCarl0's full-sized avatar
evolve or repeat

Alex M0nteCarl0

evolve or repeat
View GitHub Profile
@M0nteCarl0
M0nteCarl0 / elf_finder.go
Created July 24, 2023 07:56
Folder scaner for ELF files
package main
import (
"fmt"
"os"
"path/filepath"
)
func main() {
folderPath := "path/to/folder"
@M0nteCarl0
M0nteCarl0 / map_of_interface.go
Last active July 29, 2023 11:01
Example implentation map of interface for Golang
package main
import (
"fmt"
)
type MyMap map[string]interface{}
func (m MyMap) Set(key string, value interface{}) {
m[key] = value
@M0nteCarl0
M0nteCarl0 / README.md
Created July 24, 2023 08:12
Linux USB filter kernel module example

Linux USB filter module

  • Build: make -C /lib/modules/$(uname -r)/build M=$(pwd) modules
  • Install:sudo insmod usb_filter.ko
  • Test: dmesg
  • Remove: sudo rmmod usb_filter
@M0nteCarl0
M0nteCarl0 / usb_filter.c
Created July 24, 2023 08:25
Linux kernel module usb filter example with userspace control application
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/usb.h>
#define USB_FILTER_ADD_DEVICE _IO('u', 0)
#define USB_FILTER_REMOVE_DEVICE _IO('u', 1)
static int is_device_blacklisted(struct usb_device *dev) {
// Check if the device is blacklisted based on some criteria
return 0; // Return 1 if blacklisted, 0 otherwise
@M0nteCarl0
M0nteCarl0 / capture_and_extract_tcp_flags.c
Created July 24, 2023 10:45
Capture via PcapPlusPlus and extarct tcp flahs
#include <iostream>
#include <stdlib.h>
#include <Packet.h>
#include <PcapLiveDeviceList.h>
#include <TcpLayer.h>
void packetHandler(pcpp::RawPacket* packet, pcpp::PcapLiveDevice* dev, void* cookie) {
// Получаем пакет TCP
pcpp::Packet parsedPacket(packet);
pcpp::TcpLayer* tcpLayer = parsedPacket.getLayerOfType<pcpp::TcpLayer>();
@M0nteCarl0
M0nteCarl0 / http_data_extractor.c
Created July 24, 2023 11:04
Example for extact HTTP header and body from raw packets via PcapPlusPlus
#include <iostream>
#include <stdlib.h>
#include <Packet.h>
#include <PcapLiveDeviceList.h>
#include <HttpLayer.h>
void packetHandler(pcpp::RawPacket* packet, pcpp::PcapLiveDevice* dev, void* cookie) {
// Получаем пакет HTTP
pcpp::Packet parsedPacket(packet);
pcpp::HttpRequestLayer* httpLayer = parsedPacket.getLayerOfType<pcpp::HttpRequestLayer>();
@M0nteCarl0
M0nteCarl0 / pandas_complex_filter.py
Created July 24, 2023 11:13
Complex pandas example
import pandas as pd
# Создаем пример DataFrame
data = {
'Name': ['John', 'Alice', 'Bob', 'Charlie'],
'Age': [25, 30, 35, 40],
'Country': ['USA', 'Canada', 'UK', 'Australia']
}
df = pd.DataFrame(data)
@M0nteCarl0
M0nteCarl0 / camera_emulator_kernel.c
Created July 25, 2023 05:55
Linux camera emulation module
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/types.h>
#include <linux/cdev.h>
#include <linux/device.h>
#include <linux/slab.h>
#define MODULE_NAME "camera_emulator"
#define DEVICE_NAME "camera"
@M0nteCarl0
M0nteCarl0 / rules_from_file.cpp
Created July 26, 2023 06:23
System of rules from json
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <jsoncpp/json/json.h>
// Структура правила
struct Rule {
std::string condition;
std::string action;
@M0nteCarl0
M0nteCarl0 / Boost_HTTP_proxy.cpp
Last active July 29, 2023 10:56
Simple HTTP Proxy on C++, python, Golang, Julia
#include <iostream>
#include <string>
#include <boost/asio.hpp>
// Функция для обработки HTTP запроса и отправки его на сервер
void handleRequest(boost::asio::ip::tcp::socket& clientSocket, const std::string& serverHost, const std::string& serverPort) {
// Создание объекта io_context
boost::asio::io_context ioContext;
// Создание объекта resolver для разрешения имени хоста сервера