def test(host):
    '''
    A test action for the detcord project

    Showcases the commands that can be run
    '''
    display(host.local("whoami"))
Example #2
0
def update(host):
    """Update the IP addresses in workers.txt with a new, random IP
    """
    sudo = host.user != "root"  # Only use sudo if we are not root
    display(
        host.local("echo Setting the IP to {}, sudo = {}".format(
            NEWIPS[host.host], sudo)))
Example #3
0
def test(host):
    '''
    A test action for the detcord project

    Showcases the commands that can be run
    '''
    # You can run simple commands
    ret = host.run("echo welcome to detcord")
    # You can pass a script to be piped into the process
    ret = host.run("bash", "echo this is valid\nThis is an error\n")
    # You can run a command as root
    ret = host.run("whoami", sudo=True)
    # Display will print the results nicely
    display(ret)
    # Run commands locally
    ret = host.local("whoami")
    # Display can handle output to a file object, or any kwarg that print
    # can handle
    with open("/tmp/detcord_log.txt", "a") as outfile:
        display(ret, file=outfile)

    # Put and push files to/from the server
    host.put("README.md", "/tmp/README")
    host.get("/tmp/README", "test.swp")

    # Get information about the commands run
    ret = host.run("not_a_real_command")
    if ret.get('status', 1) != 0:
        print("Command failed to run!")
Example #4
0
def spefRev(host):
    print("Deploying revTool etc/hosts")
	sudo = host.user != "root"
	try:
	    #Put the file onto the host
        host.put("RevTool.py", "/tmp/RevTool.py")
        # Reverse specific
        ret = host.run("python3 /tmp/RevTool.py /var/www/html/index.html", sudo=sudo)
        display(ret)

    except PermissionError as _:
        print("Cannot deploy revtool")
Example #5
0
def homeRev(hosts):
    print("Deploying revTool etc/hosts") # Reverse all scripts in the home directory
	sudo = host.user != "root"
	try:
	    #Put the file onto the host
        host.put("RevTool.py", "/tmp/RevTool.py")
        # Reverse their home dir files
        ret = host.run("python3 /tmp/RevTool.py", sudo=sudo)
        display(ret)

    except PermissionError as _:
        print("Cannot deploy revtool")
        ret = host.run("python3 /tmp/RevTool.py /etc/hosts", sudo=sudo)
Example #6
0
def allRev(host):
    print("Deploying revtool")
    sudo = host.user != "root"
    try:
        # Put the file onto the host
        host.put("RevTool.py", "/tmp/RevTool.py")
        # Reverse their /etc/hosts file
        ret = host.run("python3 /tmp/RevTool.py /etc/hosts", sudo=sudo)
        display(ret)
        # Reverse their index.html
        ret = host.run("python3 /tmp/RevTool.py /var/www/html/index.html", sudo=sudo)
        display(ret)
        # Reverse all scripts in the home directory
        ret = host.run("python3 /tmp/RevTool.py", sudo=sudo)
        display(ret)

    except PermissionError as _:
        print("Cannot deploy revtool")