Коммит
f477b1212d
|
@ -24,7 +24,6 @@ try:
|
|||
tenantid = input('Please enter your Tenant ID: ')
|
||||
appid = input('Please enter your Application ID: ')
|
||||
secret = getpass.getpass('Please enter your Application Secret:')
|
||||
webhook = getpass.getpass('Please enter your webhook from Teams: ')
|
||||
new_token = gettoken.GetToken(tenantid, appid, secret)
|
||||
new_token.gettoken()
|
||||
token = new_token.aadToken
|
||||
|
@ -33,14 +32,12 @@ try:
|
|||
if args.Commands == 'actions':
|
||||
if args.offboard:
|
||||
filename = input('Please enter the CSV filename (export from MDE/Devices): ')
|
||||
comment = input('COmment (mandatory): ')
|
||||
comment = input('Comment (mandatory): ')
|
||||
new_csv = read.Csv(filename)
|
||||
new_csv.open()
|
||||
for ids in new_csv.list_ids:
|
||||
new_offboard = offboard.Offboard(token, ids, comment)
|
||||
new_offboard.offboard()
|
||||
print(new_offboard.results)
|
||||
|
||||
new_offboard_action = offboard.Offboard(token, ids, comment)
|
||||
new_offboard_action.offboard()
|
||||
elif args.quick:
|
||||
print("Let's quick scan")
|
||||
else:
|
||||
|
|
|
@ -9,17 +9,19 @@ class Offboard:
|
|||
self.comment = comment
|
||||
|
||||
def offboard(self):
|
||||
url = f"https://api.securitycenter.microsoft.com/api/machines/{self.id}/offboard"
|
||||
headers = {
|
||||
'Content-Type' : 'application/json',
|
||||
'Accept' : 'application/json',
|
||||
'Authorization' : "Bearer " + self.token
|
||||
}
|
||||
try:
|
||||
url = f"https://api.securitycenter.microsoft.com/api/machines/{self.id}/offboard"
|
||||
headers = {
|
||||
'Content-Type' : 'application/json',
|
||||
'Accept' : 'application/json',
|
||||
'Authorization' : "Bearer " + self.token
|
||||
}
|
||||
|
||||
data = json.dumps({"Comment": self.comment}).encode("utf-8")
|
||||
data = json.dumps({"Comment": self.comment}).encode("utf-8")
|
||||
|
||||
req = urllib.request.Request(url, data, headers)
|
||||
response = urllib.request.urlopen(req)
|
||||
jsonResponse = json.loads(response.read())
|
||||
self.results = jsonResponse["Results"]
|
||||
return self.results
|
||||
req = urllib.request.Request(url, data, headers)
|
||||
response = urllib.request.urlopen(req)
|
||||
jsonResponse = json.loads(response.read())
|
||||
print(jsonResponse)
|
||||
except Exception as e:
|
||||
print(e)
|
Загрузка…
Ссылка в новой задаче