mirror of
https://github.com/thunderbrewhq/binana.git
synced 2025-12-12 01:42:29 +00:00
feat(binana): improve documentation, add a way to import information into IDA
This commit is contained in:
parent
063790577d
commit
061609ed2c
19 changed files with 8072 additions and 20 deletions
38
go/cmd/binana/cmd/ida_gen.go
Normal file
38
go/cmd/binana/cmd/ida_gen.go
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/thunderbrewhq/binana/go/profile"
|
||||
)
|
||||
|
||||
var ida_gen = &cobra.Command{
|
||||
Use: "ida-gen",
|
||||
Short: "Generate IDC file using symbol file",
|
||||
Run: ida_gen_func,
|
||||
}
|
||||
|
||||
func ida_gen_func(cmd *cobra.Command, args []string) {
|
||||
// get command line arguments
|
||||
// module_name, err := cmd.Flags().GetString("module-name")
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
|
||||
game_profile_directory, err := cmd.Flags().GetString("game")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
game_profile, err := profile.Open(game_profile_directory)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if err = game_profile.CreateIDAFiles(); err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
|
@ -35,6 +35,9 @@ func init() {
|
|||
// when this action is called directly.
|
||||
// rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
|
||||
ida_gen.Flags().StringP("game", "g", "3.3.5a", "the game profile")
|
||||
rootCmd.AddCommand(ida_gen)
|
||||
|
||||
x64dbg_gen.Flags().StringP("game", "g", "3.3.5a", "the game profile")
|
||||
x64dbg_gen.Flags().StringP("module-name", "m", "wow.exe", "the name of the module")
|
||||
x64dbg_gen.Flags().StringP("base-address", "b", "00400000", "the base address of the module")
|
||||
|
|
|
|||
55
go/profile/ida_generate_files.go
Normal file
55
go/profile/ida_generate_files.go
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
package profile
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
"github.com/thunderbrewhq/binana/go/symfile"
|
||||
)
|
||||
|
||||
func (profile *Profile) generate_symbols_idc() (err error) {
|
||||
|
||||
var (
|
||||
output_file *os.File
|
||||
)
|
||||
output_file, err = os.Create(filepath.Join(profile.Directory, "ida", "import.idc"))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Fprintf(output_file, "#include <idc.idc>\n")
|
||||
fmt.Fprintf(output_file, "\n")
|
||||
fmt.Fprintf(output_file, "static main() {\n")
|
||||
fmt.Fprintf(output_file, " // Make names\n")
|
||||
|
||||
for _, symbol := range profile.SymbolTable.Entries {
|
||||
quoted_name := strconv.Quote(symbol.Name)
|
||||
address := fmt.Sprintf("0x%08X", symbol.StartAddress)
|
||||
fmt.Fprintf(output_file, " set_name(%s, %s);\n", address, quoted_name)
|
||||
}
|
||||
|
||||
fmt.Fprintf(output_file, " // Make functions\n")
|
||||
|
||||
for _, function_symbol := range profile.SymbolTable.Entries {
|
||||
if function_symbol.Kind == symfile.Function {
|
||||
address := fmt.Sprintf("0x%08X", function_symbol.StartAddress)
|
||||
fmt.Fprintf(output_file, " set_func_start(%s, %s);\n", address, address)
|
||||
if function_symbol.EndAddress != 0 {
|
||||
end_address := fmt.Sprintf("0x%08X", function_symbol.EndAddress)
|
||||
fmt.Fprintf(output_file, " set_func_end(%s, %s);\n", address, end_address)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Fprintf(output_file, "}\n")
|
||||
|
||||
output_file.Close()
|
||||
return
|
||||
}
|
||||
|
||||
func (profile *Profile) CreateIDAFiles() (err error) {
|
||||
err = profile.generate_symbols_idc()
|
||||
return
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue