Skip to content

Instantly share code, notes, and snippets.

View mosajjal's full-sized avatar
🎯
Focusing

Ali mosajjal

🎯
Focusing
View GitHub Profile
@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
@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 / 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 / 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 / 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 / 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 / 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 / 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"
package main
import (
"context"
"fmt"
"log"
"net"
"os"
"strconv"
"syscall"
@mosajjal
mosajjal / cloudflare_tailscale_sync.py
Created August 22, 2021 11:04
Automated Script to Use Cloudflare as a DNS server for Tailscale. Global alternative to Magic DNS
"""
This script trys to add and delete records from cloudflare based on the current status of the account in tailscale, and eliminate the need for TailScale's magic DNS.
Each domain will be created under a subdomain "SUBDOMAIN", that way it'll be easier to find and detele records.
IMPORTANT: this script is not very well tested and it tries to DELETE some DNS records. Use it at your own risk, especially if your SUBDOMAIN value is generic and it's also used elsewhere in your domain.
"""
import os
import requests