Saturday, June 3, 2023

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.




Continue reading

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

No comments:

Post a Comment