Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import os
- class UniqueList(list):
- def appendunique(self,item):
- if item not in self:
- self.append(item)
- return True
- return False
- def ReadFile(filename):
- f = open(filename,'r');
- return f.read();
- def ReadFileLines(filename):
- lines = []
- with open(filename,'r') as f:
- for line in f:
- lines.append(line);
- return lines
- def WriteFile(filename,text):
- f = open(filename,'w')
- f.writelines(text)
- def IsInList(DetectorList,ComparisonLine):
- for Item in DetectorList:
- if Item in ComparisonLine:
- return Item
- return ""
- def ConstantSystemdScan(Collector,lines):
- Iter = 0
- RepeatLoops = 0
- RestartLoop = True
- while RestartLoop == True:
- Iter = 0
- if RepeatLoops > 0:
- print 'Rescanning list x'+str(RepeatLoops)
- RestartLoop = False
- while Iter < len(lines):
- Check = IsInList(Collector[0],lines[Iter])
- if Check != "":
- Temp = lines[Iter].split(" ");
- Title = "["+Temp[0]+"]";
- if Collector[0].appendunique(Title):
- RestartLoop = True
- Collector[1].append(Title+" via "+Check+"\n");
- print Title + ' detected as related to systemd via ' + Check
- else:
- Iter = Iter + 1
- else:
- Iter = Iter + 1
- RepeatLoops = RepeatLoops + 1
- return Collector
- def LoadBlackList(BlackList):
- Collector = []
- DetectionList = UniqueList();
- WriteOutList = []
- for line in BlackList:
- Temp = line.replace("\n","")
- Title = "["+Temp+"]";
- DetectionList.appendunique(Title)
- WriteOutList.append(Title + " via itself\n");
- Collector.append(DetectionList);
- Collector.append(WriteOutList);
- return Collector;
- while True:
- LocalDirectory =os.path.realpath(os.path.dirname(__file__))
- Garbage = ReadFileLines(LocalDirectory+"/HasDependencies.txt");
- BlackList = ReadFileLines(LocalDirectory+"/Blacklist.txt");
- Collector = LoadBlackList(BlackList);
- Collector2 = ConstantSystemdScan(Collector,Garbage)
- WriteFile(LocalDirectory+"/InfectedWithSystemd.txt",Collector2[1])
- exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement