Reversing Some C++ Io Operations

Posted on 5:38 AM by Tina

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.




Continue reading
  1. Pentest Tools Framework
  2. Hacking Apps
  3. Hacker Hardware Tools
  4. Hacker Tool Kit
  5. Hacker Tools Apk Download
  6. Hack Tools Download
  7. Hacker Tools Linux
  8. Pentest Tools For Ubuntu
  9. Hacker Tools For Mac
  10. Ethical Hacker Tools
  11. Hack Tool Apk No Root
  12. Pentest Tools Subdomain
  13. Computer Hacker
  14. Game Hacking
  15. Best Hacking Tools 2020
  16. Hack Tools For Windows
  17. Hacking Tools Software
  18. Hack Website Online Tool
  19. Install Pentest Tools Ubuntu
  20. Hacking Tools Windows 10
  21. Hacking Tools Kit
  22. Hacker Tools Github
  23. Hacking Apps
  24. Hacker Tools For Windows
  25. Pentest Automation Tools
  26. Hacking App
  27. Hacking Tools Usb
  28. Hacker Tools Software
  29. Hacks And Tools
  30. Hacking Tools
  31. Blackhat Hacker Tools
  32. Hacker Tools Github
  33. Hack Tools For Pc
  34. Hacking Tools For Windows 7
  35. Hacking Tools For Windows 7
  36. Hack Tools Mac
  37. Pentest Tools Framework
  38. Computer Hacker
  39. Pentest Tools Online
  40. Hacker Tools 2019
  41. Hacking Tools 2020
  42. Hacker Tools Linux
  43. Pentest Tools For Ubuntu
  44. Hack Tools Mac
  45. Hacker Tools For Mac
  46. Hacker Tools Github
  47. New Hacker Tools
  48. Hacker Tools 2020
  49. Hack Tool Apk
  50. How To Hack
  51. Hacking Tools Name
  52. Hack Tools Github
  53. Blackhat Hacker Tools
  54. Hacking Tools Software
  55. Hacker Tools Github
  56. Hacker Tools Apk
  57. What Is Hacking Tools
  58. Pentest Tools For Windows
  59. Pentest Tools Kali Linux
  60. Pentest Tools Framework
  61. Hacker Tools Free
  62. Pentest Reporting Tools
  63. Github Hacking Tools
  64. Beginner Hacker Tools
  65. Hacking Tools Usb
  66. Hacking Tools 2020
  67. Pentest Tools For Ubuntu
  68. Hacker Tools Free
  69. What Are Hacking Tools
  70. Tools For Hacker
  71. Pentest Tools Kali Linux
  72. Pentest Tools Url Fuzzer
  73. Hack Tools 2019
  74. Hack Website Online Tool
  75. Hacking Tools And Software
  76. Kik Hack Tools
  77. Hacker Tools Online
  78. Hacker Tools Online
  79. Pentest Tools
  80. Hacking Tools Usb
  81. World No 1 Hacker Software
  82. Kik Hack Tools
  83. Nsa Hacker Tools
  84. Hacking Tools For Windows 7
  85. Hacking Tools For Pc
  86. Pentest Tools Online
  87. Hacking Tools Online
  88. Hack And Tools
  89. Hacking Tools 2020
  90. Pentest Tools Alternative
  91. Hacking Tools For Windows
  92. Hacking Tools Hardware
  93. Hack Tools Pc
  94. Pentest Tools Url Fuzzer
  95. Hacking Tools
  96. Hacking Tools Kit
  97. Hacking Tools Github
  98. Hack Apps
  99. Hacking Tools 2020
  100. Pentest Tools For Ubuntu
  101. Pentest Reporting Tools
  102. Hack Tool Apk
  103. Hack Tools Download
  104. Hack Tools For Games
  105. Hacker Tools For Mac
  106. Pentest Tools Online
  107. Game Hacking
  108. Hacker Tools
  109. Hack And Tools
  110. Pentest Tools Online
  111. Pentest Tools Url Fuzzer
  112. Pentest Tools Alternative
  113. Hack Rom Tools
  114. Pentest Tools For Android
  115. Hack Tools Github
  116. Hacker Tools 2020
  117. Pentest Tools Review
  118. Install Pentest Tools Ubuntu
  119. Pentest Tools For Mac
  120. Pentest Tools For Android
  121. Termux Hacking Tools 2019
  122. Hack Tools Mac
  123. Hacking Tools 2020
  124. Hack Website Online Tool
  125. Hack Tool Apk
  126. Pentest Tools Online
  127. Hacker Tools For Ios
  128. Hack Tools Pc
  129. Pentest Tools Framework
  130. Blackhat Hacker Tools
  131. Install Pentest Tools Ubuntu
  132. Pentest Tools Bluekeep
  133. Hacker Tools List
  134. Nsa Hack Tools
  135. New Hacker Tools
  136. Tools Used For Hacking
  137. Pentest Tools Kali Linux
  138. What Is Hacking Tools
  139. Wifi Hacker Tools For Windows
  140. Pentest Tools Port Scanner
  141. What Is Hacking Tools
  142. Best Pentesting Tools 2018
  143. Pentest Tools For Windows
  144. Growth Hacker Tools
  145. Hacker Tools Free
  146. Tools For Hacker
  147. Pentest Tools Github

0 comments:

Post a Comment