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

No comments:

Post a Comment