Ramiz404 commited on
Commit
d32d0a9
Β·
0 Parent(s):

Pure AI & Group Security Bot: Removed all Cyber Toolkit files

Browse files
Files changed (6) hide show
  1. .gitattributes +35 -0
  2. Dockerfile +25 -0
  3. README.md +12 -0
  4. app.py +126 -0
  5. bot.py +156 -0
  6. requirements.txt +7 -0
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
Dockerfile ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use Python 3.11 image
2
+ FROM python:3.11-slim
3
+
4
+ # Set working directory
5
+ WORKDIR /app
6
+
7
+ # Install only necessary system dependencies
8
+ RUN apt-get update && apt-get install -y \
9
+ libopenjp2-7 \
10
+ libtiff6 \
11
+ git \
12
+ && rm -rf /var/lib/apt/lists/*
13
+
14
+ # Copy requirements and install
15
+ COPY requirements.txt .
16
+ RUN pip install --no-cache-dir -r requirements.txt
17
+
18
+ # Copy all files
19
+ COPY . .
20
+
21
+ # Expose port for health check
22
+ EXPOSE 7860
23
+
24
+ # Run the bot
25
+ CMD ["python", "app.py"]
README.md ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Cyber Toolkit Bot
3
+ emoji: 🌍
4
+ colorFrom: purple
5
+ colorTo: pink
6
+ sdk: gradio
7
+ sdk_version: 6.10.0
8
+ app_file: app.py
9
+ pinned: false
10
+ ---
11
+
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import telebot
2
+ import requests
3
+ import os
4
+ import io
5
+ import time
6
+ from telebot import types
7
+ from threading import Thread
8
+ from flask import Flask
9
+ from huggingface_hub import InferenceClient
10
+ from PIL import Image
11
+
12
+ # Flask for Hugging Face Health Check
13
+ app = Flask(__name__)
14
+ @app.route('/')
15
+ def health(): return "AI Master Bot is Running!"
16
+ def run_flask(): app.run(host='0.0.0.0', port=7860)
17
+
18
+ # TOKENS (Get from Environment Variables)
19
+ BOT_TOKEN = os.getenv('BOT_TOKEN')
20
+ HF_TOKEN = os.getenv('HF_TOKEN')
21
+
22
+ bot = telebot.TeleBot(BOT_TOKEN)
23
+ client = InferenceClient(token=HF_TOKEN)
24
+
25
+ # Admin IDs
26
+ ADMIN_IDS = [1772952626]
27
+
28
+ # AI Models
29
+ TEXT_MODEL = "mistralai/Mistral-7B-Instruct-v0.3"
30
+ IMAGE_MODEL = "stabilityai/stable-diffusion-2-1"
31
+
32
+ # Security Config
33
+ ANTI_LINK = True
34
+ ANTI_SPAM = True
35
+ user_last_msg_time = {}
36
+
37
+ # AI Functions
38
+ def get_ai_response(prompt):
39
+ try:
40
+ response = client.text_generation(prompt, model=TEXT_MODEL, max_new_tokens=250)
41
+ return response
42
+ except Exception as e:
43
+ return f"AI Error: {str(e)}"
44
+
45
+ def generate_image(prompt):
46
+ try:
47
+ image = client.text_to_image(prompt, model=IMAGE_MODEL)
48
+ img_byte_arr = io.BytesIO()
49
+ image.save(img_byte_arr, format='PNG')
50
+ img_byte_arr.seek(0)
51
+ return img_byte_arr
52
+ except Exception as e:
53
+ return None
54
+
55
+ # Handlers
56
+ @bot.message_handler(commands=['start', 'help'])
57
+ def send_welcome(message):
58
+ markup = types.InlineKeyboardMarkup(row_width=2)
59
+ markup.add(
60
+ types.InlineKeyboardButton("πŸ€– AI Chat", callback_data="ai_chat"),
61
+ types.InlineKeyboardButton("🎨 Image Gen", callback_data="ai_image"),
62
+ types.InlineKeyboardButton("πŸ›‘οΈ Group Security", callback_data="security_info")
63
+ )
64
+ bot.send_message(message.chat.id, "🌟 *Ultimate AI & Group Security Bot* 🌟\n\nSelect a service:", parse_mode='Markdown', reply_markup=markup)
65
+
66
+ @bot.callback_query_handler(func=lambda call: True)
67
+ def callback_query(call):
68
+ chat_id = call.message.chat.id
69
+ bot.answer_callback_query(call.id)
70
+ if call.data == "ai_chat":
71
+ bot.send_message(chat_id, "πŸ’¬ *AI Chat Mode:* Just ask me anything directly!")
72
+ elif call.data == "ai_image":
73
+ bot.send_message(chat_id, "🎨 *Image Gen:* Type `/image <prompt>` to generate image.")
74
+ elif call.data == "security_info":
75
+ bot.send_message(chat_id, "πŸ›‘οΈ *Security:* Anti-Link and Anti-Spam are ACTIVE in groups.")
76
+
77
+ # Image Gen Command
78
+ @bot.message_handler(commands=['image'])
79
+ def image_gen(message):
80
+ prompt = message.text.replace('/image', '').strip()
81
+ if not prompt:
82
+ bot.reply_to(message, "Usage: `/image a high-tech robotic cat`", parse_mode='Markdown')
83
+ return
84
+ bot.reply_to(message, "⏳ *Generating Image...* Please wait.")
85
+ img = generate_image(prompt)
86
+ if img:
87
+ bot.send_photo(message.chat.id, img, caption=f"🎨 Prompt: {prompt}")
88
+ else:
89
+ bot.reply_to(message, "❌ Image generation failed.")
90
+
91
+ # Monitoring & Security
92
+ @bot.message_handler(func=lambda message: True, content_types=['text', 'photo', 'video'])
93
+ def monitor(message):
94
+ chat_id = message.chat.id
95
+ user_id = message.from_user.id
96
+ text = message.text or ""
97
+
98
+ # 1. Admin Auto-Reply
99
+ if user_id in ADMIN_IDS and ("bot" in text.lower() or "hello" in text.lower()):
100
+ bot.reply_to(message, "πŸ‘‹ Welcome Boss! I am monitoring everything. Let me know if you need help.")
101
+ return
102
+
103
+ # 2. Group Security (Anti-Link)
104
+ if ANTI_LINK and message.chat.type != 'private':
105
+ if "http" in text or "t.me/" in text:
106
+ if user_id not in ADMIN_IDS:
107
+ bot.delete_message(chat_id, message.message_id)
108
+ bot.send_message(chat_id, f"🚫 *No Links Allowed!* @{message.from_user.username}", parse_mode='Markdown')
109
+ return
110
+
111
+ # 3. Anti-Spam
112
+ if ANTI_SPAM:
113
+ now = time.time()
114
+ if now - user_last_msg_time.get(user_id, 0) < 0.8:
115
+ bot.delete_message(chat_id, message.message_id)
116
+ return
117
+ user_last_msg_time[user_id] = now
118
+
119
+ # 4. Private AI Chat
120
+ if message.chat.type == 'private' and not text.startswith('/'):
121
+ bot.send_chat_action(chat_id, 'typing')
122
+ bot.reply_to(message, get_ai_response(text))
123
+
124
+ if __name__ == '__main__':
125
+ Thread(target=run_flask).start()
126
+ bot.infinity_polling()
bot.py ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import telebot
2
+ import requests
3
+ import socket
4
+ import whois
5
+ import os
6
+ import subprocess
7
+ from datetime import datetime
8
+
9
+ # YOUT BOT TOKEN HERE
10
+ TOKEN = '8657709560:AAEipMz944RDOlpT43haLJo6QB-2vqjUH2U'
11
+
12
+ TOOLKIT_CORE = '/data/data/com.termux/files/home/Cyber-Toolkit/core'
13
+
14
+ bot = telebot.TeleBot(TOKEN)
15
+
16
+ @bot.message_handler(commands=['start', 'help'])
17
+ def send_welcome(message):
18
+ help_text = """
19
+ πŸ›‘οΈ *Cyber & Pentest Assistant Bot* πŸ›‘οΈ
20
+
21
+ Commands:
22
+ /geoip <ip> - Get Geo-Location of an IP
23
+ /portscan <ip> - Scan common ports (1-100)
24
+ /whois <domain> - Get WHOIS info for a domain
25
+ /headers <url> - Check HTTP Security Headers
26
+ /dns <domain> - Get DNS A records
27
+
28
+ πŸ“¦ *Cyber-Toolkit Integration*
29
+ /toolkit - List all tools in Cyber-Toolkit
30
+ /run <tool_name> <args> - Run a specific tool (e.g., /run ip_lookup.py 8.8.8.8)
31
+ """
32
+ bot.reply_to(message, help_text, parse_mode='Markdown')
33
+
34
+ @bot.message_handler(commands=['toolkit'])
35
+ def list_toolkit(message):
36
+ try:
37
+ files = [f for f in os.listdir(TOOLKIT_CORE) if f.endswith('.py') and f != 'main.py']
38
+ files.sort()
39
+ response = "πŸ› οΈ *Available Tools in Cyber-Toolkit:*\n\n"
40
+ # Split into chunks if too long for Telegram
41
+ chunk_size = 30
42
+ for i in range(0, len(files), chunk_size):
43
+ chunk = files[i:i + chunk_size]
44
+ bot.send_message(message.chat.id, "\n".join(chunk))
45
+ except Exception as e:
46
+ bot.reply_to(message, f"❌ Error listing toolkit: {str(e)}")
47
+
48
+ @bot.message_handler(commands=['run'])
49
+ def run_tool(message):
50
+ try:
51
+ args = message.text.split()
52
+ if len(args) < 2:
53
+ bot.reply_to(message, "Usage: /run <tool_name> <args>")
54
+ return
55
+
56
+ tool_name = args[1]
57
+ tool_args = args[2:]
58
+ tool_path = os.path.join(TOOLKIT_CORE, tool_name)
59
+
60
+ if not os.path.exists(tool_path):
61
+ bot.reply_to(message, f"❌ Tool '{tool_name}' not found.")
62
+ return
63
+
64
+ bot.reply_to(message, f"πŸš€ Running {tool_name}...")
65
+
66
+ # Run the tool and capture output
67
+ # Using a timeout to prevent infinite loops/long runs
68
+ cmd = ['python3', tool_path] + tool_args
69
+ result = subprocess.run(cmd, capture_output=True, text=True, timeout=60, cwd=TOOLKIT_CORE)
70
+
71
+ output = result.stdout if result.stdout else "No output."
72
+ if result.stderr:
73
+ output += f"\n\n*Error Output:*\n{result.stderr}"
74
+
75
+ # If output is too long, truncate it
76
+ if len(output) > 4000:
77
+ output = output[:4000] + "...(truncated)"
78
+
79
+ bot.reply_to(message, f"πŸ“„ *Output for {tool_name}:*\n\n`{output}`", parse_mode='Markdown')
80
+
81
+ except subprocess.TimeoutExpired:
82
+ bot.reply_to(message, "⏳ Execution timed out (60s).")
83
+ except Exception as e:
84
+ bot.reply_to(message, f"❌ Error: {str(e)}")
85
+
86
+ @bot.message_handler(commands=['geoip'])
87
+ def geoip_lookup(message):
88
+ try:
89
+ ip = message.text.split()[1]
90
+ response = requests.get(f"http://ip-api.com/json/{ip}").json()
91
+ if response['status'] == 'success':
92
+ info = f"🌍 *GeoIP Info for {ip}*\n\n" \
93
+ f"πŸ“ Country: {response.get('country')}\n" \
94
+ f"πŸ™οΈ City: {response.get('city')}\n" \
95
+ f"πŸ“‘ ISP: {response.get('isp')}\n" \
96
+ f"🌐 Lat/Lon: {response.get('lat')}, {response.get('lon')}"
97
+ bot.reply_to(message, info, parse_mode='Markdown')
98
+ else:
99
+ bot.reply_to(message, "❌ Invalid IP or API error.")
100
+ except IndexError:
101
+ bot.reply_to(message, "Usage: /geoip <ip>")
102
+
103
+ @bot.message_handler(commands=['portscan'])
104
+ def port_scanner(message):
105
+ try:
106
+ target = message.text.split()[1]
107
+ bot.reply_to(message, f"πŸ” Scanning ports 1-100 for {target}...")
108
+ open_ports = []
109
+ for port in range(1, 101):
110
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
111
+ socket.setdefaulttimeout(1)
112
+ result = s.connect_ex((target, port))
113
+ if result == 0:
114
+ open_ports.append(port)
115
+ s.close()
116
+
117
+ if open_ports:
118
+ bot.reply_to(message, f"βœ… Open Ports: {', '.join(map(str, open_ports))}")
119
+ else:
120
+ bot.reply_to(message, "🚫 No open ports found in 1-100 range.")
121
+ except Exception:
122
+ bot.reply_to(message, "Usage: /portscan <ip>")
123
+
124
+ @bot.message_handler(commands=['whois'])
125
+ def whois_lookup(message):
126
+ try:
127
+ domain = message.text.split()[1]
128
+ w = whois.whois(domain)
129
+ info = f"πŸ” *WHOIS Info for {domain}*\n\n" \
130
+ f"🏒 Registrar: {w.registrar}\n" \
131
+ f"πŸ“… Creation Date: {w.creation_date}\n" \
132
+ f"⏳ Expiration: {w.expiration_date}\n" \
133
+ f"πŸ“§ Email: {w.emails}"
134
+ bot.reply_to(message, info, parse_mode='Markdown')
135
+ except Exception as e:
136
+ bot.reply_to(message, f"❌ WHOIS lookup failed: {str(e)}")
137
+
138
+ @bot.message_handler(commands=['headers'])
139
+ def check_headers(message):
140
+ try:
141
+ url = message.text.split()[1]
142
+ if not url.startswith('http'):
143
+ url = 'http://' + url
144
+ res = requests.get(url, timeout=5)
145
+ headers = res.headers
146
+ security_headers = ['Content-Security-Policy', 'X-Frame-Options', 'X-Content-Type-Options', 'Strict-Transport-Security']
147
+ report = f"πŸ›‘οΈ *Security Headers for {url}*\n\n"
148
+ for sh in security_headers:
149
+ status = "βœ…" if sh in headers else "❌"
150
+ report += f"{status} {sh}\n"
151
+ bot.reply_to(message, report, parse_mode='Markdown')
152
+ except Exception:
153
+ bot.reply_to(message, "Usage: /headers <url>")
154
+
155
+ print("Bot is running...")
156
+ bot.infinity_polling()
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ pyTelegramBotAPI
2
+ requests
3
+ flask
4
+ pillow
5
+ huggingface_hub
6
+ python-dotenv
7
+ aiohttp