Sunday, August 23, 2020

inBINcible Writeup - Golang Binary Reversing

This file is an 32bits elf binary, compiled from go language (i guess ... coded by @nibble_ds ;)
The binary has some debugging symbols, which is very helpful to locate the functions and api calls.

GO source functions:
-  main.main
-  main.function.001

If the binary is executed with no params, it prints "Nope!", the bad guy message.

~/ncn$ ./inbincible 
Nope!

Decompiling the main.main function I saw two things:

1. The Argument validation: Only one 16 bytes long argument is needed, otherwise the execution is finished.

2. The key IF, the decision to dexor and print byte by byte the "Nope!" string OR dexor and print "Yeah!"


The incoming channel will determine the final message.


Dexor and print each byte of the "Nope!" message.


This IF, checks 16 times if the go channel reception value is 0x01, in this case the app show the "Yeah!" message.

Go channels are a kind of thread-safe queue, a channel_send is like a push, and channel_receive is like a pop.

If we fake this IF the 16 times, we got the "Yeah!" message:

(gdb) b *0x8049118
(gdb) commands
>set {char *}0xf7edeef3 = 0x01
>c
>end

(gdb) r 1234567890123456
tarting program: /home/sha0/ncn/inbincible 1234567890123456
...
Yeah!


Ok, but the problem is not in main.main, is main.function.001 who must sent the 0x01 via channel.
This function xors byte by byte the input "1234567890123456" with a byte array xor key, and is compared with another byte array.

=> 0x8049456:       xor    %ebp,%ecx
This xor,  encode the argument with a key byte by byte

The xor key can be dumped from memory but I prefer to use this macro:

(gdb) b *0x8049456
(gdb) commands
>i r  ecx
>c
>end
(gdb) c

Breakpoint 2, 0x08049456 in main.func ()
ecx            0x12 18

Breakpoint 2, 0x08049456 in main.func ()
ecx            0x45 69

Breakpoint 2, 0x08049456 in main.func ()
ecx            0x33 51

Breakpoint 2, 0x08049456 in main.func ()
ecx            0x87 135

Breakpoint 2, 0x08049456 in main.func ()
ecx            0x65 101

Breakpoint 2, 0x08049456 in main.func ()
ecx            0x12 18

Breakpoint 2, 0x08049456 in main.func ()
ecx            0x45 69

Breakpoint 2, 0x08049456 in main.func ()
ecx            0x33 51

Breakpoint 2, 0x08049456 in main.func ()
ecx            0x87 135

Breakpoint 2, 0x08049456 in main.func ()
ecx            0x65 101

Breakpoint 2, 0x08049456 in main.func ()
ecx            0x12 18

Breakpoint 2, 0x08049456 in main.func ()
ecx            0x45 69

Breakpoint 2, 0x08049456 in main.func ()
ecx            0x33 51

Breakpoint 2, 0x08049456 in main.func ()
ecx            0x87 135

Breakpoint 2, 0x08049456 in main.func ()
ecx            0x65 101

Breakpoint 2, 0x08049456 in main.func ()
ecx            0x12 18

The result of the xor will compared with another array byte,  each byte matched, a 0x01 will be sent.

The cmp of the xored argument byte,
will determine if the channel send 0 or 1


(gdb) b *0x0804946a
(gdb) commands
>i r al
>c
>end

At this point we have the byte array used to xor the argument, and the byte array to be compared with, if we provide an input that xored with the first byte array gets the second byte array, the code will send 0x01 by the channel the 16 times.


Now web have:

xorKey=[0x12,0x45,0x33,0x87,0x65,0x12,0x45,0x33,0x87,0x65,0x12,0x45,0x33,0x87,0x65,0x12]

mustGive=[0x55,0x75,0x44,0xb6,0x0b,0x33,0x06,0x03,0xe9,0x02,0x60,0x71,0x47,0xb2,0x44,0x33]


Xor is reversible, then we can get the input needed to dexor to the expected values in order to send 0x1 bytes through the go channel.

>>> x=''
>>> for i in range(len(xorKey)):
...     x+= chr(xorKey[i] ^ mustGive[i])
... 
>>> print x

G0w1n!C0ngr4t5!!


And that's the key :) let's try it:

~/ncn$ ./inbincible 'G0w1n!C0ngr4t5!!'
Yeah!

Got it!! thanx @nibble_ds for this funny crackme, programmed in the great go language. I'm also a golang lover.


More articles


  1. Pentest Tools Kali Linux
  2. Hack Tool Apk No Root
  3. Pentest Tools Nmap
  4. Pentest Recon Tools
  5. Pentest Tools For Windows
  6. Pentest Tools For Android
  7. What Are Hacking Tools
  8. Pentest Tools Find Subdomains
  9. Hack Apps
  10. Pentest Tools Android
  11. Termux Hacking Tools 2019
  12. Hacker Tools 2020
  13. Pentest Tools Framework
  14. Pentest Tools Url Fuzzer
  15. Hacker
  16. Hacker Tools For Mac
  17. Hacking Tools Download
  18. Pentest Tools Nmap
  19. Pentest Tools Framework
  20. Hacker Tools
  21. Hack Tools For Games
  22. Hacking Tools Name
  23. Hack Tools Online
  24. Pentest Tools Github
  25. Pentest Tools For Android
  26. Pentest Tools Website Vulnerability
  27. Install Pentest Tools Ubuntu
  28. Hack Tools
  29. How To Install Pentest Tools In Ubuntu
  30. Hack Tools For Games
  31. Nsa Hack Tools
  32. New Hack Tools
  33. What Are Hacking Tools
  34. Hack Rom Tools
  35. Hack Tools Pc
  36. Pentest Tools Apk
  37. Wifi Hacker Tools For Windows
  38. What Are Hacking Tools
  39. Kik Hack Tools
  40. Hacking Tools And Software
  41. Pentest Tools Find Subdomains
  42. Underground Hacker Sites
  43. Wifi Hacker Tools For Windows
  44. Hacking Tools Hardware
  45. Hack Rom Tools
  46. Pentest Tools Windows
  47. Best Pentesting Tools 2018
  48. Black Hat Hacker Tools
  49. Hacking Tools Free Download
  50. Hacker Search Tools
  51. Hacker Tools List
  52. Best Pentesting Tools 2018
  53. New Hack Tools
  54. Hacking Tools Usb
  55. Pentest Tools Android
  56. Hacking Tools For Pc
  57. Growth Hacker Tools
  58. Hacker Tools
  59. Pentest Tools Nmap
  60. Hack Tools
  61. Tools For Hacker
  62. Pentest Tools Website
  63. Bluetooth Hacking Tools Kali
  64. Black Hat Hacker Tools
  65. Pentest Tools For Mac
  66. Termux Hacking Tools 2019
  67. Pentest Tools Apk
  68. Pentest Tools Url Fuzzer
  69. Hacker Tools For Windows

No comments: