goof

Goof (Go Object Finder) is a package that does the unthinkable to your binary

  • 所有者: zeebo/goof
  • 平台:
  • 許可證: Apache License 2.0
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

Goof

Goof lets you call functions in your binary with just the string of their
name. How?

var troop goof.Troop
out, err := troop.Call("fmt.Fprintf", os.Stdout, "hello %s", []interface{}{"world"})
if err != nil { // some error calling the function
	return err
}
n, err := out[0].(int), out[1].(error)
if err != nil {
	return err
}
fmt.Printf("wrote %d bytes\n", n)

Caveat: you have to have called fmt.Fprintf elsewhere in your binary.

Goof lets you get access to globals in your binary with just the string of
their name. How?

var troop goof.Troop
rv, err := troop.Global("net/http.DefaultServeMux")
if err != nil { // couldn't find it
	return err
}
// rv contains an addressable reflect.Value of the default ServeMux!

Caveat: the global must be used elsewhere in the binary somehow.

Goof lets you get access to all of the reflect.Types in your binary. How?

var troop goof.Troop
types, err := troop.Types()
if err != nil { // something went wrong getting them
	return err
}
for _, typ := range types {
	fmt.Println(typ)
}

Caveat: the types must be possible outputs to reflect.TypeOf(val) in your binary.

Usage

You should probably just make a single Troop in your binary and use that
everywhere since it does a lot of caching and work on first use.

How?

It loads up the dwarf information of any binary it's loaded in and then does
a bunch of unsafe tom foolery to perform these dirty deeds. How unsafe is it?

  • Reusing needles unsafe.
  • Jumping into a shark tank with a steak swimming suit unsafe.
  • Carnival ride unsafe.
  • Driving on the wrong side of the highway blindfolded unsafe.

Should I use this?

Do you really have to ask? OF COURSE! If you do, please let me know what terrible
idea this enabled. I'm very interested.

Testimonials

"I can't wait to get some goof in my manhole!" - @jtolds

"README is hilarious :joy:"

"Now I just need to come up with something horrendously risky to use this for..."

主要指標

概覽
名稱與所有者zeebo/goof
主編程語言Go
編程語言Go (語言數: 1)
平台
許可證Apache License 2.0
所有者活动
創建於2017-04-18 22:20:06
推送於2024-05-28 18:01:48
最后一次提交2024-05-28 14:01:44
發布數0
用户参与
星數154
關注者數5
派生數12
提交數21
已啟用問題?
問題數5
打開的問題數2
拉請求數1
打開的拉請求數1
關閉的拉請求數0
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?