Mga Pahina

Tuesday, January 23, 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 posts


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

No comments:

Post a Comment