sia_tp_sample / 360netlab__DGA.jsonl
shahp7575's picture
commit files to HF hub
3a7f06a
{"nwo":"360netlab\/DGA","sha":"f6e1a197556e9925903b1940d401b02b3650e573","path":"code\/shiotob\/dga.py","language":"python","identifier":"get_next_domain","parameters":"(domain, crc, version)","argument_list":"","return_statement":"return domain","docstring":"calculate the new hostname length\n max: 255\/16 = 15\n min: 10","docstring_summary":"calculate the new hostname length\n max: 255\/16 = 15\n min: 10","docstring_tokens":["calculate","the","new","hostname","length","max",":","255","\/","16","=","15","min",":","10"],"function":"def get_next_domain(domain, crc, version):\n qwerty = 'qwertyuiopasdfghjklzxcvbnm123945678'\n\n def sum_of_characters(domain):\n return sum([ord(d) for d in domain[:-3]])\n\n sof = sum_of_characters(domain)\n if version == 2:\n sof ^= crc\n\n ascii_codes = [ord(d) for d in domain] + 100*[0]\n old_hostname_length = len(domain) - 4\n for i in range(0, 66):\n for j in range(0, 66):\n edi = j + i\n if edi < 65:\n p = (old_hostname_length * ascii_codes[j]) \n cl = p ^ ascii_codes[edi] ^ sof\n ascii_codes[edi] = cl & 0xFF\n\n \"\"\"\n calculate the new hostname length\n max: 255\/16 = 15\n min: 10\n \"\"\"\n cx = ((ascii_codes[2]*old_hostname_length) ^ ascii_codes[0]) & 0xFF\n hostname_length = int(cx\/16) # at most 15\n if hostname_length < 10:\n hostname_length = old_hostname_length\n\n \"\"\"\n generate hostname\n \"\"\"\n for i in range(hostname_length):\n index = int(ascii_codes[i]\/8) # max 31 --> last 3 chars of qwerty unreachable\n bl = ord(qwerty[index])\n ascii_codes[i] = bl\n\n hostname = ''.join([chr(a) for a in ascii_codes[:hostname_length]])\n\n \"\"\"\n append .net or .com (alternating)\n \"\"\"\n tld = '.com' if domain.endswith('.net') else '.net'\n domain = hostname + tld\n\n return domain","function_tokens":["def","get_next_domain","(","domain",",","crc",",","version",")",":","qwerty","=","'qwertyuiopasdfghjklzxcvbnm123945678'","def","sum_of_characters","(","domain",")",":","return","sum","(","[","ord","(","d",")","for","d","in","domain","[",":","-","3","]","]",")","sof","=","sum_of_characters","(","domain",")","if","version","==","2",":","sof","^=","crc","ascii_codes","=","[","ord","(","d",")","for","d","in","domain","]","+","100","*","[","0","]","old_hostname_length","=","len","(","domain",")","-","4","for","i","in","range","(","0",",","66",")",":","for","j","in","range","(","0",",","66",")",":","edi","=","j","+","i","if","edi","<","65",":","p","=","(","old_hostname_length","*","ascii_codes","[","j","]",")","cl","=","p","^","ascii_codes","[","edi","]","^","sof","ascii_codes","[","edi","]","=","cl","&","0xFF","cx","=","(","(","ascii_codes","[","2","]","*","old_hostname_length",")","^","ascii_codes","[","0","]",")","&","0xFF","hostname_length","=","int","(","cx","\/","16",")","# at most 15","if","hostname_length","<","10",":","hostname_length","=","old_hostname_length","\"\"\"\n generate hostname\n \"\"\"","for","i","in","range","(","hostname_length",")",":","index","=","int","(","ascii_codes","[","i","]","\/","8",")","# max 31 --> last 3 chars of qwerty unreachable","bl","=","ord","(","qwerty","[","index","]",")","ascii_codes","[","i","]","=","bl","hostname","=","''",".","join","(","[","chr","(","a",")","for","a","in","ascii_codes","[",":","hostname_length","]","]",")","\"\"\"\n append .net or .com (alternating)\n \"\"\"","tld","=","'.com'","if","domain",".","endswith","(","'.net'",")","else","'.net'","domain","=","hostname","+","tld","return","domain"],"url":"https:\/\/github.com\/360netlab\/DGA\/blob\/f6e1a197556e9925903b1940d401b02b3650e573\/code\/shiotob\/dga.py#L78-L124"}