25 mai 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. How To Install Pentest Tools In Ubuntu
  2. Pentest Tools Website
  3. Nsa Hacker Tools
  4. Hacker Tools For Pc
  5. Pentest Tools Free
  6. Growth Hacker Tools
  7. Hacking Tools Free Download
  8. Hacking Tools Software
  9. Hacker Tools Software
  10. Hacker Tool Kit
  11. Pentest Tools Url Fuzzer
  12. Hacking Tools Windows 10
  13. Hack Tool Apk
  14. Pentest Tools Website Vulnerability
  15. Hacking Tools For Mac
  16. Hacker Tools For Windows
  17. Nsa Hacker Tools
  18. New Hacker Tools
  19. Hacker Hardware Tools
  20. Nsa Hacker Tools
  21. Hacker Tools For Mac
  22. Install Pentest Tools Ubuntu
  23. Pentest Tools Open Source
  24. Pentest Tools
  25. Hacking Tools Software
  26. Growth Hacker Tools
  27. Pentest Tools Apk
  28. Hacking Tools For Windows 7
  29. Hacker Tools Linux
  30. Hacking Tools Github
  31. What Is Hacking Tools
  32. Hack Tools For Windows
  33. Pentest Tools Website
  34. How To Hack
  35. Hacker Tools Mac
  36. Hack Tools For Games
  37. Wifi Hacker Tools For Windows
  38. Wifi Hacker Tools For Windows
  39. Termux Hacking Tools 2019
  40. Hacking Tools Software
  41. Pentest Tools Android
  42. Hacker Search Tools
  43. Hacker Tools For Ios
  44. Pentest Tools
  45. Hacking Tools Windows
  46. Hacking Tools For Windows Free Download
  47. Hacker Security Tools
  48. Hack Tools Github
  49. Tools For Hacker
  50. New Hack Tools
  51. Hacker Tools
  52. Hackers Toolbox
  53. Hacking Tools For Pc
  54. Hacker Tools For Ios
  55. Pentest Tools Apk
  56. Hacking Tools Download
  57. Hack Tools For Games
  58. Hack And Tools
  59. Hack Tools Mac
  60. Hack Tool Apk
  61. Hacker Tool Kit
  62. Pentest Recon Tools
  63. Hacking Tools Hardware
  64. Hacking Tools Online
  65. Hacker Tools Linux
  66. Pentest Automation Tools
  67. Best Hacking Tools 2019
  68. Hacking Tools For Windows Free Download
  69. Underground Hacker Sites
  70. New Hack Tools
  71. Hacker Tools Online
  72. Hack Tools For Ubuntu
  73. Hack Tool Apk
  74. Hacking Tools For Pc
  75. Kik Hack Tools
  76. Pentest Automation Tools
  77. Hack Tools
  78. Hacking Tools For Games
  79. Android Hack Tools Github
  80. What Is Hacking Tools
  81. Hacker
  82. Hacking Tools Software
  83. Growth Hacker Tools
  84. Hack Rom Tools
  85. Pentest Tools For Mac
  86. Hacker Tools
  87. Hacking Tools Github
  88. Pentest Tools
  89. Hack Tools Github
  90. Blackhat Hacker Tools
  91. Pentest Tools Website
  92. Free Pentest Tools For Windows
  93. Hacking Tools Mac
  94. Best Pentesting Tools 2018
  95. Hacker Tools Software
  96. Hacking Tools Software
  97. Hacking Tools And Software
  98. Hack Tool Apk No Root
  99. Hacking Tools Hardware
  100. Hacker
  101. Pentest Tools Github
  102. Hacking Tools Windows
  103. How To Install Pentest Tools In Ubuntu
  104. How To Install Pentest Tools In Ubuntu
  105. Pentest Tools Kali Linux
  106. Tools Used For Hacking
  107. Hack And Tools

Aucun commentaire: