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.




Continue reading

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

No comments:

Post a Comment