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 links


  1. Hacking Tools Github
  2. Hacking Tools For Kali Linux
  3. Android Hack Tools Github
  4. Pentest Tools Apk
  5. Hack Tools Online
  6. Hacking Tools Online
  7. Hacking Tools For Windows 7
  8. Pentest Tools Review
  9. Tools Used For Hacking
  10. Hacking Tools Hardware
  11. Hacker Tools For Ios
  12. Hacking Tools Name
  13. Hacking Tools Windows
  14. Tools For Hacker
  15. Hacking Tools Hardware
  16. Hack Tools Pc
  17. Hack Tool Apk No Root
  18. Hack Tools For Games
  19. Hacker Tools Apk
  20. Hacker Tools Apk Download
  21. Best Hacking Tools 2020
  22. Top Pentest Tools
  23. Best Pentesting Tools 2018
  24. Pentest Tools Kali Linux
  25. Hacking Tools Windows
  26. Hak5 Tools
  27. Hacks And Tools
  28. Pentest Tools Windows
  29. Pentest Tools Website Vulnerability
  30. New Hacker Tools
  31. How To Hack
  32. Hacking Tools 2019
  33. Top Pentest Tools
  34. Hack Tools Online
  35. Hacker Tools 2020
  36. Usb Pentest Tools
  37. Hacking Tools For Windows
  38. Hack Rom Tools
  39. Hacking Tools Online
  40. Hack Tools Pc
  41. Hackrf Tools
  42. Hacker Tool Kit
  43. Hacking Tools Kit
  44. Pentest Tools For Ubuntu
  45. Hack Tools
  46. Hacker Tools Apk
  47. Pentest Tools Port Scanner
  48. Hacker Hardware Tools
  49. Hack Tools Download
  50. Hack Tools For Ubuntu
  51. Underground Hacker Sites
  52. Hacking Tools And Software
  53. Hack Tools 2019
  54. Hacking Tools Github
  55. Hacker Tools
  56. Hackers Toolbox
  57. Hacker Tool Kit
  58. Hack Tools
  59. Hack Tools Online
  60. Hacker Techniques Tools And Incident Handling
  61. Pentest Automation Tools
  62. Pentest Tools Tcp Port Scanner
  63. Pentest Box Tools Download
  64. Android Hack Tools Github
  65. Hacking App
  66. Hak5 Tools
  67. Pentest Tools Linux
  68. Pentest Automation Tools
  69. Pentest Tools Online
  70. Pentest Tools Website Vulnerability
  71. Underground Hacker Sites
  72. What Are Hacking Tools
  73. Hacker Tools 2019
  74. New Hack Tools
  75. New Hack Tools
  76. Pentest Reporting Tools
  77. Hacker Tools Hardware
  78. Black Hat Hacker Tools
  79. Best Hacking Tools 2020
  80. Install Pentest Tools Ubuntu
  81. Hacking Tools Software
  82. Hack Tools Download
  83. Pentest Tools Kali Linux
  84. Hacks And Tools
  85. Game Hacking
  86. Pentest Tools Android
  87. New Hacker Tools
  88. Hacking Tools Online
  89. Hacking App
  90. Hacking Tools Windows 10
  91. Hacker Tools Github
  92. Hacking Tools Mac
  93. Hack Tools Online
  94. Hack Tools Github
  95. Top Pentest Tools
  96. World No 1 Hacker Software

No hay comentarios:

Publicar un comentario