-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathmsc_dropper.py
More file actions
37 lines (28 loc) · 1.28 KB
/
msc_dropper.py
File metadata and controls
37 lines (28 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import sys
from urllib.parse import quote
def encode_url(input_filename, output_filename, replacement):
try:
with open(input_filename, 'r') as input_file:
content = input_file.read()
# Applying URL encoding to the replacement text
encoded_replacement = quote(replacement)
# Replace the placeholder
updated_content = content.replace('<REPLACE HERE>', encoded_replacement)
# Writing to the output file
with open(output_filename, 'w') as output_file:
output_file.write(updated_content)
print(f'Successfully replaced placeholder in {input_filename} and saved to {output_filename}.')
except FileNotFoundError:
print(f'File {input_filename} not found.')
except Exception as e:
print(f'An error occurred: {str(e)}')
# Main program
if __name__ == '__main__':
if len(sys.argv) != 4:
print('Usage: python msc_dropper.py <input_filename> <output_filename> <replacement>')
sys.exit(1)
input_filename = sys.argv[1]
output_filename = sys.argv[2]
replacement = sys.argv[3]
# Applying URL encoding to the replacement text and writing to the output file
encode_url(input_filename, output_filename, replacement)