-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathripgrok.py
34 lines (30 loc) · 1003 Bytes
/
ripgrok.py
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
import ngrok
#This isnt the official ngrok libary. This is merely my way to parse out the tunnel host and ip from the ngrok api
#Subglitch1
def find_between( s, first, last ):
try:
start = s.index( first ) + len( first )
end = s.index( last, start )
return s[start:end]
except ValueError:
return ""
def find_between_r( s, first, last ):
try:
start = s.rindex( first ) + len( first )
end = s.rindex( last, start )
return s[start:end]
except ValueError:
return ""
def get_tunnels():
# construct the api client
with open('creds', 'r') as credfile:
ngrok_auth=credfile.readline()
client = ngrok.Client(ngrok_auth)
# list all online tunnels
for t in client.tunnels.list():
with open('tmp.txt', 'w+') as tmp:
out = str(t)
tmp.write(out)
with open('tmp.txt', 'r') as tmp:
anan = tmp.readline()
return find_between(anan, "tcp://", "', 'started_at':")