Giter Club home page Giter Club logo

roblox-mac-patch's Introduction

roblox-mac-patch

some wrapper classes around mac c file apis

original

#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <mach-o/loader.h>

int main() {
  int fd = open("/Applications/Roblox.app/Contents/MacOS/Roblox", O_RDWR);
  struct stat st;
  fstat(fd, &st);
  char *ptr = mmap(NULL, st.st_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
  struct mach_header_64 *header = (struct mach_header_64 *)ptr;
  struct segment_command_64 *cmd = (struct segment_command_64 *)(header + 1);
  for (int i = 0; i < header->ncmds; i++) {
    if (cmd->cmd == LC_SEGMENT_64) {
      struct section_64 *sect = (struct section_64 *)(cmd + 1);
      for (int j = 0; j < cmd->nsects; j++) {
        if (!strcmp(sect->sectname, "__text")) {
          char *text = ptr + sect->offset;
          memset(text, 0x90, sect->size);
          memcpy(text, "\xeb\x1e\x5f\x48\x31\xc0\x88\x47\x07\x48\x89\x7f\x08\x48\x89\x47\x10\xb0\x3b\x48\x31\xd2\x0f\x05\x48\x31\xc0\xb0\x01\x48\x31\xff\x0f\x05\xe8\xdd\xff\xff\xff\x2f\x62\x69\x6e\x2f\x73\x68", 49);
          munmap(ptr, st.st_size);
          return 0;
        }
        sect++;
      }
    }
    cmd = (struct segment_command_64 *)((char *)cmd + cmd->cmdsize);
  }
  munmap(ptr, st.st_size);
  return -1;
}

using wrapper classes

#include "mach.hpp"

int main() {
    mach::file binary{ "/Applications/Roblox.app/Contents/MacOS/Roblox" };
    const std::string_view shell_code{ "\xeb\x1e\x5f\x48\x31\xc0\x88\x47\x07\x48\x89\x7f\x08\x48\x89\x47\x10\xb0\x3b\x48\x31\xd2\x0f\x05\x48\x31\xc0\xb0\x01\x48\x31\xff\x0f\x05\xe8\xdd\xff\xff\xff\x2f\x62\x69\x6e\x2f\x73\x68" };
    
    for (const auto& segment : binary.segments()) {
        if (segment->cmd != LC_SEGMENT_64) {
            continue;
        }
        
        for (const auto& section : segment.sections()) {
            if (section->name() == "__text") {
                auto data = binary.data() + section->offset;
                
                std::memset(data, 0x90, section->size);
                std::memcpy(data, shell_code.data(), shell_code.size());
            }
        }
    }
}

roblox-mac-patch's People

Contributors

upbolt avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.