Saturday, May 27, 2023

Vlang Binary Debugging

Why vlang? V is a featured, productive, safe and confortable language highly compatible with c, that generates neat binaries with c-speed, the decompilation also seems quite clear as c code.
https://vlang.io/

After open the binary with radare in debug mode "-d" we proceed to do the binary recursive analysis with "aaaa" the more a's the more deep analys.



The function names are modified when the binary is crafted, if we have a function named hello in a module named main we will have the symbol main__hello, but we can locate them quicly thanks to radare's grep done with "~" token in this case applied to the "afl" command which lists all the symbols.


Being in debug mode we can use "d*" commands, for example "db" for breakpointing the function and then "dc" to start or continue execution.


Let's dissasemble the function with "pD" command, it also displays the function variables and arguments as well, note also the xref "call xref from main"


Let's take a look to the function arguments, radare detect's this three 64bits registers used on the function.


Actually the function parameter is rsi that contains a testing html to test the href extraction algorithm.


The string structure is quite simple and it's plenty of implemented methods.




With F8 we can step over the code as we were in ollydbg on linux.


Note the rip marker sliding into the code.


We can recognize the aray creations, and the s.index_after() function used to find substrings since a specific position.


If we take a look de dissasembly we sill see quite a few calls to tos3() functions.
Those functions are involved in string initialization, and implements safety checks.

  • tos(string, len)
  • tos2(byteptr)
  • tos3(charptr)

In this case I have a crash in my V code and I want to know what is crashing, just continue the execution with "dc" and see what poits the rip register.



In visual mode "V" we can see previous instructions to figure out the arguments and state.


We've located the crash on the substring operation which is something like "s2 := s1[a..b]" probably one of the arguments of the substring is out of bounds but luckily the V language has safety checks and is a controlled termination:



Switching the basic block view "space" we can see the execution flow, in this case we know the loops and branches because we have the code but this view also we can see the tos3 parameter "href=" which is useful to locate the position on the code.



When it reach the substr, we can see the parameters with "tab" command.



Looking the implementation the radare parameter calculation is quite exact.


Let's check the param values:


so the indexes are from 0x0e to 0x24 which are inside the buffer, lets continue to next iteration,
if we set a breakpoint and check every iteration, on latest iteration before the crash we have the values 0x2c to 0x70 with overflows the buffer and produces a controlled termination of the v compiled process.





More articles
  1. Pentest Tools Download
  2. Pentest Automation Tools
  3. Pentest Tools List
  4. Tools 4 Hack
  5. Hacker Hardware Tools
  6. Pentest Tools Tcp Port Scanner
  7. Hack Website Online Tool
  8. World No 1 Hacker Software
  9. Android Hack Tools Github
  10. Hacker Tools Free
  11. Hacker Hardware Tools
  12. Hacking Tools 2020
  13. Hacking Tools For Beginners
  14. Pentest Tools Linux
  15. Hack Tool Apk
  16. Termux Hacking Tools 2019
  17. Pentest Tools Windows
  18. Hack Tools 2019
  19. Hack Tools For Pc
  20. Android Hack Tools Github
  21. Hack Tools For Pc
  22. Pentest Tools Alternative
  23. Hacker Tools Mac
  24. Pentest Tools Website
  25. Blackhat Hacker Tools
  26. Wifi Hacker Tools For Windows
  27. Hacking Tools Pc
  28. Hacker Tool Kit
  29. Hacking Tools Software
  30. Hacking Tools Usb
  31. Growth Hacker Tools
  32. Hacker Hardware Tools
  33. Android Hack Tools Github
  34. Hacker Tools For Ios
  35. Hacker Tools Free Download
  36. Hacking Tools Usb
  37. Pentest Tools Find Subdomains
  38. Github Hacking Tools
  39. Pentest Tools For Ubuntu
  40. Hacking Tools For Windows Free Download
  41. Ethical Hacker Tools
  42. Top Pentest Tools
  43. How To Install Pentest Tools In Ubuntu
  44. Pentest Tools For Windows
  45. Hacking Tools Pc
  46. Top Pentest Tools
  47. Bluetooth Hacking Tools Kali
  48. Pentest Tools Open Source
  49. Pentest Tools Tcp Port Scanner
  50. Hack Tools For Mac
  51. Tools Used For Hacking
  52. Hacking Tools For Kali Linux
  53. Hacking Tools Free Download
  54. Pentest Tools Github

No comments: