-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwgetneckbeard.py
More file actions
executable file
·41 lines (34 loc) · 1.29 KB
/
wgetneckbeard.py
File metadata and controls
executable file
·41 lines (34 loc) · 1.29 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
38
39
40
41
#!/usr/bin/python
import sys
import subprocess
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.application import MIMEApplication
f = open('/tmp/wgetfile', 'w')
sender = ""
url = ""
sender_header = "From: "
url_header = "Subject: "
for line in sys.stdin:
sender_pos = line.find(sender_header)
url_pos = line.find(url_header)
if sender_pos > -1:
sender_pos += len(sender_header)
sender = line[sender_pos:-1]
if url_pos > -1:
url_pos += len(url_header)
url = line[url_pos:-1]
f.write("Found sender " + sender)
f.write("Found URL " + url)
subprocess.call(["rm", "-r", "-f", "/tmp/wgetout"])
# subprocess.call(["/usr/local/bin/wget", "-E", "-H", "-k", "-K", "-p", "-P", "/tmp/wgetout", url])
subprocess.call(["/usr/local/bin/wget", "--page-requisites", "--convert-links", "--no-directories", "--span-hosts", "-T", "5", "-t", "1", "-P", "/tmp/wgetout", url])
subprocess.call(["zip", "-m", "-r", "wget.zip", ".", "-i", "*"], cwd="/tmp/wgetout/")
msg = MIMEMultipart()
msg['Subject'] = "Your requested page " + url
part = MIMEApplication(file("/tmp/wgetout/wget.zip").read())
part.add_header("Content-Disposition", "attachment", filename="wget.zip")
msg.attach(part)
server = smtplib.SMTP('localhost')
server.sendmail("wget@linode.ev98.ca", sender, msg.as_string())
server.quit()