From 840b22b1555097a4ae2e80096868c424eb69c460 Mon Sep 17 00:00:00 2001 From: Mohammad Shafiee <51268970+wikm360@users.noreply.github.com> Date: Sun, 16 Jun 2024 12:45:20 +0330 Subject: [PATCH] V3.4 improve porn detection optimize phone detection --- .gitignore | 4 +++ README.md | 7 ++--- base.py | 77 ++++++++++++------------------------------------------ 3 files changed, 24 insertions(+), 64 deletions(-) diff --git a/.gitignore b/.gitignore index b6133c3..cd5c632 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ design.txt +detect port scan.py +detect Repeated IP Addresses and Ports.py +detect suspect domain and IPs.py +test.txt diff --git a/README.md b/README.md index 861a8c6..1410571 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,9 @@ What does this bot do? 10) most ulr used per user 11) calculate and send The most used user 12) send users usage ( get with mysql and marzban API ) -13) send most versatile user (in porn sites) -14) send most thirsty user (in porn sites) +13) send user who has the most request in shortest time (versatile person) (in porn sites) +14) send user who spend the longest period in one domain (thirsty person) (in porn sites) +15) detect suspicious Domains and IPs and report by telegram more features coming ๐Ÿ”œ @@ -44,7 +45,7 @@ Before installing the required libraries, you must first install Python and pip First, download and extract the project with the following command : ```bash - wget https://github.com/wikm360/Xray-Log-Analyzer/releases/download/V2.7/Xray-Log-Analyzer.zip + wget https://github.com/wikm360/Xray-Log-Analyzer/releases/latest/download/Xray-Log-Analyzer.zip unzip Xray-Log-Analyzer.zip -d /root/Xray-Log-Analyzer cd Xray-Log-Analyzer/ ``` diff --git a/base.py b/base.py index d582b88..2fe039f 100644 --- a/base.py +++ b/base.py @@ -134,35 +134,7 @@ def analize () : #porn detection : - pattern_porn = r"\b\w*\s*porn\s*\w*\b" - if re.findall(pattern_porn, line_str): - with open (f"{path}porn_detection.txt" , "a" , encoding="utf-8") as file : - file.writelines(line_str) - if user not in p_user : - p_user.append(user) - - pattern_porn = r"\b\w*\s*xnxx\s*\w*\b" - if re.findall(pattern_porn, line_str): - with open (f"{path}porn_detection.txt" , "a" , encoding="utf-8") as file : - file.writelines(line_str) - if user not in p_user : - p_user.append(user) - - pattern_porn = r"\b\w*\s*xvideos\s*\w*\b" - if re.findall(pattern_porn, line_str): - with open (f"{path}porn_detection.txt" , "a" , encoding="utf-8") as file : - file.writelines(line_str) - if user not in p_user : - p_user.append(user) - - pattern_porn = r"\b\w*\s*sex\s*\w*\b" - if re.findall(pattern_porn, line_str): - with open (f"{path}porn_detection.txt" , "a" , encoding="utf-8") as file : - file.writelines(line_str) - if user not in p_user : - p_user.append(user) - - pattern_porn = r"\b\w*\s*brazzer\s*\w*\b" + pattern_porn = r"\b\w*\s*(porn|xnxx|xvideos|sex|brazzer|xxx|erotica|hardcore|BDSM|fetish|Nude|NSFW|PNP|CYOC|OnlyFans|camgirl|webcam)\s*\w*\b" if re.findall(pattern_porn, line_str): with open (f"{path}porn_detection.txt" , "a" , encoding="utf-8") as file : file.writelines(line_str) @@ -170,35 +142,26 @@ def analize () : p_user.append(user) # phone detection : - xiaomi_pattern = r"\b\w*\s*xiaomi\s*\w*\b" - samsung_pattern = r"\b\w*\s*samsung\s*\w*\b" + pattern = r"\b\w*\s*(xiaomi|samsung|dbankcloud)\s*\w*\b" + matches = re.findall(pattern, line_str) + if matches : + print(matches) + if user not in user_phone: + user_phone[user] = ["0"] + for match in matches: + if match in ["xiaomi", "samsung"] and match not in user_phone[f"{user}"]: + user_phone[user].append(match) + if match == "dbankcloud" and "huawei" not in user_phone[f"{user}"]: + user_phone[user].append("huawei") + apple_pattern = r"\b\w*\s*gsp\s*\w*\b" apple_pattern_2 = r"\b\w*\s*apple\s*\w*\b" - huawei_pattern = r"\b\w*\s*dbankcloud\s*\w*\b" - if re.findall(xiaomi_pattern, line_str): - if user not in user_phone : - user_phone[f"{user}"] = ["0"] - if "xiaomi" not in user_phone[f"{user}"] : - user_phone[f"{user}"].append("xiaomi") - - if re.findall(samsung_pattern, line_str): - if user not in user_phone : - user_phone[f"{user}"] = ["0"] - if "samsung" not in user_phone[f"{user}"] : - user_phone[f"{user}"].append("samsung") - if re.findall(apple_pattern, line_str): if re.findall(apple_pattern_2 , line_str) : if user not in user_phone : user_phone[f"{user}"] = ["0"] if "apple" not in user_phone[f"{user}"] : user_phone[f"{user}"].append("apple") - - if re.findall(huawei_pattern, line_str): - if user not in user_phone : - user_phone[f"{user}"] = ["0"] - if "huawei" not in user_phone[f"{user}"] : - user_phone[f"{user}"].append("huawei") # specific inbound detector : inbound_pattern = re.search(r"VMESS\s+\+\s+TCP", line_str, flags=re.IGNORECASE) @@ -207,16 +170,6 @@ def analize () : inbound_user.append(user) - # port scan detection : - # ip_port = line[2] - # ip = ip_port.split(":")[0] - # port = ip_port.split(":")[1] - # if ip == before_ip : - # if port != before_port : - # file_path = f"{path_user}port_scan_detection.txt" - # with open(file_path , "a") as file : - # file.writelines(line_str) - line_str = " " print(count) @@ -497,7 +450,9 @@ def clear_def() : except : pass - send_telegram_message("Done...Created by @wikm360 with โค๏ธ...V3.0") + send_telegram_message('''๐Ÿ‡ฉโ€‹โ€‹๐Ÿ‡ดโ€‹โ€‹๐Ÿ‡ณโ€‹โ€‹๐Ÿ‡ชโ€‹ +< โ€‹๐Ÿ‡จโ€‹โ€‹๐Ÿ‡ทโ€‹โ€‹๐Ÿ‡ชโ€‹โ€‹๐Ÿ‡ฆโ€‹โ€‹๐Ÿ‡นโ€‹โ€‹๐Ÿ‡ชโ€‹โ€‹๐Ÿ‡ฉโ€‹ โ€‹๐Ÿ‡งโ€‹โ€‹๐Ÿ‡พโ€‹ @wikm360 โ€‹๐Ÿ‡ผโ€‹โ€‹๐Ÿ‡ฎโ€‹โ€‹๐Ÿ‡นโ€‹โ€‹๐Ÿ‡ญโ€‹ โค๏ธ > +โ€‹๐Ÿ‡ปโ€‹3๏ธโƒฃ.4๏ธโƒฃ''') def main() :