Upload files to "/"
commit
c6dba8d67a
|
@ -0,0 +1,206 @@
|
|||
import discord, asyncio
|
||||
from subprocess import Popen, PIPE
|
||||
from discord.ext import commands, tasks
|
||||
import sys, os, socket, json
|
||||
import requests
|
||||
import subprocess
|
||||
|
||||
token = "DREADFUL DREADFUL" #CHNAGE ME!!!
|
||||
|
||||
client = commands.Bot(command_prefix = '!n', case_insensitive=True)
|
||||
|
||||
client.remove_command("help")
|
||||
|
||||
# ██████╗ ██████╗ ███████╗ █████╗ ██████╗ ███████╗██╗ ██╗██╗
|
||||
# ██╔══██╗██╔══██╗██╔════╝██╔══██╗██╔══██╗██╔════╝██║ ██║██║
|
||||
# ██║ ██║██████╔╝█████╗ ███████║██║ ██║█████╗ ██║ ██║██║
|
||||
# ██║ ██║██╔══██╗██╔══╝ ██╔══██║██║ ██║██╔══╝ ██║ ██║██║
|
||||
# ██████╔╝██║ ██║███████╗██║ ██║██████╔╝██║ ╚██████╔╝███████╗
|
||||
# ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═════╝ ╚══════╝
|
||||
#
|
||||
# Discord.py script using the checkhost JSON api it's very
|
||||
# more than 30 minutes to make so there most likely is some
|
||||
# issues but I've fixed all that I've seen.
|
||||
|
||||
nodes = "10" #number of checkhost requests
|
||||
|
||||
@client.event
|
||||
async def on_command_error(ctx, error):
|
||||
if isinstance(error, commands.CommandOnCooldown):
|
||||
await ctx.send('This command is on cooldown. Please wait %.2fs' % error.retry_after)
|
||||
elif isinstance(error, commands.errors.MissingPermissions):
|
||||
embed=discord.Embed(description="You do not have permissions to use this command", color=0x8000ff)
|
||||
await ctx.send(embed=embed)
|
||||
elif isinstance(error, commands.errors.MissingRequiredArgument):
|
||||
embed=discord.Embed(description="Missing an arg!", color=0x8000ff)
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
@client.command()
|
||||
async def help(ctx):
|
||||
embed=discord.Embed(title="__**DREADFUL**__",description=f"""
|
||||
{ctx.prefix}ping - IMCP request results
|
||||
{ctx.prefix}tcping - TCP request results
|
||||
{ctx.prefix}http - HTTP request results
|
||||
{ctx.prefix}lookup - GEO ip information""", color=0x8000ff)
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
@client.command()
|
||||
async def lookup(ctx, ip):
|
||||
try:
|
||||
socket.gethostbyname(ip)
|
||||
geodat = ("http://ip-api.com/line/"+ip+"?fields=message,continent,continentCode,country,countryCode,region,regionName,city,district,zip,lat,lon,timezone,offset,currency,isp,org,as,asname,reverse,query")
|
||||
resolve = requests.get(geodat)
|
||||
embed = discord.Embed(title="__**DREADFUL**__",description=f"%s"%(resolve.text),color=0x8000ff)
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
except socket.gaierror:
|
||||
await ctx.send(f"{ip} is invaid please retry")
|
||||
|
||||
@commands.cooldown(rate=1, per=5, type=commands.BucketType.channel)
|
||||
@client.command()
|
||||
async def ping(ctx, ip):
|
||||
try:
|
||||
socket.gethostbyname(ip)
|
||||
await loading(ctx)
|
||||
jsonfood = requests.get('https://check-host.net/check-ping?host='+ip+'&max_nodes='+nodes,headers={'Accept': 'application/json'})
|
||||
jsonfood = jsonfood.text
|
||||
j = json.loads(jsonfood)
|
||||
req_id = j["request_id"]
|
||||
await asyncio.sleep(10)
|
||||
|
||||
jsonfood = requests.get('https://check-host.net/check-result/'+req_id,headers={'Accept': 'application/json'})
|
||||
jsonfood = jsonfood.text
|
||||
j = json.loads(jsonfood)
|
||||
embed=discord.Embed(title="__**DREADFUL**__", description=f"ICMP response check-host result on {ip}", color=0x8000ff)
|
||||
embed.set_thumbnail(url="https://check-host.net/checkhost-favicon.png")
|
||||
#print(site_shit)
|
||||
for x in j :
|
||||
timeout = 0
|
||||
#print(x)
|
||||
try:
|
||||
for y in j[x][0]:
|
||||
if 'OK' in y:
|
||||
timeout = timeout + 1
|
||||
except TypeError:
|
||||
timeout = 0
|
||||
if timeout == 4:
|
||||
emoji = ":white_check_mark:"
|
||||
if timeout < 4:
|
||||
if timeout > 1:
|
||||
emoji = ":warning:"
|
||||
if timeout < 2 :
|
||||
emoji = ":x:"
|
||||
x = x.replace('.check-host.net', '')
|
||||
flagemoji = ":flag_"+x[0]+x[1]+":"
|
||||
embed.add_field(name=flagemoji+" "+x, value='RESULTS: '+emoji+' '+str(timeout)+'/4', inline=True)
|
||||
#print('RESULTS: '+str(timeout)+'/4')
|
||||
embed.set_footer(text=f"requested by {ctx.author.name} | https://check-host.net/check-result/"+req_id)
|
||||
await ctx.send(embed=embed)
|
||||
except socket.gaierror:
|
||||
await ctx.send(f"{ip} is invaid please retry")
|
||||
|
||||
async def loading(ctx):
|
||||
embed=discord.Embed(title="__**DREADFUL**__", description=f"Please allow 10 seconds for the request", color=0x8000ff)
|
||||
embed.set_thumbnail(url="https://i.imgur.com/llF5iyg.gif")
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
@commands.cooldown(rate=1, per=5, type=commands.BucketType.channel)
|
||||
@client.command()
|
||||
async def tcping(ctx, ip, port="80"):
|
||||
try:
|
||||
lmao = int(port)
|
||||
socket.gethostbyname(ip)
|
||||
await loading(ctx)
|
||||
|
||||
jsonfood = requests.get('https://check-host.net/check-tcp?host='+ip+":"+port+'&max_nodes='+nodes,headers={'Accept': 'application/json'}).text
|
||||
j = json.loads(jsonfood)
|
||||
|
||||
req_id = j["request_id"]
|
||||
await asyncio.sleep(10)
|
||||
|
||||
jsonfood = requests.get('https://check-host.net/check-result/'+req_id,headers={'Accept': 'application/json'})
|
||||
jsonfood = jsonfood.text
|
||||
j = json.loads(jsonfood)
|
||||
embed=discord.Embed(title="__**DREADFUL**__", description=f"TCP response check-host result on {ip}:{port}", color=0x8000ff)
|
||||
embed.set_thumbnail(url="https://check-host.net/checkhost-favicon.png")
|
||||
ptimeout = "Error "
|
||||
for x in j :
|
||||
timeout = 0
|
||||
#print(x)
|
||||
try:
|
||||
for y in j[x][0]:
|
||||
if 'time' in y:
|
||||
timeout = timeout + 1
|
||||
ptimeout = j[x][0]["time"]
|
||||
ptimeout = str(int(ptimeout*1000))
|
||||
except TypeError:
|
||||
timeout = 0
|
||||
if timeout == 1:
|
||||
emoji = ":white_check_mark:"
|
||||
if timeout == 0 :
|
||||
emoji = ":x:"
|
||||
x = x.replace('.check-host.net', '')
|
||||
flagemoji = ":flag_"+x[0]+x[1]+":"
|
||||
embed.add_field(name=flagemoji+" "+x, value=emoji+' '+str(ptimeout)+'ms', inline=True)
|
||||
#print('RESULTS: '+str(timeout)+'/4')
|
||||
embed.set_footer(text=f"requested by {ctx.author.name} | https://check-host.net/check-result/"+req_id)
|
||||
await ctx.send(embed=embed)
|
||||
except socket.gaierror:
|
||||
await ctx.send(f"{ip} is invaid please retry")
|
||||
|
||||
@commands.cooldown(rate=1, per=5, type=commands.BucketType.channel)
|
||||
@client.command()
|
||||
async def http(ctx, ip):
|
||||
try:
|
||||
socket.gethostbyname(ip)
|
||||
await loading(ctx)
|
||||
jsonfood = requests.get('https://check-host.net/check-http?host='+ip+'&max_nodes='+nodes,headers={'Accept': 'application/json'})
|
||||
jsonfood = jsonfood.text
|
||||
j = json.loads(jsonfood)
|
||||
|
||||
req_id = j["request_id"]
|
||||
await asyncio.sleep(10)
|
||||
|
||||
jsonfood = requests.get('https://check-host.net/check-result/'+req_id,headers={'Accept': 'application/json'})
|
||||
jsonfood = jsonfood.text
|
||||
j = json.loads(jsonfood)
|
||||
embed=discord.Embed(title="__**DREADFUL**__", description=f"HTTP response check-host result on {ip}", color=0x8000ff)
|
||||
embed.set_thumbnail(url="https://check-host.net/checkhost-favicon.png")
|
||||
for x in j :
|
||||
timeout = 0
|
||||
#print(x)
|
||||
try:
|
||||
for y in j[x][0]:
|
||||
emoji = ":x:"
|
||||
if 100 <= int(j[x][0][3]) <= 199:
|
||||
emoji = ":globe_with_meridians: "
|
||||
if 200 <= int(j[x][0][3]) <= 299:
|
||||
emoji = ":white_check_mark:"
|
||||
if 300 <= int(j[x][0][3]) <= 399:
|
||||
emoji = ":warning:"
|
||||
if 400 <= int(j[x][0][3]) <= 599:
|
||||
emoji = ":x:"
|
||||
ptimeout = j[x][0][2]
|
||||
except TypeError:
|
||||
emoji = ":x:"
|
||||
ptimeout = "Failed to get info"
|
||||
x = x.replace('.check-host.net', '')
|
||||
flagemoji = ":flag_"+x[0]+x[1]+":"
|
||||
embed.add_field(name=flagemoji+" "+x, value=emoji+' '+str(ptimeout), inline=True)
|
||||
embed.set_footer(text=f"requested by {ctx.author.name} | https://check-host.net/check-result/"+req_id)
|
||||
await ctx.send(embed=embed)
|
||||
except socket.gaierror:
|
||||
await ctx.send(f"{ip} is invaid please retry")
|
||||
|
||||
@client.event
|
||||
async def on_ready():
|
||||
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name=f'my master | !nhelp'))
|
||||
print('''
|
||||
\x1b[38;5;197m╔╦╗╦═╗╔═╗╔═╗╔╦╗╔═╗╦ ╦╦
|
||||
\x1b[38;5;198m ║║╠╦╝║╣ ╠═╣ ║║╠╣ ║ ║║
|
||||
\x1b[38;5;199m═╩╝╩╚═╚═╝╩ ╩x1b[0mo \x1b[38;5;199m═╩╝╚ ╚═╝╩═╝
|
||||
\x1b[0mDiscord bot for the Check host JSON API
|
||||
''')
|
||||
print(" disc.py Version: "+discord.__version__)
|
||||
|
||||
client.run(token, bot=True)
|
|
@ -0,0 +1,161 @@
|
|||
import asyncio
|
||||
import socket
|
||||
import json
|
||||
import requests
|
||||
from rich.console import Console
|
||||
from rich.table import Table
|
||||
from rich.panel import Panel
|
||||
from rich.align import Align
|
||||
from rich.prompt import Prompt
|
||||
from rich.progress import Progress
|
||||
|
||||
# Set up Rich Console
|
||||
console = Console()
|
||||
nodes = "10" # Number of checkhost requests
|
||||
|
||||
# Helper Functions
|
||||
async def lookup(ip):
|
||||
try:
|
||||
socket.gethostbyname(ip)
|
||||
fields = "query,status,message,continent,continentCode,country,countryCode,region,regionName,city,zip,lat,lon,timezone,offset,currency,isp,org,as,asname,reverse,mobile,proxy,hosting"
|
||||
geodat = f"http://ip-api.com/json/{ip}?fields={fields}"
|
||||
response = requests.get(geodat).json()
|
||||
|
||||
# Create a Rich Table for results
|
||||
table = Table(title=f"[bold cyan]Geo-IP Lookup for {ip}[/bold cyan]", show_lines=True)
|
||||
table.add_column("Field", style="bold magenta")
|
||||
table.add_column("Value", style="bold white")
|
||||
|
||||
ordered_fields = [
|
||||
"query", "status", "message", "continent", "continentCode", "country", "countryCode",
|
||||
"region", "regionName", "city", "zip", "lat", "lon", "timezone", "offset",
|
||||
"currency", "isp", "org", "as", "asname", "reverse", "mobile", "proxy",
|
||||
"hosting"
|
||||
]
|
||||
|
||||
# Add data to the table
|
||||
for field in ordered_fields:
|
||||
value = response.get(field, "N/A")
|
||||
table.add_row(field.capitalize(), str(value))
|
||||
|
||||
console.print(table)
|
||||
except socket.gaierror:
|
||||
console.print(f"[bold red]Error:[/bold red] Invalid IP address '{ip}'. Please enter a valid IP.", style="bold red")
|
||||
|
||||
async def ping(ip):
|
||||
try:
|
||||
socket.gethostbyname(ip)
|
||||
jsonfood = requests.get(f'https://check-host.net/check-ping?host={ip}&max_nodes={nodes}', headers={'Accept': 'application/json'}).text
|
||||
req_id = json.loads(jsonfood)["request_id"]
|
||||
|
||||
# Loading spinner
|
||||
with Progress(transient=True) as progress:
|
||||
task = progress.add_task("[cyan]Pinging...[/cyan]", total=None)
|
||||
await asyncio.sleep(10) # Simulating a wait for 10 seconds
|
||||
|
||||
jsonfood = requests.get(f'https://check-host.net/check-result/{req_id}', headers={'Accept': 'application/json'}).text
|
||||
j = json.loads(jsonfood)
|
||||
|
||||
# Table for Ping Results
|
||||
table = Table(title=f"[bold cyan]Ping Test Results for {ip}[/bold cyan]", show_lines=True)
|
||||
table.add_column("Node", style="bold magenta")
|
||||
table.add_column("Status", style="bold white")
|
||||
|
||||
for x in j:
|
||||
timeout = sum(1 for y in j[x][0] if 'OK' in y) if j[x][0] else 0
|
||||
emoji = "✅" if timeout == 4 else "⚠️" if timeout > 1 else "❌"
|
||||
node = x.replace('.check-host.net', '')
|
||||
table.add_row(node, f"{emoji} {timeout}/4")
|
||||
|
||||
console.print(table)
|
||||
except socket.gaierror:
|
||||
console.print(f"[bold red]Error:[/bold red] Invalid IP address '{ip}'. Please enter a valid IP.", style="bold red")
|
||||
|
||||
async def tcping(ip, port="80"):
|
||||
try:
|
||||
socket.gethostbyname(ip)
|
||||
jsonfood = requests.get(f'https://check-host.net/check-tcp?host={ip}:{port}&max_nodes={nodes}', headers={'Accept': 'application/json'}).text
|
||||
req_id = json.loads(jsonfood)["request_id"]
|
||||
|
||||
# Loading spinner
|
||||
with Progress(transient=True) as progress:
|
||||
task = progress.add_task("[cyan]Running TCPing...[/cyan]", total=None)
|
||||
await asyncio.sleep(10) # Simulating a wait for 10 seconds
|
||||
|
||||
jsonfood = requests.get(f'https://check-host.net/check-result/{req_id}', headers={'Accept': 'application/json'}).text
|
||||
j = json.loads(jsonfood)
|
||||
|
||||
# Table for TCPing Results
|
||||
table = Table(title=f"[bold cyan]TCPing Test Results for {ip}:{port}[/bold cyan]", show_lines=True)
|
||||
table.add_column("Node", style="bold magenta")
|
||||
table.add_column("Status", style="bold white")
|
||||
|
||||
for x in j:
|
||||
timeout = sum(1 for y in j[x][0] if 'time' in y) if j[x][0] else 0
|
||||
ptimeout = str(int(j[x][0]["time"] * 1000)) + " ms" if timeout else "Error"
|
||||
emoji = "✅" if timeout == 1 else "❌"
|
||||
node = x.replace('.check-host.net', '')
|
||||
table.add_row(node, f"{emoji} {ptimeout}")
|
||||
|
||||
console.print(table)
|
||||
except socket.gaierror:
|
||||
console.print(f"[bold red]Error:[/bold red] Invalid IP address '{ip}'. Please enter a valid IP.", style="bold red")
|
||||
|
||||
async def http(ip):
|
||||
try:
|
||||
socket.gethostbyname(ip)
|
||||
jsonfood = requests.get(f'https://check-host.net/check-http?host={ip}&max_nodes={nodes}', headers={'Accept': 'application/json'}).text
|
||||
req_id = json.loads(jsonfood)["request_id"]
|
||||
|
||||
# Loading spinner
|
||||
with Progress(transient=True) as progress:
|
||||
task = progress.add_task("[cyan]Checking HTTP...[/cyan]", total=None)
|
||||
await asyncio.sleep(10) # Simulating a wait for 10 seconds
|
||||
|
||||
jsonfood = requests.get(f'https://check-host.net/check-result/{req_id}', headers={'Accept': 'application/json'}).text
|
||||
j = json.loads(jsonfood)
|
||||
|
||||
# Table for HTTP Results
|
||||
table = Table(title=f"[bold cyan]HTTP Test Results for {ip}[/bold cyan]", show_lines=True)
|
||||
table.add_column("Node", style="bold magenta")
|
||||
table.add_column("Status", style="bold white")
|
||||
|
||||
for x in j:
|
||||
code = int(j[x][0][3]) if j[x][0] else 0
|
||||
emoji = "✅" if 200 <= code <= 299 else "⚠️" if 300 <= code <= 399 else "❌"
|
||||
ptimeout = j[x][0][2] if j[x][0] else "Failed to get info"
|
||||
node = x.replace('.check-host.net', '')
|
||||
table.add_row(node, f"{emoji} {ptimeout}")
|
||||
|
||||
console.print(table)
|
||||
except socket.gaierror:
|
||||
console.print(f"[bold red]Error:[/bold red] Invalid IP address '{ip}'. Please enter a valid IP.", style="bold red")
|
||||
|
||||
# Main UI with Rich Panel
|
||||
console.print(Panel(Align.center("Network Tools Console UI", style="bold cyan"), padding=(1, 2), border_style="blue"))
|
||||
|
||||
def main():
|
||||
while True:
|
||||
console.print(Panel("Choose an option:\n[1] Lookup\n[2] Ping\n[3] TCPing\n[4] HTTP\n[Q] Quit", style="bold green"))
|
||||
choice = Prompt.ask("[bold yellow]Enter choice[/bold yellow]").strip().lower()
|
||||
|
||||
if choice == "q":
|
||||
console.print("[bold red]Exiting...[/bold red]")
|
||||
break
|
||||
|
||||
ip = Prompt.ask("[bold yellow]Enter IP Address[/bold yellow]").strip()
|
||||
|
||||
if choice == "1":
|
||||
asyncio.run(lookup(ip))
|
||||
elif choice == "2":
|
||||
asyncio.run(ping(ip))
|
||||
elif choice == "3":
|
||||
port = Prompt.ask("[bold yellow]Enter Port (default: 80)[/bold yellow]", default="80")
|
||||
asyncio.run(tcping(ip, port))
|
||||
elif choice == "4":
|
||||
asyncio.run(http(ip))
|
||||
else:
|
||||
console.print("[bold red]Invalid choice. Try again.[/bold red]")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in New Issue