fix following review - docstring

This commit is contained in:
ayoul3
2020-08-05 00:29:51 +02:00
parent f34e226a36
commit 04f1a74c88
4 changed files with 12 additions and 7 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ func main() {
fmt.Printf("[+] DLL Return Code: %d\n", ret)
fmt.Println("[+] Executing EXE from memory")
exebytes, err := ioutil.ReadFile(`hellworld.exe`)
exebytes, err := ioutil.ReadFile("helloworld.exe")
if err != nil {
log.Fatal(err)
}
+3 -4
View File
@@ -106,7 +106,7 @@ func ExecuteDLLFromDisk(dllpath, typeName, methodName, argument string) (retCode
// ExecuteByteArray is a wrapper function that will automatically load the latest supported framework into the current
// process using the legacy APIs, then load and execute an executable from memory. It takes in a byte array of the
// executable to load and run and returns the return code. It currently does not support any arguments on the entry point
// executable to load and run and returns the return code. You can supply an array of strings as command line arguments.
func ExecuteByteArray(rawBytes []byte, params []string) (retCode int32, err error) {
retCode = -1
metahost, err := GetICLRMetaHost()
@@ -175,9 +175,8 @@ func ExecuteByteArray(rawBytes []byte, params []string) (retCode int32, err erro
methodSignature := readUnicodeStr(unsafe.Pointer(methodSignaturePtr))
if expectsParams(methodSignature) {
paramPtr, err = PrepareParameters(params)
if err != nil {
return -1, err
if paramPtr, err = PrepareParameters(params); err != nil {
return
}
}
+1
View File
@@ -117,6 +117,7 @@ func (obj *MethodInfo) Invoke_3(variantObj Variant, parameters uintptr, pRetVal
return ret
}
// GetString returns a string version of the method's signature
func (obj *MethodInfo) GetString(addr *uintptr) error {
ret, _, _ := syscall.Syscall(
obj.vtbl.get_ToString,
+7 -2
View File
@@ -30,8 +30,8 @@ type SafeArrayBound struct {
lLbound int32
}
// CreateSafeArray is a wrapper function that takes in a Go byte array and creates a SafeArray by making two syscalls
// and copying raw memory into the correct spot.
// CreateSafeArray is a wrapper function that takes in a Go byte array and creates a SafeArray containing unsigned bytes
// by making two syscalls and copying raw memory into the correct spot.
func CreateSafeArray(rawBytes []byte) (unsafe.Pointer, error) {
saPtr, err := CreateEmptySafeArray(0x11, len(rawBytes)) // VT_UI1
@@ -53,6 +53,8 @@ func CreateSafeArray(rawBytes []byte) (unsafe.Pointer, error) {
}
// CreateEmptySafeArray is a wrapper function that takes an array type and a size and creates a safe array with corresponding
// properties. It returns a pointer to that empty array.
func CreateEmptySafeArray(arrayType int, size int) (unsafe.Pointer, error) {
modOleAuto := syscall.MustLoadDLL("OleAut32.dll")
procSafeArrayCreate := modOleAuto.MustFindProc("SafeArrayCreate")
@@ -75,6 +77,8 @@ func CreateEmptySafeArray(arrayType int, size int) (unsafe.Pointer, error) {
}
// SysAllocString converts a Go string to a BTSR string, that is a unicode string prefixed with its length.
// It returns a pointer to the string's content.
func SysAllocString(str string) (unsafe.Pointer, error) {
modOleAuto := syscall.MustLoadDLL("OleAut32.dll")
sysAllocString := modOleAuto.MustFindProc("SysAllocString")
@@ -88,6 +92,7 @@ func SysAllocString(str string) (unsafe.Pointer, error) {
return unsafe.Pointer(ret), nil
}
// SafeArrayPutElement pushes an element to the safe array at a given index
func SafeArrayPutElement(array, btsr unsafe.Pointer, index int) (err error) {
modOleAuto := syscall.MustLoadDLL("OleAut32.dll")
safeArrayPutElement := modOleAuto.MustFindProc("SafeArrayPutElement")