Sottolineature pescate qua e la quando capita

giovedì 27 agosto 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.




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

Lettori fissi

Archivio blog