본문 바로가기

NET 0번 본문

wargame/Protostar

NET 0번

Seongjun_You 2021. 11. 28. 01:43
#include "../common/common.c"
#define NAME "net0"
#define UID 999
#define GID 999
#define PORT 2999
void run()
{
	unsigned int i;
	unsigned int wanted;
	wanted = random();
	printf("Please send '%d' as a little endian 32bit int\n", wanted);
	if(fread(&i, sizeof(i), 1, stdin) == NULL) {
		errx(1, ":(\n");
	}
	if(i == wanted) {
		printf("Thank you sir/madam\n");
	} else {
		printf("I'm sorry, you sent %d instead\n", i);
	}
}
int main(int argc, char **argv, char **envp)
{
	int fd;
	char *username;
    /* Run the process as a daemon */
	background_process(NAME, UID, GID);
    /* Wait for socket activity and return */
	fd = serve_forever(PORT);
    /* Set the client socket to STDIN, STDOUT, and STDERR */
	set_io(fd);
    /* Don't do this :> */
	srandom(time(NULL));
	run();
}

네트워크상에서 데이터를 읽어와 그 데이터를 확인한 후 입력 값을 보내야 한다.

random값을 맞추는 코드이다.

우리에겐 만능 pwntools가 있다.

 

 

'wargame > Protostar' 카테고리의 다른 글

NET 2번  (0) 2021.11.28
NET 1번  (0) 2021.11.28
Heap 3번  (0) 2021.11.28
Heap 2번  (0) 2021.11.27
Heap 1번  (0) 2021.11.27
Comments