Tuesday, 30 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)





Read more
  1. Hacks And Tools
  2. Hacker Security Tools
  3. Hacking Tools Kit
  4. Hacking App
  5. Hacks And Tools
  6. Pentest Tools Subdomain
  7. Nsa Hack Tools
  8. Hacker Tools Free
  9. New Hack Tools
  10. Pentest Tools For Ubuntu
  11. Hackrf Tools
  12. Pentest Tools Tcp Port Scanner
  13. Android Hack Tools Github
  14. Hacking Tools Name
  15. Tools For Hacker
  16. Pentest Tools Windows
  17. Pentest Tools Kali Linux
  18. Pentest Tools Apk
  19. Hacking Tools Pc
  20. Hacker Search Tools
  21. Hack Tool Apk No Root
  22. Hack Tools For Pc
  23. Pentest Tools Free
  24. Hacking App
  25. Hacking Tools For Windows 7
  26. Pentest Tools Website Vulnerability
  27. Hacker Security Tools
  28. Hacker Tools Mac
  29. Pentest Tools Windows
  30. Pentest Tools For Windows
  31. Usb Pentest Tools
  32. Pentest Tools Github
  33. Pentest Reporting Tools
  34. Best Hacking Tools 2019
  35. Hacker Tools
  36. Hacking Tools Windows
  37. What Is Hacking Tools
  38. Hacking Tools 2019
  39. Hacker Tool Kit
  40. What Is Hacking Tools
  41. Pentest Tools Review
  42. Pentest Recon Tools
  43. Pentest Tools
  44. Hack Tool Apk No Root
  45. Hacking Tools Kit
  46. Hacking Tools Online
  47. Hacking Tools Software
  48. Hacking Tools For Pc
  49. Hacking Tools For Windows
  50. Hacking Apps
  51. Hacking Apps
  52. Hacking Tools For Kali Linux
  53. Hack Tools For Games
  54. Pentest Tools Windows
  55. Pentest Tools Download
  56. Hack App
  57. Hak5 Tools
  58. Hacking Tools For Pc
  59. Hack Tools
  60. Pentest Tools Kali Linux
  61. Hacking Tools Pc
  62. Hacking Tools For Games
  63. World No 1 Hacker Software
  64. Hack And Tools
  65. Github Hacking Tools
  66. Pentest Tools Online
  67. World No 1 Hacker Software
  68. Hack Tools For Mac
  69. Hacker Tools Mac
  70. Hacking Tools Free Download
  71. Pentest Tools Port Scanner
  72. Pentest Tools Website Vulnerability
  73. Hacking Tools For Kali Linux
  74. Hacking Tools Pc
  75. Pentest Automation Tools
  76. Hacking Tools For Windows Free Download
  77. Pentest Tools Website Vulnerability
  78. Computer Hacker
  79. Game Hacking
  80. Pentest Tools Nmap
  81. Termux Hacking Tools 2019
  82. Hacking Tools Software
  83. Tools 4 Hack
  84. Pentest Tools Open Source
  85. Hacking Tools Name
  86. Pentest Tools Open Source
  87. Pentest Tools Port Scanner
  88. Pentest Tools List
  89. Hacking Tools For Pc
  90. Hack Tools 2019
  91. What Is Hacking Tools
  92. Hack Apps
  93. Pentest Tools For Android
  94. Hacker Tools Windows
  95. Hacking Tools Mac
  96. Hack And Tools
  97. Pentest Tools Github
  98. Pentest Tools Android
  99. Hacker Tools Apk Download
  100. Bluetooth Hacking Tools Kali
  101. Hacking Tools Download
  102. Hacker
  103. Pentest Tools Android
  104. Hacking Tools Windows
  105. World No 1 Hacker Software
  106. Hacking Tools Hardware
  107. Easy Hack Tools
  108. Pentest Tools Review
  109. Pentest Tools For Ubuntu
  110. How To Hack
  111. Hacker Tools For Mac
  112. Pentest Tools Download
  113. Pentest Tools Port Scanner
  114. Hack Tools 2019
  115. Hacking Apps
  116. World No 1 Hacker Software
  117. Hack Tools For Mac
  118. Hacking Tools Mac
  119. Hacking Tools For Pc
  120. Hack Tools 2019
  121. Hacking Tools Online
  122. Hacking Tools For Kali Linux
  123. Pentest Tools Download
  124. Pentest Tools For Ubuntu
  125. Hacking Tools For Games
  126. Pentest Automation Tools
  127. Hacker Hardware Tools
  128. Pentest Tools List
  129. Pentest Tools For Ubuntu
  130. Pentest Reporting Tools
  131. Pentest Tools Apk
  132. Hack App
  133. Hacking Tools For Kali Linux
  134. Hacker Tools Linux
  135. Hacks And Tools

No comments:

Post a Comment