26 de jan. 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.




Read more


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

Nenhum comentário: