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

No hay comentarios:

Publicar un comentario