-
Notifications
You must be signed in to change notification settings - Fork 2
/
ipghost
184 lines (148 loc) · 4.25 KB
/
ipghost
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!/usr/bin/python
import os
import sys
from commands import getoutput
import time
import signal
from json import load
from urllib2 import urlopen
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 ipghost" + 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.YELLOW + bcolors.BOLD
print """
IPGHOST v1.0
- Praveen Manohar
____________________________________________
We are using tor service to change an ip
address in effective manner.
Test :
After start our service goto "dnsleaktest.com"
or check your public IP address.
Uses:
** anonymous internet surfing
** access any restricted sites
"""
print bcolors.ENDC
def usage():
logo()
print """
USAGE:
ipghost start ----- (start ipghost)
ipghost abort ----- (abort ipghost)
"""
sys.exit()
def ip():
while True:
try:
ipadd = load(urlopen('https://api.ipify.org?format=json'))['ip']
except :
continue
break
return ipadd
signal.signal(signal.SIGINT, sigint_handler)
TorrcCfgString = """
VirtualAddrNetwork 10.0.0.0/10
AutomapHostsOnResolve 1
TransPort 9040
DNSPort 53
"""
resolvString = "nameserver 127.0.0.1"
Torrc = "/etc/tor/torrc"
resolv = "/etc/resolv.conf"
def start_ipghost():
if TorrcCfgString in open(Torrc).read():
print t()+" Torrc file already configured"
else:
with open(Torrc, "a") as myfile:
print t()+" Configuring torrc file.. ",
myfile.write(TorrcCfgString)
print bcolors.GREEN+"[done]"+bcolors.ENDC
if resolvString in open(resolv).read():
print t()+" DNS resolv.conf file already configured"
else:
with open(resolv, "w") as myfile:
print t()+" Configuring DNS resolv.conf file.. ",
myfile.write(resolvString)
print bcolors.GREEN+"[done]"+bcolors.ENDC
print t()+" Starting tor service.. ",
os.system("service tor start")
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 53
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
"""%(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
print bcolors.yellow+"TOR is now hidding your ip address, Now you can access any website without any problem..........."
print bcolors.yellow+"Congrats..........."
def abort_ipghost():
print bcolors.RED+t()+" ABORTING ipghost service "+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)
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..."
print t()+" CURRENT IP : "+bcolors.GREEN+ip()+bcolors.ENDC
print bcolors.yellow+ " Thanks... For using IPGHOST service"
print bcolors.yellow+ " Hope see you soon......."
arg = sys.argv[1:]
if len(arg)!=1:
usage()
elif sys.argv[1] == "start":
logo()
start_ipghost()
elif sys.argv[1] == "abort":
logo()
abort_ipghost()
else:
usage()