-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntrusion.py
More file actions
70 lines (61 loc) · 1.77 KB
/
Intrusion.py
File metadata and controls
70 lines (61 loc) · 1.77 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash/python3
#***********************
#Author:Mr.Whitehat
#Date:15-8-2023
#Last-Modified:15-8-2023
#***********************
#Intrusion_Detection
import socket
import time
import smtplib
import datetime
import sys
#[May use Threadin Also]
#[Import Statement]
def Is_Computer_Online():
#[Info]IF The Computer is Online
host = "google.com"
#[Info]Default Host And port This May [Bypass Firewall] Or Allow This Through Firewall
port = 443
try:
#[Socket Connection]
s = socket.create_connection((host,port))
#Return True
return True
except:
#Return False
return False
def Send_Mail(sm,Rm,msg1,time):
#[Send_Mail Through Gmail Host Through Transport Layer Security Or SSl ]
server = smtplib.SMTP("smtp.gmail.com",587)
passwd = "" #[FiLL this With the App Password For Gmail]
#[Passwd For The Email Sender]
server.starttls()
#[Starting Tls() Connection]
server.login(sm,passwd)
#[Login Connection] Smtp
msg = f"Subject:{msg1}\n\nTime:{time}"
server.sendmail(sm,Rm,msg)
#[Bingo !!]
while True:
#Infitely Run BackGround
if Is_Computer_Online():
#Run The snippet If the Function Is True
time = datetime.datetime.now()
#[Date]Current Date
cur=time.strftime("%H:%M:%S %D-%M-%Y")
#[Formating The Date]
message = "Intrusion Detected"
sender_mail=""
Receiver_mail=""
try:
Send_Mail(sender_mail,Receiver_mail,message,cur)
except:
continue
sys.exit()
else:
#If False
time.sleep(10)
#Sleep[10]
continue
#[Warning:]If The Mail is Send Then the Loop Will BReak