Skip to main content

Examples spoof py

About‚Äč

by 'Chrismoos'

Caller ID spoofing, TTS, and getDigits. This first prompts a caller to enter an access code, and if correct, the caller can then enter a number to spoof, and a destination number. Also, this example will send an email whenever a spoofed call is made (for abuse purposes, possibly).

Click here to expand Table of Contents

Code

import os,sys
from freeswitch import *
from datetime import datetime
from time import mktime
import httplib
import urllib
import random
import smtplib

def get_number(session,invalid,num=10):
digits = session.getDigits(num, "#", 6000)
if digits == '':
if invalid == 3:
session.speak('You have entered too many in valid entries. Goodbye.')
session.hangup()
else:
session.speak('Invalid entry. Please try again.')
get_number(session,invalid+1)
else:
return digits

def handler(session, args):
session.answer()
session.set_tts_parms('cepstral', 'Allison')

session.speak('Please enter the 4 digit access code.')
code = get_number(session,2,num=4)
if(code == None or code != '6969'):
session.speak('Invalid access code, goodbye!')
session.hangup()
return
session.speak('Please enter the number you would like to spoof.')
spoof_number = get_number(session, 0)
session.speak('Please enter the number you would like to call.')
dest_number = get_number(session, 0)
session.setVariable("effective_caller_id_number", spoof_number)

session.speak('Calling...please wait')
server = smtplib.SMTP('smtp.mydomain.com')

fromaddr = 'freeswitch@mydomain.com'
toaddrs = ['someaddr@mydomain.com']
subject = "A spoofed call was made"
msg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % (fromaddr, ", ".join(toaddrs), subject))
d = datetime.now().strftime('%A, %B %d, %Y %I:%M%p')
msgContents = "Date: %s\nCaller ID: %s\n\nDestination Number: %s\nSpoofed Number: %s\n\n\nSincerely, \nFreeSwitch Spoofer" % (d, session.getVariable("caller_id_number"), dest_number, spoof_number)

server.sendmail(fromaddr, toaddrs, msg+msgContents)
session.execute('transfer', dest_number)