B2R2-org / B2R2

B2R2 is a collection of useful algorithms, functions, and tools for binary analysis.
https://b2r2.org
MIT License
413 stars 62 forks source link

I think I found a B2R2 LowUIR bug. #50

Closed sanghwa95 closed 6 months ago

sanghwa95 commented 6 months ago

Describe the bug 안녕하세요. 교수님, 제가 버그를 찾은 거 같아 문의드립니다.

https://developer.arm.com/documentation/ddi0596/2021-12/Base-Instructions/BL--Branch-with-Link-

위 ARM 문서에 따르면 16진수 기계어 코드 94000007는 현재 주소에서 7 * 4 = 28(0x1C)만큼 더한 값으로 점프하라는 의미인데요. 바이너리를 B2R2 LowUIR로 리프팅해보면 2EDB80: Jmp (PC + [0x2EDB9C:I64]:I64)라고 나옵니다. 0x2EDB80 + 0x1C = 0x2EDB9C 주소로 점프를 해야하기 때문에 아래가 맞는 표현같은데요. 2EDB80: Jmp (PC + 0x1C:I64):I64

To Reproduce [\<EntryPoint>] let main argv = let address = 0x2EDB80UL let isa = ISA.OfString "aarch64" let hdl = BinHandler.Init (isa, "default_flutter_3.so") let ins = BinHandler.ParseInstr hdl address let statements = BinHandler.LiftInstr hdl ins statements |> Seq.iteri (fun i stmt -> let stmtStr = B2R2.BinIR.LowUIR.Pp.stmtToString stmt printf "%X: %A\n" address stmtStr) 0

아래는 so파일 링크입니다. https://github.com/sanghwa95/tmp/blob/main/default_flutter_3.so

Environment (please complete the following information):

Additional context AST로 출력하는 코드를 LowUIR로 출력하도록 코드 수정했습니다.

sijung07 commented 6 months ago

안녕하세요. B2R2에 관심가져주시고, 버그 리포트 해주셔서 감사합니다. 현재 버그는 새 버전에서 고쳐진 버그이고, 새 버전은 곳 올릴 예정입니다. 감사합니다.

기존 버전 리프팅 (현재 github)

[94 00 00 07]
(4) {
X30 := (PC + 0x4:I64)
ijmp (PC + [0x2edb9c:I64]:I64)
} // 4

새 버전 리프팅

[94 00 00 07]
(4) {
X30 := 0x2edb84:I64
ijmp 0x2edb9c:I64
} // 4
sangkilc commented 6 months ago

We are maintaining an internal version, and this bug was known for long. The internal version has many changes including many bug fixes, and we will release it sooner or later. Thanks for your report anyways.

sanghwa95 commented 6 months ago

Thank you for the kind reply. I hope the new version release as soon as possible.