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

load with multiple args failed #7

Open
timwhitez opened this issue May 17, 2022 · 1 comment
Open

load with multiple args failed #7

timwhitez opened this issue May 17, 2022 · 1 comment

Comments

@timwhitez
Copy link

i want to load https://github.com/trustedsec/ELFLoader this program

package main

import (
	"github.com/Binject/universal"
	"io/ioutil"
	"log"
	"syscall"
	"unsafe"
)

func main() {
	image, err := ioutil.ReadFile("libELFLoader.so")

	loader, err := universal.NewLoader()
	if err != nil {
		log.Fatal(err)
	}

	library, err := loader.LoadLibrary("main", &image)
	if err != nil {
		log.Fatal(err)
	}

	g, _ := syscall.BytePtrFromString("go")

	f, _ := ioutil.ReadFile("whoami.o")

	inDataBuff := uintptr(unsafe.Pointer(&f[0]))
	inDataSize := uintptr(uint64(len(f)))

	val, err := library.Call("ELFRunner", uintptr(unsafe.Pointer(g)), inDataBuff, inDataSize, 0, 0)
	if err != nil {
		//log.Fatal(err)
	}
	log.Printf("%+v\n", val)
}

but didn't work

@pinklettuce
Copy link

You would have to modify it, taking a look at the source code I noticed that it uses: https://github.com/awgh/cppgo/blob/master/asmcall/cdecl/cdecl.go you can directly call it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants