Advertisement
Guest User

Untitled

a guest
Aug 12th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #!/usr/bin/env python2.7
  2. import requests, sys
  3. import json
  4. import urllib3
  5.  
  6. urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
  7.  
  8. def connect(hostip,REST):
  9.  
  10. fg_host = hostip
  11. fg_api = REST
  12. fg_user = 'username'
  13. fg_pass = 'password'
  14.  
  15. login_url = 'https://%s/logincheck' % fg_host
  16. login_payload = {'username': fg_user, 'secretkey': fg_pass}
  17.  
  18. r = requests.post(login_url, data=login_payload, verify=False)
  19. cookiejar = r.cookies
  20.  
  21. r = requests.get('https://%s/api/v2/%s' % (fg_host, fg_api),
  22. cookies=cookiejar, verify=False)
  23.  
  24. state = r.content
  25.  
  26.  
  27. if __name__ == "__main__":
  28. connect(sys.argv[1],sys.argv[2])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement