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:
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.
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.
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"
More info
- Pentest Tools Open Source
- Top Pentest Tools
- Pentest Tools Port Scanner
- Hacker Tools For Mac
- Hacker Tools Free
- Hacker Tools List
- Hacking Tools For Windows Free Download
- Hacker Tools List
- Pentest Tools For Ubuntu
- Hacker
- Hack Apps
- Hacking Tools For Windows
- Pentest Tools Kali Linux
- Hacker Tools List
- Pentest Tools Url Fuzzer
- Top Pentest Tools
- Hack Website Online Tool
- Hack Tools For Pc
- Hacker Tools Free Download
- Wifi Hacker Tools For Windows
- Tools For Hacker
- Hacking Tools 2020
- Hack Rom Tools
- Hacking Tools For Games
- What Is Hacking Tools
- Hacking Tools Name
- Hacker Hardware Tools
- Physical Pentest Tools
- Game Hacking
- Pentest Tools Website Vulnerability
- Hacker Tools
- Pentest Tools Subdomain
- Pentest Tools Port Scanner
- How To Make Hacking Tools
- Hacking Tools Online
- Top Pentest Tools
- Pentest Box Tools Download
- Hacks And Tools
- Hacking Tools
- Install Pentest Tools Ubuntu
- Pentest Tools For Ubuntu
- Hacking Tools For Games
- Hacker Tools Apk
- Underground Hacker Sites
- Hacking Tools For Windows
- Hacking Tools For Pc
- Hack Website Online Tool
- Pentest Tools Online
- Hacking Tools Windows 10
- Hacker Tool Kit
- Hacker Tools Hardware
- Pentest Tools Download
- Pentest Tools Bluekeep
- Hacker Tools Free
- Termux Hacking Tools 2019
- Android Hack Tools Github
- Hacker
- Hacker Tools 2020
- Hacks And Tools
- Hacker Tool Kit
- Hacker Tools For Mac
- Hacking Tools Mac
- Pentest Tools Framework
- Hacking Tools 2020
- Hacking Tools 2019
- What Are Hacking Tools
- Hacking Tools Free Download
- Pentest Tools Open Source
- Hack Rom Tools
- How To Hack
- Pentest Tools Review
- Hack Tools Github
- Hack Apps
- Hacker Search Tools
- Hack Tools For Mac
- Pentest Tools Nmap
- Hacker Tool Kit
- Hack App
- Blackhat Hacker Tools
- Pentest Tools For Mac
- What Are Hacking Tools
- Pentest Tools Kali Linux
- Hacking Apps
- Hacking Tools Software
- Pentest Tools Kali Linux
- Hacker Tools List
- Physical Pentest Tools
- Wifi Hacker Tools For Windows
- Pentest Tools Tcp Port Scanner
- Hack Tools
- Pentest Tools For Windows
- Hack Tools 2019
- Hacker Tools 2020
- Pentest Tools Open Source
- Hacking Tools For Kali Linux
- Hacker Search Tools
- Hacker Tools Mac
- Easy Hack Tools
- Hacking Apps
- Best Pentesting Tools 2018
- Hack Tools For Pc
- Blackhat Hacker Tools
- Pentest Tools Tcp Port Scanner
- Hacking Tools For Beginners
- Hack Tools 2019
- Easy Hack Tools
- Bluetooth Hacking Tools Kali
- Easy Hack Tools
- Pentest Tools For Ubuntu
- Nsa Hacker Tools
- Hack Tools For Games
- Hacker Tools Free
- How To Make Hacking Tools
- Pentest Tools For Mac
- Pentest Tools Linux
- Hacking Tools For Pc
- Hacker Tools For Mac
- Pentest Recon Tools
- Pentest Tools Bluekeep
- Hacking Tools And Software
- New Hack Tools
- Hacker Tools Hardware
- Pentest Tools For Windows
- Best Pentesting Tools 2018
- Pentest Tools Framework
- Computer Hacker
- Free Pentest Tools For Windows
- Physical Pentest Tools
- Hacker Tools For Windows
- Pentest Tools Github
- Hacker Tools For Ios
- Hacker Tools 2019
- Hack Tools 2019
- Hack Tool Apk
- Bluetooth Hacking Tools Kali
- Hak5 Tools
- Hacker Tools Apk
- Hacker Tools Software
- Hacker Tools List
- Pentest Automation Tools
- Best Hacking Tools 2019
- Nsa Hack Tools
- Pentest Tools Alternative
- Hack And Tools
- Wifi Hacker Tools For Windows
Post a Comment