Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define PORT 50105
- #include <stdio.h>
- #include <signal.h>
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <arpa/inet.h>
- #include <pwd.h>
- #include <unistd.h>
- #include <syslog.h>
- #include <stdarg.h>
- #include <string.h>
- #include <stdlib.h>
- static void usage(char *);
- int main(int argc, char **argv)
- {
- char buf[1024];
- char cmd[512];
- char *pass;
- int soc_des;
- int soc_cli;
- int soc_rc;
- int i;
- socklen_t lenght;
- struct sockaddr_in serv_addr;
- struct sockaddr_in client_addr;
- (argc > 1) ? pass=argv[1] : usage(argv[0]);
- soc_des = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (soc_des == -1)
- {
- perror("socket");
- exit(-1);
- }
- bzero((char *)&serv_addr, sizeof(serv_addr));
- serv_addr.sin_family = AF_INET;
- serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
- serv_addr.sin_port = htons(PORT);
- soc_rc = bind(soc_des, (struct sockaddr *) & serv_addr, sizeof(serv_addr));
- if (soc_rc != 0)
- {
- perror("bind");
- exit(-1);
- }
- if (fork() != 0)
- exit(0);
- soc_rc = listen(soc_des, 5);
- if (soc_rc != 0)
- {
- perror("listen");
- exit(0);
- }
- while (1)
- {
- lenght = sizeof(client_addr);
- soc_cli = accept(soc_des, (struct sockaddr *) & client_addr,&lenght);
- if (soc_cli < 0)
- exit(0);
- if (fork() != 0)
- {
- for(i=0;i<3;i++)
- {
- dup2(soc_cli, 0);
- dup2(soc_cli, 1);
- dup2(soc_cli, 2);
- snprintf(cmd,sizeof(cmd),"What drugs do you abuse? :");
- write(soc_cli, cmd,strlen(cmd));
- fgets(buf, sizeof(buf), stdin);
- strtok(buf, "\n");
- strtok(buf,"\r");
- if (!strcmp(buf,argv[1]))
- {
- snprintf(cmd,sizeof(cmd),"/sbin/ipfw add 10 allow ip from %s to any in via igb0",inet_ntoa(client_addr.sin_addr));
- system(cmd);
- syslog(LOG_NOTICE,"SOLknocker: Allow ip from \"%s\" \n",inet_ntoa(client_addr.sin_addr));
- printf("All your drugs are belong to us!\n");
- close(soc_cli);
- exit(0);
- }
- else
- {
- syslog(LOG_WARNING, "SOLkocker: Failed to authenticate from \"%s\"\n", inet_ntoa(client_addr.sin_addr));
- printf("Go to hell!\n");
- }
- }
- snprintf(cmd,sizeof(cmd),"/sbin/ipfw add 11 deny ip from %s to any in via igb0",inet_ntoa(client_addr.sin_addr));
- system(cmd);
- close(soc_cli);
- exit(0);
- }
- close(soc_cli);
- }
- }
- static void usage(char *s)
- {
- printf("usage: %s password\n",s);
- exit(-1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement