Monday, January 22, 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 word

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

No comments:

Post a Comment