Closed nicerloop closed 11 months ago
My RBR50 allows me to download the encrypted config via a request to the SOAP API. Here's a Python script that I use to do that. Update the URL and credentials in the main()
function for your own device.
import base64
import re
import requests
class SOAPError(Exception):
pass
def login(s, url, username, password):
body = '''<SOAP-ENV:Body>
<M1:SOAPLogin xmlns:M1="urn:NETGEAR-ROUTER:service:DeviceConfig:1">
<Username>{}</Username>
<Password>{}</Password>
</M1:SOAPLogin>
</SOAP-ENV:Body>'''.format(username, password)
s.post('{}/soap/server_sa/'.format(url), data=body, headers={
'SOAPAction': 'urn:NETGEAR-ROUTER:service:DeviceConfig:1#SOAPLogin'
})
def get_config(s, url):
body = '''<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:M1="urn:NETGEAR-ROUTER:service:DeviceConfig:1">
<soap:Body>
<M1:GetConfigInfo xsi:nil="true" />
</soap:Body>
</soap:Envelope>'''
t = s.post('{}/soap/server_sa/'.format(url), data=body, headers={
'SOAPAction': 'urn:NETGEAR-ROUTER:service:DeviceConfig:1#GetConfigInfo'
}).text
if '<ResponseCode>000</ResponseCode>' not in t:
raise SOAPError('Bad or missing response code')
return re.search('<NewConfigFile>([^<]+)<', t).group(1)
def main():
s = requests.Session()
# log in to router (replace with your URL and credentials)
login(s, 'http://10.0.0.1', 'admin', 'password')
# send SOAP API request to download config
config = get_config(s, 'http://10.0.0.1')
# write encrypted config to 'encrypted.cfg'
with open('encrypted.cfg', 'wb') as f:
f.write(base64.b64decode(config))
if __name__ == '__main__':
main()
Originally posted by @Fysac in https://github.com/Fysac/orbicfg/issues/3#issuecomment-899747104
I did not find any reference to a SOAP API to download/upload config. Do you have any pointer ? Thank you for this nice tool.