Saturday, 27 May 2023

Introduction To Reversing Golang Binaries


Golang binaries are a bit hard to analyze but there are some tricks to locate the things and view what is doing the code.






Is possible to list all the go files compiled in the binary even in an striped binaries, in this case we have only one file gohello.go this is a good clue to guess what is doing the program.


On stripped binaries the runtime functions are not resolved so is more difficult to locate the user algorithms:


If we start from the entry point, we will found this mess:

The golang string initialization are encoded and is not displayed on the strings window.


How to locate main?  if its not stripped just bp on [package name].main for example bp main.main, (you can locate the package-name searching strings with ".main")


And here is our main.main:


The code is:

So in a stripped binary we cant find the string "hello world" neither the initialization 0x1337 nor the comparator 0x1337, all this is obfuscated.

The initialization sequence is:


The procedure for locating main.main in stripped binaries is:
1. Click on the entry point and locate the runtime.mainPC pointer:



2. click on runtime.main function (LAB_0042B030):


3. locate the main.main call after the zero ifs:



4. click on it and here is the main:




The runtime is not obvious for example the fmt.Scanf() call perform several internal calls until reach the syscall, and in a stripped binary there are no function names.



In order to identify the functions one option is compile another binary with symbols and make function fingerprinting.

In Ghidra we have the script golang_renamer.py which is very useful:


After applying this plugin the main looks like more clear:




This script is an example of function fingerprinting, in this case all the opcodes are included on the crc hashing:
# This script fingerprints the functions
#@author: sha0coder
#@category fingerprinting

print "Fingerprinting..."

import zlib


# loop through program functions
function = getFirstFunction()
while function is not None:
name = str(function.getName())
entry = function.getEntryPoint()
body = function.getBody()
addresses = body.getAddresses(True)

if not addresses.hasNext():
# empty function
continue

ins = getInstructionAt(body.getMinAddress())
opcodes = ''
while ins and ins.getMinAddress() <= body.getMaxAddress():
for b in ins.bytes:
opcodes += chr(b & 0xff)
ins = getInstructionAfter(ins)
crchash = zlib.crc32(opcodes) & 0xffffffff

print name, hex(crchash)


function = getFunctionAfter(function)





More articles
  1. Pentest Tools Subdomain
  2. Hacking Tools And Software
  3. Hacker Tool Kit
  4. Underground Hacker Sites
  5. Hack App
  6. Hacking Tools For Kali Linux
  7. Computer Hacker
  8. Hack Tool Apk
  9. Hack Apps
  10. Hacker Tools Linux
  11. Pentest Tools Free
  12. Pentest Reporting Tools
  13. World No 1 Hacker Software
  14. Pentest Tools Download
  15. Hacking Tools Software
  16. Hacking Tools 2020
  17. Best Hacking Tools 2020
  18. Hacking Tools Online
  19. Hack Tool Apk
  20. Hacking Tools Kit
  21. Hack Tools Online
  22. Physical Pentest Tools
  23. Best Hacking Tools 2019
  24. Pentest Tools Android
  25. Hacking Tools And Software
  26. Hacker Tools Mac
  27. Nsa Hack Tools Download
  28. Hacking Tools Software
  29. Hacker Hardware Tools
  30. Hack Tools For Mac
  31. Hack Website Online Tool
  32. Hacking Tools Software
  33. Pentest Tools Free
  34. Pentest Tools Github
  35. Hacker Tools Windows
  36. Hack Tools
  37. Underground Hacker Sites
  38. Hak5 Tools
  39. Pentest Tools Url Fuzzer
  40. Pentest Tools Website
  41. Github Hacking Tools
  42. Pentest Box Tools Download
  43. Hacking Tools Software
  44. Computer Hacker
  45. Hacking Tools Windows
  46. Hacker Tools Apk Download
  47. Hacking Tools And Software
  48. Hack Tools Download
  49. Hack Tool Apk
  50. Hacker Tools Apk Download
  51. Wifi Hacker Tools For Windows
  52. Hacker Tools For Pc
  53. Black Hat Hacker Tools
  54. Hacker Tools Apk Download
  55. Hacking Tools Usb
  56. Free Pentest Tools For Windows
  57. Pentest Tools Linux
  58. Hacking Tools Github
  59. Hack Tools For Mac
  60. Hacking Tools 2020
  61. Hacker Techniques Tools And Incident Handling
  62. What Are Hacking Tools
  63. Hacker Tools For Ios
  64. Pentest Tools Apk
  65. Pentest Tools Github
  66. Hack Apps
  67. Pentest Tools Android
  68. Hack Tools For Windows
  69. Hack Tools For Pc
  70. Hacking Tools Software
  71. What Is Hacking Tools
  72. Tools For Hacker
  73. Blackhat Hacker Tools
  74. Ethical Hacker Tools
  75. Pentest Tools Bluekeep
  76. Hacking Tools For Windows
  77. Free Pentest Tools For Windows
  78. Hack Tools For Games
  79. Bluetooth Hacking Tools Kali
  80. Pentest Tools Online
  81. Hack Tools Pc
  82. Hack Tools
  83. Hack Tools For Windows
  84. Hacking Tools Kit
  85. Pentest Tools Free
  86. Pentest Tools Website
  87. Hacking Tools Hardware
  88. Hacking Tools For Mac
  89. Hack Tools For Games
  90. How To Make Hacking Tools
  91. Tools 4 Hack
  92. Pentest Tools For Windows
  93. Hacking Tools 2019
  94. Tools Used For Hacking
  95. Tools Used For Hacking
  96. Pentest Tools Windows
  97. Hack Tools For Games
  98. Hacking Tools Usb

No comments:

Post a Comment