1
0
Fork 0

first working version

This commit is contained in:
ston1th 2019-02-12 20:55:02 +01:00
commit 84e26d7f6c
50 changed files with 6145 additions and 182 deletions

70
main.go
View file

@ -1,33 +1,53 @@
// Copyright (C) 2019 ston1th
//go:generate ./generate.sh
package main
import (
"bytes"
"flag"
"fmt"
"git.giftfish.de/ston1th/duckycode/pkg/encode"
"io"
"os"
"git.giftfish.de/ston1th/duckycode/pkg/encoder"
)
func main() {
// var buf = bytes.NewBufferString(`
//REM The next three lines execute a command prompt in Windows
//GUI r
//STRING cmd
//ENTER
//`)
var buf = bytes.NewBufferString(`
REM Type Hello World into Windows notepad. Target: Windows 95 and beyond. Author: Darren
DELAY 1000
GUI r
DELAY 100
STRING c:\windows\notepad.exe
ENTER
DELAY 1000
STRING Hello World
`)
e := encode.NewEncoder(buf, "de")
b, err := e.Encode()
if err != nil {
fmt.Println(err)
}
os.Stdout.Write(b)
var (
language string
inFile string
outFile string
)
func fatal(v interface{}) {
fmt.Fprintf(os.Stderr, "%s\n", v)
os.Exit(1)
}
func main() {
flag.StringVar(&language, "l", "de", "language (available: be, br, ca, ch, de, dk, es, fi, fr, gb, hr, it, no, pt, ru, si, sv, tr, us)")
flag.StringVar(&inFile, "f", "", "input file")
flag.StringVar(&outFile, "o", "inject.bin", "output file (use - for stdout)")
flag.Parse()
if inFile == "" {
fatal("input file cannot be empty")
}
in, err := os.Open(inFile)
if err != nil {
fatal(err)
}
var out io.Writer
if outFile == "-" {
out = os.Stdout
} else {
out, err = os.OpenFile(outFile, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0640)
if err != nil {
fatal(err)
}
}
e := encoder.NewEncoder(out, "de")
err = e.Encode(in)
if err != nil {
fatal(err)
}
}