8000 Update v1.0 · mlcsec/Graphpython@a9abd53 · GitHub
[go: up one dir, main page]

Skip to content

Commit a9abd53

Browse files
committed
Update v1.0
1 parent 8133dfb commit a9abd53

File tree

4 files changed

+33
-28
lines changed

4 files changed

+33
-28
lines changed

Graphpython/__main__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,12 @@ def main():
196196
"display-lapsaccountprotectionpolicyrules",
197197
"display-usergroupaccountprotectionpolicyrules", "add-exclusiongrouptopolicy",
198198
"deploy-maliciousscript", "deploy-maliciousweblink", "backdoor-script",
199-
"update-deviceconfig", "reboot-device", "retire-device", "lock-device",
200-
"shutdown-device"]:
199+
"update-deviceconfig", "reboot-device", "lock-device", "shutdown-device"]:
201200
getattr(intune_exploit, args.command.replace("-", "_"))(args)
202201

203202
# Cleanup commands
204203
elif args.command in ["delete-user", "delete-group", "remove-groupmember", "delete-application",
205-
"delete-device", "wipe-device"]:
204+
"delete-device", "wipe-device", "retire-device"]:
206205
getattr(cleanup, args.command.replace("-", "_"))(args)
207206

208207
# Locator commands

Graphpython/commands/cleanup.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# Cleanup #
66
###########
77

8+
# delete-user
89
def delete_user(args):
910
if not args.id:
1011
print_red("[-] Error: --id argument is required for Delete-User command")
@@ -27,6 +28,7 @@ def delete_user(args):
2728
print_red(response.text)
2829
print("=" * 80)
2930

31+
# delete-group
3032
def delete_group(args):
3133
if not args.id:
3234
print_red("[-] Error: --id argument is required for Delete-Group command")
@@ -49,6 +51,7 @@ def delete_group(args):
4951
print_red(response.text)
5052
print("=" * 80)
5153

54+
# remove-groupmember
5255
def remove_groupmember(args):
5356
if not args.id:
5457
print_red("[-] Error: --id groupid,objectid required for Remove-GroupMember command")
@@ -77,6 +80,7 @@ def remove_groupmember(args):
7780
print_red(response.text)
7881
print("=" * 80)
7982

83+
# delete-application
8084
def delete_application(args):
8185
if not args.id:
8286
print_red("[-] Error: --id argument is required for Delete-Application command")
@@ -99,6 +103,7 @@ def delete_application(args):
99103
print_red(response.text)
100104
print("=" * 80)
101105

106+
# delete-device
102107
def delete_device(args):
103108
if not args.id:
104109
print_red("[-] Error: --id argument is required for Delete-Device command")
@@ -121,6 +126,7 @@ def delete_device(args):
121126
print_red(response.text)
122127
print("=" * 80)
123128

129+
# wipe-device
124130
def wipe_device(args):
125131
if not args.id:
126132
print_red("[-] Error: --id argument is required for Wipe-Device command")
@@ -149,4 +155,28 @@ def wipe_device(args):
149155
else:
150156
print_red(f"[-] Failed to initiate device wipe: {response.status_code}")
151157
print_red(response.text)
158+
print("=" * 80)
159+
160+
# retire-device
161+
def retire_device(args):
162+
if not args.id:
163+
print_red("[-] Error: --id argument is required for Retire-Device command")
164+
return
165+
166+
print_yellow("[*] Retire-Device")
167+
print("=" * 80)
168+
api_url = f"https://graph.microsoft.com/beta/deviceManagement/managedDevices/{args.id}/retire"
169+
user_agent = get_user_agent(args)
170+
171+
headers = {
172+
'Authorization': f'Bearer {get_access_token(args.token)}',
173+
'User-Agent': user_agent
174+
}
175+
176+
response = requests.post(api_url, headers=headers)
177+
if response.ok:
178+
print_green(f"[+] Device retire initiated successfully")
179+
else:
180+
print_red(f"[-] Failed to initiate device retire: {response.status_code}")
181+
print_red(response.text)
152182
print("=" * 80)

Graphpython/commands/intune_exploit.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,30 +1972,6 @@ def reboot_device(args):
19721972
print_red(response.text)
19731973
print("=" * 80)
19741974

1975-
# retire-device
1976-
def retire_device(args):
1977-
if not args.id:
1978-
print_red("[-] Error: --id argument is required for Retire-Device command")
1979-
return
1980-
1981-
print_yellow("[*] Retire-Device")
1982-
print("=" * 80)
1983-
api_url = f"https://graph.microsoft.com/beta/deviceManagement/managedDevices/{args.id}/retire"
1984-
user_agent = get_user_agent(args)
1985-
1986-
headers = {
1987-
'Authorization': f'Bearer {get_access_token(args.token)}',
1988-
'User-Agent': user_agent
1989-
}
1990-
1991-
response = requests.post(api_url, headers=headers)
1992-
if response.ok:
1993-
print_green(f"[+] Device retire initiated successfully")
1994-
else:
1995-
print_red(f"[-] Failed to initiate device retire: {response.status_code}")
1996-
print_red(response.text)
1997-
print("=" * 80)
1998-
19991975
# lock-device
20001976
def lock_device(args):
20011977
if not args.id:

Graphpython/utils/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ def list_commands():
161161
["Display-UserGroupAccountProtectionPolicyRules", "Display user group account protection policy rules"],
162162
["Add-ExclusionGroupToPolicy", "Bypass av, asr, etc. rules by adding an exclusion group containing compromised user or device"],
163163
["Reboot-Device", "Reboot managed device"],
164-
["Retire-Device", "Retire managed device"],
165164
["Lock-Device", "Lock managed device"],
166165
["Shutdown-Device", "Shutdown managed device"],
167166
["Update-DeviceConfig", "Update properties of the managed device configuration"]
@@ -174,6 +173,7 @@ def list_commands():
174173
["Delete-Application", "Delete an application"],
175174
["Delete-Device", "Delete managed device"],
176175
["Wipe-Device", "Wipe managed device"],
176+
["Retire-Device", "Retire managed device"]
177177
]
178178

179179
locator_commands = [

0 commit comments

Comments
 (0)
0