Partage
  • Partager sur Facebook
  • Partager sur Twitter

Base Adress Linux

    18 juin 2020 à 15:55:13

    Salut je suis entrain de créer un programme qui me permettra de lire et d'écrire dans la mémoire.

    Je voulais savoir si il était possible d'avoir la Base Adress d'un programme à partir du PID ? Je suis sur Linux.

    • Partager sur Facebook
    • Partager sur Twitter
      18 juin 2020 à 17:40:56

      Avec si peu de detail sur ce que tu compte faire , je doute que qui que ce soit t'aide ici .. aller jouer dans la memoire d'un autre programme , ca sonne pas tres 'bonnes intentions'.
      • Partager sur Facebook
      • Partager sur Twitter
        19 juin 2020 à 2:53:58

        +1 sur les détails. pour le reste, j'imagine que checker comment fonctionne (en gros) un débuggeur peut être une bonne piste de recherche
        • Partager sur Facebook
        • Partager sur Twitter
          26 juin 2020 à 14:56:36

          Salut alors le but était de pouvoir créer un programme de triche sur linux ( comme un wallhack par exemple) pour voir comment cela pouvait marcher. J'avais déjà réussi sur Windows je me suis alors lancé un défi de le faire sur Linux. 

          J'ai déjà fait un tout petit prototype que j'ai posté sur Unknowncheats ( https://www.unknowncheats.me/forum/programming-for-beginners/402740-read-write-processmemory-linux.html)

          Voici le code : 

          #include <stdio.h>
          #include <unistd.h>
          #include <sys/types.h>
          #include <sys/wait.h>
          #include <sys/stat.h>
          #include <sys/ptrace.h>
          #include <errno.h>
          #include <string.h>
          #include <fcntl.h>
          #include <stdlib.h>
          
          struct StockPid
          {
              pid_t pid;
              char buff[512];
              FILE *pid_pipe;
          } stockthepid;
          
          void Func_StockPid(const char *processtarget)
          {
              stockthepid.pid_pipe = popen(processtarget, "r");
              fgets(stockthepid.buff, 512, stockthepid.pid_pipe);
              stockthepid.pid = strtoul(stockthepid.buff, NULL, 10);
          
              if (stockthepid.pid == 0)
              {
                  printf("App Var is not launch ! \n");
                  pclose(stockthepid.pid_pipe);
                  exit(-1);
              }
              else
              {
                  printf("App Var is running - PID NUMBER -> {%d} \n", stockthepid.pid);
                  pclose(stockthepid.pid_pipe);
              }
          }
          
          void ReadProcessMemory(unsigned long address, int pid) {
          
              int buf = 0;
          
              int err_code = ptrace(PTRACE_ATTACH, stockthepid.pid, NULL, NULL);
          
              if (err_code == -1)
              {
                  printf("%s\n", "error 1");
                  exit(-1);
              }
              wait(NULL);
          
              printf("Read the adress of the process \n");
              for (int i = 0; i < 1; i++) 
              {
                 buf = ptrace(PTRACE_PEEKDATA, stockthepid.pid, address + i * sizeof(int), NULL);
                   if (buf == -1)
                  {
                      printf("%s\n", "error 2");
                      exit(-1);
                  }
          
                  printf("%d\n", buf);
                 
              }
              err_code = ptrace(PTRACE_DETACH, stockthepid.pid, NULL, NULL);
              if (err_code == -1)
              {
                  printf("%s\n", "error 3");
                  exit(-1);
              } 
          }
          
          void WriteProcessMemory(unsigned long address, int pid) {
              int WhatValue = 0;
              int buf = 0;
          
              printf("Enter the new Value !\n");
              scanf("%d", &WhatValue);
          
              int err_code = ptrace(PTRACE_ATTACH, stockthepid.pid, NULL, NULL);
              if (err_code == -1)
              {
                  printf("%s\n", "error 1");
                  exit(-1);
              }
          
              wait(NULL);
              printf("Write the new value ! \n");
              for(int i = 0; i < 1; i++) {
                  buf = ptrace(PTRACE_POKEDATA, stockthepid.pid, address + i * sizeof(int), WhatValue);
                  if (buf == -1)
                  {
                      printf("%s\n", "error 2");
                      exit(-1);
                  }
                  printf("The new value has just been added! \n");
              } 
              err_code = ptrace(PTRACE_DETACH, stockthepid.pid, NULL, NULL);
              if (err_code == -1) 
              {
                  printf("%s\n", "error 3");
                  exit(-1);
              }
          }
          
          
          
          int main()
          {
              Func_StockPid("pidof -s assaultcube");
              ReadProcessMemory(0x5618ed508838, stockthepid.pid); //Adresse mémoire des munitions 
              WriteProcessMemory(0x5618ed508838, stockthepid.pid); // Adresse mémoire des munitions
              return 0;
          }

          Maintenant il me suffit de creuser plus pour pouvoir arriver à faire un wallhack sur linux.

          • Partager sur Facebook
          • Partager sur Twitter

          Base Adress Linux

          × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
          × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
          • Editeur
          • Markdown