Skip to content

Instantly share code, notes, and snippets.

View mosajjal's full-sized avatar
🎯
Focusing

Ali mosajjal

🎯
Focusing
View GitHub Profile
package main
import (
"context"
"fmt"
"log"
"net"
"os"
"strconv"
"syscall"
@mosajjal
mosajjal / email_parser.go
Last active November 6, 2022 21:49
Parse a directory containing .tgz mailbox imports into one JSONL doc + a folder of attachments.
// email parser built to process large amounts of .tgz exports containing one or more .eml files inside
package main
import (
"archive/tar"
"bytes"
"compress/gzip"
"crypto/sha256"
"encoding/json"
"fmt"
@mosajjal
mosajjal / dnsUnmarshaller.go
Created January 5, 2023 00:00
miekg DNS unmarshaller
package main
import (
"fmt"
"log"
"testing"
json "github.com/bytedance/sonic"
"github.com/miekg/dns"
@mosajjal
mosajjal / falconfeeds2rss.py
Created December 28, 2023 04:59
Converts the incoming webhook from falconfeeds to an RSS feed that you can ingest. please consider T&C of Falconfeeds before making the RSS public
#!/bin/env python3
from bottle import Bottle, request, response, static_file
import json
import xml.etree.ElementTree as ET
from datetime import datetime
import pytz
import os
app = Bottle()
@mosajjal
mosajjal / ub64.py
Created January 6, 2024 22:52
recursively replace base64-encoded strings in a JSON file with the decoded string
# recursively replace base64-encoded strings in a JSON file with the decoded string
# usage: python main.py <input_file> <output_file>
import sys
import json
import base64
def decode_json(data):
if isinstance(data, dict):
return {decode_json(key): decode_json(value) for key, value in data.items()}
@mosajjal
mosajjal / flatten.go
Created January 6, 2024 23:00
flatten nested json strings
// use:
// cat nested.json | go run . > flattenned.json
package main
import (
"bytes"
"compress/gzip"
"encoding/base64"
"fmt"
"io"
@mosajjal
mosajjal / buildinfo.go
Created January 6, 2024 23:01
get build info of a go binary
package main
import (
"debug/buildinfo"
"encoding/json"
"flag"
"fmt"
"log"
)
@mosajjal
mosajjal / get_pcap_timestamp.py
Created August 19, 2025 05:18
Get first and last packet timestamp of a huge pcap instantly.
#!/usr/bin/env python3
import struct
import datetime
import sys
def read_pcap_timestamps(filename):
"""
Quickly extract first and last packet timestamps from a pcap file
by reading the binary structure directly.
"""
@mosajjal
mosajjal / sed-ai.go
Last active October 4, 2025 10:55
Sed but with AI
// # AI Sed-like Tool
// A Go script that behaves like sed but uses AI models to edit files. It can read from stdin or edit files in-place with the `-i` flag. The tool supports splitting files into sections using delimiters and can work with multiple AI providers.
// ## Features
// - Edit files in-place with the `-i` flag
// - Read from stdin for pipe-based operations
// - Support for multiple AI providers (OpenAI, Anthropic, OpenRouter, Vertex AI)
// - Delimiter-based file sectioning for processing large files