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

No hay comentarios:

Publicar un comentario