Skip to content

Instantly share code, notes, and snippets.

@dmknght
dmknght / Nix-Malware-dev-syllabus.md
Last active April 26, 2025 02:24
[WIP] A for-fun *Nix malware development syllabus

Hand-on Malware Development on Linux Syllabus

Course Overview

This course provides an in-depth exploration of advanced malware development techniques on Linux, focusing on sophisticated methods such as binary injection, process injection, and file hijacking. Designed for learners with a foundational understanding of Linux and programming, the course emphasizes practical application in a safe, controlled environment (virtual machines) and underscores ethical and legal considerations for academic or authorized security testing purposes.

Malin 101

Day 0: Introduction to Malware and Linux System Programming

  • Objectives:
@dmknght
dmknght / avp_edit.py
Last active April 10, 2025 08:44
Likely signature management of Kaspersky 2008
import tkinter as tk
from tkinter import ttk, messagebox, filedialog
import struct
import os
import hashlib
from datetime import datetime
from dataclasses import dataclass
from typing import List, Optional, Tuple
import re

Researcher and product info

  • Production: Avast on Linux
  • Version: 4.5.1
  • Database Update: 24092704
  • Research: FIS Security Team
  • Report by: Nông Hoàng Tú ([email protected])

Insecure update protocol leads to DNS spoofing

Description and Impact

By default, update server of Avast for Linux uses HTTP protocol which is vulnerable to Man-In-The-Middle and DNS Spoofing attack. An attacker in LAN network can use ARP Spoofing attack, redirect update packet to a fake server or even capture response data and tamper update file.

@dmknght
dmknght / dangerous_methods.yara
Last active September 11, 2024 07:52
Yara rules to find dangerous functions and methods in various file format. This file is meant to help researchers find source sinks. It doesn't mean to find vulnerabilities automatically.
import "elf"
import "console"
/*
To use this rule, simply run: yara <path to this rule> <pah to dir to scan> -r -p 1 -N
Explain:
-r: recursively search
-p 1: Run single thread only. Show console log won't be messed up
-N: No follow symlink. Ignore duplicate results from symlink
Suggestion: In future, run with -s could be good
@dmknght
dmknght / CheckPoint_CVE-2024-24919_Shodan.py
Last active July 1, 2024 15:34
Scan for CheckPoint CVE-2024-24919 using Shodan
#!/usr/bin/python3
import os
import requests
from shodan import Shodan
API_KEY_PATH = os.path.expanduser("~/.config/shodan/api_key") # read API key from config file
KEYWORD = "country:cn http.status:200 \"Server: Check Point SVN foundation\""
URL_REQ = "/clients/MyCRL"
@dmknght
dmknght / scan_ports_with_bash.sh
Last active December 11, 2023 22:53
A port scanner in bash. No netcat / nmap is required. Might be useful when discover open ports in internal network on a Linux server.
#!/bin/bash
# Example of using bash with array
port_arr=(80 22 3306)
max_timeout=2 # Timeout requires coreutils (on Debian-based system)
function do_scan_port {
# If use array like above, use the line above
for port in "${port_arr[@]}"; do
# Otherwise, use the port range
@dmknght
dmknght / yr_find_creds.nim
Created November 19, 2023 04:34
Demo of using yara to find files that contains credentials. Requires Yara binding for Nim to compile.
import .. / src / engine / libyara # Binding lib co san. Neu tai ve thi sua cho nay, lay binding o day https://github.com/dmknght/nimyara
import strformat
import os
# Pass vao compiler de link voi thu vien Yara
{.passL: "-lyara".}
type
COMPILER_RESULT = object
errors: int
warnings: int
@dmknght
dmknght / WinDef_Extractor.cpp
Created October 30, 2023 23:05
Read, Extract, Merge extracted db of Windows Defender
/*
Forked from https://github.com/hongson11698/defender-database-extract/
- Fixed some buffer overflow in sprintf
- Compile: g++ extract_sig.cpp -o extract_sig -Wall -lstdc++fs
- Usage: ./extract_sig <dir to write result> <extracted av/as base> <optional: extracted av/as dlta>
If both av and dlta is defined, the program will merge both of them to make a final db
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@dmknght
dmknght / qiling_to_dump.py
Last active November 2, 2023 09:59
Use qiling to execute file (rootfs is required). Support showing ASM code and save Dump file
from qiling import *
from qiling.const import *
from unicorn.x86_const import UC_X86_INS_SYSCALL # https://github.com/unicorn-engine/unicorn/blob/master/bindings/python/unicorn/x86_const.py
import argparse
import yara
def mem_scan(ql: Qiling, address: int, size: int, yr_pointer) -> None:
buf = ql.mem.read(address, size)
for insn in ql.arch.disassembler.disasm(buf, address):