domingo, enero 21, 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.




More articles

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