-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Major loader update! - Added TLS callback support - Added forwarded imports support - Removed GetProcAddress and LoadLibrary WinAPI usage - Switched to NTDLL WinApi functions - Wiper code improved - Added lite loader option for appending PE files on the fly! - Added experimental raw syscall loader - Added static build flags in makefile - File name bug fixed - Dockerfile updated - Github workflows added - README updated
- Loading branch information
Showing
79 changed files
with
3,477 additions
and
2,227 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
|
||
name: build | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
|
||
jobs: | ||
linux-build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.19 | ||
- name: Install Keystone | ||
run: ./install-keystone.sh | ||
- name: Build for Linux | ||
run: make | ||
- name: 'Upload Artifact' | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: amber_linux | ||
path: amber | ||
retention-days: 5 | ||
macos-run: | ||
runs-on: macos-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.19 | ||
- name: Install Keystone | ||
run: ./install-keystone.sh | ||
- name: Build for MacOS | ||
run: make | ||
- name: 'Upload Artifact' | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: amber_darwin | ||
path: amber | ||
retention-days: 5 | ||
|
||
windows-build: | ||
runs-on: windows-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.19 | ||
- name: Build for Windows | ||
run: make | ||
- name: 'Upload Artifact' | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: amber.exe | ||
path: amber.exe | ||
retention-days: 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,5 @@ | ||
normal: | ||
go build -ldflags="-s -w" -trimpath -o amber | ||
386: | ||
CGO_ENABLED=1 GOARCH=386 go build -ldflags="-s -w" -trimpath -o amber | ||
linux_amd64: | ||
GOOS=linux CGO_ENABLED=1 GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o amber | ||
linux_386: | ||
GOOS=linux CGO_ENABLED=1 GOARCH=386 go build -ldflags="-s -w" -trimpath -o amber | ||
windows_amd64: | ||
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CGO_LDFLAGS="-lkeystone -L`pwd`/build/lib/" CXX=x86_64-w64-mingw32-g++ CC=x86_64-w64-mingw32-gcc go build -ldflags="-s -w" -trimpath -o amber.exe | ||
windows_386: | ||
GOOS=windows GOARCH=386 CGO_ENABLED=1 CGO_LDFLAGS="-lkeystone -L`pwd`/build/lib32/" CXX=i686-w64-mingw32-g++ CC=i686-w64-mingw32-gcc go build -ldflags="-s -w" -trimpath -o amber32.exe | ||
darwin: | ||
GOOS=darwin CGO_ENABLED=1 CGO_LDFLAGS="-lkeystone -L`pwd`/build/lib/" go build -ldflags="-s -w" -trimpath -o amber | ||
BUILD=go build | ||
BUILD_FLAGS=-trimpath -buildvcs=false -ldflags="-extldflags=-static -s -w -X github.com/egebalci/amber/config.Version=$$(git log --pretty=format:'v1.0.%at-%h' -n 1)" | ||
|
||
default: | ||
${BUILD} ${BUILD_FLAGS} -o amber |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,83 @@ | ||
package config | ||
|
||
import ( | ||
"errors" | ||
"flag" | ||
"fmt" | ||
"os" | ||
|
||
amber "github.com/EgeBalci/amber/pkg" | ||
sgn "github.com/EgeBalci/sgn/pkg" | ||
"github.com/fatih/color" | ||
"github.com/EgeBalci/amber/utils" | ||
"github.com/alecthomas/kong" | ||
) | ||
|
||
var usageStr = ` | ||
Usage: amber [options] | ||
Options: | ||
-f, --file <file> Input PE file | ||
-s, --stub <file> Use custom stub file (experimental) | ||
-m, --max <int> Maximum number of bytes for obfuscation | ||
-e, <int> Number of times to encode the generated reflective payload | ||
-b, --build Build EXE stub that executes the generated reflective payload | ||
--iat, Use IAT API resolver block instead of CRC API resolver block | ||
--ignore-checks, Ignore integrity check errors. | ||
-h, Show this message | ||
` | ||
const Version = "3.2.0" | ||
|
||
// PrintUsageErrorAndDie ... | ||
func PrintUsageErrorAndDie(err error) { | ||
color.Red(err.Error()) | ||
fmt.Println(usageStr) | ||
os.Exit(1) | ||
func HelpPrompt(options kong.HelpOptions, ctx *kong.Context) error { | ||
err := kong.DefaultHelpPrinter(options, ctx) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
// PrintHelpAndDie ... | ||
func PrintHelpAndDie() { | ||
fmt.Println(usageStr) | ||
os.Exit(0) | ||
// Main config struct for parsing the TOML file | ||
type Config struct { | ||
FileName string `help:"Input PE file name." name:"file" short:"f"` | ||
OutputFile string `help:"Output binary payload file name." name:"out" short:"o"` | ||
EncodeCount int `help:"Number of times to encode the generated reflective payload." name:"encode" short:"e" default:"1"` | ||
ObfuscationLimit int `help:"Maximum number of bytes for encoder obfuscation." name:"obfuscate-limit" short:"l" default:"5"` | ||
UseIAT bool `help:"Use IAT API resolver block instead of CRC API resolver block." name:"iat"` | ||
UseSyscalls bool `help:"Perform raw syscalls. (only x64)" name:"sys"` | ||
ScrapePeHeaders bool `help:"Scrape magic byte and DOS stub from PE." name:"scrape"` | ||
// IgnoreIntegrity bool `help:"Ignore PE file integrity check errors." name:"ignore"` | ||
Verbose bool `help:"Verbose mode." name:"verbose" short:"v"` | ||
Version kong.VersionFlag | ||
} | ||
|
||
// ConfigureOptions accepts a flag set and augments it with agentgo-server | ||
// specific flags. On success, an options structure is returned configured | ||
// based on the selected flags. | ||
func ConfigureOptions(fs *flag.FlagSet, args []string) (*amber.Blueprint, *sgn.Encoder, error) { | ||
|
||
// Create empty options | ||
bp := &amber.Blueprint{} | ||
encoder := sgn.NewEncoder() | ||
func Parse() (*Config, error) { | ||
|
||
// Define flags | ||
help := fs.Bool("h", false, "Show help message") | ||
fs.StringVar(&bp.FileName, "f", "", "Input PE file") | ||
fs.StringVar(&bp.FileName, "file", "", "Input PE file") | ||
fs.BoolVar(&bp.IAT, "iat", false, "Use IAT API resolver block instead of CRC API resolver block") | ||
fs.BoolVar(&bp.IgnoreIntegrity, "ignore-checks", false, "Ignore integrity check errors.") | ||
fs.StringVar(&bp.CustomStubName, "s", "", "Use custom stub file (experimental)") | ||
fs.StringVar(&bp.CustomStubName, "stub", "", "Use custom stub file (experimental)") | ||
fs.IntVar(&encoder.ObfuscationLimit, "max", 5, "Maximum number of bytes for obfuscation") | ||
fs.IntVar(&encoder.EncodingCount, "e", 1, "Number of times to encode the generated reflective payload") | ||
fs.BoolVar(&bp.BuildStub, "b", false, "Build EXE stub that executes the generated reflective payload") | ||
fs.BoolVar(&bp.BuildStub, "build", false, "Build EXE stub that executes the generated reflective payload") | ||
|
||
// Parse arguments and check for errors | ||
if err := fs.Parse(args); err != nil { | ||
return nil, nil, err | ||
cfg := new(Config) | ||
parser, err := kong.New( | ||
cfg, | ||
kong.Help(HelpPrompt), | ||
kong.UsageOnError(), | ||
kong.Vars{"version": Version}, | ||
kong.ConfigureHelp(kong.HelpOptions{ | ||
Summary: true, | ||
}), | ||
) | ||
if err != nil { | ||
return nil, err | ||
} | ||
_, err = parser.Parse(os.Args[1:]) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// If it is not help and other args are empty, return error | ||
if (*help == false) && bp.FileName == "" { | ||
err := errors.New("please specify all required arguments") | ||
return nil, nil, err | ||
if cfg.FileName == "" { | ||
utils.PrintErr("no file specified! (-f <empty>)\n") | ||
kong.Help(HelpPrompt) | ||
os.Exit(1) | ||
} | ||
|
||
// If -help flag is defined, print help | ||
if *help { | ||
PrintHelpAndDie() | ||
if cfg.OutputFile == "" { | ||
cfg.OutputFile = fmt.Sprintf("%s.bin", cfg.FileName) | ||
} | ||
|
||
return bp, encoder, nil | ||
return cfg, nil | ||
} | ||
|
||
func (cfg *Config) PrintSummary() { | ||
utils.PrintStatus("File: %s\n", cfg.FileName) | ||
utils.PrintStatus("Encode Count: %d\n", cfg.EncodeCount) | ||
utils.PrintStatus("Obfuscation Limit: %d\n", cfg.ObfuscationLimit) | ||
if cfg.UseIAT { | ||
utils.PrintStatus("API Resolver: IAT\n") | ||
} else { | ||
utils.PrintStatus("API Resolver: CRC\n") | ||
} | ||
if cfg.UseSyscalls { | ||
utils.PrintStatus("Raw Syscalls: True\n") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.