Every time I find a new group of scammers I also always find a long list of numbers for their victims, usually older people they've managed to have success in scamming. Hard to deal with so many numbers so I've made a script that will call them.
Not finished yet but works pretty well so far.
Code: Select all
import os
import time
from dotenv import load_dotenv
from flask import Flask
from twilio.rest import Client
from threading import Thread
from callbacks import handle_callbacks
from conn import create_table
from conn import get_next_call
from conn import update_in_call
from common import printGood
from common import printBad
from common import printNeutral
victimTableSql = '''CREATE TABLE IF NOT EXISTS victims (
id integer PRIMARY KEY AUTOINCREMENT,
phone text,
attempts integer NOT NULL,
stop_calling integer NOT NULL,
in_call integer NOT NULL,
created_date text NOT NULL,
last_call text NOT NULL,
dial_code integer NOT NULL
);'''
current_code = 1
def main():
t1 = Thread(target=handle_calls)
t2 = Thread(target=handle_callbacks)
t1.start()
t2.start()
t1.join()
t2.join()
def handle_calls():
load_dotenv()
account_sid = os.getenv('TWILIO_SID')
auth_token = os.getenv('TWILIO_TOKEN')
client = Client(account_sid, auth_token)
create_table(victimTableSql)
while True:
next_call = get_next_call(current_code)
if next_call and next_call[4] != 1:
call_to = next_call[1]
in_call = next_call[4]
dial_code = next_call[7]
if dial_code == current_code:
if dial_code == 1:
call_from = os.getenv('TWILIO_US_NUM')
elif dial_code == 61:
# Need to buy an AU number!
call_from = os.getenv('TWILIO_US_NUM')
else:
printBad("No number for this country, skipping")
continue
printGood("Calling: " + next_call[1])
update_in_call(next_call[1], 1)
call = client.calls.create(
url=os.getenv('TWILIO_NGROK') + '/important?language=en-US',
to=next_call[1],
from_=call_from,
status_callback=os.getenv('TWILIO_NGROK') + '/status',
status_callback_method= 'POST',
record=True,
recording_channels='dual',
recording_status_callback=os.getenv('TWILIO_NGROK') + '/recordingStatus'
)
printGood("Call SID: " + call.sid)
time.sleep(60)
else:
printBad("Not current dial code, skipping")
if __name__ == "__main__":
main()
Code: Select all
from flask import Flask, request
from twilio.twiml.voice_response import VoiceResponse, Gather
from conn import update_stop_calling
from conn import update_attempts
from common import printGood
from common import printBad
from common import printNeutral
calledDict = {}
app = Flask(__name__)
@app.route("/answer", methods=['GET', 'POST'])
def answer_call():
resp = VoiceResponse()
resp.say("", voice='alice', language='de-DE')
return str(resp)
@app.route("/important", methods=['GET', 'POST'])
def important_call():
resp = VoiceResponse()
language = request.values['language']
gather = Gather(num_digits=1, action='/stop_calling?language=' + language)
if language == 'de-DE':
message = ''
else:
message = 'Please listen carefully. We are calling from an anti scammer association. You are receiving this call because we suspect you have been targeted by scammers recently. If someone has called you regarding a charge or suspicious activity on your credit card or account, it is most likely a scam. Please do not give out any information concerning your credit or debit card over the phone. If anyone calls you and wants you to buy gift cards for them, hang up. If someone tries to convince you to give them access to your computer remotely, hang up. If you are uncertain what to do in these situations, please call your local authorities for assistance. If you understand this message, press 1 and we will not call you again.'
gather.say(message, voice='alice', language=language)
resp.append(gather)
try:
calledDict[request.values['Called']] += 1
printGood("Message number " + str(calledDict[request.values['Called']]) + " for " + request.values['Called'])
except:
calledDict[request.values['Called']] = 0
printGood("Message number 0 for " + request.values['Called'])
if calledDict[request.values['Called']] < 2:
resp.redirect('/important?language=' + language)
return str(resp)
@app.route("/stop_calling", methods=['GET', 'POST'])
def stop_calling():
resp = VoiceResponse()
language = request.values['language']
if language == 'de-DE':
message = ''
else:
message = 'Thank you. We will not call you again.'
if 'Digits' in request.values:
choice = request.values['Digits']
if choice == '1':
printGood(request.values['Called'] + " pressed 1, removing from list")
resp.say(message, voice='alice', language=language)
update_stop_calling(request.values['Called'])
return str(resp)
return str(resp)
@app.route("/status", methods=['GET', 'POST'])
def status():
printGood("Call status called, updating record")
#print(request.values)
update_attempts(request.values['Called'])
if request and request.values['CallStatus'] == 'completed':
pass
return "ok"
@app.route("/recordingStatus", methods=['GET', 'POST'])
def recording_status():
#printGood("Recording status called")
#print(request.values)
return "ok"
def handle_callbacks():
app.run(debug=False)