Powered by Blogger.

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

0 comments

Post a Comment