Skip to content

Commit

Permalink
Cleanup remote server extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
battleoverflow committed Jul 10, 2023
1 parent f924d1a commit dd4a042
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions iocextract.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import sys
import json
import base64
import random
import string
import argparse
import requests
import binascii
Expand Down Expand Up @@ -1139,12 +1141,12 @@ def main():
args.output.write("Unable to access remote host: {0}".format(args.url))
sys.exit(1)

d = "/tmp/url.txt"
file_contents = "/tmp/{0}.txt".format("".join(random.choice(string.ascii_lowercase) for _ in range(10)))

with open(d, "w") as f:
f.write(remote_url.content)
with open(file_contents, "w") as f:
f.write(str(remote_url.content))

with open(d, "r") as f:
with open(file_contents, "r") as f:
data = f.read()

if args.extract_emails or extract_all:
Expand Down Expand Up @@ -1201,7 +1203,7 @@ def main():
args.output.flush()

# Cleanup temp file
os.remove(d)
os.remove(file_contents)

else:
if args.extract_emails or extract_all:
Expand Down

0 comments on commit dd4a042

Please sign in to comment.