Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing desockmulti on server #3

Open
Filarna opened this issue Oct 13, 2022 · 3 comments
Open

Testing desockmulti on server #3

Filarna opened this issue Oct 13, 2022 · 3 comments

Comments

@Filarna
Copy link

Filarna commented Oct 13, 2022

hello zyingp i have question on how desockmulti works
i write vulnerable server for testing desockmulti

 #include <netinet/in.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/socket.h>
 #include <unistd.h>
 #define PORT 8080
 int main(int argc, char const* argv[])
 {
	int server_fd, new_socket, valread;
	struct sockaddr_in address;
	int opt = 1;
	int addrlen = sizeof(address);
	char buffer[30] = { 0 };
	char* hello = "Hello from server";
	

        // Creating socket file descriptor
	if ((server_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
		perror("socket failed");
		exit(EXIT_FAILURE);
	}

	// Forcefully attaching socket to the port 8080
	if (setsockopt(server_fd, SOL_SOCKET,
				SO_REUSEADDR | SO_REUSEPORT, &opt,
				sizeof(opt))) {
		perror("setsockopt");
		exit(EXIT_FAILURE);
	}
	address.sin_family = AF_INET;
	address.sin_addr.s_addr = INADDR_ANY;
	address.sin_port = htons(PORT);

	// Forcefully attaching socket to the port 8080
	if (bind(server_fd, (struct sockaddr*)&address,
			sizeof(address))
		< 0) {
		perror("bind failed");
		exit(EXIT_FAILURE);
	}
	if (listen(server_fd, 3) < 0) {
		perror("listen");
		exit(EXIT_FAILURE);
	}
	if ((new_socket
		= accept(server_fd, (struct sockaddr*)&address,
				(socklen_t*)&addrlen))
		< 0) {
		perror("accept");
		exit(EXIT_FAILURE);
	}
	valread = read(new_socket, buffer, 1024);
	printf("%s\n", buffer);
	send(new_socket, hello, strlen(hello), 0);
	printf("Hello message sent\n");

	// closing the connected socket
	close(new_socket);
	// closing the listening socket
	shutdown(server_fd, SHUT_RDWR);
	return 0;
}

and than i use afl to fuzz this program
but regarding of my buffer[30] or my input i cant get any error form this
i even test
USE_RAW_FORMAT=1 LD_PRELOAD=./desockmulti-master/desockmulti.so ss/server in/base_test.txt
to directly give input to sever but seems like its not working
Sorry for some newbie question and thanks for your time

@Filarna Filarna changed the title Testinf desockmulti on server Testing desockmulti on server Oct 13, 2022
@zyingp
Copy link
Owner

zyingp commented Oct 13, 2022

You can direct start your server to test whether it works. When I ran your code and the following error shows:

$ ./server
bind failed: Address already in use

Then I change the port to other uncommon port number like #define PORT 8040, after that, it seems both the server and desockmulti work as expected.

@Filarna
Copy link
Author

Filarna commented Oct 16, 2022

I finally make it work but afl give me odd output .
As intentionally give buffer[30] length to get buffer overflow but surprisingly i get 1 saved crash and almost all other input of afl result in crash but not saved.
than when i saw saved crash it wasn't about overflow related errors at all despite that i where looking for something like this
"//////////////////////////////////////////////////////////////////////////////////////////////////////"
in that saved crash.
so I want to make sure you get same result and i config afl and desockmulti in right way.(if you can send me your saved crash it would be awesome)
and what your opinion about this subject ?

@zyingp
Copy link
Owner

zyingp commented Oct 17, 2022

I suggest you use AddressSanitizer (ASan) to build the program, either use it to re-run the crash input, or use ASan+AFL to instrument the program at the same time and use the instrumented program to fuzz directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants