requestsexample.py 605 B

123456789101112131415161718192021222324252627
  1. import requests
  2. surl = 'https://localhost:32768'
  3. auth = {'username': 'salt', 'password':'foobar', 'eauth':'sharedsecret'}
  4. ver = False
  5. with requests.Session() as s:
  6. res = s.post(url=f'{surl}/login', json=auth, verify=ver)
  7. print(res.text)
  8. resp = s.post('https://localhost:32768', json=[{
  9. 'client': 'local',
  10. 'tgt': '*',
  11. 'fun': 'network.ipaddrs'
  12. }],
  13. verify=False)
  14. print(resp.text)
  15. resp = s.post('https://localhost:32768', json=[{
  16. 'client': 'local',
  17. 'tgt': '*',
  18. 'fun': 'file.readdir',
  19. 'arg': ['/etc/']
  20. }],
  21. verify=False)
  22. print(resp.text)