Gambar Kenangan

Gambar Kenangan
Kami yang ceria

Ahad, 4 Jun 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 news


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