File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import requests
22import subprocess
3+ import shlex
34
45if __name__ == '__main__':
56 formats.get_format()
89 sessions.SessionRedirectMixin.resolve_redirects()
910 session = requests.Session()
1011 proxies = {
11- 'http': 'http ://test:pass@localhost:8080',
12- 'https': 'http ://test:pass@localhost:8090',
12+ 'http': 'https ://test:pass@localhost:8080',
13+ 'https': 'https ://test:pass@localhost:8090',
1314 }
14- url = 'http ://example.com' # Replace with a valid URL
15+ url = 'https ://example.com' # Replace with a valid URL
1516 req = requests.Request('GET', url)
1617 prep = req.prepare()
1718 session.rebuild_proxies(prep, proxies)
1819
19- # Introduce a command injection vulnerability
20+ # Introduced secure command handling
2021 user_input = input("Enter a command to execute: ")
21- command = "ping " + user_input
22- subprocess.call(command, shell=True )
22+ command = shlex.split( "ping " + user_input)
23+ subprocess.call(command, shell=False )
2324
24- print("Command executed!")
25+ print("Command executed!")
You can’t perform that action at this time.
0 commit comments