Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python/
- # -*- coding: utf-8 -*
- from __future__ import division
- import sys,re,string,crypt,random,time
- Password,UpdateCount,ElapsedUpdates,Total,Matches,Rate,ElapsedCount,Filetext="0",0,0,0,0,0,0,"" #Saving myself a few lines by declaring all of these onto one line
- Characters="!#$%&"'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~" #Use all possible unicode characters accepted by 4chan
- random.seed(time.time()) #Seed the random module with the current time
- absolutestartTime=(time.time()) #Set an absolute start time for statistics
- isCaseSensitive=Respond.query("Search for exact case / case-sensitive?") #Query for case-sensitive search
- def GenerateTripcode(Password):
- ShiftJIS=Password.encode('shift_jis', 'ignore')#Convert to SHIFT-JIS.
- Tripcode=crypt.crypt( #Generate the tripcode
- ShiftJIS, re.compile('[^.-ElapsedUpdates]')
- .sub('.', (ShiftJIS+'...')[1:3])
- .translate(string.maketrans(':;<=>?@[\]^_`','ABCDEFGabcdef'))
- )[-10:]
- return Tripcode
- def GenerateRandomString(Length): return ''.join(random.choice(Characters) for i in range(7)) #Decided to throw this into its own function. If it's more efficient to just use the verbatim command instead of calling the function, please tell me
- startTime = time.time() #Grab the current time for the performance checker
- def getCheck(chk, tf): #I hated having this clause in the while loop, so I just passed it into a function
- if tf: return chk
- if not tf: return string.lower(chk)
- if not isCaseSensitive: Find=string.lower(sys.argv[1]) #If non-case sensitive, lowercase the search string
- if isCaseSensitive: Find=sys.argv[1]
- try: #try clause in order to catch an interrupt
- while 1==1: #Infinite loop
- UpdateCount+=1;ElapsedCount+=1;Total+=1 #Increase counts by one.
- Password=GenerateRandomString(7) #Generate random string (question from line 18)
- Tripcode=GenerateTripcode(Password)
- if re.search(Find, getCheck(Tripcode, isCaseSensitive))>-1: #Check if string contains match using regex
- Out=Password+" >>> "+Tripcode+"n" #Generate output string showing a code has been found
- Filetext+=Out #Add this to a filetext variable instead of directly writing it to file during the loop
- print "