Created
February 7, 2013 13:37
-
-
Save Zitrax/4730967 to your computer and use it in GitHub Desktop.
Tiny python script to search for pastebin entries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2 | |
import re | |
import sys | |
import getpass | |
# FILL IN | |
username = "test" | |
passwd = getpass.getpass("Enter password for %s: " % username) | |
realm = "test" | |
base_url = "http://test/" | |
def setup_http_auth(url): | |
auth_handler = urllib2.HTTPBasicAuthHandler() | |
auth_handler.add_password(realm=realm, | |
uri=url, | |
user=username, | |
passwd=passwd) | |
opener = urllib2.build_opener(auth_handler) | |
urllib2.install_opener(opener) | |
def check_id(id): | |
url = "%s%s" % (base_url, id) | |
setup_http_auth(url) | |
sys.stdout.write("\rChecking %d" % id) | |
sys.stdout.flush() | |
html_content = urllib2.urlopen(url).read() | |
if re.search("Posted by %s" % username, html_content): | |
print "\nMatch for '%s'" % url | |
for id in range(9714,9650,-1): | |
check_id(id) | |
print "\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment