rendered paste body#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <netdb.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#define HOST "semtex.labs.pulltheplug.org"
#define PORT 24000
int main(int argc, char *argv[]) {
int sockfd, i=0;
char c;
struct hostent *he;
struct sockaddr_in server;
FILE *fuck;
fuck = fopen("elf", "w");
he = gethostbyname(HOST);
sockfd = socket(AF_INET, SOCK_STREAM, 0);
server.sin_family = AF_INET;
server.sin_port = htons(PORT);
server.sin_addr = *((struct in_addr *)he->h_addr);
memset(&(server.sin_zero), '\0', 8);
connect(sockfd, (struct sockaddr *)&server, sizeof(struct sockaddr));
while(1) {
recv(sockfd, &c, 1, 0);
if(c==0) {
printf("File Done.\n");
break;
}
if(i % 2 == 0)
fprintf(fuck, "%c", c);
i++;
}
close(sockfd);
fclose(fuck);
}
/*
matt@deathstar ~/code/wargames/semtex $ cc level1.c
level1.c:53:2: warning: no newline at end of file
matt@deathstar ~/code/wargames/semtex $ ./a.out
File Done.
matt@deathstar ~/code/wargames/semtex $ ./elf
bash: ./elf: Permission denied
matt@deathstar ~/code/wargames/semtex $ hexdump elf
0000000 457f 464c 0101 0001
0000007
matt@deathstar ~/code/wargames/semtex $ cat elf
ELFmatt@deathstar ~/code/wargames/semtex $
*/