Saterdag 20 Januarie 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. Hacking Tools Online
  2. Pentest Reporting Tools
  3. Hack Tools For Windows
  4. Hacker Tools Software
  5. Hack Rom Tools
  6. Hack Tools Mac
  7. Pentest Box Tools Download
  8. Hack Tools 2019
  9. Pentest Tools Nmap
  10. Hack App
  11. Usb Pentest Tools
  12. Hacking Apps
  13. Hack Apps
  14. Hack Tools
  15. Pentest Tools Find Subdomains
  16. Hacking Tools For Windows Free Download
  17. Hacking Tools For Windows Free Download
  18. Hacker Tools 2019
  19. Hacking Tools For Games
  20. Pentest Automation Tools
  21. Pentest Tools Open Source
  22. Hack And Tools
  23. Hacking Tools For Games
  24. Pentest Tools For Mac
  25. Pentest Tools For Ubuntu
  26. Pentest Tools Github
  27. How To Make Hacking Tools
  28. Pentest Tools Subdomain
  29. Easy Hack Tools
  30. Computer Hacker
  31. Hacking Tools For Kali Linux
  32. Hacking Tools For Pc
  33. Tools 4 Hack
  34. How To Make Hacking Tools
  35. Nsa Hack Tools Download
  36. Best Hacking Tools 2020
  37. Pentest Tools Website
  38. Hacker Tools For Pc
  39. Pentest Tools Android
  40. Hack Tools For Windows
  41. Hack Tools
  42. Underground Hacker Sites
  43. Hacker Tools Mac
  44. Kik Hack Tools
  45. Pentest Tools Find Subdomains
  46. Hacker Tools Free
  47. Pentest Tools Bluekeep
  48. Pentest Tools Website
  49. Hack Tools Online
  50. Hack Apps
  51. Pentest Tools Online
  52. Hacker Tools Apk Download
  53. Pentest Tools Review
  54. Pentest Tools Alternative
  55. Tools Used For Hacking
  56. Hacking Tools Pc
  57. Hacker Tools Apk
  58. Hackrf Tools
  59. Hacking Tools For Windows 7
  60. Android Hack Tools Github
  61. Pentest Tools For Windows
  62. Hack Tools Mac
  63. Hack Tools Mac
  64. Pentest Tools For Mac
  65. Pentest Tools Github
  66. Hacker Tools Linux
  67. Hacking Tools For Windows Free Download
  68. Hack Tools
  69. Hacker Tools Free
  70. Hacker Tools Free Download
  71. Hack Tools 2019
  72. Pentest Tools Bluekeep
  73. Hacker Tools
  74. Hacking Tools For Beginners
  75. Hacking Tools Free Download
  76. Pentest Automation Tools
  77. Hacking Tools Free Download
  78. Hack Website Online Tool
  79. Pentest Tools Windows
  80. Kik Hack Tools
  81. How To Hack
  82. Hacking Tools Download
  83. Hack Tools For Games
  84. Pentest Tools Port Scanner
  85. Pentest Tools For Windows
  86. Hacking Tools Hardware
  87. How To Install Pentest Tools In Ubuntu
  88. Pentest Tools Download
  89. Pentest Reporting Tools
  90. Hacking Tools
  91. Hacking Tools Usb
  92. Hacker Hardware Tools
  93. Pentest Tools
  94. Termux Hacking Tools 2019
  95. Hacker Tools 2019
  96. Hacker Tools For Pc
  97. Hacker Tools
  98. Growth Hacker Tools
  99. Hack Tools For Ubuntu
  100. Hacking Tools Windows 10
  101. Black Hat Hacker Tools
  102. Hacking Tools Usb
  103. Hack Tools Pc
  104. Hack Tool Apk
  105. Pentest Tools Kali Linux
  106. Hacking Tools For Pc
  107. Hack Tools
  108. Pentest Tools Linux
  109. Hacking App
  110. Underground Hacker Sites
  111. Hack Tools Pc
  112. Hacker Techniques Tools And Incident Handling
  113. Hacking Tools For Windows 7
  114. What Is Hacking Tools
  115. Hacking Tools Online
  116. Pentest Recon Tools
  117. Hacking Tools For Beginners
  118. Hack Apps
  119. Nsa Hack Tools Download
  120. Hacking Tools For Windows
  121. Hacking Tools Online
  122. Pentest Recon Tools
  123. Pentest Automation Tools
  124. Pentest Tools For Windows
  125. Pentest Tools Url Fuzzer
  126. Hacker Tools Windows

Geen opmerkings nie:

Plaas 'n opmerking