sábado, 27 de janeiro 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.




Related news


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

Nenhum comentário:

Postar um comentário