update,
This commit is contained in:
Binary file not shown.
BIN
hdhdjshxh/task1/SASP Assignment 1c Python Scripting 2023 v3.doc
Normal file
BIN
hdhdjshxh/task1/SASP Assignment 1c Python Scripting 2023 v3.doc
Normal file
Binary file not shown.
9
hdhdjshxh/task1/helloworld.py
Normal file
9
hdhdjshxh/task1/helloworld.py
Normal file
@@ -0,0 +1,9 @@
|
||||
import tkinter as tk
|
||||
|
||||
# Create an instance of the Tk class (root window)
|
||||
window = tk.Tk()
|
||||
|
||||
# Add widgets and functionality to the window
|
||||
|
||||
# Start the event loop for application execution
|
||||
window.mainloop()
|
BIN
hdhdjshxh/task1/original/PCAP/ay2223_sasp_nmapcatured_1.pcap
Normal file
BIN
hdhdjshxh/task1/original/PCAP/ay2223_sasp_nmapcatured_1.pcap
Normal file
Binary file not shown.
BIN
hdhdjshxh/task1/original/PCAP/ay2223_sasp_nmapcatured_2.pcap
Normal file
BIN
hdhdjshxh/task1/original/PCAP/ay2223_sasp_nmapcatured_2.pcap
Normal file
Binary file not shown.
BIN
hdhdjshxh/task1/original/PCAP/ay2223_sasp_nmapcatured_3.pcap
Normal file
BIN
hdhdjshxh/task1/original/PCAP/ay2223_sasp_nmapcatured_3.pcap
Normal file
Binary file not shown.
12
hdhdjshxh/task1/original/Pipfile
Normal file
12
hdhdjshxh/task1/original/Pipfile
Normal file
@@ -0,0 +1,12 @@
|
||||
[[source]]
|
||||
url = "https://pypi.org/simple"
|
||||
verify_ssl = true
|
||||
name = "pypi"
|
||||
|
||||
[packages]
|
||||
|
||||
[dev-packages]
|
||||
|
||||
[requires]
|
||||
python_version = "3.11"
|
||||
python_full_version = "3.11.3"
|
Binary file not shown.
128
hdhdjshxh/task1/original/sasp-part-b-assignment-v1.py
Normal file
128
hdhdjshxh/task1/original/sasp-part-b-assignment-v1.py
Normal file
@@ -0,0 +1,128 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sqlite3
|
||||
from sqlite3 import Error
|
||||
import tkinter as tk
|
||||
from tkinter import ttk
|
||||
from scapy.all import *
|
||||
from datetime import datetime
|
||||
|
||||
def create_connection(db_file):
|
||||
conn = None
|
||||
try:
|
||||
conn = sqlite3.connect(db_file)
|
||||
except Error as e:
|
||||
print(e)
|
||||
return conn
|
||||
|
||||
def select_all_pcaprecords(conn):
|
||||
cur = conn.cursor()
|
||||
cur.execute("SELECT * FROM pcap_records")
|
||||
|
||||
rows = cur.fetchall()
|
||||
return rows
|
||||
|
||||
def open_popup(text_display):
|
||||
top = tk.Toplevel(mainwindow)
|
||||
top.geometry("550x250")
|
||||
top.title("Analysis Results!")
|
||||
popup_text = tk.Text(top, height=10, width=65,font=('Consolas',10))
|
||||
popup_text.grid(row=0,column=0,padx=5,pady=5,sticky=tk.W)
|
||||
popup_text.insert(tk.END,text_display)
|
||||
|
||||
def callback(event):
|
||||
filepath = "./outputfiles/"
|
||||
# get the index of the mouse click
|
||||
index = event.widget.index("@%s,%s" % (event.x, event.y))
|
||||
|
||||
# get the indices of all "adj" tags
|
||||
tag_indices = list(event.widget.tag_ranges('tag'))
|
||||
|
||||
# iterate them pairwise (start and end index)
|
||||
for start, end in zip(tag_indices[0::2], tag_indices[1::2]):
|
||||
# check if the tag matches the mouse click index
|
||||
if event.widget.compare(start, '<=', index) and event.widget.compare(index, '<', end):
|
||||
# return string between tag start and end
|
||||
filename = filepath + event.widget.get(start, end)
|
||||
print(filename)
|
||||
file1 = open(filename,'r')
|
||||
lines = file1.readlines()
|
||||
d = ""
|
||||
for line in lines:
|
||||
d += line.strip() + "\n"
|
||||
|
||||
open_popup(d)
|
||||
|
||||
def display_to_text(in_data):
|
||||
displaytext.tag_config("tag",foreground="blue")
|
||||
displaytext.tag_bind("tag","<Button-1>", callback)
|
||||
displaytext.insert(tk.END, 'ID' + "\t" + "PCAP Filename" + " " + "Date" + "\t\t\t\t" + "Time" + "\t" + "Output File\n")
|
||||
displaytext.insert(tk.END, '==' + "\t" + "==========================" + "\t" + "========" + "\t" + "====" + "\t" + "===========\n")
|
||||
for row in in_data:
|
||||
displaytext.insert(tk.END, str(row[0]) + "\t" + row[1] + " \t\t\t" + row[2] + "\t" + row[3] + " " + row[4] + "\t")
|
||||
displaytext.insert(tk.END,row[4],"tag")
|
||||
displaytext.insert(tk.END,"\n")
|
||||
|
||||
def get_current_date():
|
||||
now = datetime.now()
|
||||
return now.strftime('%Y%m%d')
|
||||
|
||||
def get_current_time():
|
||||
now = datetime.now()
|
||||
return now.strftime('%H%M%S')
|
||||
|
||||
|
||||
def analysispcap():
|
||||
pcapFile = getfiletextbox.get()
|
||||
pcap = rdpcap(pcapFile)
|
||||
numofpackets = len(pcap)
|
||||
resultstextbox.insert(tk.END,numofpackets)
|
||||
|
||||
def saveresult():
|
||||
pcapFile = getfiletextbox.get()
|
||||
analysis_date = get_current_date()
|
||||
analysis_time = get_current_time()
|
||||
analysis_output = resultstextbox.get("1.0","end-1c")
|
||||
output_filename = analysis_date + analysis_time + '.txt'
|
||||
print(pcapFile)
|
||||
print(analysis_date)
|
||||
print(analysis_time)
|
||||
print(analysis_output)
|
||||
print(output_filename)
|
||||
|
||||
# ====================== Main Start Here =====================================================
|
||||
|
||||
database = r"saspdemo.db"
|
||||
conn = create_connection(database)
|
||||
rows = select_all_pcaprecords(conn)
|
||||
data = []
|
||||
|
||||
for row in rows:
|
||||
data.append([row[0], row[1], row[2], row[3], row[4]])
|
||||
|
||||
mainwindow = tk.Tk()
|
||||
mainwindow.title("SASP Part B Assignment AY2223 - PCAP Analysis By Chan Tai Man")
|
||||
tabControl = ttk.Notebook(mainwindow)
|
||||
|
||||
tab1 = ttk.Frame(tabControl)
|
||||
tab2 = ttk.Frame(tabControl)
|
||||
|
||||
tabControl.add(tab1, text ='Network Traffic Analysis')
|
||||
tabControl.add(tab2, text ='History')
|
||||
tabControl.pack(expand = 1, fill ="both")
|
||||
|
||||
# =================== tab 1 GUI Layout ========================================================
|
||||
|
||||
getfilelabel = tk.Label(tab1,text='Start to work on your assignment',fg='red',font=('Consolas',12))
|
||||
getfilelabel.grid(row=0,column=0,padx=5,sticky=tk.W)
|
||||
|
||||
|
||||
# =================== tab 2 GUI Layout ========================================================
|
||||
|
||||
displaybtn = tk.Button(tab2, text="DISPLAY", fg='blue', width=20, command=lambda:display_to_text(data))
|
||||
displaybtn.grid(row=0,column=0, padx=5,pady=10,sticky=tk.W)
|
||||
|
||||
displaytext = tk.Text(tab2,height=10, width=100,font=('Consolas',10))
|
||||
displaytext.grid(row=2,column=0,padx=5,pady=5,sticky=tk.W)
|
||||
|
||||
mainwindow.mainloop()
|
BIN
hdhdjshxh/task1/original/saspdemo.db
Normal file
BIN
hdhdjshxh/task1/original/saspdemo.db
Normal file
Binary file not shown.
478
hdhdjshxh/task1/requirements.txt
Normal file
478
hdhdjshxh/task1/requirements.txt
Normal file
@@ -0,0 +1,478 @@
|
||||
aardwolf==0.2.2
|
||||
adblockparser==0.7
|
||||
AdvancedHTTPServer==2.2.0
|
||||
aesedb==0.1.3
|
||||
aiocmd==0.1.2
|
||||
aioconsole==0.3.1
|
||||
aiodns==3.0.0
|
||||
aiofiles==23.1.0
|
||||
aiohttp==3.8.4
|
||||
aiomultiprocess==0.9.0
|
||||
aioredis==1.3.1
|
||||
aiosignal==1.3.1
|
||||
aiosmb==0.4.4
|
||||
aiosqlite==0.17.0
|
||||
aiowinreg==0.0.7
|
||||
ajpy==0.0.4
|
||||
alembic==1.8.1.dev0
|
||||
altgraph==0.17.3
|
||||
aniso8601==9.0.1
|
||||
anyio==3.6.2
|
||||
apispec==5.2.2
|
||||
apispec-webframeworks==0.5.2
|
||||
appdirs==1.4.4
|
||||
APScheduler==3.9.1
|
||||
arc4==0.3.0
|
||||
arrow==1.2.3
|
||||
asciitree==0.3.3
|
||||
asgiref==3.6.0
|
||||
asn1crypto==1.5.1
|
||||
asn1tools==0.164.0
|
||||
asttokens==2.2.1
|
||||
asyauth==0.0.9
|
||||
async-timeout==4.0.2
|
||||
asysocks==0.2.2
|
||||
attrs==22.2.0
|
||||
autobahn==22.7.1
|
||||
autocommand==2.2.2
|
||||
Automat==22.10.0
|
||||
Babel==2.10.3
|
||||
backcall==0.2.0
|
||||
backoff==2.2.1
|
||||
base58==1.0.3
|
||||
bcrypt==3.2.2
|
||||
beautifulsoup4==4.11.2
|
||||
beniget==0.4.1
|
||||
bidict==0.22.1
|
||||
binwalk==2.3.3
|
||||
bitstruct==8.15.1
|
||||
bleach==5.0.1
|
||||
blinker==1.5
|
||||
bluepy==1.3.0
|
||||
boltons==21.0.0
|
||||
bottle==0.12.23
|
||||
Bottleneck==1.3.5
|
||||
Brlapi==0.8.4
|
||||
Brotli==1.0.9
|
||||
cbor==1.0.0
|
||||
censys==2.1.9
|
||||
certifi==2022.9.24
|
||||
cffi==1.15.1
|
||||
chardet==5.1.0
|
||||
charset-normalizer==3.0.1
|
||||
cheroot==9.0.0+ds1
|
||||
CherryPy==18.8.0
|
||||
cherrypy-cors==1.6
|
||||
cli-helpers==2.3.0
|
||||
click==8.1.3
|
||||
click-plugins==1.1.1
|
||||
cmd2==2.4.2+ds
|
||||
colorama==0.4.6
|
||||
configobj==5.0.8
|
||||
constantly==15.1.0
|
||||
contourpy==1.0.7
|
||||
crackmapexec==5.4.0
|
||||
cryptography==38.0.4
|
||||
cryptography37==37.0.2
|
||||
cvss==2.4
|
||||
cycler==0.11.0
|
||||
Cython==0.29.32
|
||||
dbus-python==1.3.2
|
||||
debtags==2.1
|
||||
decorator==5.1.1
|
||||
defusedxml==0.7.1
|
||||
Deprecated==1.2.13
|
||||
dicttoxml==1.7.15
|
||||
diskcache==5.4.0
|
||||
distlib==0.3.6
|
||||
distro==1.8.0
|
||||
Django==3.2.19
|
||||
dnslib==0.9.23
|
||||
dnspython==2.3.0
|
||||
docopt==0.6.2
|
||||
donut-shellcode==0.9.3
|
||||
dropbox==11.34.0
|
||||
dsinternals==1.2.4
|
||||
ecdsa==0.18.0
|
||||
email-validator==1.3.0
|
||||
et-xmlfile==1.0.1
|
||||
executing==1.2.0
|
||||
ExifRead==3.0.0
|
||||
faraday-agent-dispatcher==2.4.0
|
||||
faraday-agent-parameters-types==1.2.0
|
||||
faraday-cli==2.1.8
|
||||
faraday-plugins==1.10.0
|
||||
faradaysec==4.3.5
|
||||
fastapi==0.92.0
|
||||
feedparser==6.0.10
|
||||
fierce==1.5.0
|
||||
filedepot==0.5.2
|
||||
filelock==3.9.0
|
||||
filteralchemy==0.1.0
|
||||
flasgger==0.9.5
|
||||
Flask==2.2.2
|
||||
Flask-Classful==0.15.0.dev1
|
||||
Flask-KVSession-fork==0.6.4
|
||||
Flask-Limiter==3.3.0
|
||||
Flask-Login==0.6.2
|
||||
Flask-Mail==0.9.1
|
||||
Flask-Principal==0.4.0
|
||||
Flask-RESTful==0.3.9
|
||||
Flask-Security-Too==4.0.0
|
||||
Flask-SocketIO==5.3.2
|
||||
Flask-SQLAlchemy==3.0.3
|
||||
Flask-WTF==1.1.1
|
||||
flatbuffers==2.0.8+dfsg1.2
|
||||
fonttools==4.38.0
|
||||
frozenlist==1.3.3
|
||||
fs==2.4.16
|
||||
future==0.18.2
|
||||
gast==0.5.2
|
||||
GDAL==3.6.2
|
||||
GeoIP==1.3.2
|
||||
geoip2==2.9.0
|
||||
geojson==3.0.0
|
||||
gitdb==4.0.9
|
||||
GitPython==3.1.30
|
||||
gpg==1.18.0
|
||||
graphene==2.1.9
|
||||
graphene-sqlalchemy==2.1.2
|
||||
graphql-core==2.2.1
|
||||
graphql-relay==2.0.1
|
||||
greenlet==2.0.2
|
||||
h11==0.14.0
|
||||
h2==4.1.0
|
||||
hashID==3.1.4
|
||||
hiredis==1.0.1
|
||||
hkdf==0.0.3
|
||||
hpack==4.0.0
|
||||
html2text==2020.1.16
|
||||
html5lib==1.1
|
||||
httpagentparser==1.9.1
|
||||
httpcore==0.16.3
|
||||
httpx==0.23.3
|
||||
humanize==0.0.0
|
||||
hupper==1.10.3
|
||||
hyperframe==6.0.0
|
||||
hyperlink==21.0.0
|
||||
icalendar==4.0.3
|
||||
idna==3.3
|
||||
impacket==0.10.0
|
||||
importlib-metadata==4.12.0
|
||||
incremental==21.3.0
|
||||
inflect==2.1.0
|
||||
iniconfig==1.1.1
|
||||
invoke==2.0.0
|
||||
ipwhois==1.2.0
|
||||
IPy==1.1
|
||||
ipython==8.5.0
|
||||
itsdangerous==2.1.2
|
||||
jaraco.classes==3.2.1
|
||||
jaraco.collections==3.8.0
|
||||
jaraco.context==4.2.0
|
||||
jaraco.functools==3.5.0
|
||||
jaraco.text==3.11.1
|
||||
jdcal==1.0
|
||||
jedi==0.18.2
|
||||
Jinja2==3.1.2
|
||||
jq==1.2.1
|
||||
jsonpointer==2.3
|
||||
jsonschema==4.10.3
|
||||
kaitaistruct==0.10
|
||||
kali-tweaks==2023.2.2
|
||||
KismetCaptureBtGeiger==2021.7.1
|
||||
KismetCaptureFreaklabsZigbee==2018.7.0
|
||||
KismetCaptureRtl433==2020.10.1
|
||||
KismetCaptureRtladsb==2020.10.1
|
||||
KismetCaptureRtlamr==2020.10.1
|
||||
kiwisolver==0.0.0
|
||||
ldap3==2.9.1
|
||||
ldapdomaindump==0.9.3
|
||||
lightdm-gtk-greeter-settings==1.2.2
|
||||
limits==2.8.0
|
||||
llvmlite==0.39.1
|
||||
log-symbols==0.0.14
|
||||
louis==3.24.0
|
||||
lsassy==3.1.6
|
||||
lxml==4.9.2
|
||||
lz4==4.0.2+dfsg
|
||||
macholib==1.16.2
|
||||
magic-wormhole==0.12.0
|
||||
Mako==1.2.4.dev0
|
||||
Markdown==3.4.1
|
||||
markdown-it-py==2.1.0
|
||||
MarkupSafe==2.1.2
|
||||
marshmallow==3.18.0
|
||||
marshmallow-sqlalchemy==0.29.0
|
||||
masky==0.1.1
|
||||
matplotlib==3.6.3
|
||||
matplotlib-inline==0.1.6
|
||||
maxminddb==2.1.0
|
||||
mdurl==0.1.2
|
||||
mechanize==0.4.8
|
||||
minidump==0.0.21
|
||||
minikerberos==0.4.0
|
||||
mistune0==0.8.4
|
||||
mitmproxy==9.0.1
|
||||
mnemonic==0.19
|
||||
more-itertools==8.10.0
|
||||
mpmath==0.0.0
|
||||
msgpack==1.0.3
|
||||
msldap==0.4.7
|
||||
multidict==6.0.4
|
||||
mysqlclient==1.4.6
|
||||
nassl==5.0.1
|
||||
neo4j==5.2.dev0
|
||||
neobolt==1.7.17
|
||||
neotime==1.7.4
|
||||
netaddr==0.8.0
|
||||
netifaces==0.11.0
|
||||
networkx==2.8.8
|
||||
notus-scanner==22.4.4
|
||||
nplusone==1.0.0
|
||||
ntpsec==1.2.2
|
||||
numba==0.56.4
|
||||
numexpr==2.8.4
|
||||
numpy==1.24.2
|
||||
odfpy==1.4.2
|
||||
olefile==0.46
|
||||
onboard==1.4.1
|
||||
openpyxl==3.0.9
|
||||
ordered-set==4.1.0
|
||||
oscrypto==1.3.0
|
||||
ospd-openvas==22.4.6
|
||||
packaging==23.0
|
||||
paho-mqtt==1.6.1
|
||||
pandas==1.5.3
|
||||
paramiko==2.12.0
|
||||
parso==0.8.3
|
||||
passlib==1.7.4
|
||||
Paste==3.5.2
|
||||
PasteDeploy==3.0.1
|
||||
PasteScript==3.2.1
|
||||
patator==0.9
|
||||
pcapy==0.11.5.dev0
|
||||
pefile==2023.2.7
|
||||
pendulum==2.1.2
|
||||
pexpect==4.8.0
|
||||
pgcli==3.5.0
|
||||
pgspecial==2.0.1
|
||||
phonenumbers==8.12.57
|
||||
pickleshare==0.7.5
|
||||
Pillow==9.4.0
|
||||
plaster==1.0
|
||||
plaster-pastedeploy==0.5
|
||||
platformdirs==2.6.0
|
||||
pluggy==1.0.0+repack
|
||||
pluginbase==1.0.1
|
||||
ply==3.11
|
||||
portend==3.1.0
|
||||
prettytable==3.6.0
|
||||
promise==2.3
|
||||
prompt-toolkit==3.0.36
|
||||
protobuf==4.21.12
|
||||
psutil==5.9.4
|
||||
psycopg==3.1.7
|
||||
psycopg2==2.9.5
|
||||
ptyprocess==0.7.0
|
||||
publicsuffix2==2.20191221
|
||||
publicsuffixlist==0.9.3
|
||||
pure-eval==0.0.0
|
||||
py==1.11.0
|
||||
py-sneakers==1.0.1
|
||||
py-ubjson==0.16.1
|
||||
pyasn1==0.4.8
|
||||
pyasn1-modules==0.2.8
|
||||
pycairo==1.20.1
|
||||
pycares==4.3.0
|
||||
pycparser==2.21
|
||||
pycryptodomex==3.11.0
|
||||
pycurl==7.45.2
|
||||
pydantic==1.10.4
|
||||
PyDispatcher==2.0.5
|
||||
pydot==1.4.2
|
||||
pyee==9.0.4
|
||||
pyExploitDb==0.2.6
|
||||
pyfiglet==0.8.post0
|
||||
pygame==2.1.2
|
||||
pygexf==0.2.2
|
||||
Pygments==2.14.0
|
||||
PyGObject==3.42.2
|
||||
pygraphviz==1.7
|
||||
PyHamcrest==2.0.3
|
||||
pyinotify==0.9.6
|
||||
PyInstaller==3.5+498e6ee058
|
||||
PyJWT==2.6.0
|
||||
pylnk3==0.4.2
|
||||
pyminifier==2.1
|
||||
pymssql==2.2.2
|
||||
PyMySQL==1.0.2
|
||||
PyNaCl==1.5.0
|
||||
PyOpenGL==3.1.6
|
||||
pyOpenSSL==23.0.0
|
||||
pyotp==2.6.0
|
||||
pyparsing==3.0.9
|
||||
PyPDF2==2.12.1
|
||||
pyperclip==1.8.2
|
||||
pypng==0.20220715.0
|
||||
pyppeteer==1.0.1
|
||||
pypsrp==0.8.1
|
||||
pypykatz==0.6.6
|
||||
PyQRCode==1.2.1
|
||||
PyQt5==5.15.9
|
||||
PyQt5-sip==12.11.1
|
||||
PyQt6==6.4.2
|
||||
PyQt6-sip==13.4.1
|
||||
pyqtgraph==0.13.1
|
||||
pyramid==2.0
|
||||
pyrsistent==0.18.1
|
||||
PySecretSOCKS==0.9.1
|
||||
pyserial==3.5
|
||||
pyShodan==0.2.6
|
||||
pysmi==0.3.2
|
||||
pysnmp==4.4.12
|
||||
PySocks==1.7.1
|
||||
pyspnego==0.8.0
|
||||
pytest==7.2.1
|
||||
python-apt==2.5.3
|
||||
python-dateutil==2.8.2
|
||||
python-debian==0.1.49
|
||||
python-docx==0.8.11
|
||||
python-dotenv==0.21.0
|
||||
python-engineio==4.3.4
|
||||
python-gnupg==0.4.9
|
||||
python-gvm==23.2.0
|
||||
python-jose==3.3.0
|
||||
python-magic==0.4.26
|
||||
python-multipart==0.0.5
|
||||
python-owasp-zap-v2.4==0.0.20
|
||||
python-pam==2.0.2
|
||||
python-pptx==0.6.18
|
||||
python-slugify==4.0.0
|
||||
python-snappy==0.5.3
|
||||
python-socketio==5.7.2
|
||||
python-status==1.0.1
|
||||
pythran==0.11.0
|
||||
PyTrie==0.4.0
|
||||
pytz==2022.7.1
|
||||
pytz-deprecation-shim==0.1.0.post0
|
||||
pytzdata==2020.1
|
||||
pyVNC==0.1
|
||||
pywerview==0.3.3
|
||||
pyxdg==0.28
|
||||
PyYAML==6.0
|
||||
qrcode==7.4.2
|
||||
Quamash==0.6.1
|
||||
redis==4.3.4
|
||||
repoze.lru==0.7
|
||||
requests==2.28.1
|
||||
requests-file==1.5.1
|
||||
requests-toolbelt==0.10.1
|
||||
retrying==1.3.3
|
||||
rfc3986==1.5.0
|
||||
rfc3987==1.3.8
|
||||
rich==13.3.1
|
||||
Routes==2.5.1
|
||||
rq==1.13.0
|
||||
rsa==4.8
|
||||
ruamel.yaml==0.17.21
|
||||
ruamel.yaml.clib==0.2.7
|
||||
rule-engine==3.5.0
|
||||
Rx==3.2.0
|
||||
scapy==2.5.0
|
||||
scipy==1.10.1
|
||||
secure==0.3.0
|
||||
service-identity==18.1.0
|
||||
setproctitle==1.3.1
|
||||
sgmllib3k==1.0.0
|
||||
shodan==1.28.0
|
||||
simple-rest-client==1.1.3
|
||||
simplejson==3.18.3
|
||||
simplekv==0.14.1
|
||||
six==1.16.0
|
||||
slowapi==0.1.4
|
||||
smmap==5.0.0
|
||||
smoke-zephyr==2.0.1
|
||||
sniffio==1.2.0
|
||||
sortedcontainers==2.4.0
|
||||
soupsieve==2.3.2
|
||||
spake2==0.8
|
||||
spinners==0.0.24
|
||||
SQLAlchemy==1.4.46
|
||||
sqlalchemy-schemadisplay==1.3
|
||||
SQLAlchemy-Utc==0.14.0
|
||||
sqlparse==0.4.2
|
||||
sslyze==5.1.3
|
||||
stack-data==0.6.2
|
||||
starlette==0.26.1
|
||||
stone==3.3.1
|
||||
sympy==1.11.1
|
||||
syslog-rfc5424-formatter==1.2.3
|
||||
tables==3.7.0
|
||||
tabulate==0.8.9
|
||||
Tempita==0.5.2
|
||||
tempora==5.1.0
|
||||
termcolor==1.1.0
|
||||
terminaltables==3.1.10
|
||||
texttable==1.6.7
|
||||
theHarvester==4.2.0
|
||||
tinycss2==1.2.1
|
||||
tld==0.11.11
|
||||
tls-parser==1.2.2
|
||||
tomli==2.0.1
|
||||
tornado==6.2
|
||||
tqdm==4.64.1
|
||||
traitlets==5.5.0
|
||||
translationstring==1.4
|
||||
Twisted==22.4.0
|
||||
txaio==21.2.1
|
||||
txtorcon==23.5.0
|
||||
typing_extensions==4.4.0
|
||||
tzlocal==4.2
|
||||
u-msgpack-python==2.3.0
|
||||
ufoLib2==0.14.0
|
||||
ujson==5.7.0
|
||||
unicodecsv==0.14.1
|
||||
unicrypto==0.0.10
|
||||
Unidecode==1.3.6
|
||||
uritemplate==4.1.1
|
||||
urllib3==1.26.12
|
||||
urwid==2.1.2
|
||||
uvicorn==0.17.6
|
||||
uvloop==0.17.0
|
||||
validators==0.20.0
|
||||
venusian==3.0.0
|
||||
virtualenv==20.17.1+ds
|
||||
wafw00f==2.2.0
|
||||
wapiti3==3.0.4
|
||||
wcwidth==0.2.5
|
||||
webargs==8.0.1
|
||||
webcolors==1.11.1
|
||||
webencodings==0.5.1
|
||||
WebOb==1.8.6
|
||||
websocket-client==1.2.3
|
||||
websockets==10.4
|
||||
websockify==0.10.0
|
||||
Werkzeug==2.2.2
|
||||
wfuzz==3.1.0
|
||||
whois==0.8
|
||||
wifite==2.6.6
|
||||
winacl==0.1.7
|
||||
wrapt==1.14.1
|
||||
wsaccel==0.6.3
|
||||
wsproto==1.2.0
|
||||
WTForms==3.0.1
|
||||
xdg==5
|
||||
xlrd==1.2.0
|
||||
XlsxWriter==3.0.2
|
||||
xlutils==2.0.0
|
||||
xlwt==1.3.0
|
||||
xmltodict==0.13.0
|
||||
yara-python==4.2.0
|
||||
yarl==1.8.2
|
||||
yaswfp==0.9.3
|
||||
zc.lockfile==2.0
|
||||
zipp==1.0.0
|
||||
zlib-wrapper==0.1.3
|
||||
zope.deprecation==4.4.0
|
||||
zope.interface==5.5.2
|
52
hdhdjshxh/task1/scapy_helloworld.py
Normal file
52
hdhdjshxh/task1/scapy_helloworld.py
Normal file
@@ -0,0 +1,52 @@
|
||||
from scapy.all import *
|
||||
|
||||
packets = rdpcap('PCAP/ay2223_sasp_nmapcatured_1.pcap')
|
||||
|
||||
scanned_ports = set() # Set to store unique scanned ports
|
||||
|
||||
for pkt in packets:
|
||||
if pkt.haslayer(TCP):
|
||||
dst_port = pkt[TCP].dport # Destination port
|
||||
scanned_ports.add(dst_port)
|
||||
|
||||
print("Number of ports scanned:", len(scanned_ports))
|
||||
|
||||
|
||||
from scapy.all import *
|
||||
|
||||
# Provide the path to your PCAP file
|
||||
pcap_file = 'PCAP/ay2223_sasp_nmapcatured_1.pcap'
|
||||
|
||||
# Read the PCAP file
|
||||
packets = rdpcap(pcap_file)
|
||||
|
||||
# Create an empty set to store unique destination ports
|
||||
scanned_ports = set()
|
||||
|
||||
for packet in packets:
|
||||
# Check if it's a TCP packet with destination port information
|
||||
if TCP in packet and packet[TCP].dport not in scanned_ports:
|
||||
scanned_ports.add(packet[TCP].dport)
|
||||
|
||||
print("Ports that have been scanned:")
|
||||
for port in sorted(scanned_ports):
|
||||
print(port)
|
||||
|
||||
|
||||
|
||||
|
||||
# PCAP/ay2223_sasp_nmapcatured_1.pcap
|
||||
from scapy.all import *
|
||||
|
||||
# Provide the path to your PCAP file
|
||||
pcap_file = 'PCAP/ay2223_sasp_nmapcatured_1.pcap'
|
||||
|
||||
# Read the PCAP file
|
||||
packets = rdpcap(pcap_file)
|
||||
|
||||
# Retrieve the number of packets in the file
|
||||
num_packets = len(packets)
|
||||
|
||||
print(f"The number of packets in '{pcap_file}' is: {num_packets}")
|
||||
|
||||
|
BIN
hdhdjshxh/task1/src/PCAP/ay2223_sasp_nmapcatured_1.pcap
Normal file
BIN
hdhdjshxh/task1/src/PCAP/ay2223_sasp_nmapcatured_1.pcap
Normal file
Binary file not shown.
BIN
hdhdjshxh/task1/src/PCAP/ay2223_sasp_nmapcatured_2.pcap
Normal file
BIN
hdhdjshxh/task1/src/PCAP/ay2223_sasp_nmapcatured_2.pcap
Normal file
Binary file not shown.
BIN
hdhdjshxh/task1/src/PCAP/ay2223_sasp_nmapcatured_3.pcap
Normal file
BIN
hdhdjshxh/task1/src/PCAP/ay2223_sasp_nmapcatured_3.pcap
Normal file
Binary file not shown.
12
hdhdjshxh/task1/src/Pipfile
Normal file
12
hdhdjshxh/task1/src/Pipfile
Normal file
@@ -0,0 +1,12 @@
|
||||
[[source]]
|
||||
url = "https://pypi.org/simple"
|
||||
verify_ssl = true
|
||||
name = "pypi"
|
||||
|
||||
[packages]
|
||||
scapy = "*"
|
||||
|
||||
[dev-packages]
|
||||
|
||||
[requires]
|
||||
python_version = "3.11"
|
28
hdhdjshxh/task1/src/Pipfile.lock
generated
Normal file
28
hdhdjshxh/task1/src/Pipfile.lock
generated
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "48a942209e07edced25af57319fa326b1f119473fddb9cb78f4a1e53be218cdc"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
"python_version": "3.11"
|
||||
},
|
||||
"sources": [
|
||||
{
|
||||
"name": "pypi",
|
||||
"url": "https://pypi.org/simple",
|
||||
"verify_ssl": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"default": {
|
||||
"scapy": {
|
||||
"hashes": [
|
||||
"sha256:5b260c2b754fd8d409ba83ee7aee294ecdbb2c235f9f78fe90bc11cb6e5debc2"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==2.5.0"
|
||||
}
|
||||
},
|
||||
"develop": {}
|
||||
}
|
7
hdhdjshxh/task1/src/README.md
Normal file
7
hdhdjshxh/task1/src/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# README
|
||||
```bash
|
||||
$ pipenv shell
|
||||
|
||||
# inside pipenv shell
|
||||
$ python ./sasp-part-b-assignment-v1.py
|
||||
```
|
13
hdhdjshxh/task1/src/package.json
Normal file
13
hdhdjshxh/task1/src/package.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "src",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"dev": "npx nodemon --ext py --exec \"./test.sh\""
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
330
hdhdjshxh/task1/src/sasp-part-b-assignment-v1.py
Normal file
330
hdhdjshxh/task1/src/sasp-part-b-assignment-v1.py
Normal file
@@ -0,0 +1,330 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sqlite3
|
||||
from sqlite3 import Error
|
||||
import tkinter as tk
|
||||
from tkinter import ttk
|
||||
from scapy.all import *
|
||||
from datetime import datetime
|
||||
|
||||
import os
|
||||
import threading
|
||||
|
||||
# NOTE: look into PCAP for pcap file
|
||||
PCAP_DIRECTORY = "PCAP"
|
||||
|
||||
# NOTE: global variables for threading
|
||||
files = []
|
||||
pcap_files=[]
|
||||
pcap_filename = ''
|
||||
|
||||
# NOTE: global variables for result
|
||||
num_of_packet = 0
|
||||
list_of_scanned_port = []
|
||||
num_of_scanned_port = 0
|
||||
pcap_process_status = 'start'
|
||||
|
||||
# NOTE: initial get all files in the directory
|
||||
files = os.listdir(PCAP_DIRECTORY)
|
||||
|
||||
# NOTE: Filter files with '.pcap' extension
|
||||
pcap_files = [file for file in files if file.endswith('.pcap')]
|
||||
|
||||
def handle_pcap_file_select_update(event):
|
||||
# NOTE: make analyse button when pcap file selected
|
||||
analysebtn.config(state=tk.ACTIVE)
|
||||
|
||||
def create_connection(db_file):
|
||||
conn = None
|
||||
try:
|
||||
conn = sqlite3.connect(db_file)
|
||||
except Error as e:
|
||||
print(e)
|
||||
return conn
|
||||
|
||||
def select_all_pcaprecords(conn):
|
||||
cur = conn.cursor()
|
||||
cur.execute("SELECT * FROM pcap_records")
|
||||
|
||||
rows = cur.fetchall()
|
||||
return rows
|
||||
|
||||
def open_popup(text_display):
|
||||
top = tk.Toplevel(mainwindow)
|
||||
top.geometry("550x250")
|
||||
top.title("Analysis Results!")
|
||||
popup_text = tk.Text(top, height=10, width=65,font=('Consolas',10))
|
||||
popup_text.grid(row=0,column=0,padx=5,pady=5,sticky=tk.W)
|
||||
popup_text.insert(tk.END,text_display)
|
||||
|
||||
def callback(event):
|
||||
filepath = "./outputfiles/"
|
||||
# get the index of the mouse click
|
||||
index = event.widget.index("@%s,%s" % (event.x, event.y))
|
||||
|
||||
# get the indices of all "adj" tags
|
||||
tag_indices = list(event.widget.tag_ranges('tag'))
|
||||
|
||||
# iterate them pairwise (start and end index)
|
||||
for start, end in zip(tag_indices[0::2], tag_indices[1::2]):
|
||||
# check if the tag matches the mouse click index
|
||||
if event.widget.compare(start, '<=', index) and event.widget.compare(index, '<', end):
|
||||
# return string between tag start and end
|
||||
filename = filepath + event.widget.get(start, end)
|
||||
print(filename)
|
||||
file1 = open(filename,'r')
|
||||
lines = file1.readlines()
|
||||
d = ""
|
||||
for line in lines:
|
||||
d += line.strip() + "\n"
|
||||
|
||||
open_popup(d)
|
||||
|
||||
def find_num_of_packet(pcap_filename):
|
||||
global PCAP_DIRECTORY,num_of_packet
|
||||
|
||||
# Provide the path to your PCAP file
|
||||
pcap_file = f'{PCAP_DIRECTORY}/{pcap_filename}'
|
||||
|
||||
# Read the PCAP file
|
||||
packets = rdpcap(pcap_file)
|
||||
|
||||
# return 'num_packets'
|
||||
num_of_packet = len(packets)
|
||||
pass
|
||||
|
||||
def count_scanned_port(list_of_scanned_port):
|
||||
return len(list_of_scanned_port)
|
||||
|
||||
def find_scanned_port(pcap_filename):
|
||||
global list_of_scanned_port
|
||||
global num_of_scanned_port
|
||||
global PCAP_DIRECTORY
|
||||
|
||||
pcap_file = f'{PCAP_DIRECTORY}/{pcap_filename}'
|
||||
|
||||
# Read the PCAP file
|
||||
packets = rdpcap(pcap_file)
|
||||
|
||||
# Create an empty set to store unique destination ports
|
||||
scanned_ports = set()
|
||||
|
||||
for packet in packets:
|
||||
# Check if it's a TCP packet with destination port information
|
||||
if TCP in packet and packet[TCP].dport not in scanned_ports:
|
||||
scanned_ports.add(packet[TCP].dport)
|
||||
|
||||
list_of_scanned_port = sorted(scanned_ports)
|
||||
num_of_scanned_port = count_scanned_port(scanned_ports)
|
||||
|
||||
pass
|
||||
|
||||
def display_to_text(in_data):
|
||||
displaytext.tag_config("tag",foreground="blue")
|
||||
displaytext.tag_bind("tag","<Button-1>", callback)
|
||||
displaytext.insert(tk.END, 'ID' + "\t" + "PCAP Filename" + " " + "Date" + "\t\t\t\t" + "Time" + "\t" + "Output File\n")
|
||||
displaytext.insert(tk.END, '==' + "\t" + "==========================" + "\t" + "========" + "\t" + "====" + "\t" + "===========\n")
|
||||
for row in in_data:
|
||||
displaytext.insert(tk.END, str(row[0]) + "\t" + row[1] + " \t\t\t" + row[2] + "\t" + row[3] + " " + row[4] + "\t")
|
||||
displaytext.insert(tk.END,row[4],"tag")
|
||||
displaytext.insert(tk.END,"\n")
|
||||
|
||||
|
||||
def clear_text():
|
||||
pcap_file_select_cb.set(DEFAULT_COMBOBOX_TEXT)
|
||||
analysetext.delete(1.0, tk.END)
|
||||
|
||||
clearbtn.config(state=tk.DISABLED)
|
||||
analysebtn.config(state=tk.DISABLED)
|
||||
storebtn.config(state=tk.DISABLED)
|
||||
|
||||
def store_to_db(conn):
|
||||
global pcap_filename
|
||||
|
||||
print(pcap_filename)
|
||||
|
||||
try:
|
||||
current_date = get_current_date()
|
||||
current_time = get_current_time()
|
||||
output_filename = current_date+current_time+'.txt'
|
||||
|
||||
cursor = conn.cursor()
|
||||
|
||||
# cursor.execute("INSERT INTO pcap_records (pcafilename) VALUES (?)", (name))
|
||||
cursor.execute('INSERT INTO pcap_records (pcapfilename, date, time, outputfilename) VALUES (?, ?, ?, ?)', (pcap_filename,current_date, current_time, output_filename))
|
||||
|
||||
# Commit the changes and close the connection
|
||||
conn.commit()
|
||||
print('save to db done')
|
||||
|
||||
except:
|
||||
print('error found during saving to db')
|
||||
|
||||
# TODO: relocate me
|
||||
thread1 = 0
|
||||
thread2 = 0
|
||||
|
||||
def update_result():
|
||||
global pcap_filename
|
||||
global thread1, thread2
|
||||
global num_of_scanned_port, list_of_scanned_port, num_of_packet
|
||||
|
||||
thread1.join()
|
||||
thread2.join()
|
||||
|
||||
clear_text()
|
||||
|
||||
analysetext.insert(tk.END, f"-- ANALYSIS RESULT --\n")
|
||||
|
||||
analysetext.insert(tk.END, f"File analyzed: {pcap_filename}\n")
|
||||
|
||||
# # NOTES: count number of packets
|
||||
analysetext.insert(tk.END, f"The number of packets : {num_of_packet}\n")
|
||||
|
||||
# # NOTES: find the ports scanned
|
||||
analysetext.insert(tk.END, f"Scanned port : {list_of_scanned_port}\n")
|
||||
|
||||
# NOTES: find_num_of_port_scanned
|
||||
analysetext.insert(tk.END, f"Scanned port : {num_of_scanned_port}\n")
|
||||
|
||||
analysetext.insert(tk.END, f"-- ANALYSIS END --\n")
|
||||
|
||||
|
||||
|
||||
|
||||
def analyse_to_text():
|
||||
global num_of_packet
|
||||
global thread1, thread2
|
||||
global pcap_filename
|
||||
|
||||
pcap_filename = pcap_file_select_cb.get()
|
||||
|
||||
# NOTE: seperate thread for process analysis of scanned port and number of packet
|
||||
thread1 = threading.Thread(target=find_scanned_port, args=(pcap_filename,))
|
||||
thread2 = threading.Thread(target=find_num_of_packet, args=(pcap_filename,))
|
||||
|
||||
# NOTE: start thread
|
||||
thread1.start()
|
||||
thread2.start()
|
||||
|
||||
# NOTE: prepare textbox for output
|
||||
analysetext.tag_config("tag",foreground="blue")
|
||||
analysetext.tag_bind("tag","<Button-1>", callback)
|
||||
|
||||
# NOTE: show processing file and wait for finish
|
||||
analysetext.insert(tk.END, f"processing file\n")
|
||||
|
||||
update_result()
|
||||
|
||||
clearbtn.config(state=tk.ACTIVE)
|
||||
storebtn.config(state=tk.ACTIVE)
|
||||
|
||||
|
||||
def get_current_date():
|
||||
now = datetime.now()
|
||||
return now.strftime('%Y%m%d')
|
||||
|
||||
def get_current_time():
|
||||
now = datetime.now()
|
||||
return now.strftime('%H%M%S')
|
||||
|
||||
|
||||
def analysispcap():
|
||||
pcapFile = getfiletextbox.get()
|
||||
pcap = rdpcap(pcapFile)
|
||||
numofpackets = len(pcap)
|
||||
resultstextbox.insert(tk.END,numofpackets)
|
||||
|
||||
def saveresult():
|
||||
pcapFile = getfiletextbox.get()
|
||||
analysis_date = get_current_date()
|
||||
analysis_time = get_current_time()
|
||||
analysis_output = resultstextbox.get("1.0","end-1c")
|
||||
output_filename = analysis_date + analysis_time + '.txt'
|
||||
print(pcapFile)
|
||||
print(analysis_date)
|
||||
print(analysis_time)
|
||||
print(analysis_output)
|
||||
print(output_filename)
|
||||
|
||||
def refresh_pcap_file_list(Noneevent):
|
||||
global files
|
||||
global pcap_files
|
||||
|
||||
files = os.listdir(directory)
|
||||
pcap_files = [file for file in files if file.endswith('.pcap')]
|
||||
# ====================== Main Start Here =====================================================
|
||||
|
||||
database = r"saspdemo.db"
|
||||
conn = create_connection(database)
|
||||
rows = select_all_pcaprecords(conn)
|
||||
data = []
|
||||
|
||||
for row in rows:
|
||||
data.append([row[0], row[1], row[2], row[3], row[4]])
|
||||
|
||||
mainwindow = tk.Tk()
|
||||
mainwindow.geometry("1620x600")
|
||||
mainwindow.title("SASP Part B Assignment AY2223 - PCAP Analysis By Chan Tai Man")
|
||||
|
||||
tabControl = ttk.Notebook(mainwindow)
|
||||
|
||||
tab1 = ttk.Frame(tabControl)
|
||||
tab2 = ttk.Frame(tabControl)
|
||||
|
||||
tabControl.add(tab1, text ='Network Traffic Analysis')
|
||||
tabControl.add(tab2, text ='History')
|
||||
tabControl.pack(expand = 1, fill ="both")
|
||||
|
||||
# # =================== tab 1 GUI Layout ========================================================
|
||||
|
||||
# # Options
|
||||
|
||||
# NOTE: this is combobox for pcap file list
|
||||
DEFAULT_COMBOBOX_TEXT = 'Select a pcap file'
|
||||
pcap_file_select_cb = ttk.Combobox(tab1, width=30, textvariable=tk.StringVar())
|
||||
pcap_file_select_cb.set(DEFAULT_COMBOBOX_TEXT)
|
||||
pcap_file_select_cb.grid(row=0,column=0, padx=5,pady=10,sticky=tk.W)
|
||||
pcap_file_select_cb.bind('<<ComboboxSelected>>', handle_pcap_file_select_update)
|
||||
|
||||
pcap_file_select_cb['values'] = pcap_files
|
||||
pcap_file_select_cb['state'] = 'readonly'
|
||||
|
||||
# NOTE: this is "REFRESH" button
|
||||
refreshbtn = tk.Button(tab1, text="REFRESH", fg='blue', width=10, command=lambda:refresh_pcap_file_list(None))
|
||||
refreshbtn.grid(row=0,column=0, padx=500,pady=10,sticky=tk.W)
|
||||
|
||||
# NOTE: this is "ANALYSE" button
|
||||
analysebtn = tk.Button(tab1, text="ANALYSE", fg='blue', width=10, command=lambda:analyse_to_text())
|
||||
analysebtn.grid(row=0,column=0, padx=700,pady=10,sticky=tk.W)
|
||||
analysebtn.config(state=tk.DISABLED)
|
||||
|
||||
# NOTE: this is "CLEAR" button
|
||||
clearbtn = tk.Button(tab1, text="CLEAR", fg='blue', width=10, command=lambda:clear_text())
|
||||
clearbtn.grid(row=0,column=0, padx=900,pady=10,sticky=tk.W)
|
||||
clearbtn.config(state=tk.DISABLED)
|
||||
|
||||
# NOTE: store to database
|
||||
# NOTE: Store all the information
|
||||
# NOTE: (e.g. date and time, PCAP filename, and the results of items)
|
||||
# NOTE: related to analysing PCAP files in the SQLite database.
|
||||
storebtn = tk.Button(tab1, text="STORE", fg='blue', width=10, command=lambda:store_to_db(conn))
|
||||
storebtn.grid(row=0,column=0, padx=1100,pady=10,sticky=tk.W)
|
||||
storebtn.config(state=tk.DISABLED)
|
||||
|
||||
# NOTE: result window
|
||||
analysetext = tk.Text(tab1,height=10, width=100,font=('Consolas',10))
|
||||
analysetext.grid(row=2,column=0,padx=5,pady=20,sticky=tk.W)
|
||||
|
||||
# # =================== tab 2 GUI Layout ========================================================
|
||||
|
||||
displaybtn = tk.Button(tab2, text="DISPLAY", fg='blue', width=20, command=lambda:display_to_text(data))
|
||||
displaybtn.grid(row=0,column=0, padx=5,pady=10,sticky=tk.W)
|
||||
|
||||
displaytext = tk.Text(tab2,height=10, width=100,font=('Consolas',10))
|
||||
displaytext.grid(row=2,column=0,padx=5,pady=5,sticky=tk.W)
|
||||
|
||||
# TODO: resume me
|
||||
mainwindow.mainloop()
|
||||
|
||||
print('program ended')
|
BIN
hdhdjshxh/task1/src/saspdemo.db
Normal file
BIN
hdhdjshxh/task1/src/saspdemo.db
Normal file
Binary file not shown.
6
hdhdjshxh/task1/src/test.sh
Normal file
6
hdhdjshxh/task1/src/test.sh
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
find . |entr -c -s "python ./sasp-part-b-assignment-v1.py"
|
||||
# pipenv run python ./sasp-part-b-assignment-v1.py
|
34
hdhdjshxh/task1/test_threading.py
Normal file
34
hdhdjshxh/task1/test_threading.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import threading
|
||||
|
||||
helloworld = "start"
|
||||
|
||||
def task1(name):
|
||||
print(f"Task 1 executing with name: {name}")
|
||||
return f"Hello, {name}!"
|
||||
|
||||
def task2(age):
|
||||
global helloworld
|
||||
helloworld = 'done'
|
||||
print(f"Task 2 executing with age: {age}")
|
||||
return f"You are {age} years old."
|
||||
|
||||
# Create thread objects for each task, passing arguments as a tuple
|
||||
thread1 = threading.Thread(target=task1, args=("John",))
|
||||
thread2 = threading.Thread(target=task2, args=(25,))
|
||||
|
||||
# Start the threads
|
||||
thread1.start()
|
||||
thread2.start()
|
||||
|
||||
# Wait for both threads to finish execution
|
||||
thread1.join()
|
||||
thread2.join()
|
||||
|
||||
# Retrieve the return values from each thread
|
||||
result_task1 = thread1.result if hasattr(thread1, 'result') else None
|
||||
result_task2 = thread2.result if hasattr(thread2, 'result') else None
|
||||
|
||||
print("All tasks completed")
|
||||
print("Result from Task 1:", result_task1)
|
||||
print("Result from Task 2:", result_task2)
|
||||
print(helloworld)
|
Reference in New Issue
Block a user