Spaces:
Sleeping
Sleeping
prince1604 commited on
Commit ·
2d3eeb0
1
Parent(s): a5dfcf4
Integrated professional cybersecurity application template into Campaign Builder
Browse files- app.py +32 -5
- email_automation.py +4 -4
- templates/campaign.html +53 -5
app.py
CHANGED
|
@@ -36,15 +36,37 @@ def setup_campaign():
|
|
| 36 |
subject = request.form.get('subject')
|
| 37 |
body = request.form.get('body')
|
| 38 |
|
| 39 |
-
contacts_file
|
| 40 |
-
if not contacts_file:
|
| 41 |
return jsonify({'error': 'Contacts file is required.'}), 400
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
campaign_id = str(uuid.uuid4())
|
| 44 |
campaign_dir = os.path.join(app.config['UPLOAD_FOLDER'], campaign_id)
|
| 45 |
os.makedirs(campaign_dir, exist_ok=True)
|
| 46 |
|
| 47 |
-
contacts_path = os.path.join(campaign_dir,
|
| 48 |
contacts_file.save(contacts_path)
|
| 49 |
|
| 50 |
# Handle attachments
|
|
@@ -52,13 +74,18 @@ def setup_campaign():
|
|
| 52 |
attachment_paths = []
|
| 53 |
for att in attachments:
|
| 54 |
if att.filename:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
att_path = os.path.join(campaign_dir, att.filename)
|
| 56 |
att.save(att_path)
|
| 57 |
attachment_paths.append(att_path)
|
| 58 |
|
| 59 |
# Parse Contacts
|
| 60 |
try:
|
| 61 |
-
if
|
| 62 |
df = pd.read_csv(contacts_path)
|
| 63 |
else:
|
| 64 |
df = pd.read_excel(contacts_path)
|
|
@@ -66,7 +93,7 @@ def setup_campaign():
|
|
| 66 |
return jsonify({'error': f'Failed to read contacts file: {str(e)}'}), 400
|
| 67 |
|
| 68 |
if 'RecipientEmail' not in df.columns:
|
| 69 |
-
return jsonify({'error': '
|
| 70 |
|
| 71 |
for col in ['EmailSent', 'DateSent', 'Notes']:
|
| 72 |
if col not in df.columns:
|
|
|
|
| 36 |
subject = request.form.get('subject')
|
| 37 |
body = request.form.get('body')
|
| 38 |
|
| 39 |
+
if not contacts_file or contacts_file.filename == '':
|
|
|
|
| 40 |
return jsonify({'error': 'Contacts file is required.'}), 400
|
| 41 |
+
|
| 42 |
+
# Secure filename and check extension
|
| 43 |
+
allowed_extensions = {'.csv', '.xlsx', '.xls'}
|
| 44 |
+
file_ext = os.path.splitext(contacts_file.filename)[1].lower()
|
| 45 |
+
if file_ext not in allowed_extensions:
|
| 46 |
+
return jsonify({'error': f'Invalid file type. Allowed: {", ".join(allowed_extensions)}'}), 400
|
| 47 |
+
|
| 48 |
+
# Basic input validation
|
| 49 |
+
if not sender_email or "@" not in sender_email:
|
| 50 |
+
return jsonify({'error': 'A valid sender email is required.'}), 400
|
| 51 |
+
if not sender_password or len(sender_password) < 8:
|
| 52 |
+
return jsonify({'error': 'A valid App Password is required.'}), 400
|
| 53 |
+
if not subject or not body:
|
| 54 |
+
return jsonify({'error': 'Subject and Body are required.'}), 400
|
| 55 |
+
|
| 56 |
+
# Verify SMTP credentials BEFORE starting campaign
|
| 57 |
+
try:
|
| 58 |
+
server = smtplib.SMTP('smtp.gmail.com', 587)
|
| 59 |
+
server.starttls()
|
| 60 |
+
server.login(sender_email, sender_password)
|
| 61 |
+
server.quit()
|
| 62 |
+
except Exception as e:
|
| 63 |
+
return jsonify({'error': f'SMTP Login Failed: Ensure 2-Step Verification is on and you are using an "App Password". Error: {str(e)}'}), 401
|
| 64 |
|
| 65 |
campaign_id = str(uuid.uuid4())
|
| 66 |
campaign_dir = os.path.join(app.config['UPLOAD_FOLDER'], campaign_id)
|
| 67 |
os.makedirs(campaign_dir, exist_ok=True)
|
| 68 |
|
| 69 |
+
contacts_path = os.path.join(campaign_dir, "contacts" + file_ext)
|
| 70 |
contacts_file.save(contacts_path)
|
| 71 |
|
| 72 |
# Handle attachments
|
|
|
|
| 74 |
attachment_paths = []
|
| 75 |
for att in attachments:
|
| 76 |
if att.filename:
|
| 77 |
+
# Check attachment extension for safety
|
| 78 |
+
att_ext = os.path.splitext(att.filename)[1].lower()
|
| 79 |
+
if att_ext in {'.exe', '.bat', '.sh', '.msi'}:
|
| 80 |
+
return jsonify({'error': f'Security Alert: File type {att_ext} is not allowed as an attachment.'}), 400
|
| 81 |
+
|
| 82 |
att_path = os.path.join(campaign_dir, att.filename)
|
| 83 |
att.save(att_path)
|
| 84 |
attachment_paths.append(att_path)
|
| 85 |
|
| 86 |
# Parse Contacts
|
| 87 |
try:
|
| 88 |
+
if file_ext == '.csv':
|
| 89 |
df = pd.read_csv(contacts_path)
|
| 90 |
else:
|
| 91 |
df = pd.read_excel(contacts_path)
|
|
|
|
| 93 |
return jsonify({'error': f'Failed to read contacts file: {str(e)}'}), 400
|
| 94 |
|
| 95 |
if 'RecipientEmail' not in df.columns:
|
| 96 |
+
return jsonify({'error': 'Excel/CSV must contain a "RecipientEmail" column.'}), 400
|
| 97 |
|
| 98 |
for col in ['EmailSent', 'DateSent', 'Notes']:
|
| 99 |
if col not in df.columns:
|
email_automation.py
CHANGED
|
@@ -44,8 +44,8 @@ class EmailAutomation:
|
|
| 44 |
self.delay_between_emails = 10 # seconds
|
| 45 |
|
| 46 |
# Email configuration (user will set these)
|
| 47 |
-
self.sender_email = "
|
| 48 |
-
self.sender_password = "
|
| 49 |
self.sender_name = "Prince Kothiya"
|
| 50 |
|
| 51 |
def get_email_template(self, company_name):
|
|
@@ -72,8 +72,8 @@ Thank you for considering my application. I look forward to hearing from you.
|
|
| 72 |
|
| 73 |
Best regards,
|
| 74 |
Prince Kothiya
|
| 75 |
-
|
| 76 |
-
|
| 77 |
LinkedIn: linkedin.com/in/prince-kothiya-331073287
|
| 78 |
GitHub: github.com/prince1604
|
| 79 |
Rajkot, Gujarat, India"""
|
|
|
|
| 44 |
self.delay_between_emails = 10 # seconds
|
| 45 |
|
| 46 |
# Email configuration (user will set these)
|
| 47 |
+
self.sender_email = "[EMAIL_ADDRESS]" # Replace with your email
|
| 48 |
+
self.sender_password = "[PASSWORD]" # Replace with App Password
|
| 49 |
self.sender_name = "Prince Kothiya"
|
| 50 |
|
| 51 |
def get_email_template(self, company_name):
|
|
|
|
| 72 |
|
| 73 |
Best regards,
|
| 74 |
Prince Kothiya
|
| 75 |
+
|
| 76 |
+
[EMAIL_ADDRESS]
|
| 77 |
LinkedIn: linkedin.com/in/prince-kothiya-331073287
|
| 78 |
GitHub: github.com/prince1604
|
| 79 |
Rajkot, Gujarat, India"""
|
templates/campaign.html
CHANGED
|
@@ -154,15 +154,39 @@
|
|
| 154 |
Subject</label>
|
| 155 |
<input name="subject" required
|
| 156 |
class="rounded-lg border-slate-200 px-4 py-2.5 w-full dark:bg-slate-800"
|
| 157 |
-
|
|
|
|
| 158 |
<p class="text-xs text-slate-500">Tip: Use {ColumnName} to personalize</p>
|
| 159 |
</div>
|
| 160 |
<div class="flex flex-col gap-2">
|
| 161 |
<label class="text-sm font-semibold text-slate-700 dark:text-slate-300">Email Body
|
| 162 |
Message</label>
|
| 163 |
<textarea name="body" required
|
| 164 |
-
class="w-full border-slate-200 rounded-lg p-4 dark:bg-slate-900"
|
| 165 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
</div>
|
| 167 |
</div>
|
| 168 |
</section>
|
|
@@ -285,13 +309,37 @@
|
|
| 285 |
<div class="flex flex-col gap-1.5">
|
| 286 |
<label class="text-sm font-semibold text-slate-700">Subject Line</label>
|
| 287 |
<input name="subject" required class="w-full rounded-lg border-slate-200 text-sm p-3"
|
| 288 |
-
|
| 289 |
</div>
|
| 290 |
<div class="flex flex-col gap-1.5">
|
| 291 |
<label class="text-sm font-semibold text-slate-700">Email Body</label>
|
| 292 |
<textarea name="body" required
|
| 293 |
class="w-full border border-slate-200 rounded-lg text-sm p-3 resize-none focus:ring-1 focus:ring-primary"
|
| 294 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 295 |
</div>
|
| 296 |
</div>
|
| 297 |
</section>
|
|
|
|
| 154 |
Subject</label>
|
| 155 |
<input name="subject" required
|
| 156 |
class="rounded-lg border-slate-200 px-4 py-2.5 w-full dark:bg-slate-800"
|
| 157 |
+
value="Application for Cybersecurity Position - Prince Kothiya | BSc IT 2026"
|
| 158 |
+
type="text" />
|
| 159 |
<p class="text-xs text-slate-500">Tip: Use {ColumnName} to personalize</p>
|
| 160 |
</div>
|
| 161 |
<div class="flex flex-col gap-2">
|
| 162 |
<label class="text-sm font-semibold text-slate-700 dark:text-slate-300">Email Body
|
| 163 |
Message</label>
|
| 164 |
<textarea name="body" required
|
| 165 |
+
class="w-full border-slate-200 rounded-lg p-4 dark:bg-slate-900" rows="12">Dear Hiring Manager,
|
| 166 |
+
|
| 167 |
+
I am writing to express my strong interest in the Cybersecurity position at {CompanyName}. As a final-year BSc Information Technology student at Harivandana College with hands-on experience in penetration testing, secure web development, and Laravel application security, I am eager to contribute to your security team.
|
| 168 |
+
|
| 169 |
+
KEY HIGHLIGHTS OF MY PROFILE:
|
| 170 |
+
• Developed comprehensive Kali Linux-based security toolkit with 50+ integrated penetration testing tools
|
| 171 |
+
• Created secure Laravel web applications implementing JWT authentication, input validation, and SQL injection prevention
|
| 172 |
+
• Built automated OSINT tool for reconnaissance across 15+ data sources
|
| 173 |
+
• Currently working as Junior Laravel Developer Intern at Eminent Coders, focusing on secure web development
|
| 174 |
+
• Proficient in: Penetration Testing, Web Application Security, Python, PHP/Laravel, Bash Scripting, Kali Linux Tools
|
| 175 |
+
• Completed practical cybersecurity simulations with Deloitte Australia and Tata
|
| 176 |
+
|
| 177 |
+
I am particularly drawn to {CompanyName}'s work in cybersecurity. My combination of development experience and security testing skills positions me to contribute effectively to your security initiatives.
|
| 178 |
+
|
| 179 |
+
I have attached my resume for your review and would welcome the opportunity to discuss how my background in security testing and secure application development can benefit {CompanyName}.
|
| 180 |
+
|
| 181 |
+
Thank you for considering my application. I look forward to hearing from you.
|
| 182 |
+
|
| 183 |
+
Best regards,
|
| 184 |
+
Prince Kothiya
|
| 185 |
+
|
| 186 |
+
[EMAIL_ADDRESS]
|
| 187 |
+
LinkedIn: linkedin.com/in/prince-kothiya-331073287
|
| 188 |
+
GitHub: github.com/prince1604
|
| 189 |
+
Rajkot, Gujarat, India</textarea>
|
| 190 |
</div>
|
| 191 |
</div>
|
| 192 |
</section>
|
|
|
|
| 309 |
<div class="flex flex-col gap-1.5">
|
| 310 |
<label class="text-sm font-semibold text-slate-700">Subject Line</label>
|
| 311 |
<input name="subject" required class="w-full rounded-lg border-slate-200 text-sm p-3"
|
| 312 |
+
value="Application for Cybersecurity Position - Prince Kothiya | BSc IT 2026" type="text" />
|
| 313 |
</div>
|
| 314 |
<div class="flex flex-col gap-1.5">
|
| 315 |
<label class="text-sm font-semibold text-slate-700">Email Body</label>
|
| 316 |
<textarea name="body" required
|
| 317 |
class="w-full border border-slate-200 rounded-lg text-sm p-3 resize-none focus:ring-1 focus:ring-primary"
|
| 318 |
+
rows="10">Dear Hiring Manager,
|
| 319 |
+
|
| 320 |
+
I am writing to express my strong interest in the Cybersecurity position at {CompanyName}. As a final-year BSc Information Technology student at Harivandana College with hands-on experience in penetration testing, secure web development, and Laravel application security, I am eager to contribute to your security team.
|
| 321 |
+
|
| 322 |
+
KEY HIGHLIGHTS OF MY PROFILE:
|
| 323 |
+
• Developed comprehensive Kali Linux-based security toolkit with 50+ integrated penetration testing tools
|
| 324 |
+
• Created secure Laravel web applications implementing JWT authentication, input validation, and SQL injection prevention
|
| 325 |
+
• Built automated OSINT tool for reconnaissance across 15+ data sources
|
| 326 |
+
• Currently working as Junior Laravel Developer Intern at Eminent Coders, focusing on secure web development
|
| 327 |
+
• Proficient in: Penetration Testing, Web Application Security, Python, PHP/Laravel, Bash Scripting, Kali Linux Tools
|
| 328 |
+
• Completed practical cybersecurity simulations with Deloitte Australia and Tata
|
| 329 |
+
|
| 330 |
+
I am particularly drawn to {CompanyName}'s work in cybersecurity. My combination of development experience and security testing skills positions me to contribute effectively to your security initiatives.
|
| 331 |
+
|
| 332 |
+
I have attached my resume for your review and would welcome the opportunity to discuss how my background in security testing and secure application development can benefit {CompanyName}.
|
| 333 |
+
|
| 334 |
+
Thank you for considering my application. I look forward to hearing from you.
|
| 335 |
+
|
| 336 |
+
Best regards,
|
| 337 |
+
Prince Kothiya
|
| 338 |
+
|
| 339 |
+
[EMAIL_ADDRESS]
|
| 340 |
+
LinkedIn: linkedin.com/in/prince-kothiya-331073287
|
| 341 |
+
GitHub: github.com/prince1604
|
| 342 |
+
Rajkot, Gujarat, India</textarea>
|
| 343 |
</div>
|
| 344 |
</div>
|
| 345 |
</section>
|