diff --git a/install.sh b/install.sh index 1f67d6c..47f38af 100755 --- a/install.sh +++ b/install.sh @@ -1,25 +1,7 @@ -clear -echo "******* Torghost installer ********" -echo "" -echo "=====> Installing tor bundle " -sudo apt-get install tor -y -qq -echo "=====> Installing TorGhost & dependencies " - -pyv="$(python -V 2>&1)" || pyv="$(python3 -V 2>&1)" -pyv=${pyv:7:1} - -if [[ $pyv == "3" ]] -then - sudo pip3 install stem - sudo cp torghost3 /usr/bin/torghost -else - sudo pip install stem - sudo cp torghost /usr/bin/torghost -fi -sudo chmod +x /usr/bin/torghost -echo "=====> Restarting tor service" -sudo systemctl stop tor -sudo systemctl enable tor -sudo systemctl start tor +echo "Torghost installer v3.0" +echo "Installing prerequisites " +sudo apt-get install tor python-pip -y +echo "Installing dependencies " +pip install -r requirements.txt +pyinstaller torghost.py echo "=====> Done " -echo "=====> Open terminal and type 'torghost' for usage " diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a505ae6 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +stem==1.7.1 +PyInstaller==3.5 \ No newline at end of file diff --git a/torghost b/torghost deleted file mode 100644 index ca7a83d..0000000 --- a/torghost +++ /dev/null @@ -1,190 +0,0 @@ -#!/usr/bin/python - -import os -import sys -import commands -from commands import getoutput -import time -import signal -from stem import Signal -from stem.control import Controller - - -class bcolors: - BLUE = '\033[94m' - GREEN = '\033[92m' - RED = '\033[31m' - YELLOW = '\033[93m' - FAIL = '\033[91m' - ENDC = '\033[0m' - BOLD = '\033[1m' - BGRED = '\033[41m' - WHITE = '\033[37m' - - -def t(): - current_time = time.localtime() - ctime = time.strftime('%H:%M:%S', current_time) - return "["+ ctime + "]" -def shutdown(): - print "" - print bcolors.BGRED + bcolors.WHITE + t() + "[info] shutting down torghost" + bcolors.ENDC +"\n\n" - sys.exit() - - -def sigint_handler(signum, frame): - print '\n user interrupt ! shutting down' - shutdown() - -def logo(): - os.system("clear") - print bcolors.RED + bcolors.BOLD - print """ - _____ ____ _ _ - |_ _|__ _ __ / ___| |__ ___ ___| |_ - | |/ _ \| '__| | _| '_ \ / _ \/ __| __| - | | (_) | | | |_| | | | | (_) \__ \ |_ - |_|\___/|_| \____|_| |_|\___/|___/\__| - v2.0 - SusmithKrishnan - - """ - print bcolors.ENDC -def usage(): - logo() - print """ - - USAGE: - torghost start -----(start torghost) - torghost stop -----(stop torghost) - torghost switch ----(switch IP) - - """ - sys.exit() - -def ip(): - while True: - try: - ipadd = commands.getstatusoutput('wget -qO- https://check.torproject.org | grep -Po "(?<=strong>)[\d\.]+(?= /dev/null 2>&1') + print bcolors.GREEN + '[done]' + bcolors.ENDC + print t() + ' Starting new tor daemon ', + os.system('sudo -u debian-tor tor -f /etc/tor/torghostrc > /dev/null' + ) + print bcolors.GREEN + '[done]' + bcolors.ENDC + print t() + ' setting up iptables rules', + + iptables_rules = \ + """ + NON_TOR="192.168.1.0/24 192.168.0.0/24" + TOR_UID=%s + TRANS_PORT="9040" + + iptables -F + iptables -t nat -F + + iptables -t nat -A OUTPUT -m owner --uid-owner $TOR_UID -j RETURN + iptables -t nat -A OUTPUT -p udp --dport 53 -j REDIRECT --to-ports 5353 + for NET in $NON_TOR 127.0.0.0/9 127.128.0.0/10; do + iptables -t nat -A OUTPUT -d $NET -j RETURN + done + iptables -t nat -A OUTPUT -p tcp --syn -j REDIRECT --to-ports $TRANS_PORT + + iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT + for NET in $NON_TOR 127.0.0.0/8; do + iptables -A OUTPUT -d $NET -j ACCEPT + done + iptables -A OUTPUT -m owner --uid-owner $TOR_UID -j ACCEPT + iptables -A OUTPUT -j REJECT + """ \ + % commands.getoutput('id -ur debian-tor') + + os.system(iptables_rules) + print bcolors.GREEN + '[done]' + bcolors.ENDC + print t() + ' Fetching current IP...' + print t() + ' CURRENT IP : ' + bcolors.GREEN + ip() + bcolors.ENDC + + +def stop_torghost(): + print bcolors.RED + t() + 'STOPPING torghost' + bcolors.ENDC + print t() + ' Flushing iptables, resetting to default', + IpFlush = \ + """ + iptables -P INPUT ACCEPT + iptables -P FORWARD ACCEPT + iptables -P OUTPUT ACCEPT + iptables -t nat -F + iptables -t mangle -F + iptables -F + iptables -X + """ + os.system(IpFlush) + os.system('sudo fuser -k 9051/tcp > /dev/null 2>&1') + print bcolors.GREEN + '[done]' + bcolors.ENDC + print t() + ' Restarting Network manager', + os.system('service network-manager restart') + print bcolors.GREEN + '[done]' + bcolors.ENDC + print t() + ' Fetching current IP...' + time.sleep(3) + print t() + ' CURRENT IP : ' + bcolors.GREEN + ip() + bcolors.ENDC + + +def switch_tor(): + print t() + ' Please wait...' + time.sleep(7) + print t() + ' Requesting new circuit...', + with Controller.from_port(port=9051) as controller: + controller.authenticate() + controller.signal(Signal.NEWNYM) + print bcolors.GREEN + '[done]' + bcolors.ENDC + print t() + ' Fetching current IP...' + print t() + ' CURRENT IP : ' + bcolors.GREEN + ip() + bcolors.ENDC + +def check_update(): + print t() + ' Checking for update...' + newversion= get(API_DOMAIN+'/latestversion').json() + if newversion['version'] != VERSION: + print t() + bcolors.GREEN + ' New update available please check https://github.com/SusmithKrishnan/torghost' + bcolors.ENDC + else: + print t() + ' Torghost is up to date...' + + +def main(): + if len(sys.argv) <= 1 : + check_update() + usage() + try: + (opts, args) = getopt.getopt(sys.argv[1:], 'srxh', ['start', 'stop', 'switch', 'help']) + except getopt.GetoptError, err: + usage() + sys.exit(2) + for (o, a) in opts: + if o in ('-h', '--help'): + usage() + elif o in ('-s', '--start'): + start_torghost() + elif o in ('-x', '--stop'): + stop_torghost() + elif o in ('-r', '--switch'): + switch_tor() + else: + usage() + + +if __name__ == '__main__': + main() diff --git a/torghost3 b/torghost3 deleted file mode 100644 index d13873d..0000000 --- a/torghost3 +++ /dev/null @@ -1,190 +0,0 @@ -#!/usr/bin/python3 - -import os -import sys -import subprocess -from subprocess import getoutput -import time -import signal -from stem import Signal -from stem.control import Controller - - -class bcolors: - BLUE = '\033[94m' - GREEN = '\033[92m' - RED = '\033[31m' - YELLOW = '\033[93m' - FAIL = '\033[91m' - ENDC = '\033[0m' - BOLD = '\033[1m' - BGRED = '\033[41m' - WHITE = '\033[37m' - - -def t(): - current_time = time.localtime() - ctime = time.strftime('%H:%M:%S', current_time) - return "["+ ctime + "]" -def shutdown(): - print("") - print(bcolors.BGRED + bcolors.WHITE + t() + "[info] shutting down torghost" + bcolors.ENDC +"\n\n") - sys.exit() - - -def sigint_handler(signum, frame): - print('\n user interrupt ! shutting down') - shutdown() - -def logo(): - os.system("clear") - print(bcolors.RED + bcolors.BOLD) - print(""" - _____ ____ _ _ - |_ _|__ _ __ / ___| |__ ___ ___| |_ - | |/ _ \| '__| | _| '_ \ / _ \/ __| __| - | | (_) | | | |_| | | | | (_) \__ \ |_ - |_|\___/|_| \____|_| |_|\___/|___/\__| - v2.0 - SusmithHCK | www.askthehackers.com - - """) - print(bcolors.ENDC) -def usage(): - logo() - print(""" - - USAGE: - torghost start -----(start torghost) - torghost stop -----(stop torghost) - torghost switch ----(switch IP) - - """) - sys.exit() - -def ip(): - while True: - try: - ipadd = subprocess.getstatusoutput('wget -qO- https://check.torproject.org | grep -Po "(?<=strong>)[\d\.]+(?=