Skip to content
This repository was archived by the owner on May 29, 2023. It is now read-only.

Buffer overflow #1 #2

Open
poechsel opened this issue May 13, 2019 · 1 comment
Open

Buffer overflow #1 #2

poechsel opened this issue May 13, 2019 · 1 comment
Assignees
Labels
True vulnerability Actual vulnerability in the project wontfix This will not be worked on

Comments

@poechsel
Copy link

poechsel commented May 13, 2019

Looking at the function receiveFileUpload we can see the following snippet:

if (size == port) {
strcpy(stuff, big.c_str());

The problem is that stuff is only of size 4 and big can be very big (it is as big as the size of file...), so if we managed to execute the strcpy we should be able to trigger a buffer overflow and rewrite the rip.

Now, the condition size == port is true if the size of the file is equal to the port. The port number is generated "randomly" by the function getRandomPort:

int ServerSocket::getRandomPort() {
// 42420 blaze it
int portNumber = 12000 + (std::rand() % (42420 - 12000 + 1));
return portNumber;
}

However, the seed for the rand function is never initialized, and therefore is constant between executions of the server. The generated port numbers will always be the same. We can easily generate a file with the size of a port and include a payload in it to trigger the overflow.

Exploit:

This gist contains a python exploit generator that will:

  • generate a payload.txt of size 31872 (first port generated by getRandomPort
  • generate a overflow1.in file containing a sequence of command that will run the exploit
login q
pass q
put payload.txt 31873
@alex-chambet alex-chambet self-assigned this May 19, 2019
@alex-chambet alex-chambet added True vulnerability Actual vulnerability in the project wontfix This will not be worked on labels May 19, 2019
@alex-chambet
Copy link
Collaborator

Nice write-up, well done!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
True vulnerability Actual vulnerability in the project wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants