Monday, 5 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 posts


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

No comments:

Post a Comment