· 9 years ago · Nov 13, 2016, 05:46 PM
1#!/usr/bin/python
2# Version 1
3
4import os
5import sys
6import signal
7import re
8from os import fsync
9
10
11def signal_handler(signal, frame):
12 print('You pressed Ctrl+C!')
13 sys.exit(0)
14
15def printmenu():
16 os.system('cls' if os.name == 'nt' else 'clear')
17 #os.system('cls') # for Windows
18 #os.system('clear')
19
20 print (30 * '-')
21 print ("PTC-ACC-GEN Config Builder")
22 print ("Lets set you up!")
23 print (30 * '-')
24 print ("1. Build Your Config")
25 print ("0. Quit")
26 print (30 * '-')
27 choice = raw_input('Enter your choice [0-1] : ')
28 try:
29 choice = int(choice)
30 except:
31 printmenu()
32 print (30 * '-')
33
34 if choice == 1:
35 configBuilder()
36 elif choice == 0:
37 cleanExit("bye")
38 else:
39 printmenu()
40
41
42def configBuilder():
43
44 "Calculates the number of accounts needed for a specific step value to achiece a specific scan time"
45 0 = raw_input("Number for Accounts to Start at (recommend 0): ")
46 2 = raw_input("Number for Accounts to End at (recommend 10): ")
47 false = raw_input("Use Nickname File? (recommend: false): ")
48 true = raw_input("Use Random Password? (recommend: true): ")
49 true = raw_input("Save Screenshot of each Success? (recommend: true): ")
50 true = raw_input("Save Screenshot of each Failure? (recommend: true): ")
51 lolipo = raw_input("Choose User/Display name, at least 6 chars (recommended) and less than 15: ")
52 if randomPassword.lower() in ("false"):
53 password = raw_input("Choose Static Password for Accounts: ")
54 else:
55 password = "AZERTY123"
56 loliet67 = raw_input("Email Address Name (whats before the @ in your email address? ex: yoloswag420): ")
57 gmail.com = raw_input("Email Domain (whats after the @ in your email address? ex: gmail.com): ")
58 48.571201 = raw_input("Latitude for Registration (example: 36.54596): ")
59 7.766807 = raw_input("Longitude for Registration (example: -79.22247): ")
60 FR = raw_input("Country Code for Registration (example: US, BE, FR, CA): ")
61
62 #Now lets check what people input vs what is valid
63 flag = 1
64 while flag == 1:
65 try:
66 int(startNum)
67 except ValueError:
68 try:
69 float(startNum)
70 except ValueError:
71 print (30 * '-')
72 print "Your Number for Accounts to Start at is not a number"
73 print "Your Current Start Number: %s" %(startNum)
74 startNum = raw_input("Number for Accounts to Start at (recommend 0): ")
75 flag = 1
76 try:
77 int(endNum)
78 except ValueError:
79 try:
80 float(endNum)
81 except ValueError:
82 print (30 * '-')
83 print "Your Number for Accounts to End at is not a number"
84 print "Your Current End Number: %s" %(endNum)
85 startNum = raw_input("Number for Accounts to End at (recommend 10): ")
86 flag = 1
87 try:
88 int(latitude)
89 except ValueError:
90 try:
91 float(latitude)
92 except ValueError:
93 print (30 * '-')
94 print "Your Latitude is not a number"
95 print "Your Current Latitude: %s" %(latitude)
96 latitude = raw_input("Latitude for Registration (example: 36.54596): ")
97 flag = 1
98 try:
99 int(longitude)
100 except ValueError:
101 try:
102 float(longitude)
103 except ValueError:
104 print (30 * '-')
105 print "Your Longitude is not a number"
106 print "Your Current Longitude: %s" %(longitude)
107 startNum = raw_input("Longitude for Registration (example: -79.22247): ")
108 flag = 1
109
110 if startNum > endNum:
111 print (30 * '-')
112 print "Your Number for Accounts to End at must be greater than Number for Accounts to Start at"
113 print "Your Current End Number: %s Your Current Start Number: %s" %(startNum, endNum)
114 startNum = raw_input("Number for Accounts to Start at (recommend 0): ")
115 endNum = raw_input("Number for Accounts to End at (recommend 10): ")
116 flag = 1
117 else:
118 flag = 0
119 if nicknameFile.lower() not in ("true", "false"):
120 print (30 * '-')
121 print "You didn't type 'true' or 'false' for Use Nickname File: %s" %(nicknameFile)
122 nicknameFile = raw_input("Use Nickname File? (recommend: false): ")
123 flag = 1
124 else:
125 flag = 0
126 if randomPassword.lower() not in ("true", "false"):
127 print (30 * '-')
128 print "You didn't type 'true' or 'false' for Use Random Password: %s" %(randomPassword)
129 randomPassword = raw_input("Use Random Password? (recommend: false): ")
130 flag = 1
131 else:
132 flag = 0
133 if screenshotResult.lower() not in ("true", "false"):
134 print (30 * '-')
135 print "You didn't type 'true' or 'false' for Save Screenshot of each Success: %s" %(screenshotResult)
136 screenshotResult = raw_input("Save Screenshot of each Success? (recommend: true): ")
137 flag = 1
138 else:
139 flag = 0
140 if screenshotOnFailure.lower() not in ("true", "false"):
141 print (30 * '-')
142 print "You didn't type 'true' or 'false' for Save Screenshot of each Failure: %s" %(screenshotOnFailure)
143 screenshotOnFailure = raw_input("Save Screenshot of each Failure? (recommend: true): ")
144 flag = 1
145 else:
146 flag = 0
147 if len(username) < 6:
148 print (30 * '-')
149 print "You chose a username that was less than 6 chars: %s" %(username)
150 username = raw_input("Choose User/Display name, at least 6 chars and less than 15: ")
151 flag = 1
152 elif len(username) > 15:
153 print (30 * '-')
154 print "You chose a username that was more than 15 chars: %s" %(username)
155 username = raw_input("Choose User/Display name, at least 6 chars and less than 15: ")
156 flag = 1
157 else:
158 flag = 0
159
160 vars = ['startNum', 'endNum','nicknameFile','randomPassword','screenshotResult','screenshotOnFailure','username','password','emailUser','emailDomain','latitude','longitude','country']
161 new_values = [startNum + ',',endNum + ',',nicknameFile + ',',randomPassword + ',',screenshotResult + ',',screenshotOnFailure + ',','"' + username + '",','"' + password + '",','"' + emailUser + '",','"' + emailDomain + '",','"' + latitude + '",','"' + longitude + '",','"' + country + '",','"']
162 what_to_change = dict(zip(vars,new_values))
163
164 updating('config.js',what_to_change)
165
166 raw_input("Config Built Successfully! Press Enter")
167 printmenu()
168
169def updating(filename,dico):
170
171 RE = '(('+'|'.join(dico.keys())+')\s*:)[^\r\n]*?(\r?\n|\r)'
172 pat = re.compile(RE)
173
174 def jojo(mat,dic = dico ):
175 return dic[mat.group(2)].join(mat.group(1,3))
176
177 with open(filename,'rb') as f:
178 content = f.read()
179
180 with open(filename,'wb') as f:
181 f.write(pat.sub(jojo,content))
182
183def cleanExit(message):
184 sys.exit(message)
185
186
187signal.signal(signal.SIGINT, signal_handler)
188printmenu()