mirror of
http://git.nowherejezfoltodf4jiyl6r56jnzintap5vyjlia7fkirfsnfizflqd.onion/nihilist/darknet-lantern.git
synced 2025-07-02 06:46:42 +00:00
issue 26: removed unused module and over indentation
This commit is contained in:
parent
f5913a9cef
commit
b653171e84
1 changed files with 154 additions and 153 deletions
|
@ -1,6 +1,6 @@
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import os,re,pwd
|
import os,re,pwd
|
||||||
import csv
|
import csv
|
||||||
import random
|
import random
|
||||||
|
@ -28,167 +28,168 @@ tor_port = os.getenv("TOR_PORT")
|
||||||
#apt install python3-pandas python3-requests python3-socks
|
#apt install python3-pandas python3-requests python3-socks
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print('[+] ONION UPTIME CHECKER')
|
|
||||||
|
|
||||||
# TODO get the instance name and exit if its not there
|
print('[+] ONION UPTIME CHECKER')
|
||||||
rootpath='/srv/darknet-lantern/'
|
|
||||||
urlpath=pwd.getpwuid(os.getuid()).pw_dir+"/.darknet_participant_url"
|
|
||||||
|
|
||||||
#print(urlpath)
|
# TODO get the instance name and exit if its not there
|
||||||
|
rootpath='/srv/darknet-lantern/'
|
||||||
|
urlpath=pwd.getpwuid(os.getuid()).pw_dir+"/.darknet_participant_url"
|
||||||
|
|
||||||
|
#print(urlpath)
|
||||||
|
|
||||||
|
|
||||||
# check if ~/.darknet_participant_url exists,
|
# check if ~/.darknet_participant_url exists,
|
||||||
# if exists, instance= the content of ~/.darknet_participant_url (which is the url: such as uptime.nowherejez...onion)
|
# if exists, instance= the content of ~/.darknet_participant_url (which is the url: such as uptime.nowherejez...onion)
|
||||||
isitvalid="n"
|
isitvalid="n"
|
||||||
while isitvalid != "y":
|
while isitvalid != "y":
|
||||||
if os.path.isfile(urlpath):
|
if os.path.isfile(urlpath):
|
||||||
with open(urlpath) as f:
|
with open(urlpath) as f:
|
||||||
instance = f.read().rstrip()
|
instance = f.read().rstrip()
|
||||||
# check if the instance URL domain is valid
|
# check if the instance URL domain is valid
|
||||||
if IsOnionValid(instance):
|
if IsOnionValid(instance):
|
||||||
print("[+] Instance Name:",instance,IsOnionValid(instance))
|
print("[+] Instance Name:",instance,IsOnionValid(instance))
|
||||||
isitvalid="y"
|
isitvalid="y"
|
||||||
else:
|
else:
|
||||||
print('[-] Invalid instance name in ~/.darknet_participant_url:', instance)
|
print('[-] Invalid instance name in ~/.darknet_participant_url:', instance)
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
print("[-] Instance path doesn't exist yet, run darknet_exploration.py to set it up" )
|
print("[-] Instance path doesn't exist yet, run darknet_exploration.py to set it up" )
|
||||||
return False
|
return False
|
||||||
|
|
||||||
proxies = {
|
proxies = {
|
||||||
'http': f'{tor_host}:{tor_port}',
|
'http': f'{tor_host}:{tor_port}',
|
||||||
'https': f'{tor_host}:{tor_port}'
|
'https': f'{tor_host}:{tor_port}'
|
||||||
}
|
}
|
||||||
|
|
||||||
instancepath=rootpath+'www/participants/'+instance+'/'
|
instancepath=rootpath+'www/participants/'+instance+'/'
|
||||||
csvfiles2check=['verified.csv','unverified.csv','webring-participants.csv']
|
csvfiles2check=['verified.csv','unverified.csv','webring-participants.csv']
|
||||||
csvfiles2sortcat=['verified.csv','unverified.csv']
|
csvfiles2sortcat=['verified.csv','unverified.csv']
|
||||||
|
|
||||||
#for csvfile in glob.glob("/srv/darknet-lantern/www/links/*.csv"):
|
#for csvfile in glob.glob("/srv/darknet-lantern/www/links/*.csv"):
|
||||||
for csvfilename in csvfiles2check:
|
for csvfilename in csvfiles2check:
|
||||||
csvfile = instancepath+csvfilename
|
csvfile = instancepath+csvfilename
|
||||||
print('[+] Reading the CSV File:', csvfile)
|
print('[+] Reading the CSV File:', csvfile)
|
||||||
|
|
||||||
df = pd.read_csv(csvfile)
|
df = pd.read_csv(csvfile)
|
||||||
print(df[['Name','URL']])
|
print(df[['Name','URL']])
|
||||||
print('[+] Checking if each .onion link is reachable:')
|
print('[+] Checking if each .onion link is reachable:')
|
||||||
#for i in range(df.index.stop):
|
#for i in range(df.index.stop):
|
||||||
for i in df.index:
|
for i in df.index:
|
||||||
print("[+] Editing the uptime score")
|
print("[+] Editing the uptime score")
|
||||||
#if empty, set to 100
|
#if empty, set to 100
|
||||||
if pd.isnull(df.at[i,"Score"]):
|
if pd.isnull(df.at[i,"Score"]):
|
||||||
df.at[i,"Score"] = 100
|
df.at[i,"Score"] = 100
|
||||||
|
|
||||||
print(i)
|
print(i)
|
||||||
#print(df.at[i,"URL"])
|
#print(df.at[i,"URL"])
|
||||||
url=df.at[i,"URL"]
|
url=df.at[i,"URL"]
|
||||||
try:
|
try:
|
||||||
index1 = url.find("http://")
|
index1 = url.find("http://")
|
||||||
index2 = url.find("https://")
|
index2 = url.find("https://")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if url.startswith("smp://") or url.startswith("xftp://"):
|
if url.startswith("smp://") or url.startswith("xftp://"):
|
||||||
if IsSimpleXServerValid(url):
|
if IsSimpleXServerValid(url):
|
||||||
with connect(f"ws://localhost:3030") as websocket:
|
with connect(f"ws://localhost:3030") as websocket:
|
||||||
if url.startswith("smp"):
|
if url.startswith("smp"):
|
||||||
query = f"/_server test 1 {url}"
|
query = f"/_server test 1 {url}"
|
||||||
command = {
|
command = {
|
||||||
'corrId': f"id{random.randint(0,999999)}",
|
'corrId': f"id{random.randint(0,999999)}",
|
||||||
'cmd': query,
|
'cmd': query,
|
||||||
}
|
}
|
||||||
websocket.send(json.dumps(command))
|
websocket.send(json.dumps(command))
|
||||||
message = websocket.recv()
|
message = websocket.recv()
|
||||||
response = json.loads(message)
|
response = json.loads(message)
|
||||||
failed_response = response['resp'].get('testFailure')
|
failed_response = response['resp'].get('testFailure')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if failed_response is None:
|
if failed_response is None:
|
||||||
print(url, "✔️")
|
print(url, "✔️")
|
||||||
df.at[i, "Status"]="YES"
|
df.at[i, "Status"]="YES"
|
||||||
if df.at[i, "Score"] < 100:
|
if df.at[i, "Score"] < 100:
|
||||||
df.at[i,"Score"] = df.at[i,"Score"] + 1
|
df.at[i,"Score"] = df.at[i,"Score"] + 1
|
||||||
else:
|
|
||||||
|
|
||||||
print(url,"❌")
|
|
||||||
df.at[i,"Status"]="NO"
|
|
||||||
#if uptime >0 do -1 to the value
|
|
||||||
if df.at[i,"Score"] > 0:
|
|
||||||
df.at[i,"Score"] = df.at[i,"Score"] - 1
|
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
query = f"/_server test 1 {url}"
|
|
||||||
command = {
|
print(url,"❌")
|
||||||
'corrId': f"id{random.randint(0,999999)}",
|
df.at[i,"Status"]="NO"
|
||||||
'cmd': query,
|
#if uptime >0 do -1 to the value
|
||||||
}
|
if df.at[i,"Score"] > 0:
|
||||||
websocket.send(json.dumps(command))
|
df.at[i,"Score"] = df.at[i,"Score"] - 1
|
||||||
message = websocket.recv()
|
|
||||||
response = json.loads(message)
|
|
||||||
failed_response = response['resp']['testFailure']
|
|
||||||
|
|
||||||
|
|
||||||
if failed_response is None:
|
else:
|
||||||
print(url, "✔️")
|
query = f"/_server test 1 {url}"
|
||||||
df.at[i, "Status"]="YES"
|
command = {
|
||||||
if df.at[i, "Score"] < 100:
|
'corrId': f"id{random.randint(0,999999)}",
|
||||||
df.at[i,"Score"] = df.at[i,"Score"] + 1
|
'cmd': query,
|
||||||
else:
|
}
|
||||||
print(url,"❌")
|
websocket.send(json.dumps(command))
|
||||||
df.at[i,"Status"]="NO"
|
message = websocket.recv()
|
||||||
#if uptime >0 do -1 to the value
|
response = json.loads(message)
|
||||||
if df.at[i,"Score"] > 0:
|
failed_response = response['resp']['testFailure']
|
||||||
df.at[i,"Score"] = df.at[i,"Score"] - 1
|
|
||||||
|
|
||||||
|
|
||||||
|
if failed_response is None:
|
||||||
|
print(url, "✔️")
|
||||||
|
df.at[i, "Status"]="YES"
|
||||||
|
if df.at[i, "Score"] < 100:
|
||||||
|
df.at[i,"Score"] = df.at[i,"Score"] + 1
|
||||||
|
else:
|
||||||
|
print(url,"❌")
|
||||||
|
df.at[i,"Status"]="NO"
|
||||||
|
#if uptime >0 do -1 to the value
|
||||||
|
if df.at[i,"Score"] > 0:
|
||||||
|
df.at[i,"Score"] = df.at[i,"Score"] - 1
|
||||||
|
|
||||||
|
|
||||||
|
else:
|
||||||
|
if index1 == -1 and index2 == -1:
|
||||||
|
url = "http://"+url
|
||||||
|
|
||||||
|
status = requests.get(url,proxies=proxies, timeout=5).status_code
|
||||||
|
print('[+]',url,status)
|
||||||
|
if status != 502:
|
||||||
|
print(url,"✔️")
|
||||||
|
df.at[i,"Status"]="YES"
|
||||||
|
#if uptime <100 do +1 to the value
|
||||||
|
if df.at[i,"Score"] < 100:
|
||||||
|
df.at[i,"Score"] = df.at[i,"Score"] + 1
|
||||||
else:
|
else:
|
||||||
if index1 == -1 and index2 == -1:
|
print(url,"❌")
|
||||||
url = "http://"+url
|
df.at[i,"Status"]="NO"
|
||||||
|
#if uptime >0 do -1 to the value
|
||||||
|
if df.at[i,"Score"] > 0:
|
||||||
|
df.at[i,"Score"] = df.at[i,"Score"] - 1
|
||||||
|
|
||||||
status = requests.get(url,proxies=proxies, timeout=5).status_code
|
except requests.ConnectionError as e:
|
||||||
print('[+]',url,status)
|
#print(e)
|
||||||
if status != 502:
|
print(url,"❌")
|
||||||
print(url,"✔️")
|
df.at[i,"Status"]="NO"
|
||||||
df.at[i,"Status"]="YES"
|
#if uptime >0 do -1 to the value
|
||||||
#if uptime <100 do +1 to the value
|
if df.at[i,"Score"] > 0:
|
||||||
if df.at[i,"Score"] < 100:
|
df.at[i,"Score"] = df.at[i,"Score"] - 1
|
||||||
df.at[i,"Score"] = df.at[i,"Score"] + 1
|
except requests.exceptions.ReadTimeout as e:
|
||||||
else:
|
#print(e)
|
||||||
print(url,"❌")
|
print(url,"❌")
|
||||||
df.at[i,"Status"]="NO"
|
df.at[i,"Status"]="NO"
|
||||||
#if uptime >0 do -1 to the value
|
#if uptime >0 do -1 to the value
|
||||||
if df.at[i,"Score"] > 0:
|
if df.at[i,"Score"] > 0:
|
||||||
df.at[i,"Score"] = df.at[i,"Score"] - 1
|
df.at[i,"Score"] = df.at[i,"Score"] - 1
|
||||||
|
except ConnectionRefusedError:
|
||||||
except requests.ConnectionError as e:
|
print(url,"✔️")
|
||||||
#print(e)
|
df.at[i, "Status"]="YES"
|
||||||
print(url,"❌")
|
if df.at[i, "Score"] < 100:
|
||||||
df.at[i,"Status"]="NO"
|
df.at[i,"Score"] = df.at[i,"Score"] + 1
|
||||||
#if uptime >0 do -1 to the value
|
|
||||||
if df.at[i,"Score"] > 0:
|
|
||||||
df.at[i,"Score"] = df.at[i,"Score"] - 1
|
|
||||||
except requests.exceptions.ReadTimeout as e:
|
|
||||||
#print(e)
|
|
||||||
print(url,"❌")
|
|
||||||
df.at[i,"Status"]="NO"
|
|
||||||
#if uptime >0 do -1 to the value
|
|
||||||
if df.at[i,"Score"] > 0:
|
|
||||||
df.at[i,"Score"] = df.at[i,"Score"] - 1
|
|
||||||
except ConnectionRefusedError:
|
|
||||||
print(url,"✔️")
|
|
||||||
df.at[i, "Status"]="YES"
|
|
||||||
if df.at[i, "Score"] < 100:
|
|
||||||
df.at[i,"Score"] = df.at[i,"Score"] + 1
|
|
||||||
|
|
||||||
|
|
||||||
df2 = df.sort_values(by=["Score"], ascending=False)
|
df2 = df.sort_values(by=["Score"], ascending=False)
|
||||||
#sort by category if you are verified/unverified.csv
|
#sort by category if you are verified/unverified.csv
|
||||||
if csvfilename in csvfiles2sortcat:
|
if csvfilename in csvfiles2sortcat:
|
||||||
df2 = df.sort_values(by=["Category"], ascending=True)
|
df2 = df.sort_values(by=["Category"], ascending=True)
|
||||||
#print(df2)
|
#print(df2)
|
||||||
df2.to_csv(csvfile, index=False)
|
df2.to_csv(csvfile, index=False)
|
||||||
|
|
||||||
|
|
||||||
def IsUrlValid(url:str)->bool:
|
def IsUrlValid(url:str)->bool:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue