Humour In Verse

From The warped mind of Emac

Monday, June 05, 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.




More info


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

0 Comments:

Post a Comment

<< Home