May 30, 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 word


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