· 10 years ago · Aug 03, 2016, 10:00 PM
1import urllib2 # d/l web pages
2import BeautifulSoup # parse URLs
3import re # to grep URLs
4import time # time.sleep()
5from time import gmtime, strftime # time entry
6import sys # sys.stdout()
7
8archive_url = "http://pastebin.com/archive"
9
10# Define the maximum length of saved post in characters
11# Huge posts tend to be irrelevant.
12max_length = 100000
13
14# Define seconds between each download. If you set this to 0, you
15# will be banned by Pastebin. The default has been tested.
16wait_secs = 2
17
18# Define search-words here!
19search_list = ['@hotmail.fr',
20'@aol.com',
21'@yahoo.com',
22'@gmail.com',
23'@hotmail.com',
24'@hotmail.fr:',
25'@aol.com:',
26'@yahoo.com:',
27'@gmail.com:',
28'@hotmail.com:',
29'@outlook.com:',
30'@outlook.fr:',
31'@live.fr:',
32'@live.be:',
33'http://members.',
34'CharExtractMinHeight=',
35'|2021|',
36'|2020|',
37'|2019|',
38'|201',
39'|2017|',
40'|2016|',
41'|2015|',
42'| oneClick: ',
43'IBAN:',
44'[Wordlist]',
45'[Settings] SiteURL=',
46'[Wordlist] UserIndex=',
47'https://membres.',
48'http://www.starpass.fr',
49'https://www.paypal.com/fr/cgi-bin/webscr',
50'https://wifi.free.fr/',
51'https://store.playstation.com',
52'https://login.live.com',
53'https://www.amazon.',
54'https://signin.ea.com',
55'http://www.t411.ch',
56'https://www.paypal.com/fr/webapps/mpp/home',
57'https://dossier.admission-postbac.fr/Postbac/authentification']
58
59# Define excluded words here!
60excl_list = ['video',
61'.mkv',
62'.wmv',
63'.avi',
64'.mp4',
65'error report',
66'system information'
67'debug',
68'log',
69'FAQ'
70'using', # Filtering source-code
71'import',
72'include',
73'static',
74'array',
75'function',
76'class',
77'define',
78'git',
79'<head>', # Filtering complete HTML files
80'script',
81'CloudFlare', # Some people posting CloudFlare errors
82'Technic'] # Dude using Pastebin as error log
83
84class color:
85red = '\033[31m'
86green = '\033[92m'
87reset = '\033[0m'
88
89def download_page(dl_url):
90try:
91response = urllib2.urlopen(dl_url)
92text = response.read()
93except:
94sys.stdout.write("Skipping %s" % dl_url)
95text = 0
96pass
97return text
98
99def test_for_relevance(content):
100keyword_list = []
101
102if content != 0 and len(content) < max_length:
103for search_word in search_list:
104if search_word in content:
105keyword_list.append(search_word)
106
107# keyword_list returned empty if an excl_word is seen
108if len(excl_list) > 0:
109for excl_word in excl_list:
110if excl_word in content:
111keyword_list = []
112return keyword_list
113
114def save_as_file(name, content):
115sys.stdout.write("Testing pastebin.com/%s:" %name)
116keyword_list = test_for_relevance(content)
117
118if len(keyword_list) > 0:
119sys.stdout.write(color.green + "\t match" + color.reset + "\n")
120
121cur_time = strftime("%Y-%m-%d %H:%M:%S", gmtime())
122
123index = open("index.html","a")
124index.write("{tm} - <A HREF='store.html/#{nm}'>" \
125"{nm}</A> - matched: {kw}<br>"\
126.format(tm = cur_time, nm = name, \
127ct = content, kw =keyword_list))
128index.close()
129
130store = open("store.html", "a")
131store.write("<A NAME='{nm}'><br><pre>{ct}</pre><br><hr>"\
132.format(nm=name, ct=content))
133
134store.close()
135else:
136sys.stdout.write(color.red + "\t no match" + color.reset + "\n")
137time.sleep(wait_secs)
138
139def download_all_urls(url_list):
140for url in url_list:
141page = download_page("http://pastebin.com/raw.php?i=%s" % url)
142save_as_file(url, page)
143
144def extract_urls():
145""" Returns the stripped 8 char pastebin-string """
146sys.stdout.write("Extracting archive-URLs:")
147
148request = urllib2.Request(archive_url)
149response = urllib2.urlopen(request)
150
151soup = BeautifulSoup.BeautifulSoup(response)
152links = soup.findAll('a', href=re.compile('^\/([A-Za-z0-9]{8})'))
153
154result = []
155for link in links:
156if not 'settings' in link['href']:
157if not 'languages' in link['href']:
158result.append(link['href'].encode('ascii')[1)
159sys.stdout.write(color.green + "\t success" + color.reset + "\n")
160return result
161
162def main():
163url_list = extract_urls()
164download_all_urls(url_list)
165
166if name == "__main__":
167main()