Level10
Access the file.
level10@SnowCrash:~$ ls -l
total 16
-rwsr-sr-x+ 1 flag10 level10 10817 Mar 5 2016 level10
-rw------- 1 flag10 flag10 26 Mar 5 2016 tokenlevel10@SnowCrash:~$ ./level10
./level10 file host
sends file to host if you have access to itlevel10@SnowCrash:~$ ./level10 token localhost
You don't have access to token
level10@SnowCrash:~$ ./level10 /bin/ls localhost
Connecting to localhost:6969 .. Unable to connect to host localhostint main(int argc, char ** argv) {
char buffer[4096]; // bp-4132
int32_t v1 = (int32_t)argv; // 0x80486e0
int32_t v2 = __readgsdword(20); // 0x80486e7
if (argc <= 2) {
int32_t v3 = *(int32_t *)argv; // 0x8048700
printf("%s file host\n\tsends file to host if you have access to it\n", (char *)v3);
exit(1);
// UNREACHABLE
}
int32_t * path = (int32_t *)(: + 4); // 0x8048723
char * path2 = (char *)*path; // 0x8048726
char * cp = (char *)*(int32_t *)(v1 + 8); // 0x8048731
int32_t chars_printed;
int32_t result; // 0x804896b
int32_t * v4;
if (access((char *)*path, R_OK) != 0) {
// 0x8048940
chars_printed = printf("You don't have access to %s\n", path2);
// branch -> 0x8048955
// 0x8048955
if (v2 == __readgsdword(20)) {
// 0x8048955
result = chars_printed;
// branch -> 0x804896a
} else {
// 0x8048965
__stack_chk_fail();
result = (int32_t)&v4;
// branch -> 0x804896a
}
// 0x804896a
return result;
}
// 0x8048756
printf("Connecting to %s:6969 .. ", cp);
fflush((struct _IO_FILE *)g1);
int32_t sock_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_IP); // 0x804878f
int32_t sin = 2; // bp-36
inet_addr(cp);
htons(0x1b39);
if (connect(sock_fd, (struct sockaddr *)&sin, 16) == -1) {
// 0x804880f
printf("Unable to connect to host %s\n", cp);
exit(1);
// UNREACHABLE
}
// 0x8048830
if (write(sock_fd, (int32_t *)".*( )*.\n", 8) == -1) {
// 0x8048851
printf("Unable to write banner to host %s\n", cp);
exit(1);
// UNREACHABLE
}
// 0x8048872
printf("Connected!\nSending file .. ");
fflush((struct _IO_FILE *)g1);
int32_t fd = open(path2, O_RDONLY); // 0x804889b
if (fd == -1) {
// 0x80488ab
puts("Damn. Unable to open file");
exit(1);
// UNREACHABLE
}
// 0x80488c3
int32_t nbyte = read(fd, (int32_t *)&buffer, 0x1000); // 0x80488da
if (nbyte == -1) {
int32_t err_num = *__errno_location(); // 0x80488ef
printf("Unable to read from file: %s\n", strerror(err_num));
exit(1);
// UNREACHABLE
}
// 0x8048916
write(sock_fd, (int32_t *)&buffer, nbyte);
chars_printed = puts("wrote file!");
// branch -> 0x8048955
// 0x8048955
if (v2 == __readgsdword(20)) {
// 0x8048955
result = chars_printed;
// branch -> 0x804896a
} else {
// 0x8048965
__stack_chk_fail();
result = (int32_t)&v4;
// branch -> 0x804896a
}
// 0x804896a
return result;
}
Password for next level
Command summery
Last updated