Skip to content

Instantly share code, notes, and snippets.

@Jinmo
Last active June 6, 2019 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jinmo/3ddcbdf870e9cabbb8b9b9f259890dd1 to your computer and use it in GitHub Desktop.
Save Jinmo/3ddcbdf870e9cabbb8b9b9f259890dd1 to your computer and use it in GitHub Desktop.
package main
import (
"swig/plugin"
"swig/ida_kernwin"
)
func InitPlugin() int {
ida_kernwin.Msg("console!")
return plugin.PLUGIN_KEEP
}
func RunPlugin(arg int) bool {
switch arg {
case 0:
ida_kernwin.Warning("warning")
case 1:
ida_kernwin.Info("info")
}
return true
}
func init() {
plugin.InitPlugin(plugin.Plugin{
Flags: plugin.PLUGIN_FIX,
Name: "jinmo123",
Init: InitPlugin,
Run: RunPlugin,
})
}
func main() {}
import ctypes, subprocess, tempfile
path = os.path.expanduser('~/idasdk70')
os.environ['GOPATH'] = path
os.putenv('GOPATH', path)
def run_script(script):
with open('script.go', 'wb') as f:
f.write(script)
dll = tempfile.NamedTemporaryFile(suffix='.dll')
dll.close()
p = subprocess.Popen(['go', 'build', '-buildmode', 'c-shared', '-o', dll.name, 'script.go'], stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
print stderr
ctypes.WinDLL(dll.name)
run_script(r"""
package main
import (
"swig/ida_kernwin"
)
func init() {
ida_kernwin.Msg("hello!\n")
}
func main() {}
""".strip())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment