Skip to content

Instantly share code, notes, and snippets.

@Davnit
Created March 25, 2022 15:51
Show Gist options
  • Save Davnit/423607285f34a78fba201b51c70b9e54 to your computer and use it in GitHub Desktop.
Save Davnit/423607285f34a78fba201b51c70b9e54 to your computer and use it in GitHub Desktop.
Web server for intercepting provisioning requests and unlocking Cisco SPA504G IP phone
from http.server import HTTPServer, BaseHTTPRequestHandler
class GlobalResponseHandler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header("Content-Type", "application/xml")
self.end_headers()
xml_data = r'<?xml version="1.0" encoding="ISO-8859-1"?>' \
r'<flat-profile>' \
r'<Protect_IVR_FactoryReset>No</Protect_IVR_FactoryReset>' \
r'<Admin_Passwd ua="na">123</Admin_Passwd>' \
r'</flat-profile>'
self.wfile.write(xml_data.encode("iso-8859-1"))
def main():
endpoint = ("", 80)
server = HTTPServer(endpoint, GlobalResponseHandler)
print("started")
try:
server.serve_forever()
except KeyboardInterrupt:
pass
server.server_close()
print("stopped")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment