Created
November 11, 2018 21:35
-
-
Save random-robbie/1cdf8ad5b0fc445a069f21fbba2c1faf to your computer and use it in GitHub Desktop.
Binary Edge - Filter kubernetes systems by API endpoint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, fnmatch | |
import re | |
import shutil | |
folder = "/home/host/MyBinaryEdge/kube/cfg/" | |
def readkube(folder,file): | |
filename = ""+folder+""+file+"" | |
with open(filename, "r") as dd: | |
details = dd.read() | |
try: | |
master = re.compile("--master=https://api.internal.(.+?) --oom-score-adj").findall(str(details))[0] | |
print ("[*] Master Found: "+master+" [*]") | |
if not os.path.exists("/home/host/MyBinaryEdge/kube/knownapis/"+master+"/"): | |
os.makedirs("/home/host/MyBinaryEdge/kube/knownapis/"+master+"/") | |
newfilename = "/home/host/MyBinaryEdge/kube/knownapis/"+master+"/"+file+"" | |
os.system ("mv "+filename+" "+newfilename+"") | |
except: | |
print ("[*] Unable to find master [*]") | |
dd.close() | |
listOfFiles = os.listdir(""+folder+".") | |
pattern = "*.json" | |
for entry in listOfFiles: | |
if fnmatch.fnmatch(entry, pattern): | |
readkube(folder,entry) | |
#exit(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment