2023-05-31 16:17:03 +07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/alecthomas/kong"
|
2023-05-31 16:31:52 +07:00
|
|
|
"ios-wrapper/pkg/ios/macho"
|
2023-05-31 16:17:03 +07:00
|
|
|
|
2023-05-31 16:31:52 +07:00
|
|
|
"bytes"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
2023-05-31 16:17:03 +07:00
|
|
|
)
|
|
|
|
|
|
|
|
type Argument struct {
|
|
|
|
One string `arg short:"o" required help:"" type:"existingfile"`
|
|
|
|
Two string `arg short:"t" required help:"" type:"existingfile"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
var cli Argument
|
|
|
|
kong.Parse(&cli)
|
|
|
|
|
2023-05-31 16:31:52 +07:00
|
|
|
compare(cli.One, cli.Two)
|
2023-05-31 16:17:03 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
func compare(one string, two string) {
|
|
|
|
f1, _ := os.OpenFile(one, os.O_RDONLY, 0644)
|
|
|
|
f2, _ := os.OpenFile(two, os.O_RDONLY, 0644)
|
|
|
|
|
2023-05-31 16:31:52 +07:00
|
|
|
var mc1 macho.MachoContext
|
|
|
|
var mc2 macho.MachoContext
|
2023-05-31 16:17:03 +07:00
|
|
|
mc1.ParseFile(f1, 0)
|
|
|
|
mc2.ParseFile(f2, 0)
|
|
|
|
|
2023-05-31 16:31:52 +07:00
|
|
|
s1 := mc1.FindSection("__text")
|
|
|
|
s2 := mc2.FindSection("__text")
|
2023-05-31 16:17:03 +07:00
|
|
|
|
2023-05-31 16:31:52 +07:00
|
|
|
if s1.Size() == s2.Size() {
|
|
|
|
fmt.Println("Size is equal")
|
|
|
|
} else {
|
|
|
|
fmt.Printf("%x <> %x\n", s1.Size(), s2.Size())
|
|
|
|
}
|
2023-05-31 16:17:03 +07:00
|
|
|
|
2023-05-31 16:31:52 +07:00
|
|
|
data1 := mc1.Cut(uint64(s1.Offset()), s1.Size())
|
|
|
|
data2 := mc1.Cut(uint64(s2.Offset()), s2.Size())
|
|
|
|
if bytes.Compare(data1, data2) == 0 {
|
|
|
|
fmt.Println("Data is equal")
|
|
|
|
}
|
2023-05-31 16:17:03 +07:00
|
|
|
}
|