-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
55 lines (41 loc) · 1.93 KB
/
main.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# import phonenumbers
# from openpyxl import Workbook
# # All ISPs codes
# mtn = ["+98933", "+98935", "+98936", "+98937", "+98938",
# "+98939", "+98930", "+98901", "+98902", "+98903", "+98905"]
# mci = ["+98910", "+98913", "+98990", "+98919", "+98992", "+98910", "+98912",
# "+98914", "+98915", "+98916", "+98917", "+98918", "+98991", "+98993"]
# rtl = ["+98920", "+98921", "+98922", "+98923"]
import itertools
import vobject
def generate_numbers(number):
"""Generate a list of 11 digit numbers with missing digits replaced by every possible digit from 0 to 9"""
# Find the positions of the stars in the input number
star_positions = [i for i in range(len(number)) if number[i] == "*"]
# Generate a list of every possible digit permutation for the missing positions
digit_permutations = [[str(digit) for digit in range(10)]
for _ in range(len(star_positions))]
digit_combinations = itertools.product(*digit_permutations)
digit_combinations = [''.join(x) for x in digit_combinations]
# Replace the stars in the input number with each possible digit combination to generate a list of 11 digit numbers
numbers = []
for digits in digit_combinations:
new_number = number
for i in range(len(star_positions)):
new_number = new_number[:star_positions[i]] + \
digits[i] + new_number[star_positions[i]+1:]
numbers.append(new_number)
return numbers
number = "9123*45**3" # Change this Value to your missing number
contacts = generate_numbers(number)
# Create a VCF file with the generated contacts
vcard_list = []
for contact in contacts:
vcard = vobject.vCard()
vcard.add('fn').value = "Contact " + contact
vcard.add('tel').value = "+98" + contact
vcard_list.append(vcard)
with open("contacts.vcf", "w") as vcf_file:
for vcard in vcard_list:
vcf_file.write(vcard.serialize())
vcf_file.write('\n')