Created
December 5, 2018 12:51
-
-
Save mtrimarchi/ab49ce394c254a9c07b2f5857df6e6bc to your computer and use it in GitHub Desktop.
Python Script VoIP TIM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Credenziali voip TIM + Proxy IP | |
import sys | |
import random | |
import json | |
try: | |
import requests | |
except ImportError: | |
print ("ERRORE: Il modulo \"requests\" deve essere installato. Eseguire -> pip install requests") | |
raise SystemExit(0) | |
try: | |
import dns | |
import dns.resolver | |
except ImportError: | |
print ("ERRORE: Il modulo \"dnspython\" deve essere installato. Eseguire -> pip install dnspython") | |
def getTargetFromSRV(name): | |
try: | |
srv_ans = dns.resolver.query(name,'SRV') | |
except (dns.resolver.NXDOMAIN,dns.resolver.NoAnswer) as err: | |
raise SystemExit('Errore risoluzione record SRV per {0}'.format(name)) | |
for a in srv_ans: | |
#print ("SRV record: {0} priotita' {1}".format(a.target.to_text(),a.priority)) | |
try: | |
a_ans = dns.resolver.query(a.target.to_text(),'A') | |
except (dns.resolver.NXDOMAIN,dns.resolver.NoAnswer) as err: | |
raise SystemExit('Errore risoluzione record A per {0}'.format(a.target.to_text())) | |
for a1 in a_ans: | |
print ("Indirizzo proxy priorita' {1} : {0}".format(a1.to_text(),a.priority)) | |
if len(sys.argv) != 4: | |
raise SystemExit('Uso: {0} lineavoip celulare nomedispositivo'.format(sys.argv[0])) | |
tel = sys.argv[1] | |
cell = sys.argv[2] | |
devicename = sys.argv[3] | |
uid = random.getrandbits(16) | |
regmanurl1 = "https://regman-telefono.interbusiness.it:10800/AppTelefono/AnyModem/wsTIphoneProvisioning/v1/otpProvisioningSessions?CLI=%2B39{0}&DeviceId={1}&Mobile=%2B39{2}".format(tel,uid,cell) | |
regmanurl2 = "https://regman-telefono.interbusiness.it:10800/AppTelefono/AnyModem/wsTIphoneProvisioning/v1/associations" | |
headers = {'Content-Type':'application/json', 'Accept':'application/json','charset':'utf-8','Authorization':'Basic aDloa003NXltWTVGamtRWjpCczd5RC1tdS1ObmR3QyErNU0zOWRZIW5IUmJFS2pocw==',\ | |
'User-Agent':'Dalvik/2.1.0 (Linux; U; Android 5.0.2; P10 Build/LRX22G)',\ | |
'Connection':'Keep-Alive','Accept-Encoding':'identity'} | |
r = requests.get(regmanurl1, headers=headers) | |
resp = r.json() | |
otp = input("Inserisci OTP ricevuta via sms:") | |
payload = \ | |
{\ | |
"CLI": "{0}".format(resp['CLI']),\ | |
"DeviceId": "{0}".format(uid),\ | |
"DeviceName": "{0}".format(devicename),\ | |
"Mobile": "+39{0}".format(cell),\ | |
"NotificationId": "android:ctHDua{0}:BPA91bEvIgToivB52yRJ8_ati5sP5DSE4j2SnjUYG1dHRSetM0G6jqd{0}FmhlP3zq7QlVAnYluf2yqbh-6lHPFWuzzq4BoqjgE4A-VnRo3xWmmFIrJYal5Hd3jyLRWCpTwh7TzW1_".format(uid),\ | |
"OTP": "{0}".format(otp),\ | |
"SessionOTP": "{0}".format(resp['SessionOTP']),\ | |
"TGU": "{0}".format(resp['TGU'])\ | |
} | |
r = requests.post(regmanurl2, headers=headers, json=payload) | |
resp = r.json() | |
voipcreds=resp['ManagementObject'] | |
print("\n ====== CREDENZIALI VOIP ========== \n") | |
for k, v in voipcreds.items(): | |
print(k, v) | |
print("\n ====== INDIRIZZI DEI PROXY ========== \n") | |
getTargetFromSRV("_sip._udp."+voipcreds['P-CSCF_Address']) | |
#End |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Mi sa che da oggi non va più, ho fatto con postman un test della chiamata fatta linea #49 e ritorna
Molti parametri sono a null
Fino a mercoledì 1 Febbraio 2023 fa ha funzionato