File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change 1
1
import requests
2
2
import subprocess
3
+ import shlex
3
4
4
5
def func_calls ():
5
6
formats .get_format ()
@@ -11,16 +12,17 @@ def func_calls():
11
12
session = requests .Session ()
12
13
proxies = {
13
14
'http' : 'http://test:pass@localhost:8080' ,
14
- 'https' : 'http ://test:pass@localhost:8090' ,
15
+ 'https' : 'https ://test:pass@localhost:8090' , # Changed http to https for secure transmission
15
16
}
16
- url = 'http ://example.com' # Replace with a valid URL
17
+ url = 'https ://example.com' # Changed http to https for secure transmission
17
18
req = requests .Request ('GET' , url )
18
19
prep = req .prepare ()
19
20
session .rebuild_proxies (prep , proxies )
20
21
21
- # Introduce a command injection vulnerability
22
+ # Fix for command injection vulnerability
22
23
user_input = input ("Enter a command to execute: " )
23
- command = "ping " + user_input
24
+ safe_user_input = shlex .quote (user_input )
25
+ command = "ping " + safe_user_input
24
26
subprocess .call (command , shell = True )
25
27
26
- print ("Command executed!" )
28
+ print ("Command executed!" )
You can’t perform that action at this time.
0 commit comments