from subprocess import Popen
import os
import csv

srcfile = "/" + input('File Input Name: ')
dirpath = os.path.dirname(__file__)
srcpath = os.path.dirname(__file__) + srcfile

with open(srcpath, newline='') as f:
	reader = csv.reader(f)
	for row in reader:
		host = (row[0])
		user = (row[1])
		
		newpath = os.path.dirname(__file__) + "\\" + host
		os.mkdir(newpath)
		
		p = open(newpath + '\{}'.format(host) + '.bat', 'w')
		p.write('net use x: \\\{}'.format(host) + '\c$'  + '\n')
		
		p.write(r'xcopy /H x:\Users\{}'.format(user) + r'\AppData\Local\Microsoft\Windows\History\History.IE5\index.dat ' + newpath + '\n')
		p.write(r'attrib -s -h ' + newpath + '/index.dat' + '\n')
		p.write(r'ren ' + newpath + '\index.dat {}'.format(user) +'_History.dat' + '\n')
		
		p.write(r'xcopy /H "x:\Users\{}'.format(user) + r'\AppData\Local\Microsoft\Windows\Temporary Internet Files\Low\Content.IE5\index.dat" ' + newpath + '\n')
		p.write(r'attrib -s -h ' + newpath + '\index.dat' + '\n')
		p.write(r'ren ' + newpath + '\index.dat {}'.format(user) +'_Temp.dat' + '\n')
		
		p.write(r'xcopy /H x:\Windows\System32\winevt\Logs\Security.evtx ' + newpath + '\n')
		p.write(r'xcopy /H x:\Windows\System32\winevt\Logs\System.evtx ' + newpath + '\n')
		p.write(r'xcopy /H x:\Windows\System32\winevt\Logs\Application.evtx ' + newpath + '\n')
		p.write('net use x: /d')
		p.close()

		p = Popen(newpath + '\{}'.format(host) + '.bat')
		stdout, stderr = p.communicate()
