venerdì 19 gennaio 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.




Related posts


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

Nessun commento:

Posta un commento