Coder Social home page Coder Social logo

bin2delphi's Introduction

Command Line Tool

Install with

go install github.com/gonutz/bin2delphi/cmd/bin2delphi@latest

Usage:

bin2delphi -const="VirusExe" -unit="VirusPayload" < virus.exe > VirusPayload.pas

This will create a file VirusPayload.pas and place a byte array in it, containing the binary data from the file virus.exe. Now you can create your trojan in Delphi.

The tool generates a full Delphi unit like this one:

unit VirusPayload;

interface

const
  VirusExe: array [0 .. 6] of Byte = (
    $48, $65, $6C, $6C, $6F, $0D, $0A
  );

implementation

end.

The interface relies on stdin and stdout, meaning you can use it with one input and one output. The example above uses the < and > operators for this.

If you want to have multiple constants in a single file, you need to use the Go API.

Go API

This example reads all .exe files in a directory and adds them to a Delphi file ExeFiles.pas. The constants are named with the base file names (without .exe).

package main

import (
	"os"
	"strings"

	"github.com/gonutz/bin2delphi"
)

func main() {
	unit := bin2delphi.NewUnit("ExeFiles")

	files, _ := os.ReadDir(".")
	for _, file := range files {
		if strings.HasSuffix(file.Name(), ".exe") {
			data, _ := os.ReadFile(file.Name())
			unit.AddConstant(strings.TrimSuffix(file.Name(), ".exe"), data)
		}
	}

	os.WriteFile("ExeFiles.pas", unit.Generate(), 0666)
}

The resulting Delphi file might look like this:

unit ExeFiles;

interface

const
  First: array [0 .. 2] of Byte = (
    $61, $62, $63
  );

const
  TheSecond: array [0 .. 2] of Byte = (
    $61, $62, $63
  );

implementation

end.

bin2delphi's People

Watchers

 avatar  avatar  avatar

Forkers

atkins126 tmtkt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.