Vrydag 26 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.




Read more


  1. Hackrf Tools
  2. Hacker Tools Mac
  3. Hacking Tools Mac
  4. Hacker Tools Windows
  5. New Hacker Tools
  6. Tools Used For Hacking
  7. What Are Hacking Tools
  8. Hacking Tools Download
  9. Tools 4 Hack
  10. Pentest Tools Windows
  11. Pentest Tools Website
  12. Hacking Tools For Pc
  13. Hack Tools For Pc
  14. Hack Tools Github
  15. Hacking Tools Online
  16. Best Hacking Tools 2020
  17. Hacker Tools Linux
  18. Growth Hacker Tools
  19. Pentest Tools List
  20. Hack Tools For Games
  21. Pentest Tools For Mac
  22. Pentest Tools Tcp Port Scanner
  23. Pentest Tools Free
  24. Pentest Tools For Ubuntu
  25. Hacking Tools Windows 10
  26. Hack Tools Github
  27. Pentest Tools Framework
  28. Pentest Tools Alternative
  29. Hacking Tools Pc
  30. Hack Tools For Ubuntu
  31. Hacking Tools For Beginners
  32. Hacker Tools For Mac
  33. Hack Tools For Games
  34. Hacking Tools Github
  35. Hack Tools Mac
  36. Hack Tools For Pc
  37. Top Pentest Tools
  38. Top Pentest Tools
  39. Hack And Tools
  40. Hacker Tools For Windows
  41. Hacks And Tools
  42. Tools Used For Hacking
  43. Hacking Tools Download
  44. Nsa Hacker Tools
  45. Pentest Tools Alternative
  46. Hacking Apps
  47. Hack Website Online Tool
  48. Hacker Tools List
  49. Hacker Tools Apk
  50. Hack Tools Github
  51. Hacker Tools For Ios
  52. Hacker Tools Hardware
  53. Hack Tools For Windows
  54. Hack Tools Pc
  55. Tools For Hacker
  56. How To Make Hacking Tools
  57. Hack Apps
  58. Hacking Tools Name
  59. Hacker Tools Software
  60. Hacker Tools List
  61. Pentest Tools Port Scanner
  62. Usb Pentest Tools
  63. Android Hack Tools Github
  64. Hacking Tools Online
  65. Nsa Hacker Tools
  66. Hacking Tools Windows
  67. How To Make Hacking Tools
  68. Pentest Tools Alternative
  69. Hack Tool Apk No Root
  70. Pentest Tools Subdomain
  71. Hacking Tools Hardware
  72. Pentest Tools Website Vulnerability
  73. Hacking Apps
  74. Usb Pentest Tools
  75. Hacker Tools Free
  76. Pentest Tools For Mac
  77. Hack Tools
  78. Pentest Tools Android
  79. Hacking Tools Name
  80. Pentest Tools List
  81. Pentest Tools Free
  82. Hacking Tools For Windows 7
  83. Best Hacking Tools 2019
  84. Kik Hack Tools
  85. Hacker Tools For Windows
  86. Hack Tools For Ubuntu
  87. Pentest Tools Open Source
  88. Hacker Search Tools
  89. Pentest Recon Tools
  90. How To Install Pentest Tools In Ubuntu
  91. Kik Hack Tools
  92. Hacker Tools Online
  93. Physical Pentest Tools
  94. World No 1 Hacker Software
  95. Nsa Hack Tools Download
  96. Hacks And Tools
  97. Easy Hack Tools
  98. Blackhat Hacker Tools
  99. Hacker Tools Linux
  100. New Hack Tools
  101. Hacker Tools Software
  102. What Is Hacking Tools
  103. Hack App
  104. Hacking Tools For Windows 7
  105. Hack Tool Apk
  106. Hacking Tools For Windows Free Download
  107. Hacker Tools Online

Geen opmerkings nie:

Plaas 'n opmerking