viernes, 19 de enero de 2024

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.




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

No hay comentarios: