This commit is contained in:
MunyDev 2024-08-16 18:27:48 -04:00
parent d23ad7082a
commit f2fe4186ef
No known key found for this signature in database
GPG Key ID: 7DFBB51356064F62
2 changed files with 28 additions and 13 deletions

2
requirements.txt Normal file

@ -0,0 +1,2 @@
requests
protobuf

@ -3,37 +3,50 @@ import http.client as cli
import requests
import device_management_pb2
import socket
from urllib import parse
class A(BaseHTTPRequestHandler):
def do_POST(self):
self.send_response(200)
self.send_header("Content-Type", "text/html")
self.end_headers()
dat = self.rfile.read(int(self.headers.get('Content-Length')))
dmr = device_management_pb2.DeviceManagementRequest()
dmr.ParseFromString(dat)
print(dmr)
if (dmr.device_state_retrieval_request):
if (dmr.HasField('device_state_retrieval_request')):
# Expecting a device state response
print("intercepting")
x = device_management_pb2.DeviceManagementResponse()
rr = device_management_pb2.DeviceStateRetrievalResponse()
rr = x.device_state_retrieval_response
dv = device_management_pb2.DeviceInitialEnrollmentStateResponse()
dv.Clear()
dv = rr.initial_state_response
dv.initial_enrollment_mode = 0
dv.management_domain = ""
dv.is_license_packaged_with_device = False
dv.disabled_state = False
rr.initial_state_response = dv
dv.disabled_state.message = ""
rr.restore_mode = 0
rr.management_domain = ""
self.wfile.write(rr.SerializeToString())
self.send_response(200)
self.send_header("Content-Type", "application/x-protobuffer")
self.send_header("Content-Length", str(len(x.SerializeToString())))
self.end_headers()
print(x)
self.wfile.write(x.SerializeToString())
return
print(parse.urlparse(self.path).query)
con = requests.request('POST', 'https://m.google.com/devicemanagement/data/api?' + parse.urlparse(self.path).query, data=dat, headers=dict(self.headers))
print(f"Status code: {con.status_code}")
self.send_response(con.status_code)
self.end_headers()
dmr = device_management_pb2.DeviceManagementResponse()
dmr.ParseFromString(con.content)
print(dmr)
self.wfile.write(dmr.SerializeToString())
print("data read")
print(dat)
con = requests.request('POST', 'https://m.google.com/devicemanagement/data/api', data=dat, headers=dict(self.headers))
self.wfile.write(bytes(str(con.status_code), 'utf-8'))
# self.wfile.close()
hs = HTTPServer(("0.0.0.0", 3040), A)
hs.serve_forever()