Update torghostng.py

This commit is contained in:
Git Kern3l 2020-04-26 11:13:06 +07:00 committed by GitHub
parent eac016e08d
commit dd581b550d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,16 +2,20 @@
import argparse import argparse
from time import sleep from time import sleep
from json import loads from json import JSONDecodeError, loads
from sys import argv, exit from sys import argv, exit
from subprocess import getoutput from subprocess import getoutput
from torngconf.theme import *
from os import geteuid, system, path, name from os import geteuid, system, path, name
try:
from torngconf.theme import *
except ModuleNotFoundError:
print("TorghostNG is lacking its needed files. Reinstall TorghostNG pls")
exit()
SLEEP_TIME = 1.0 SLEEP_TIME = 1.0
VERSION = "1.2" VERSION = "1.2"
def the_argparse(language=English): def the_argparse(language=English):
parser = argparse.ArgumentParser(usage="torghostng [-h] -s|-x|-id|-r|-m|-c|-l|--list", add_help=False) parser = argparse.ArgumentParser(usage="torghostng [-h] -s|-x|-id|-r|-m|-c|-l|--list", add_help=False)
parser._optionals.title = language.options parser._optionals.title = language.options
@ -28,7 +32,6 @@ def the_argparse(language=English):
parser.add_argument("-u", "--update", help=language.update_help, action="store_true") parser.add_argument("-u", "--update", help=language.update_help, action="store_true")
parser.add_argument("--nodelay", help=language.no_delay_help, action="store_true") parser.add_argument("--nodelay", help=language.no_delay_help, action="store_true")
if len(argv) == 1: if len(argv) == 1:
banner() banner()
parser.print_help() parser.print_help()
@ -37,12 +40,11 @@ def the_argparse(language=English):
return parser.parse_args() return parser.parse_args()
if path.isfile('/usr/bin/upgradepkg') == True: if (path.isfile('/usr/bin/upgradepkg') == True) or (path.isfile('/usr/bin/torngconf/langconf.txt') == False):
LANGCONF = 'torngconf/langconf.txt' LANGCONF = 'torngconf/langconf.txt'
else: else:
LANGCONF = '/usr/bin/torngconf/langconf.txt' LANGCONF = '/usr/bin/torngconf/langconf.txt'
if path.isfile('/usr/bin/apt') == True: if path.isfile('/usr/bin/apt') == True:
TOR_USER = 'debian-tor' TOR_USER = 'debian-tor'
else: else:
@ -149,7 +151,6 @@ def check_update():
if choice[0].upper() == "Y": if choice[0].upper() == "Y":
print(language.updating.format(version)) print(language.updating.format(version))
system(update_commands) system(update_commands)
print(language.uptodate)
exit() exit()
else: else:
@ -159,7 +160,6 @@ def check_update():
print() print()
exit() exit()
def check_tor(status): def check_tor(status):
try: try:
print(language.checking_tor, end='', flush=True) print(language.checking_tor, end='', flush=True)
@ -184,6 +184,10 @@ def check_tor(status):
print() print()
exit() exit()
except JSONDecodeError:
print()
sleep(1)
check_tor(status)
def check_ip(): def check_ip():
try: try:
@ -202,7 +206,6 @@ def check_ip():
print() print()
exit() exit()
def check_lang(): def check_lang():
try: try:
if path.isfile(LANGCONF) == True: if path.isfile(LANGCONF) == True:
@ -230,7 +233,6 @@ def check_lang():
print("TorghostNG is lacking its needed files. Reinstall TorghostNG pls") print("TorghostNG is lacking its needed files. Reinstall TorghostNG pls")
exit() exit()
def choose_lang(language=English): def choose_lang(language=English):
try: try:
with open(LANGCONF, mode="w") as file_lang: with open(LANGCONF, mode="w") as file_lang:
@ -265,7 +267,6 @@ def choose_lang(language=English):
print() print()
exit() exit()
def start_connecting(id=None): def start_connecting(id=None):
try: try:
print(icon.process + ' ' + language.start_help) print(icon.process + ' ' + language.start_help)
@ -277,7 +278,7 @@ def start_connecting(id=None):
else: else:
print(language.disable_ipv6_info) print(language.disable_ipv6_info)
system('sudo cp /etc/sysctl.conf /etc/sysctl.conf.backup') system('sudo cp {} /etc/sysctl.conf.backup'.format(Sysctl))
print(language.disabling_ipv6, end='', flush=True) print(language.disabling_ipv6, end='', flush=True)
with open(Sysctl, mode='w') as file_sysctl: with open(Sysctl, mode='w') as file_sysctl:
@ -311,11 +312,11 @@ def start_connecting(id=None):
print(language.done) print(language.done)
if resolvConfig in open(resolv).read(): if resolvConfig == open(resolv).read():
print(language.already_configured.format('DNS resolv.conf')) print(language.already_configured.format('DNS resolv.conf'))
else: else:
system("cp /etc/resolv.conf /etc/resolv.conf.backup") system("cp {} /etc/resolv.conf.backup".format(resolv))
with open(resolv, mode='w') as file_resolv: with open(resolv, mode='w') as file_resolv:
print(language.configuring.format('DNS resolv.conf'), end='', flush=True) print(language.configuring.format('DNS resolv.conf'), end='', flush=True)
@ -352,16 +353,14 @@ def start_connecting(id=None):
print() print()
exit() exit()
def stop_connecting(): def stop_connecting():
try: try:
print(icon.process + ' ' + language.stop_help) print(icon.process + ' ' + language.stop_help)
if path.isfile('/etc/resolv.conf.backup') == True: if path.isfile('/etc/resolv.conf.backup') == True:
print(language.restoring_configuration.format('DNS resolv.conf'), end='', flush=True) print(language.restoring_configuration.format('DNS resolv.conf'), end='', flush=True)
system('mv /etc/resolv.conf.backup /etc/resolv.conf') system('mv /etc/resolv.conf.backup {}'.format(resolv))
sleep(SLEEP_TIME) sleep(SLEEP_TIME)
print(language.done) print(language.done)
@ -369,13 +368,12 @@ def stop_connecting():
if path.isfile('/etc/sysctl.conf.backup') == True: if path.isfile('/etc/sysctl.conf.backup') == True:
print(language.restoring_configuration.format('IPv6'), end='', flush=True) print(language.restoring_configuration.format('IPv6'), end='', flush=True)
system('mv /etc/sysctl.conf.backup /etc/sysctl.conf') system('mv /etc/sysctl.conf.backup {}'.format(Sysctl))
system('sudo sysctl -p') system('sudo sysctl -p')
sleep(SLEEP_TIME) sleep(SLEEP_TIME)
print(language.done) print(language.done)
print(language.flushing_iptables, end='', flush=True) print(language.flushing_iptables, end='', flush=True)
system(IpFlush) system(IpFlush)
system('fuser -k 9051/tcp > /dev/null 2>&1') system('fuser -k 9051/tcp > /dev/null 2>&1')
@ -395,7 +393,6 @@ def stop_connecting():
print() print()
exit() exit()
def change_tor_circuit(): def change_tor_circuit():
try: try:
print(language.changing_tor_circuit, end='', flush=True) print(language.changing_tor_circuit, end='', flush=True)
@ -416,20 +413,18 @@ def change_tor_circuit():
print() print()
exit() exit()
def changemac(interface): def changemac(interface):
try: try:
print(language.changing_mac, end='', flush=True) print(language.changing_mac)
sleep(SLEEP_TIME)
i = getoutput('ifconfig {} down'.format(interface)) i = getoutput('ifconfig {} down'.format(interface))
if "ERROR" in i: if "ERROR" in i:
print(language.interface_error.format(interface)) print(language.interface_error.format(interface))
else: else:
print(language.done)
system('macchanger -r {}'.format(interface)) system('macchanger -r {}'.format(interface))
system('ifconfig {} up'.format(interface)) system('ifconfig {} up'.format(interface))
sleep(SLEEP_TIME)
print(language.mac_changed) print(language.mac_changed)
print(language.ifconfig_tip) print(language.ifconfig_tip)
@ -438,7 +433,6 @@ def changemac(interface):
print() print()
exit() exit()
def fix_dns(): def fix_dns():
try: try:
print(language.fixing_dns, end='', flush=True) print(language.fixing_dns, end='', flush=True)
@ -456,35 +450,26 @@ def fix_dns():
if __name__ == "__main__": if __name__ == "__main__":
language = check_lang() language = check_lang()
check_windows_check_root() check_windows_check_root()
args = the_argparse(language) args = the_argparse(language)
banner() banner()
print() print()
if args.nodelay == True: if args.nodelay == True: SLEEP_TIME = 0
SLEEP_TIME = 0
if args.list == True: if args.list == True: print(language.language_list)
print(language.language_list)
if args.language == True: if args.language == True: language = choose_lang(language)
language = choose_lang(language)
if args.update == True: if args.update == True: check_update()
check_update()
if args.dns == True: if args.dns == True: fix_dns()
fix_dns()
if args.checkip == True: if args.checkip == True: check_tor('stopped')
check_tor('stopped')
your_interface = args.mac your_interface = args.mac
if your_interface != None: if your_interface != None: changemac(your_interface)
changemac(your_interface)
if args.start == True: if args.start == True:
start_connecting() start_connecting()
@ -499,7 +484,6 @@ if __name__ == "__main__":
start_connecting(the_id) start_connecting(the_id)
exit() exit()
if args.renew == True: if args.renew == True: change_tor_circuit()
change_tor_circuit()
print(language.video_tutorials) print(language.video_tutorials)