elDescartable

masquerade_ip.py

Nov 3rd, 2023
838
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.10 KB | Cybersecurity | 0 0
  1. """
  2. setup:
  3.    pip install requests
  4.    pip install requests[socks]
  5.  
  6. super helpful:
  7.    - http://packetforger.wordpress.com/2013/08/27/pythons-requests-module-with-socks-support-requesocks/
  8.    - http://docs.python-requests.org/en/master/user/advanced/#proxies
  9.  
  10. *** For Termux ***
  11.  
  12. 1- Tor Should be Installed
  13. apt install tor
  14. 2- Tor Service must be opened
  15. tor
  16. 3- install requirements
  17. pip install requests
  18. pip install requests[socks]
  19. 4 - change the port in the tool from 9150 to 9050
  20. 5 - RUN :)
  21.  
  22. """
  23. import requests
  24.  
  25. # Define proxies for tor
  26. proxies = {
  27.     'http': 'socks5://127.0.0.1:9050',
  28.     'https': 'socks5://127.0.0.1:9050'
  29. }
  30.  
  31. # Define User-Agent
  32. headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36'}
  33.  
  34.  
  35. def main():
  36.     url = 'http://ifconfig.me/ip'
  37.  
  38.     response = requests.get(url)
  39.     print('ip: {}'.format(response.text.strip()))
  40.  
  41.     response = requests.get(url, headers=headers, proxies=proxies)
  42.     print('tor ip: {}'.format(response.text.strip()))
  43.  
  44.  
  45. if __name__ == '__main__':
  46.     main()
Advertisement
Add Comment
Please, Sign In to add comment