Friday, June 2, 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)





Related word


  1. Kik Hack Tools
  2. Hacking Tools For Games
  3. Hacker Tools Mac
  4. Hack Tools Mac
  5. Physical Pentest Tools
  6. Tools 4 Hack
  7. Hacking Tools For Pc
  8. Pentest Automation Tools
  9. Hacking Tools For Beginners
  10. Hack Website Online Tool
  11. Hacking Tools Software
  12. Tools 4 Hack
  13. Hacker Tools Mac
  14. Hack Website Online Tool
  15. Hak5 Tools
  16. Physical Pentest Tools
  17. Pentest Tools Online
  18. Hacking Tools For Windows Free Download
  19. Hack Website Online Tool
  20. Hack Tools For Pc
  21. Growth Hacker Tools
  22. Pentest Reporting Tools
  23. Pentest Tools Subdomain
  24. Hacking Tools Free Download
  25. Easy Hack Tools
  26. Pentest Tools Bluekeep
  27. Hack Tool Apk No Root
  28. Hacking Tools Free Download
  29. Hacker Tools List
  30. Hak5 Tools
  31. Hack Tools
  32. Hacker Tools Apk Download
  33. Hacking Tools Kit
  34. Hack Rom Tools
  35. Hacking Apps
  36. Pentest Tools Subdomain
  37. Black Hat Hacker Tools
  38. Hacking Tools Github
  39. Ethical Hacker Tools
  40. Hacker Tools Online
  41. Hack Tools Github
  42. Pentest Tools Website Vulnerability
  43. Hacker Techniques Tools And Incident Handling
  44. Hack Website Online Tool
  45. Hack Tools For Mac
  46. Hak5 Tools
  47. Hacking Tools For Windows Free Download
  48. Hackers Toolbox
  49. Hacker Tools Free
  50. Pentest Tools Framework
  51. Hack Tools Pc
  52. Hack Tools Download
  53. Usb Pentest Tools
  54. Pentest Box Tools Download
  55. Hacker
  56. Hacker Tools 2019
  57. Ethical Hacker Tools
  58. Termux Hacking Tools 2019
  59. Pentest Box Tools Download
  60. Pentest Tools Bluekeep
  61. Nsa Hack Tools
  62. Hacker Tools Linux
  63. Hacker Tools Apk Download
  64. Termux Hacking Tools 2019
  65. Hacker Tools Apk
  66. Hacker Tools
  67. Hacking Tools Online
  68. Hak5 Tools
  69. What Is Hacking Tools
  70. Pentest Tools Url Fuzzer
  71. Underground Hacker Sites
  72. Pentest Box Tools Download
  73. Hacker Tools Linux
  74. Hackrf Tools
  75. Pentest Tools For Ubuntu
  76. Kik Hack Tools
  77. Pentest Tools Github
  78. Hacker Tools Hardware
  79. Hack Tools For Mac
  80. Hack Rom Tools
  81. Install Pentest Tools Ubuntu
  82. Tools Used For Hacking
  83. Hack Tools For Ubuntu
  84. Hacker Techniques Tools And Incident Handling
  85. Usb Pentest Tools
  86. Hacking Tools Github
  87. Hacking Tools Online
  88. Tools For Hacker
  89. Pentest Tools Nmap
  90. Pentest Tools Framework
  91. Hackers Toolbox
  92. Hacker Tools List
  93. New Hack Tools
  94. Hacker Tools For Windows
  95. What Are Hacking Tools
  96. Hack Apps
  97. Hacking Tools For Games
  98. Pentest Tools Website Vulnerability
  99. Best Pentesting Tools 2018
  100. Pentest Tools For Windows
  101. Nsa Hack Tools
  102. How To Install Pentest Tools In Ubuntu
  103. Hacker Techniques Tools And Incident Handling
  104. Github Hacking Tools
  105. Tools For Hacker
  106. Pentest Tools Kali Linux
  107. Physical Pentest Tools
  108. Hacker Tools Github
  109. Pentest Tools Download
  110. Beginner Hacker Tools
  111. Pentest Automation Tools
  112. Hacking Tools And Software
  113. Hacker Tools
  114. Hack Tools For Games
  115. Hacker Tools For Mac
  116. Growth Hacker Tools
  117. Tools 4 Hack
  118. Hackers Toolbox
  119. Hacker Hardware Tools
  120. Hack Tools Online
  121. Hack Tools Download
  122. Top Pentest Tools
  123. Hack Website Online Tool
  124. Hacker Tools Software
  125. Hacker Tools Mac
  126. Hacker Tools
  127. Wifi Hacker Tools For Windows
  128. Pentest Tools Website
  129. Hacking Tools Name
  130. Hacker Tools Linux
  131. Pentest Tools For Mac
  132. Nsa Hacker Tools
  133. Growth Hacker Tools

No comments: