domingo, 21 de enero de 2024

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 articles


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

No hay comentarios:

Publicar un comentario