Sunday, 4 June 2023

Reversing Some C++ Io Operations

In general decompilers are not friendly with c++ let's analyse a simple program to get familiar with it.
Let's implement a simple code that loads a file into a vector and then save the vector with following functions:

  • err
  • load
  • save
  • main


Lets identify the typical way in C++ to print to stdout with the operator "<<"


The basic_ostream is initialized writing the word "error" to the cout, and then the operator<< again to add the endl.




The Main function simply calls  "vec = load(filename)"  but the compiler modified it and passed the vector pointer as a parĂ¡meter. Then it bulds and prints "loaded  " << size << " users".
And finally saves the vector to /tmp/pwd and print "saved".
Most of the mess is basically the operator "<<" to concat and print values.
Also note that the vectors and strings are automatically deallocated when exit the function.


And here is the code:


Let's take a look to the load function, which iterates the ifs.getline() and push to the vector.
First of all there is a mess on the function definition, __return_storage_ptr is the vector.
the ifstream object ifs is initialized as a basic_ifstream and then operator! checks if it wasn't possible to open the file and in that case calls err()
We see the memset and a loop, getline read a cstr like line from the file, and then is converted to a string before pushing it to the vector. lVar1 is the stack canary value.

In this situations dont obfuscate with the vector pointer vec initialization at the begining, in this case the logic is quite clear.



The function save is a bit more tricky, but it's no more than a vector iteration and ofs writing.
Looping a simple "for (auto s : *vec)" in the decompiler is quite dense, but we can see clearly two write, the second write DAT_0010400b is a "\n"



As we see, save implememtation is quite straightforward.




Related links
  1. Pentest Tools Free
  2. Pentest Tools Find Subdomains
  3. Hacker Hardware Tools
  4. Hack Tools Online
  5. Blackhat Hacker Tools
  6. Beginner Hacker Tools
  7. Tools For Hacker
  8. Hacking Tools Hardware
  9. Easy Hack Tools
  10. Hacker
  11. Pentest Automation Tools
  12. Hacker Tools Online
  13. How To Make Hacking Tools
  14. Hack App
  15. Pentest Tools Download
  16. Hack Tools Pc
  17. Pentest Tools Port Scanner
  18. Pentest Tools List
  19. Pentest Box Tools Download
  20. Hacking Tools For Mac
  21. Install Pentest Tools Ubuntu
  22. Best Hacking Tools 2019
  23. Hak5 Tools
  24. Hacker Tools Github
  25. Hack Tools For Mac
  26. Hacker Tools Linux
  27. Hacking Tools For Games
  28. Hacking Tools Usb
  29. Hacking Tools For Pc
  30. Pentest Tools Github
  31. Hack Tools For Mac
  32. What Is Hacking Tools
  33. What Is Hacking Tools
  34. Hack Tools Download
  35. Hacking Tools Hardware
  36. Hacker
  37. Pentest Tools Github
  38. Hacker Tools Hardware
  39. Hacker Tools 2020
  40. Black Hat Hacker Tools
  41. Hacker Tools Apk Download
  42. Hacker Hardware Tools
  43. Pentest Tools For Ubuntu
  44. Hack Tool Apk No Root
  45. Hacker Hardware Tools
  46. Nsa Hack Tools
  47. Hacker Tools Free Download
  48. Hacking Tools For Windows
  49. Hacking Tools Mac
  50. Hack Tool Apk
  51. Hacking App
  52. Hacking Tools For Windows
  53. Hacker Tools For Pc
  54. Nsa Hack Tools Download
  55. Hack Rom Tools
  56. Pentest Tools Free
  57. Pentest Tools Url Fuzzer
  58. New Hacker Tools
  59. Physical Pentest Tools
  60. Hack Tools Mac
  61. Usb Pentest Tools
  62. Growth Hacker Tools
  63. Hacking Tools Windows
  64. Pentest Tools List
  65. How To Make Hacking Tools
  66. Hacking Tools For Beginners
  67. Hacker Tools
  68. Pentest Tools Framework
  69. Bluetooth Hacking Tools Kali
  70. Pentest Tools Online
  71. Pentest Tools Bluekeep
  72. Hacker Security Tools
  73. Pentest Tools Bluekeep
  74. Ethical Hacker Tools
  75. Hacking Tools Download
  76. Hacker Tools Github
  77. Pentest Tools Online
  78. Beginner Hacker Tools
  79. Underground Hacker Sites
  80. Kik Hack Tools
  81. Pentest Tools Port Scanner
  82. Hacks And Tools
  83. Growth Hacker Tools
  84. Pentest Tools Framework
  85. Hak5 Tools
  86. Hack Tools Github
  87. Pentest Tools
  88. Hacking Tools Free Download
  89. Hacker Tools
  90. Hack Tools For Mac
  91. Pentest Tools Online
  92. Hacker Tools Software
  93. Hacker Tools Linux
  94. Hack Tools For Games
  95. Nsa Hack Tools Download
  96. Pentest Tools Apk
  97. Best Pentesting Tools 2018
  98. Hacking Tools For Games
  99. Pentest Tools Windows
  100. Hacking Tools For Windows Free Download
  101. Nsa Hack Tools Download
  102. Underground Hacker Sites
  103. Pentest Tools Free
  104. Usb Pentest Tools
  105. Hacking Tools For Games
  106. Hacker Hardware Tools
  107. Hack Tools Online
  108. Hacker Tools Apk
  109. Hak5 Tools
  110. Hacker Tools List
  111. Hacker Tools For Windows
  112. Pentest Tools Android
  113. Hacking Tools For Kali Linux
  114. Hacking Tools For Kali Linux
  115. Pentest Tools Linux
  116. Best Hacking Tools 2019
  117. Hacking Tools Software
  118. Hacker Tools Github
  119. Hacking Tools Windows
  120. Nsa Hack Tools Download
  121. Nsa Hack Tools
  122. Hacking Tools 2019
  123. Pentest Reporting Tools
  124. Pentest Tools Apk
  125. Pentest Tools Tcp Port Scanner
  126. Pentest Tools Nmap
  127. Hackrf Tools
  128. Hacker Search Tools
  129. Pentest Tools Free
  130. Hacker
  131. Pentest Tools Find Subdomains
  132. Pentest Tools Kali Linux
  133. Hackers Toolbox
  134. Wifi Hacker Tools For Windows
  135. Hacker Tools For Mac
  136. Underground Hacker Sites
  137. Hacking Tools Windows
  138. Growth Hacker Tools
  139. Hack Tools Pc
  140. Pentest Tools Website
  141. Nsa Hack Tools Download
  142. Hacking Tools For Windows Free Download
  143. Hacking Tools Usb
  144. Hacker Security Tools
  145. Hack Tools Online
  146. Nsa Hack Tools Download
  147. Hacker Tools
  148. Hacker Techniques Tools And Incident Handling
  149. Pentest Tools Apk
  150. New Hacker Tools
  151. Pentest Tools Url Fuzzer
  152. Hacker Tools Online
  153. Hacking Tools For Windows 7
  154. Hacking Tools Usb
  155. Pentest Tools Find Subdomains
  156. Pentest Tools Nmap
  157. Hack Rom Tools
  158. Hackers Toolbox
  159. How To Hack
  160. Hacker Tools Github
  161. Pentest Tools Download
  162. Github Hacking Tools
  163. Hacking Tools For Games
  164. Pentest Tools Subdomain
  165. Pentest Tools Windows
  166. Hackers Toolbox
  167. Hacker
  168. Pentest Tools Windows
  169. Hack Tools For Windows
  170. Pentest Tools Website Vulnerability

No comments:

Post a Comment