mirror of
https://github.com/gnh1201/caterpillar.git
synced 2025-09-06 09:51:06 +00:00
Update server.py
This commit is contained in:
parent
3165a4441f
commit
84d64348f1
48
server.py
48
server.py
|
@ -60,6 +60,15 @@ resource.setrlimit(
|
||||||
resource.RLIMIT_CORE,
|
resource.RLIMIT_CORE,
|
||||||
(resource.RLIM_INFINITY, resource.RLIM_INFINITY))
|
(resource.RLIM_INFINITY, resource.RLIM_INFINITY))
|
||||||
|
|
||||||
|
# load data to use KnownWords5 strategy
|
||||||
|
# Download data: https://github.com/dwyl/english-words
|
||||||
|
known_words = []
|
||||||
|
if os.path.exists("words_alpha.txt"):
|
||||||
|
with open("words_alpha.txt", "r") as file:
|
||||||
|
words = file.readlines()
|
||||||
|
known_words = [word.strip() for word in words if len(word.strip()) > 5]
|
||||||
|
print ("[*] data loaded to use KnownWords5 strategy")
|
||||||
|
|
||||||
def start(): #Main Program
|
def start(): #Main Program
|
||||||
try:
|
try:
|
||||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
@ -187,18 +196,28 @@ def proxy_check_filtered(data, webserver, port, scheme, method, url):
|
||||||
print ("[*] K-Anonymity strategy not working! %s" % (str(e)))
|
print ("[*] K-Anonymity strategy not working! %s" % (str(e)))
|
||||||
filtered = True
|
filtered = True
|
||||||
|
|
||||||
'''
|
# feedback
|
||||||
# check ID with VowelRatio10 strategy
|
|
||||||
if filtered and len(matches) > 0:
|
if filtered and len(matches) > 0:
|
||||||
|
score = 0
|
||||||
|
|
||||||
|
# check ID with VowelRatio10 strategy
|
||||||
def vowel_ratio_test(s):
|
def vowel_ratio_test(s):
|
||||||
ratio = calculate_vowel_ratio(s)
|
ratio = calculate_vowel_ratio(s)
|
||||||
return ratio > 0.2 and ratio < 0.7
|
return ratio > 0.2 and ratio < 0.7
|
||||||
filtered = not all(map(vowel_ratio_test, matches))
|
if all(map(vowel_ratio_test, matches)):
|
||||||
'''
|
score += 1
|
||||||
|
|
||||||
# check ID with Palindrome5 strategy
|
# check ID with Palindrome5 strategy
|
||||||
if filtered and len(matches) > 0:
|
if all(map(has_palindrome, matches)):
|
||||||
filtered = not all(map(has_palindrome, matches))
|
score += 1
|
||||||
|
|
||||||
|
# check ID with EnglishWords5 strategy
|
||||||
|
if all(map(has_known_word, matches)):
|
||||||
|
score += 1
|
||||||
|
|
||||||
|
# make decision
|
||||||
|
if score > 1:
|
||||||
|
filtered = False
|
||||||
|
|
||||||
# check an attached images (check images with Not-CAPTCHA strategy)
|
# check an attached images (check images with Not-CAPTCHA strategy)
|
||||||
if not filtered and len(matches) > 0 and truecaptcha_userid != '':
|
if not filtered and len(matches) > 0 and truecaptcha_userid != '':
|
||||||
|
@ -465,7 +484,6 @@ def truecaptcha_solve(encoded_image):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Strategy: VowelRatio10
|
# Strategy: VowelRatio10
|
||||||
'''
|
|
||||||
def calculate_vowel_ratio(s):
|
def calculate_vowel_ratio(s):
|
||||||
# Calculate the length of the string.
|
# Calculate the length of the string.
|
||||||
length = len(s)
|
length = len(s)
|
||||||
|
@ -479,7 +497,6 @@ def calculate_vowel_ratio(s):
|
||||||
vowel_ratio = vowel_count / length
|
vowel_ratio = vowel_count / length
|
||||||
|
|
||||||
return vowel_ratio
|
return vowel_ratio
|
||||||
'''
|
|
||||||
|
|
||||||
# Strategy: Palindrome5
|
# Strategy: Palindrome5
|
||||||
def has_palindrome(input_string):
|
def has_palindrome(input_string):
|
||||||
|
@ -494,5 +511,18 @@ def has_palindrome(input_string):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
# Strategy: KnownWords5
|
||||||
|
def has_known_word(input_string):
|
||||||
|
def is_known_word(s):
|
||||||
|
return s in known_words
|
||||||
|
|
||||||
|
n = len(input_string)
|
||||||
|
for i in range(n):
|
||||||
|
for j in range(i + 5, n + 1): # Find substrings of at least 5 characters
|
||||||
|
substring = input_string[i:j]
|
||||||
|
if is_known_word(substring):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
if __name__== "__main__":
|
if __name__== "__main__":
|
||||||
start()
|
start()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user