Saturday, August 29, 2020

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. Hacker Hardware Tools
  2. Hacker Search Tools
  3. Pentest Tools Download
  4. Hacker Tools Free Download
  5. Hacker Techniques Tools And Incident Handling
  6. Easy Hack Tools
  7. Hacker Tools For Mac
  8. Pentest Tools Linux
  9. Hacking Tools For Games
  10. Hacker Tools Linux
  11. Hacker Tools 2019
  12. Pentest Tools Download
  13. Hacking App
  14. Black Hat Hacker Tools
  15. Hack Tools
  16. Physical Pentest Tools
  17. Hacker Tools
  18. Kik Hack Tools
  19. Best Hacking Tools 2019
  20. Ethical Hacker Tools
  21. Hack Tools Mac
  22. Pentest Tools Url Fuzzer
  23. How To Hack
  24. Hacking Tools For Games
  25. Pentest Tools Tcp Port Scanner
  26. Underground Hacker Sites
  27. Pentest Tools For Windows
  28. Pentest Recon Tools
  29. Hacking Tools For Windows 7
  30. Hacks And Tools
  31. Hacker Tools
  32. Hacking Tools Kit
  33. Pentest Tools For Android
  34. Nsa Hack Tools Download
  35. Hack Tools 2019
  36. Hacking Tools For Mac
  37. Hacking Tools For Windows
  38. Best Hacking Tools 2019
  39. Hak5 Tools
  40. Hack Tools Mac
  41. Nsa Hack Tools Download
  42. Pentest Tools Apk
  43. Hacking Tools Download
  44. Hacker Tools Linux
  45. Computer Hacker
  46. Hacker Tools Free Download
  47. Pentest Box Tools Download
  48. Best Hacking Tools 2019
  49. Hack Tools For Games
  50. Pentest Tools Review
  51. Hacker Tool Kit
  52. Hack Tool Apk
  53. Pentest Tools Online
  54. Hacker Tools Free Download
  55. Pentest Tools Github
  56. Physical Pentest Tools
  57. Hacker Tools Free
  58. Top Pentest Tools
  59. Hacking Tools Usb
  60. Hack Rom Tools
  61. Pentest Tools For Android
  62. Hacking Tools For Kali Linux
  63. Hack Tools Github
  64. Pentest Tools Tcp Port Scanner
  65. Best Hacking Tools 2019
  66. Nsa Hacker Tools
  67. Kik Hack Tools
  68. Hacker Tools Apk
  69. Hacker
  70. Termux Hacking Tools 2019
  71. Hack Rom Tools
  72. Hacking Tools Usb
  73. Hack Rom Tools
  74. Pentest Tools For Windows
  75. Physical Pentest Tools
  76. Hak5 Tools
  77. Hacker Tools For Windows
  78. Tools Used For Hacking
  79. Pentest Automation Tools
  80. Hack Tools Pc
  81. Github Hacking Tools
  82. Pentest Recon Tools
  83. Pentest Tools Download
  84. Pentest Tools For Mac
  85. Pentest Tools Tcp Port Scanner
  86. Pentest Automation Tools
  87. Hacking Tools For Mac
  88. Pentest Tools Url Fuzzer
  89. Hacker Tools For Mac
  90. Hacking Tools Pc
  91. Hacking Tools For Games
  92. Hack Tools For Windows
  93. Pentest Tools Download
  94. Pentest Tools Alternative
  95. Underground Hacker Sites
  96. Hacking Tools Windows
  97. Hacker Tools Apk
  98. How To Install Pentest Tools In Ubuntu
  99. Computer Hacker
  100. Hacking Tools Kit
  101. Pentest Tools Kali Linux
  102. Hacker Tools
  103. Hacking Tools And Software
  104. How To Hack
  105. Hacker Tools For Windows
  106. Hack Tools Github
  107. Hacking Tools For Games
  108. Hacker Tools Linux
  109. Hacking Tools For Windows 7
  110. How To Make Hacking Tools
  111. Hack Tools
  112. Hackers Toolbox
  113. Hack Tools For Windows
  114. How To Hack
  115. Pentest Tools For Mac
  116. Hacking Tools Name
  117. Hacks And Tools
  118. Hack Tools Github
  119. Hacker Tools For Ios
  120. Pentest Tools Website Vulnerability
  121. Pentest Tools Linux
  122. Hacker Tools List
  123. Hacker Tools Free Download
  124. Hacker Tools 2019
  125. Hacking Tools Github
  126. Hack Tools Mac
  127. Hacking Tools For Windows Free Download
  128. Beginner Hacker Tools

No comments:

Post a Comment