تقييم الموضوع :
  • 1 أصوات - بمعدل 5
  • 1
  • 2
  • 3
  • 4
  • 5
التعديل على ملفات bin
#8
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>

class hexo {
public:
    hexo() = default;

    static unsigned short hextobyte(std::string hexstr) { //one at a time. == 0x00 ~ 0xFF
        int cnt = 0, byte = 0;
        char ch;

        for (int i = (int)hexstr.length() - 1; i >= 0; i--)
        {
            ch = hexstr[i];
            if (ch >= '0' && ch <= '9')
                byte += (ch - '0') * (int)std::pow(16, cnt++);
            else if (ch >= 'A' && ch <= 'F')
                byte += (ch - 'A' + 10) * (int)std::pow(16, cnt++);
            else if (ch >= 'a' && ch <= 'f')
                byte += (ch - 'a' + 10) * (int)std::pow(16, cnt++);
            else
                return -1;
        }
        return byte;
    }

    static std::vector<unsigned short> hexstrtobytes(std::string hexstr) {
        std::vector<unsigned short> hexbytes;
        int cnt = 0;
        hexstr = hexstr.substr(2, hexstr.length() - 1);

        for (int i = (int)hexstr.length() - 2; i >= -1; i = i - 2)
            if (i == -1)
                hexbytes.push_back(hextobyte(hexstr.substr(0, 1)));
            else
                hexbytes.push_back(hextobyte(hexstr.substr(i, 2)));
        return hexbytes;
    }
};

int main(int argc, char const* argv[]) {
    if (argc == 4) {
        /*
        * argv[1] == file name to patch.
        * argv[2] == Patch Address
        * argv[3] == Patch Value [must be the multiply of 2]
        */

        std::cout << "File Name: " << argv[1] << std::endl;
        std::cout << "Patch Start Address: " << argv[2] << std::endl;
        std::cout << "Patch Value: " << argv[3] << std::endl;

        std::istringstream addr(argv[2]);
        std::vector<unsigned short> hexbytes = hexo::hexstrtobytes(argv[3]);
        std::fstream binaryfile(argv[1], std::ios::in | std::ios::out | std::ios::binary);

        int patchaddr;
        //convert patch address from text to hex number.
        addr >> std::hex >> patchaddr;

        size_t arrlen = hexbytes.size();
        for (size_t i = 0; i < arrlen; i++) {
            binaryfile.seekp(patchaddr + i);
            binaryfile << char(hexbytes[i]);
        }
        binaryfile.close();
    }
    else {
        std::cout << "filepatcher.exe filetopatch patchaddress patchvalue" << std::endl;
        std::cout << "\nEx: " << std::endl;
        std::cout << "   filepatcher.exe at4re.exe 0x4325 0x56789654" << std::endl;
    }

    system("pause"); //Works on Windows only

    return 0;
}

أو من هنا

https://pastebin.com/8uWAjv2F
كلمة السر: AT4RETEAM
من طلب العلا ... سهر الليالي
أعضاء أعجبوا بهذه المشاركة : Untold , aliouat50 , rce3033 , Polia


الردود في هذا الموضوع
التعديل على ملفات bin - بواسطة aliouat50 - 05-12-2021, 10:39 PM
RE: التعديل على ملفات bin - بواسطة Polia - 06-12-2021, 08:18 AM
RE: التعديل على ملفات bin - بواسطة aliouat50 - 06-12-2021, 09:16 AM
RE: التعديل على ملفات bin - بواسطة Cyperior - 06-12-2021, 11:48 AM
RE: التعديل على ملفات bin - بواسطة aliouat50 - 06-12-2021, 01:07 PM
RE: التعديل على ملفات bin - بواسطة Cyperior - 06-12-2021, 03:50 PM
RE: التعديل على ملفات bin - بواسطة aliouat50 - 06-12-2021, 05:12 PM
RE: التعديل على ملفات bin - بواسطة Cyperior - 06-12-2021, 05:18 PM
RE: التعديل على ملفات bin - بواسطة wattan - 30-05-2022, 04:04 PM

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم