Code to Send a Get Request to a URL and Print Response and Headers
this code will do a get request on the URL and then print the request headers and response
Below in the target URL i have passed IP address and Injection Point as %s which i will supply on command line
import sys
import requests
from bs4 import BeautifulSoup
import json
def search_friends(ip, param):
target = "http://%s/ATutor/mods/_standard/social/index_public.php?q=%s" % (ip, param)
r = requests.get(target)
s = BeautifulSoup(r.text, 'lxml')
print()
print("Request Headers:")
print(json.dumps(dict(r.request.headers), indent=4))
print()
print("Response Headers:")
print(json.dumps(dict(r.headers), indent=4))
print()
print("Response Content:")
print(s.text)
def main():
if len(sys.argv) != 3:
print("Please supply 2 parameters")
sys.exit(1)
ip = sys.argv[1]
inj_str = sys.argv[2]
search_friends(ip, inj_str)
if __name__ == "__main__":
main()