Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C2 Framework Support #8

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b99b1aa
Merge pull request #1 from ropnop/master
Ne0nd0g Feb 26, 2021
86c796b
Update SafeArray functions, fixed example program
Ne0nd0g Mar 18, 2021
46d27d5
Fixed composite literal use of unkeyed fields
Ne0nd0g Mar 18, 2021
d54978b
Fixed misuse of unsafe.Pointer in iclrmetahost
Ne0nd0g Mar 18, 2021
b3af3fa
Fixed misuse of unsafe.Pointer for iclrmetahost
Ne0nd0g Mar 18, 2021
d17a78a
Modified iclrruntimeinfo methods
Ne0nd0g Mar 18, 2021
4715ed5
Fixed misuse of unsafe.Pointer
Ne0nd0g Mar 19, 2021
e81f8eb
Update GetDefaultDomain
Ne0nd0g Mar 19, 2021
a46d3ab
Fixed misuse of unsafe.Pointer
Ne0nd0g Mar 19, 2021
f0888b8
Fixed misuse of unsafe.Pointer
Ne0nd0g Mar 19, 2021
a88b841
Fixed misuse of unsafe.Pointer
Ne0nd0g Mar 19, 2021
07d499f
Fixed misuse of unsafe.Pointer
Ne0nd0g Mar 19, 2021
ff8ffa7
Updated MethodInfo and PrepareParameters
Ne0nd0g Mar 19, 2021
e8b430e
Updated runtime enumeration
Ne0nd0g Mar 19, 2021
fed3a5e
Fixed misuse of unsafe.Pointer
Ne0nd0g Mar 19, 2021
278992d
Fixed misuse of unsafe.Pointer
Ne0nd0g Mar 19, 2021
d5949ed
Fixed misuse of unsafe.Pointer
Ne0nd0g Mar 19, 2021
441da9d
Code cleanup
Ne0nd0g Mar 19, 2021
3c6feff
Documentation and cleanup
Ne0nd0g Mar 19, 2021
85f36cd
Added C2 Framework Support
Ne0nd0g Mar 25, 2021
d791ef9
Updated STDOUT/STDERR Read
Ne0nd0g Mar 27, 2021
46c71d5
Added SafeArrayDelete
Ne0nd0g Mar 27, 2021
b7ac0af
Removed unused code
Ne0nd0g Mar 27, 2021
a2bef24
Update go.mod
Ne0nd0g Mar 28, 2021
875ea40
Updated STDOUT/STDERR to use a buffer
Ne0nd0g Apr 8, 2021
37fb9d6
Modules + Tags Hard...
Ne0nd0g Apr 8, 2021
b14c9ea
ignore windows error that doesn't impact execution
audibleblink Feb 10, 2022
474a510
Merge pull request #2 from audibleblink/patch/edgcase_error
Ne0nd0g Apr 2, 2022
b96d0f1
Updated supporting packages
Ne0nd0g Apr 2, 2022
d57278d
Remove must from go-clr.go
mec07 Oct 25, 2022
cb41266
Fixed #4
Ne0nd0g Nov 10, 2022
ce145f5
Merge pull request #3 from mec07/remove-must
Ne0nd0g Nov 10, 2022
7aa95c6
v1.3.0
Ne0nd0g Nov 10, 2022
6176f4a
Fixed CHANGELOG version numbers
Ne0nd0g Nov 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
v1.3.0
Ne0nd0g committed Nov 10, 2022
commit 7aa95c6ac17cb98d71e83678b22aff05f80685df
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 1.3.0 2022-XX-XX
## 1.3.0 2022-11-10

## Changed

- Merged [Pull 3](https://github.com/Ne0nd0g/go-clr/pull/3) from @mec07 to return errors instead of exiting the program

### Fixed

@@ -14,7 +18,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Fixed

- Fixed an error when attempting to load correctly targeted assemblies through https://github.com/Ne0nd0g/go-clr/pull/2
- Merged [Pull 2](https://github.com/Ne0nd0g/go-clr/pull/2) from @audibleblink that fixed an error when attempting to
load correctly targeted assemblies through

### Changed

11 changes: 6 additions & 5 deletions go-clr.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//go:build windows
// +build windows

// go-clr is a PoC package that wraps Windows syscalls necessary to load and the CLR into the current process and
// Package clr is a PoC package that wraps Windows syscalls necessary to load and the CLR into the current process and
// execute a managed DLL from disk or a managed EXE from memory
package clr

@@ -11,7 +12,7 @@ import (
"unsafe"
)

// GetInstallRuntimes is a wrapper function that returns an array of installed runtimes. Requires an existing ICLRMetaHost
// GetInstalledRuntimes is a wrapper function that returns an array of installed runtimes. Requires an existing ICLRMetaHost
func GetInstalledRuntimes(metahost *ICLRMetaHost) ([]string, error) {
var runtimes []string
enumICLRRuntimeInfo, err := metahost.EnumerateInstalledRuntimes()
@@ -210,7 +211,7 @@ func ExecuteByteArray(targetRuntime string, rawBytes []byte, params []string) (r

// LoadCLR loads the target runtime into the current process and returns the runtimehost
// The intended purpose is for the runtimehost to be reused for subsequent operations
// throught the duration of the program. Commonly used with C2 frameworks
// throughout the duration of the program. Commonly used with C2 frameworks
func LoadCLR(targetRuntime string) (runtimeHost *ICORRuntimeHost, err error) {
if targetRuntime == "" {
targetRuntime = "v4"
@@ -310,7 +311,7 @@ func ExecuteByteArrayDefaultDomain(runtimeHost *ICORRuntimeHost, rawBytes []byte

// LoadAssembly uses a previously instantiated runtimehost and loads an assembly into the default AppDomain
// and returns the assembly's methodInfo structure. The intended purpose is for the assembly to be loaded
// once but executed many times throught the duration of the program. Commonly used with C2 frameworks
// once but executed many times throughout the duration of the program. Commonly used with C2 frameworks
func LoadAssembly(runtimeHost *ICORRuntimeHost, rawBytes []byte) (methodInfo *MethodInfo, err error) {
appDomain, err := GetAppDomain(runtimeHost)
if err != nil {
@@ -329,7 +330,7 @@ func LoadAssembly(runtimeHost *ICORRuntimeHost, rawBytes []byte) (methodInfo *Me
}

// InvokeAssembly uses the MethodInfo structure of a previously loaded assembly and executes it.
// The intended purpose is for the assembly to be executed many times throught the duration of the
// The intended purpose is for the assembly to be executed many times throughout the duration of the
// program. Commonly used with C2 frameworks
func InvokeAssembly(methodInfo *MethodInfo, params []string) (stdout string, stderr string) {
var paramSafeArray *SafeArray